Merge branch 'dev' of http://git.verdnatura.es/salix into dev

This commit is contained in:
Carlos Jimenez 2018-08-12 10:55:27 +02:00
commit 90fdb5db84
7 changed files with 109 additions and 4 deletions

View File

@ -67,6 +67,23 @@ describe('Client', () => {
});
});
describe('cancel()', () => {
it('should call preventDefault, stopImmediatePropagation and goToIndex', () => {
let event = {
preventDefault: () => {},
stopImmediatePropagation: () => {}
};
spyOn(event, 'preventDefault');
spyOn(event, 'stopImmediatePropagation');
spyOn(controller, 'goToIndex');
controller.cancel(event);
expect(controller.goToIndex).toHaveBeenCalledWith();
expect(event.preventDefault).toHaveBeenCalledWith();
expect(event.stopImmediatePropagation).toHaveBeenCalledWith();
});
});
describe('returnDialog()', () => {
it('should call addCredit() when is called with ACCEPT', () => {
spyOn(controller, 'addCredit');

View File

@ -0,0 +1,27 @@
import './index.js';
describe('Item', () => {
describe('Component vnItemDescriptor', () => {
let $componentController;
let controller;
beforeEach(() => {
angular.mock.module('item');
});
beforeEach(angular.mock.inject(_$componentController_ => {
$componentController = _$componentController_;
controller = $componentController('vnItemDescriptor');
controller.$state.go = () => {};
}));
describe('quicklinkGo()', () => {
it(`shoud set _itemFk to a given value and call _getItem if the given value is not null`, () => {
spyOn(controller.$state, 'go');
controller.quicklinkGo('state', 'params');
expect(controller.$state.go).toHaveBeenCalledWith('state', 'params');
});
});
});
});

View File

@ -39,5 +39,7 @@
"The new quantity should be smaller than the old one": "La nueva cantidad debe de ser menor que la anterior",
"The value should not be greater than 100%": "El valor no debe de ser mayor de 100%",
"The value should be a number": "El valor debe ser un numero",
"This order is not editable": "Esta orden no se puede modificar"
"This order is not editable": "Esta orden no se puede modificar",
"You can't create an order for a frozen client": "No puedes crear una orden para un cliente congelado",
"You can't create an order for a client that has a debt": "No puedes crear una orden para un cliente con deuda"
}

View File

@ -0,0 +1,15 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket deleted()', () => {
it('should call the getShipped method', async() => {
let oldTicket = await app.models.Ticket.findOne({where: {id: 1}});
expect(oldTicket.isDeleted).toEqual(false);
await app.models.Ticket.deleted({id: 1});
let ticket = await app.models.Ticket.findOne({where: {id: 1}, fields: ['isDeleted']});
expect(ticket.isDeleted).toEqual(true);
oldTicket.isDeleted = 0;
await app.models.Ticket.upsert(oldTicket);
});
});

View File

@ -0,0 +1,15 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket getSalesPersonMana()', () => {
it('should get the mana of a salesperson of a given ticket', async() => {
let mana = await app.models.Ticket.getSalesPersonMana(1);
expect(mana).toEqual(330);
});
it('should return 0 if the given ticket does not exists', async() => {
let mana = await app.models.Ticket.getSalesPersonMana(20);
expect(mana).toEqual(0);
});
});

View File

@ -25,17 +25,37 @@ module.exports = Self => {
let order = await Self.findById(where.id);
let stmt = `CALL vn2008.bionic_from_type(?, ?, ?, ?);
SELECT bi.*, i.* FROM tmp.bionic_item bi
SELECT bi.*, i.*, w.name AS workerName, w.firstName AS workerFirstName FROM tmp.bionic_item bi
JOIN vn.item i ON i.id = bi.item_id
ORDER BY relevancy DESC, item_id ASC, producer DESC;`;
JOIN vn.itemType it ON it.id = i.typeFk
JOIN vn.worker w on w.id = it.workerFk
ORDER BY relevancy DESC, item_id ASC, producer DESC;
SELECT pri.*, w.name AS warehouseName FROM tmp.bionic_price pri
JOIN vn.warehouse w ON w.id = pri.warehouse_id;`;
let [rs, items] = await Self.rawSql(stmt, [
let [rs, items, prices] = await Self.rawSql(stmt, [
order.landed,
order.address_id,
order.agency_id,
where.typeFk
]);
if (items) {
items.forEach(item => {
prices.forEach(price => {
if (item.item_id === price.item_id) {
if (item.prices) {
item.prices.push(price);
} else {
item.prices = [price];
}
item.disponible = price.grouping;
}
});
});
}
return items;
};
};

View File

@ -0,0 +1,9 @@
const app = require(`../../../../server/server`);
fdescribe('order getTotal()', () => {
it('should call the getTaxes method and return undefined if its called with a string', async() => {
let result = await app.models.Order.getTotal(1);
expect(result.total).toEqual(14.45);
});
});