From 2a64fde57c74836804c639e7cd21cc2b2f43064f Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 22 Sep 2022 14:58:38 +0200 Subject: [PATCH 01/19] feat: add option "move expedition" --- modules/ticket/front/expedition/index.html | 119 ++++++++++++--------- modules/ticket/front/expedition/index.js | 11 ++ 2 files changed, 82 insertions(+), 48 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index a41d368f6..37e64fad5 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -8,54 +8,77 @@ auto-load="true"> - - - - - - Expedition - Item - Name - Package type - Counter - externalId - Created - State - - - - - - - - - - {{expedition.id | zeroFill:6}} - - - {{expedition.packagingFk}} - - - {{::expedition.packageItemName}} - {{::expedition.freightItemName}} - {{::expedition.counter}} - {{::expedition.externalId}} - {{::expedition.created | date:'dd/MM/yyyy HH:mm'}} - {{::expedition.state}} - - - - - - - + + + + + + + + + +

Subtotal {{$ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

+

VAT {{$ctrl.ticket.totalWithVat - $ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

+

Total {{$ctrl.ticket.totalWithVat | currency: 'EUR':2}}

+
+
+ + + + + + + + Expedition + Item + Name + Package type + Counter + externalId + Created + State + + + + + + + + + + {{expedition.id | zeroFill:6}} + + + {{expedition.packagingFk}} + + + {{::expedition.packageItemName}} + {{::expedition.freightItemName}} + {{::expedition.counter}} + {{::expedition.externalId}} + {{::expedition.created | date:'dd/MM/yyyy HH:mm'}} + {{::expedition.state}} + + + + + + +
Date: Fri, 23 Sep 2022 08:50:11 +0200 Subject: [PATCH 02/19] feat: add totalChecked --- modules/ticket/front/expedition/index.html | 20 ++++++++++++++++---- modules/ticket/front/expedition/index.js | 4 ++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 37e64fad5..3a5d5f8a6 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -12,12 +12,11 @@ + ng-show="$ctrl.totalChecked"> @@ -134,4 +133,17 @@ - \ No newline at end of file + + + + + New ticket without route + + + New ticket with route + + \ No newline at end of file diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index adbbc53d4..38d02f548 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -22,6 +22,10 @@ class Controller extends Section { return checkedRows; } + + get totalChecked() { + return this.checked.length; + } } ngModule.vnComponent('vnTicketExpedition', { -- 2.40.1 From 11484edd105c0c57210b523c89f246a55bb1f17d Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 3 Oct 2022 15:18:07 +0200 Subject: [PATCH 03/19] feat: create new ticket --- modules/ticket/front/expedition/index.html | 22 +++++++++++++++++++--- modules/ticket/front/expedition/index.js | 17 +++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 3a5d5f8a6..694b3eb33 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -138,12 +138,28 @@ + ng-click="$ctrl.createTicket()"> New ticket without route + ng-click="selectRoute.show()"> New ticket with route - \ No newline at end of file + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 38d02f548..d80c8e812 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -26,6 +26,23 @@ class Controller extends Section { get totalChecked() { return this.checked.length; } + + createTicket(routeFk) { + const tomorrow = new Date(); + const params = { + clientId: this.ticket.clientFk, + landed: tomorrow.getDay() + 1, + addressId: this.ticket.addressFk, + agencyModeId: this.ticket.agencyModeFk, + warehouseId: this.ticket.warehouseFk + }; + const query = `Tickets/new`; + this.$http.post(query, params).then(res => { + if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); + this.vnApp.showSuccess(this.$t('Data saved!')); + this.$state.go('ticket.card.summary', {id: res.data.id}); + }); + } } ngModule.vnComponent('vnTicketExpedition', { -- 2.40.1 From a3a432c753c19d263d642c379aa1d7c4977b3a6e Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 6 Oct 2022 10:18:19 +0200 Subject: [PATCH 04/19] fix: delete one or more expeditions --- modules/ticket/front/expedition/index.html | 11 ++++++----- modules/ticket/front/expedition/index.js | 14 ++++++++++++++ modules/ticket/front/expedition/locale/es.yml | 3 ++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 694b3eb33..caef67f59 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -17,8 +17,9 @@ ng-show="$ctrl.totalChecked"> @@ -88,11 +89,11 @@ - + on-accept="$ctrl.onRemove()"> diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index d80c8e812..1525f97b5 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -27,6 +27,20 @@ class Controller extends Section { return this.checked.length; } + async onRemove() { + const params = []; + for (let expedition of this.checked) + params.push(expedition.id); + + for (let id of params) { + await this.$http.delete(`Expeditions/${id}`) + .then(() => { + this.vnApp.showSuccess(this.$t('Expedition removed')); + this.$state.reload(); + }); + } + } + createTicket(routeFk) { const tomorrow = new Date(); const params = { diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index d23cf25af..9c7872fd7 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -1 +1,2 @@ -Status log: Hitorial de estados \ No newline at end of file +Status log: Hitorial de estados +Expedition removed: Expedición eliminada \ No newline at end of file -- 2.40.1 From 37601934f579e55668e5b2eae07e9b68e95a3e81 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 6 Oct 2022 11:40:46 +0200 Subject: [PATCH 05/19] feat: first option to delete and update --- modules/ticket/front/expedition/index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 1525f97b5..4f7b34e7c 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -42,17 +42,25 @@ class Controller extends Section { } createTicket(routeFk) { - const tomorrow = new Date(); - const params = { + const date = new Date(); // esta fecha hay que preguntarla a Fran Monsalvez + const ticketParams = { clientId: this.ticket.clientFk, - landed: tomorrow.getDay() + 1, + landed: date, addressId: this.ticket.addressFk, agencyModeId: this.ticket.agencyModeFk, warehouseId: this.ticket.warehouseFk }; const query = `Tickets/new`; - this.$http.post(query, params).then(res => { + this.$http.post(query, ticketParams).then(res => { if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); + + const params = []; + for (let expedition of this.checked) + params.push(expedition.id); + const expeditionParams = {ticketFk: res.data.id}; + for (let id of params) + this.$http.patch(`Expeditions/${id}`, expeditionParams); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('ticket.card.summary', {id: res.data.id}); }); -- 2.40.1 From deb8a00dfb2edbd5d3a2a2e84caec89679cce5ad Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 7 Oct 2022 10:47:54 +0200 Subject: [PATCH 06/19] feat: add backRoutes --- .../methods/expedition/deleteExpeditions.js | 48 +++++++++++++++ .../methods/expedition/moveExpeditions.js | 59 +++++++++++++++++++ modules/ticket/back/models/expedition.js | 2 + modules/ticket/front/expedition/index.html | 4 +- modules/ticket/front/expedition/index.js | 35 +++++------ modules/ticket/front/expedition/locale/es.yml | 5 +- 6 files changed, 130 insertions(+), 23 deletions(-) create mode 100644 modules/ticket/back/methods/expedition/deleteExpeditions.js create mode 100644 modules/ticket/back/methods/expedition/moveExpeditions.js diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js new file mode 100644 index 000000000..b902b9f0c --- /dev/null +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -0,0 +1,48 @@ + +module.exports = Self => { + Self.remoteMethod('deleteExpeditions', { + description: 'Delete the selected expeditions', + accessType: 'WRITE', + accepts: [{ + arg: 'expeditionsIds', + type: ['number'], + required: true, + description: 'The expeditions ids to delete' + }], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/deleteExpeditions`, + verb: 'POST' + } + }); + + Self.deleteExpeditions = async(expeditionsIds, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const deletedExpeditions = await models.Expedition.destroyAll({ + id: {inq: expeditionsIds} + }, myOptions); + + if (tx) await tx.commit(); + + return deletedExpeditions; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js new file mode 100644 index 000000000..2c521dda7 --- /dev/null +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -0,0 +1,59 @@ + +module.exports = Self => { + Self.remoteMethod('moveExpeditions', { + description: 'Move the selected expeditions to another ticket', + accessType: 'WRITE', + accepts: [{ + arg: 'expeditionsIds', + type: ['number'], + required: true, + description: 'The expeditions ids to nove' + }, + { + arg: 'ticketId', + type: 'number', + required: true, + description: 'the ticket id to which the expeditions are added' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/moveExpeditions`, + verb: 'POST' + } + }); + + Self.moveExpeditions = async(expeditionsIds, ticketId, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const promises = []; + for (let expeditionsId of expeditionsIds) { + const expeditionToUpdate = await models.Expedition.findById(expeditionsId); + const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions); + promises.push(expeditionUpdated); + } + + const updated = await Promise.all(promises); + + if (tx) await tx.commit(); + + return updated; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/models/expedition.js b/modules/ticket/back/models/expedition.js index 9d6564373..46cde6890 100644 --- a/modules/ticket/back/models/expedition.js +++ b/modules/ticket/back/models/expedition.js @@ -1,3 +1,5 @@ module.exports = function(Self) { require('../methods/expedition/filter')(Self); + require('../methods/expedition/deleteExpeditions')(Self); + require('../methods/expedition/moveExpeditions')(Self); }; diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index caef67f59..35f56872c 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -14,10 +14,10 @@ + disabled="!$ctrl.totalChecked"> diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 4f7b34e7c..a81439d64 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -17,7 +17,7 @@ class Controller extends Section { const checkedRows = []; for (let row of rows) { if (row.checked) - checkedRows.push(row); + checkedRows.push(row.id); } return checkedRows; @@ -27,18 +27,14 @@ class Controller extends Section { return this.checked.length; } - async onRemove() { - const params = []; - for (let expedition of this.checked) - params.push(expedition.id); - - for (let id of params) { - await this.$http.delete(`Expeditions/${id}`) - .then(() => { - this.vnApp.showSuccess(this.$t('Expedition removed')); - this.$state.reload(); - }); - } + onRemove() { + const params = {expeditionsIds: this.checked}; + const query = `Expeditions/deleteExpeditions`; + this.$http.post(query, params) + .then(() => { + this.vnApp.showSuccess(this.$t('Expedition removed')); + this.$state.reload(); + }); } createTicket(routeFk) { @@ -54,13 +50,12 @@ class Controller extends Section { this.$http.post(query, ticketParams).then(res => { if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); - const params = []; - for (let expedition of this.checked) - params.push(expedition.id); - const expeditionParams = {ticketFk: res.data.id}; - for (let id of params) - this.$http.patch(`Expeditions/${id}`, expeditionParams); - + const params = { + expeditionsIds: this.checked, + ticketId: res.data.id + }; + const query = `Expeditions/moveExpeditions`; + this.$http.post(query, params); this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('ticket.card.summary', {id: res.data.id}); }); diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index 9c7872fd7..bc3ec3345 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -1,2 +1,5 @@ Status log: Hitorial de estados -Expedition removed: Expedición eliminada \ No newline at end of file +Expedition removed: Expedición eliminada +Move: Mover +New ticket without route: Nuevo ticket sin ruta +New ticket with route: Nuevo ticket con ruta \ No newline at end of file -- 2.40.1 From bb26fa6502232335c784f9fb101a381bf4f1be39 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 7 Oct 2022 13:49:42 +0200 Subject: [PATCH 07/19] feat: add tFront --- modules/ticket/front/expedition/index.js | 23 ++++---- modules/ticket/front/expedition/index.spec.js | 58 +++++++++++++++++++ 2 files changed, 69 insertions(+), 12 deletions(-) diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index a81439d64..f7674716b 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -2,16 +2,6 @@ import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { - onDialogAccept(id) { - return this.$http.delete(`Expeditions/${id}`) - .then(() => this.$.model.refresh()); - } - - showLog(expedition) { - this.expedition = expedition; - this.$.statusLog.show(); - } - get checked() { const rows = this.$.model.data || []; const checkedRows = []; @@ -27,13 +17,23 @@ class Controller extends Section { return this.checked.length; } + onDialogAccept(id) { + return this.$http.delete(`Expeditions/${id}`) + .then(() => this.$.model.refresh()); + } + + showLog(expedition) { + this.expedition = expedition; + this.$.statusLog.show(); + } + onRemove() { const params = {expeditionsIds: this.checked}; const query = `Expeditions/deleteExpeditions`; this.$http.post(query, params) .then(() => { this.vnApp.showSuccess(this.$t('Expedition removed')); - this.$state.reload(); + this.$.model.refresh(); }); } @@ -49,7 +49,6 @@ class Controller extends Section { const query = `Tickets/new`; this.$http.post(query, ticketParams).then(res => { if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); - const params = { expeditionsIds: this.checked, ticketId: res.data.id diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index 586ef2109..fe23046ce 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -17,6 +17,14 @@ describe('Ticket', () => { refresh: () => {} }; controller = $componentController('vnTicketExpedition', {$element: null, $scope}); + controller.$.model.data = [ + {id: 1}, + {id: 2}, + {id: 3} + ]; + const modelData = controller.$.model.data; + modelData[0].checked = true; + modelData[1].checked = true; })); describe('onDialogAccept()', () => { @@ -50,5 +58,55 @@ describe('Ticket', () => { expect(controller.$.statusLog.show).toHaveBeenCalledWith(); }); }); + + describe('onRemove()', () => { + it('should make a query and then call to the model refresh() method', () => { + jest.spyOn($scope.model, 'refresh'); + + const expectedParams = {expeditionsIds: [1, 2]}; + $httpBackend.expect('POST', 'Expeditions/deleteExpeditions', expectedParams).respond(200); + controller.onRemove(); + $httpBackend.flush(); + + expect($scope.model.refresh).toHaveBeenCalledWith(); + }); + }); + + describe('createTicket()', () => { + it('should make a query and then call to the $state go() method', () => { + jest.spyOn(controller.$state, 'go').mockReturnThis(); + + const ticket = { + clientFk: 1101, + landed: new Date(), + addressFk: 121, + agencyModeFk: 1, + warehouseFk: 1 + }; + controller.ticket = ticket; + + const expectedTicket = { + clientId: 1101, + landed: new Date(), + addressId: 121, + agencyModeId: 1, + warehouseId: 1 + }; + + const ticketIdToTransfer = 28; + const expectedResponse = {id: ticketIdToTransfer}; + + const expectedParams = { + expeditionsIds: [1, 2], + ticketId: 28 + }; + $httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse); + $httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(200); + controller.createTicket(); + $httpBackend.flush(); + + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketIdToTransfer}); + }); + }); }); }); -- 2.40.1 From 843f67919c9992e7e622f01b8dcfca7697fd81b3 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 10 Oct 2022 12:56:03 +0200 Subject: [PATCH 08/19] feat: add backTest --- .../specs/deleteExpeditions.spec.js | 22 ++++++++++++++++++ .../expedition/specs/moveExpeditions.spec.js | 23 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js create mode 100644 modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js diff --git a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js new file mode 100644 index 000000000..0a47c78da --- /dev/null +++ b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js @@ -0,0 +1,22 @@ +const models = require('vn-loopback/server/server').models; + +describe('ticket deleteExpeditions()', () => { + it('should delete the selected expeditions', async() => { + const tx = await models.Expedition.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const expeditionIds = [12, 13]; + const result = await models.Expedition.deleteExpeditions(expeditionIds, options); + + expect(result.count).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); + diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js new file mode 100644 index 000000000..0bb402a55 --- /dev/null +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -0,0 +1,23 @@ +const models = require('vn-loopback/server/server').models; + +describe('ticket moveExpeditions()', () => { + it('should delete the selected expeditions', async() => { + const tx = await models.Expedition.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const expeditionIds = [12, 13]; + const ticketId = 1; + const result = await models.Expedition.moveExpeditions(expeditionIds, ticketId, options); + + expect(result.length).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); + -- 2.40.1 From ea1714240e63f97bd91a9de75d3ca8463c88de17 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 10 Oct 2022 13:45:34 +0200 Subject: [PATCH 09/19] fix: test e2e --- e2e/helpers/selectors.js | 3 ++- e2e/paths/05-ticket/02_expeditions_and_log.spec.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index fedcaf5f9..97a58ba9c 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -596,7 +596,8 @@ export default { submitNotesButton: 'button[type=submit]' }, ticketExpedition: { - thirdExpeditionRemoveButton: 'vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(3) > vn-td:nth-child(1) > vn-icon-button[icon="delete"]', + thirdSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(3) vn-check[ng-model="expedition.checked"]', + deleteExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="delete"]', expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr' }, ticketPackages: { diff --git a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js index dd2525f43..f970247e5 100644 --- a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js +++ b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js @@ -18,7 +18,8 @@ describe('Ticket expeditions and log path', () => { }); it(`should delete a former expedition and confirm the remaining expedition are the expected ones`, async() => { - await page.waitToClick(selectors.ticketExpedition.thirdExpeditionRemoveButton); + await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox); + await page.waitToClick(selectors.ticketExpedition.deleteExpeditionButton); await page.waitToClick(selectors.globalItems.acceptButton); await page.reloadSection('ticket.card.expedition'); -- 2.40.1 From 423454d19ea755b1ebc1667c1ebbb6830a7bfb80 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 11:47:22 +0200 Subject: [PATCH 10/19] feat: add date-picker --- modules/ticket/front/expedition/index.html | 20 ++++++++++++-------- modules/ticket/front/expedition/index.js | 15 ++++++++++----- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 35f56872c..f4b261533 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -138,25 +138,29 @@ + name="withoutRoute" + ng-click="selectLanded.show('withoutRoute')"> New ticket without route + name="withRoute" + ng-click="selectLanded.show('withRoute')"> New ticket with route + vn-id="selectLanded" + on-accept="$ctrl.createTicket($ctrl.landed, $ctrl.newRoute)"> + + + ng-model="$ctrl.newRoute"> diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index f7674716b..49ba3280d 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -2,6 +2,12 @@ import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { + constructor($element, $scope) { + super($element, $scope); + this.landed = new Date(); + this.newRoute = null; + } + get checked() { const rows = this.$.model.data || []; const checkedRows = []; @@ -28,7 +34,7 @@ class Controller extends Section { } onRemove() { - const params = {expeditionsIds: this.checked}; + const params = {expeditionIds: this.checked}; const query = `Expeditions/deleteExpeditions`; this.$http.post(query, params) .then(() => { @@ -37,11 +43,10 @@ class Controller extends Section { }); } - createTicket(routeFk) { - const date = new Date(); // esta fecha hay que preguntarla a Fran Monsalvez + createTicket(landed, routeFk) { const ticketParams = { clientId: this.ticket.clientFk, - landed: date, + landed: landed, addressId: this.ticket.addressFk, agencyModeId: this.ticket.agencyModeFk, warehouseId: this.ticket.warehouseFk @@ -50,7 +55,7 @@ class Controller extends Section { this.$http.post(query, ticketParams).then(res => { if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); const params = { - expeditionsIds: this.checked, + expeditionIds: this.checked, ticketId: res.data.id }; const query = `Expeditions/moveExpeditions`; -- 2.40.1 From 5fce93abd5bd36720eec2ffa6d7df0f0ec3cbcd4 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 11:47:37 +0200 Subject: [PATCH 11/19] refactor: change variables name --- modules/ticket/back/methods/expedition/deleteExpeditions.js | 6 +++--- modules/ticket/back/methods/expedition/moveExpeditions.js | 6 +++--- modules/ticket/front/expedition/index.spec.js | 4 ++-- modules/ticket/front/expedition/locale/es.yml | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index b902b9f0c..5b9d0daaa 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -4,7 +4,7 @@ module.exports = Self => { description: 'Delete the selected expeditions', accessType: 'WRITE', accepts: [{ - arg: 'expeditionsIds', + arg: 'expeditionIds', type: ['number'], required: true, description: 'The expeditions ids to delete' @@ -19,7 +19,7 @@ module.exports = Self => { } }); - Self.deleteExpeditions = async(expeditionsIds, options) => { + Self.deleteExpeditions = async(expeditionIds, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -34,7 +34,7 @@ module.exports = Self => { try { const deletedExpeditions = await models.Expedition.destroyAll({ - id: {inq: expeditionsIds} + id: {inq: expeditionIds} }, myOptions); if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index 2c521dda7..338568fdb 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -4,7 +4,7 @@ module.exports = Self => { description: 'Move the selected expeditions to another ticket', accessType: 'WRITE', accepts: [{ - arg: 'expeditionsIds', + arg: 'expeditionIds', type: ['number'], required: true, description: 'The expeditions ids to nove' @@ -25,7 +25,7 @@ module.exports = Self => { } }); - Self.moveExpeditions = async(expeditionsIds, ticketId, options) => { + Self.moveExpeditions = async(expeditionIds, ticketId, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -40,7 +40,7 @@ module.exports = Self => { try { const promises = []; - for (let expeditionsId of expeditionsIds) { + for (let expeditionsId of expeditionIds) { const expeditionToUpdate = await models.Expedition.findById(expeditionsId); const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions); promises.push(expeditionUpdated); diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index fe23046ce..ad5dafbd7 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -63,7 +63,7 @@ describe('Ticket', () => { it('should make a query and then call to the model refresh() method', () => { jest.spyOn($scope.model, 'refresh'); - const expectedParams = {expeditionsIds: [1, 2]}; + const expectedParams = {expeditionIds: [1, 2]}; $httpBackend.expect('POST', 'Expeditions/deleteExpeditions', expectedParams).respond(200); controller.onRemove(); $httpBackend.flush(); @@ -97,7 +97,7 @@ describe('Ticket', () => { const expectedResponse = {id: ticketIdToTransfer}; const expectedParams = { - expeditionsIds: [1, 2], + expeditionIds: [1, 2], ticketId: 28 }; $httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse); diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index bc3ec3345..68812f985 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -2,4 +2,5 @@ Status log: Hitorial de estados Expedition removed: Expedición eliminada Move: Mover New ticket without route: Nuevo ticket sin ruta -New ticket with route: Nuevo ticket con ruta \ No newline at end of file +New ticket with route: Nuevo ticket con ruta +Id route: Id ruta \ No newline at end of file -- 2.40.1 From ae3e3c3c49c4dc474d96fbd510febaa03fb28f7c Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 12:37:06 +0200 Subject: [PATCH 12/19] fix: id model duplicated --- modules/ticket/front/expedition/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index f4b261533..0ebe388c1 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -98,16 +98,16 @@ - + - + State -- 2.40.1 From 9ea427dbfece8d68a6350e1f9861f2222c31f631 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 13:45:46 +0200 Subject: [PATCH 13/19] refactor: move front to back funcionality --- loopback/locale/es.json | 3 +- .../methods/expedition/moveExpeditions.js | 60 +++++++++++++++---- modules/ticket/front/expedition/index.js | 17 ++---- 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 67370b343..bd9de41c2 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -235,5 +235,6 @@ "Dirección incorrecta": "Dirección incorrecta", "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", - "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente" + "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", + "This route not exists": "Esta ruta no existe" } \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index 338568fdb..d0f8aa893 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -1,19 +1,47 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('moveExpeditions', { + Self.remoteMethodCtx('moveExpeditions', { description: 'Move the selected expeditions to another ticket', accessType: 'WRITE', accepts: [{ + arg: 'clientId', + type: 'number', + description: `The client id`, + required: true + }, + { + arg: 'landed', + type: 'date', + description: `The landing date` + }, + { + arg: 'warehouseId', + type: 'number', + description: `The warehouse id`, + required: true + }, + { + arg: 'addressId', + type: 'number', + description: `The address id`, + required: true + }, + { + arg: 'agencyModeId', + type: 'any', + description: `The agencyMode id` + }, + { + arg: 'routeId', + type: 'any', + description: `The route id` + }, + { arg: 'expeditionIds', type: ['number'], required: true, - description: 'The expeditions ids to nove' - }, - { - arg: 'ticketId', - type: 'number', - required: true, - description: 'the ticket id to which the expeditions are added' + description: 'The expeditions ids to move' }], returns: { type: 'object', @@ -25,8 +53,9 @@ module.exports = Self => { } }); - Self.moveExpeditions = async(expeditionIds, ticketId, options) => { + Self.moveExpeditions = async(ctx, options) => { const models = Self.app.models; + const args = ctx.args; const myOptions = {}; let tx; @@ -39,18 +68,23 @@ module.exports = Self => { } try { + if (args.routeId) { + const route = await models.Route.findById(args.routeId, null, myOptions); + if (!route) throw new UserError('This route not exists'); + } + const ticket = await models.Ticket.new(ctx, myOptions); const promises = []; - for (let expeditionsId of expeditionIds) { + for (let expeditionsId of args.expeditionIds) { const expeditionToUpdate = await models.Expedition.findById(expeditionsId); - const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions); + const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions); promises.push(expeditionUpdated); } - const updated = await Promise.all(promises); + await Promise.all(promises); if (tx) await tx.commit(); - return updated; + return ticket; } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 49ba3280d..7ffe2fe5e 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -44,22 +44,17 @@ class Controller extends Section { } createTicket(landed, routeFk) { - const ticketParams = { + const params = { clientId: this.ticket.clientFk, landed: landed, + warehouseId: this.ticket.warehouseFk, addressId: this.ticket.addressFk, agencyModeId: this.ticket.agencyModeFk, - warehouseId: this.ticket.warehouseFk + routeId: routeFk, + expeditionIds: this.checked }; - const query = `Tickets/new`; - this.$http.post(query, ticketParams).then(res => { - if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); - const params = { - expeditionIds: this.checked, - ticketId: res.data.id - }; - const query = `Expeditions/moveExpeditions`; - this.$http.post(query, params); + const query = `Expeditions/moveExpeditions`; + this.$http.post(query, params).then(res => { this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('ticket.card.summary', {id: res.data.id}); }); -- 2.40.1 From 51cad752984fb2d13f804772aa8bec233430e4f7 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 08:17:15 +0200 Subject: [PATCH 14/19] fix: testFront --- modules/ticket/front/expedition/index.spec.js | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index ad5dafbd7..b95d64fa3 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -83,29 +83,25 @@ describe('Ticket', () => { agencyModeFk: 1, warehouseFk: 1 }; + const routeId = null; controller.ticket = ticket; - const expectedTicket = { - clientId: 1101, - landed: new Date(), - addressId: 121, - agencyModeId: 1, - warehouseId: 1 - }; - - const ticketIdToTransfer = 28; - const expectedResponse = {id: ticketIdToTransfer}; + const ticketToTransfer = {id: 28}; const expectedParams = { - expeditionIds: [1, 2], - ticketId: 28 + clientId: 1101, + landed: new Date(), + warehouseId: 1, + addressId: 121, + agencyModeId: 1, + routeId: null, + expeditionIds: [1, 2] }; - $httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse); - $httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(200); - controller.createTicket(); + $httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(ticketToTransfer); + controller.createTicket(ticket.landed, routeId); $httpBackend.flush(); - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketIdToTransfer}); + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketToTransfer.id}); }); }); }); -- 2.40.1 From bcc9acac0ac997d9c54df4e12efc830dc50c1331 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 08:41:00 +0200 Subject: [PATCH 15/19] fix: tBack --- .../expedition/specs/moveExpeditions.spec.js | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js index 0bb402a55..67919e76c 100644 --- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -1,17 +1,33 @@ const models = require('vn-loopback/server/server').models; describe('ticket moveExpeditions()', () => { - it('should delete the selected expeditions', async() => { + it('should move the selected expeditions to new ticket', async() => { const tx = await models.Expedition.beginTransaction({}); + const ctx = { + req: {accessToken: {userId: 9}}, + args: {}, + params: {} + }; + const myCtx = Object.assign({}, ctx); try { const options = {transaction: tx}; + myCtx.args = { + clientId: 1101, + landed: new Date(), + warehouseId: 1, + addressId: 121, + agencyModeId: 1, + routeId: null, + expeditionIds: [1, 2] - const expeditionIds = [12, 13]; - const ticketId = 1; - const result = await models.Expedition.moveExpeditions(expeditionIds, ticketId, options); + }; - expect(result.length).toEqual(2); + const ticket = await models.Expedition.moveExpeditions(myCtx, options); + + const newestTicketIdInFixtures = 27; + + expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures); await tx.rollback(); } catch (e) { -- 2.40.1 From 2da34d0850de92ee8684fb9d339b59a4ff2cc852 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 09:40:11 +0200 Subject: [PATCH 16/19] feat: add e2e --- e2e/helpers/selectors.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 74dabc31a..dabb4c0cd 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -596,8 +596,14 @@ export default { submitNotesButton: 'button[type=submit]' }, ticketExpedition: { + firstSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(1) vn-check[ng-model="expedition.checked"]', thirdSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(3) vn-check[ng-model="expedition.checked"]', deleteExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="delete"]', + moveExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="keyboard_arrow_down"]', + moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]', + moreMenuWithRoute: 'vn-item[name="withRoute"]', + newRouteId: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newRoute"]', + saveButton: '.vn-dialog.shown [response="accept"]', expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr' }, ticketPackages: { -- 2.40.1 From 5824fee213055de7401a1ebd3e63f7879199315a Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 09:40:23 +0200 Subject: [PATCH 17/19] feat: add e2e --- e2e/paths/05-ticket/20_moveExpedition.spec.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 e2e/paths/05-ticket/20_moveExpedition.spec.js diff --git a/e2e/paths/05-ticket/20_moveExpedition.spec.js b/e2e/paths/05-ticket/20_moveExpedition.spec.js new file mode 100644 index 000000000..9673c7071 --- /dev/null +++ b/e2e/paths/05-ticket/20_moveExpedition.spec.js @@ -0,0 +1,50 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +fdescribe('Ticket expeditions', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('production', 'ticket'); + await page.accessToSearchResult('1'); + await page.accessToSection('ticket.card.expedition'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it(`should move one expedition to new ticket withoute route`, async() => { + await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox); + await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton); + await page.waitToClick(selectors.ticketExpedition.moreMenuWithoutRoute); + await page.waitToClick(selectors.ticketExpedition.saveButton); + await page.waitForState('ticket.card.summary'); + await page.accessToSection('ticket.card.expedition'); + + await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {}); + const result = await page + .countElement(selectors.ticketExpedition.expeditionRow); + + expect(result).toEqual(1); + }); + + it(`should move one expedition to new ticket with route`, async() => { + await page.waitToClick(selectors.ticketExpedition.firstSaleCheckbox); + await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton); + await page.waitToClick(selectors.ticketExpedition.moreMenuWithRoute); + await page.write(selectors.ticketExpedition.newRouteId, '1'); + await page.waitToClick(selectors.ticketExpedition.saveButton); + await page.waitForState('ticket.card.summary'); + await page.accessToSection('ticket.card.expedition'); + + await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {}); + const result = await page + .countElement(selectors.ticketExpedition.expeditionRow); + + expect(result).toEqual(1); + }); +}); -- 2.40.1 From dd15d06f5edfb7c439482764551175e7fe225b70 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 10:21:44 +0200 Subject: [PATCH 18/19] delete focus test --- e2e/paths/05-ticket/20_moveExpedition.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/05-ticket/20_moveExpedition.spec.js b/e2e/paths/05-ticket/20_moveExpedition.spec.js index 9673c7071..cf1c5ded3 100644 --- a/e2e/paths/05-ticket/20_moveExpedition.spec.js +++ b/e2e/paths/05-ticket/20_moveExpedition.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Ticket expeditions', () => { +describe('Ticket expeditions', () => { let browser; let page; -- 2.40.1 From d4e278363009abaa45090212dc3e50a2f0430086 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 26 Oct 2022 08:39:07 +0200 Subject: [PATCH 19/19] =?UTF-8?q?refactor:=20corregidas=20traducciones,=20?= =?UTF-8?q?eliminado=20destroyAll=20y=20a=C3=B1adida=20transacci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loopback/locale/es.json | 2 +- .../back/methods/expedition/deleteExpeditions.js | 10 +++++++--- .../ticket/back/methods/expedition/moveExpeditions.js | 4 ++-- .../methods/expedition/specs/deleteExpeditions.spec.js | 2 +- modules/ticket/front/expedition/index.html | 2 +- modules/ticket/front/expedition/locale/es.yml | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index bd9de41c2..2d9bae1d8 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -236,5 +236,5 @@ "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", - "This route not exists": "Esta ruta no existe" + "This route does not exists": "Esta ruta no existe" } \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 5b9d0daaa..2419d3a5e 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -33,9 +33,13 @@ module.exports = Self => { } try { - const deletedExpeditions = await models.Expedition.destroyAll({ - id: {inq: expeditionIds} - }, myOptions); + const promises = []; + for (let expeditionId of expeditionIds) { + const deletedExpedition = models.Expedition.destroyById(expeditionId, myOptions); + promises.push(deletedExpedition); + } + + const deletedExpeditions = await Promise.all(promises); if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index d0f8aa893..cef35ab86 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -70,12 +70,12 @@ module.exports = Self => { try { if (args.routeId) { const route = await models.Route.findById(args.routeId, null, myOptions); - if (!route) throw new UserError('This route not exists'); + if (!route) throw new UserError('This route does not exists'); } const ticket = await models.Ticket.new(ctx, myOptions); const promises = []; for (let expeditionsId of args.expeditionIds) { - const expeditionToUpdate = await models.Expedition.findById(expeditionsId); + const expeditionToUpdate = await models.Expedition.findById(expeditionsId, null, myOptions); const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions); promises.push(expeditionUpdated); } diff --git a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js index 0a47c78da..14bdf7aea 100644 --- a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js @@ -10,7 +10,7 @@ describe('ticket deleteExpeditions()', () => { const expeditionIds = [12, 13]; const result = await models.Expedition.deleteExpeditions(expeditionIds, options); - expect(result.count).toEqual(2); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 0ebe388c1..ec6dc7ee2 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -159,7 +159,7 @@ diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index 68812f985..278dcc8f2 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -3,4 +3,4 @@ Expedition removed: Expedición eliminada Move: Mover New ticket without route: Nuevo ticket sin ruta New ticket with route: Nuevo ticket con ruta -Id route: Id ruta \ No newline at end of file +Route id: Id ruta \ No newline at end of file -- 2.40.1