From a58e534a6d42e7a43e1048609df79dc6ca4b2f66 Mon Sep 17 00:00:00 2001 From: gerard Date: Thu, 9 Aug 2018 16:12:28 +0200 Subject: [PATCH 1/8] item descriptor front test --- client/item/src/descriptor/index.spec.js | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 client/item/src/descriptor/index.spec.js diff --git a/client/item/src/descriptor/index.spec.js b/client/item/src/descriptor/index.spec.js new file mode 100644 index 000000000..4e419c50f --- /dev/null +++ b/client/item/src/descriptor/index.spec.js @@ -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'); + }); + }); + }); +}); From 9b2a2b7a9fc02b63a6ad4f1a93393ffb4171aacf Mon Sep 17 00:00:00 2001 From: gerard Date: Fri, 10 Aug 2018 13:22:11 +0200 Subject: [PATCH 2/8] translations added --- services/loopback/common/locale/es.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/loopback/common/locale/es.json b/services/loopback/common/locale/es.json index 1653030b6..a2eba7d3c 100644 --- a/services/loopback/common/locale/es.json +++ b/services/loopback/common/locale/es.json @@ -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" } \ No newline at end of file From 3875f4298c799199f3e5ac2ec9c204d9c4bc2420 Mon Sep 17 00:00:00 2001 From: gerard Date: Fri, 10 Aug 2018 16:15:17 +0200 Subject: [PATCH 3/8] filter modified to get the prices of a product --- .../order/common/methods/order/itemFilter.js | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/services/order/common/methods/order/itemFilter.js b/services/order/common/methods/order/itemFilter.js index 916e0cca0..d04f3aa92 100644 --- a/services/order/common/methods/order/itemFilter.js +++ b/services/order/common/methods/order/itemFilter.js @@ -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; }; }; From 06a3f0b6bc5876d8334dcd87d135ffb2018ab82a Mon Sep 17 00:00:00 2001 From: gerard Date: Fri, 10 Aug 2018 16:30:18 +0200 Subject: [PATCH 4/8] /order/getTotal.js Backend unit tests --- .../order/common/methods/order/specs/getTotal.spec.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 services/order/common/methods/order/specs/getTotal.spec.js diff --git a/services/order/common/methods/order/specs/getTotal.spec.js b/services/order/common/methods/order/specs/getTotal.spec.js new file mode 100644 index 000000000..036d46e6c --- /dev/null +++ b/services/order/common/methods/order/specs/getTotal.spec.js @@ -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); + }); +}); From ac90bb3b1826a0a9a5ccc879df693aeb00bc545d Mon Sep 17 00:00:00 2001 From: gerard Date: Fri, 10 Aug 2018 16:31:44 +0200 Subject: [PATCH 5/8] /ticket/getSalesPersonMana.js Backend unit tests --- .../ticket/specs/getSalespersonMana.spec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 services/loopback/common/methods/ticket/specs/getSalespersonMana.spec.js diff --git a/services/loopback/common/methods/ticket/specs/getSalespersonMana.spec.js b/services/loopback/common/methods/ticket/specs/getSalespersonMana.spec.js new file mode 100644 index 000000000..c804ec592 --- /dev/null +++ b/services/loopback/common/methods/ticket/specs/getSalespersonMana.spec.js @@ -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); + }); +}); From 439adaf409ea28148228c941fd266a60fdb6d669 Mon Sep 17 00:00:00 2001 From: gerard Date: Fri, 10 Aug 2018 17:13:25 +0200 Subject: [PATCH 6/8] Tarea #471 credit/create/index.js Front unit test --- client/client/src/credit/create/index.spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client/client/src/credit/create/index.spec.js b/client/client/src/credit/create/index.spec.js index 6efd355d1..9aaa095b7 100644 --- a/client/client/src/credit/create/index.spec.js +++ b/client/client/src/credit/create/index.spec.js @@ -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'); From 4076934644db8ba18c9a0193b60ad6c6eee762ed Mon Sep 17 00:00:00 2001 From: gerard Date: Fri, 10 Aug 2018 17:17:53 +0200 Subject: [PATCH 7/8] Tarea #541 /methods/ticket/deleted.js --- .../common/methods/ticket/specs/deleted.spec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 services/loopback/common/methods/ticket/specs/deleted.spec.js diff --git a/services/loopback/common/methods/ticket/specs/deleted.spec.js b/services/loopback/common/methods/ticket/specs/deleted.spec.js new file mode 100644 index 000000000..ab0a5038a --- /dev/null +++ b/services/loopback/common/methods/ticket/specs/deleted.spec.js @@ -0,0 +1,15 @@ +const app = require(`${servicesDir}/ticket/server/server`); + +fdescribe('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); + }); +}); From c62ed68d28a776b0587aba5f99ec672b3bfa3e55 Mon Sep 17 00:00:00 2001 From: gerard Date: Fri, 10 Aug 2018 17:18:21 +0200 Subject: [PATCH 8/8] Tarea #541 /methods/ticket/deleted.js Backend unit tests --- services/loopback/common/methods/ticket/specs/deleted.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/loopback/common/methods/ticket/specs/deleted.spec.js b/services/loopback/common/methods/ticket/specs/deleted.spec.js index ab0a5038a..7b1e8e2dc 100644 --- a/services/loopback/common/methods/ticket/specs/deleted.spec.js +++ b/services/loopback/common/methods/ticket/specs/deleted.spec.js @@ -1,6 +1,6 @@ const app = require(`${servicesDir}/ticket/server/server`); -fdescribe('ticket deleted()', () => { +describe('ticket deleted()', () => { it('should call the getShipped method', async() => { let oldTicket = await app.models.Ticket.findOne({where: {id: 1}});