From 46b59473a39bed651fce21d8436b7fe1d5837422 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 9 Sep 2021 16:06:44 +0200 Subject: [PATCH 01/13] refactor(lastbuyrefresh): moved last buy refresh calls to fixtures + some more fixtures --- db/dump/fixtures.sql | 20 ++++++++++--------- db/tests/cache/last_buy_refresh.spec.js | 14 +++++-------- .../back/methods/entry/latestBuysFilter.js | 1 - modules/item/back/methods/item/filter.js | 1 - 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 8c1a3c8bc..fb71f091f 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -125,14 +125,14 @@ INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) (1, 'Main Warehouse'), (2, 'Silla'); -INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`) +INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`) VALUES - (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 2, 1), - (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 0, 1, 2, 13), - (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1), - (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1), - (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1), - (13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 0, 2, 1); + (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 2, 1, 1), + (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 0, 1, 2, 13, 1), + (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1), + (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1), + (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1), + (13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 0, 2, 1, 0); INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`) VALUES @@ -845,7 +845,7 @@ INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `create (7, 2, 4, 71, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL, 1, 1, 18, NULL, 94), (8, 3, 5, 71, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), NULL, 1, 1, 18, NULL, 94), (9, 3, 6, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94), - (10, 7, 7, 71, CURDATE(), NULL, 1, 1, 18, NULL, 94); + (10, 7, 7, 71, NOW(), NULL, 1, 1, 18, NULL, 94); INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`) VALUES @@ -2408,4 +2408,6 @@ INSERT INTO `vn`.`expeditionScan` (`id`, `expeditionFk`, `scanned`, `palletFk`) (7, 7, CURDATE(), 1), (8, 8, CURDATE(), 1), (9, 9, CURDATE(), 1), - (10, 10, CURDATE(), 1); \ No newline at end of file + (10, 10, CURDATE(), 1); + +CALL `cache`.`last_buy_refresh`(FALSE); \ No newline at end of file diff --git a/db/tests/cache/last_buy_refresh.spec.js b/db/tests/cache/last_buy_refresh.spec.js index 0036e2762..71a9c3872 100644 --- a/db/tests/cache/last_buy_refresh.spec.js +++ b/db/tests/cache/last_buy_refresh.spec.js @@ -3,22 +3,18 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('last_buy_refresh()', () => { it(`should store some data on cache.last_buy`, async() => { - let stmts = []; - let stmt; + const stmts = []; stmts.push('START TRANSACTION'); - stmt = new ParameterizedSQL('CALL cache.last_buy_refresh(true)'); - stmts.push(stmt); - - let lastBuyTableIndex = stmts.push(`SELECT * FROM cache.last_buy ORDER BY item_id ASC`) - 1; + const lastBuyTableIndex = stmts.push(`SELECT * FROM cache.last_buy ORDER BY item_id ASC`) - 1; stmts.push('ROLLBACK'); - let sql = ParameterizedSQL.join(stmts, ';'); - let result = await app.models.Ticket.rawStmt(sql); + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await app.models.Ticket.rawStmt(sql); - let lastBuyTable = result[lastBuyTableIndex]; + const lastBuyTable = result[lastBuyTableIndex]; expect(lastBuyTable.length).toEqual(12); diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js index d59e34e64..cbf9e3b6a 100644 --- a/modules/entry/back/methods/entry/latestBuysFilter.js +++ b/modules/entry/back/methods/entry/latestBuysFilter.js @@ -115,7 +115,6 @@ module.exports = Self => { const stmts = []; let stmt; - stmts.push('CALL cache.last_buy_refresh(FALSE)'); stmts.push('CALL cache.visible_refresh(@calc_id, FALSE, 1)'); stmt = new ParameterizedSQL(` diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index 7063c386e..cff36a223 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -127,7 +127,6 @@ module.exports = Self => { filter = mergeFilters(filter, {where}); const stmts = []; - stmts.push('CALL cache.last_buy_refresh(FALSE)'); const stmt = new ParameterizedSQL( `SELECT i.id, From f7e2dd25e434676dafed7a495949fc6cb9db4570 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 9 Sep 2021 16:07:46 +0200 Subject: [PATCH 02/13] refactor(monitors): added column practicalHour to tickets monitor and renamed two columns --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 6 ++++-- modules/monitor/front/index/locale/es.yml | 4 +++- modules/monitor/front/index/tickets/index.html | 6 ++++-- modules/monitor/front/index/tickets/index.js | 4 ---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 1546aee0e..6483a906a 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -223,7 +223,8 @@ module.exports = Self => { MINUTE(z.hour) AS zoneMinute, z.name AS zoneName, z.id AS zoneFk, - CAST(z.hour AS CHAR) AS hour + CAST(z.hour AS CHAR) AS hour, + TIME_FORMAT(zed.etc, '%H:%i') AS practicalHour FROM ticket t LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN zone z ON z.id = t.zoneFk @@ -235,7 +236,8 @@ module.exports = Self => { LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk - LEFT JOIN account.user u ON u.id = wk.userFk`); + LEFT JOIN account.user u ON u.id = wk.userFk + LEFT JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk`); if (args.orderFk) { stmt.merge({ diff --git a/modules/monitor/front/index/locale/es.yml b/modules/monitor/front/index/locale/es.yml index 160392245..4eef3c93f 100644 --- a/modules/monitor/front/index/locale/es.yml +++ b/modules/monitor/front/index/locale/es.yml @@ -6,4 +6,6 @@ Delete selected elements: Eliminar los elementos seleccionados All the selected elements will be deleted. Are you sure you want to continue?: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar? Component lack: Faltan componentes Minimize/Maximize: Minimizar/Maximizar -Problems: Problemas \ No newline at end of file +Problems: Problemas +Theoretical: Teórica +Practical: Práctica \ No newline at end of file diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index 2d2c5fa78..82adf2765 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -37,8 +37,9 @@ Client Salesperson Date - Hour - Closure + Prep. + Theoretical + Practical Province State Zone @@ -112,6 +113,7 @@ {{::ticket.shipped | date: 'HH:mm'}} {{::ticket.zoneLanding | date: 'HH:mm'}} + {{::ticket.practicalHour | date: 'HH:mm'}} {{::ticket.province}} Date: Fri, 10 Sep 2021 10:38:19 +0200 Subject: [PATCH 03/13] feat(closure): send to driver the route report on route closure --- db/dump/fixtures.sql | 7 ++++++- print/methods/closure.js | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 8c1a3c8bc..6f667aa9b 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -6,6 +6,11 @@ ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; +INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) + VALUES + ('TOTALLY_SECURE_TOKEN', '1209600', CURDATE(), 66); + + INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES ('1', '6'); @@ -208,7 +213,7 @@ UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 8; UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 4 WHERE `id` = 23; UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 10; -UPDATE `vn`.`agencyMode` SET `web` = 1; +UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com'; UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; diff --git a/print/methods/closure.js b/print/methods/closure.js index 4c6f91b58..daa2d5e7c 100644 --- a/print/methods/closure.js +++ b/print/methods/closure.js @@ -143,8 +143,24 @@ module.exports = app => { AND t.refFk IS NULL GROUP BY e.ticketFk`, [reqArgs.routeId]); const ticketIds = tickets.map(ticket => ticket.id); - await closeAll(ticketIds, reqArgs); + + // Send route report to the agency + const agencyMail = await db.findValue(` + SELECT am.reportMail + FROM route r + JOIN agencyMode am ON am.id = r.agencyModeFk + WHERE r.id = ?`, [reqArgs.routeId]); + + if (agencyMail) { + const args = Object.assign({ + routeId: reqArgs.routeId, + recipient: agencyMail + }, reqArgs); + + const email = new Email('driver-route', args); + await email.send(); + } } catch (error) { next(error); } From c442073eae6d17d607479e137874db6ce3cf64e7 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 14 Sep 2021 09:33:23 +0200 Subject: [PATCH 04/13] feat(upload-photo): added options to choose between upload from computer or external url Refs: 2627 --- .../salix/components/upload-photo/index.html | 28 +++++++++++++++-- front/salix/components/upload-photo/index.js | 30 ++++++++++++------- .../components/upload-photo/locale/es.yml | 4 ++- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/front/salix/components/upload-photo/index.html b/front/salix/components/upload-photo/index.html index 09b36d531..a9b674f42 100644 --- a/front/salix/components/upload-photo/index.html +++ b/front/salix/components/upload-photo/index.html @@ -4,7 +4,7 @@ message="Edit photo"> - + - + + + + + + + @@ -37,6 +51,14 @@ + + + + this.editor.bind({url: e.target.result}); - reader.readAsDataURL(value[0]); + if (this.uploadMethod == 'computer') { + const reader = new FileReader(); + reader.onload = e => this.editor.bind({url: e.target.result}); + reader.readAsDataURL(value); + } else if (this.uploadMethod == 'URL') + this.editor.bind({url: value}); } } diff --git a/front/salix/components/upload-photo/locale/es.yml b/front/salix/components/upload-photo/locale/es.yml index bba3a985a..fca0a4ac3 100644 --- a/front/salix/components/upload-photo/locale/es.yml +++ b/front/salix/components/upload-photo/locale/es.yml @@ -3,4 +3,6 @@ Select an image: Selecciona una imagen File name: Nombre del fichero Rotate left: Girar a la izquierda Rotate right: Girar a la derecha -Panoramic: Panorámico \ No newline at end of file +Panoramic: Panorámico +Select from computer: Seleccionar foto desde ordenador +Import from external URL: Importar desde URL externa \ No newline at end of file From 59efc240771e2d9848aecf0e4b9e976c177fe51a Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 14 Sep 2021 11:26:22 +0200 Subject: [PATCH 05/13] Updated unit test --- .../components/upload-photo/index.spec.js | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/front/salix/components/upload-photo/index.spec.js b/front/salix/components/upload-photo/index.spec.js index e8ac05fd4..f2aad6a5c 100644 --- a/front/salix/components/upload-photo/index.spec.js +++ b/front/salix/components/upload-photo/index.spec.js @@ -24,17 +24,30 @@ describe('Salix', () => { }); describe('viewportSelection()', () => { - it('should call to displayEditor() and updatePhotoPreview() methods', () => { - controller.displayEditor = jest.fn(); + it('should call to the updatePhotoPreview() method when uploadMethod property is set to "computer"', () => { controller.updatePhotoPreview = jest.fn(); const files = [{name: 'test.jpg'}]; controller.newPhoto.files = files; + controller.uploadMethod = 'computer'; controller.viewportSelection = {code: 'normal'}; - expect(controller.displayEditor).toHaveBeenCalledWith(); - expect(controller.updatePhotoPreview).toHaveBeenCalledWith(files); + const firstFile = files[0]; + + expect(controller.updatePhotoPreview).toHaveBeenCalledWith(firstFile); + }); + + it('should call to the updatePhotoPreview() method when uploadMethod property is set to "URL"', () => { + controller.updatePhotoPreview = jest.fn(); + + const url = 'http://gothamcity.com/batman.png'; + controller.newPhoto.url = url; + + controller.uploadMethod = 'URL'; + controller.viewportSelection = {code: 'normal'}; + + expect(controller.updatePhotoPreview).toHaveBeenCalledWith(url); }); }); From 0f1b33802e5fe51b4fb71a8d01ad2ffe6c1874ef Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 15 Sep 2021 13:24:01 +0200 Subject: [PATCH 06/13] refactor(newbankentity): added id as entity code input + translation --- front/salix/components/bank-entity/index.html | 19 ++++++++++++++----- .../components/bank-entity/locale/es.yml | 3 ++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/front/salix/components/bank-entity/index.html b/front/salix/components/bank-entity/index.html index 3a7786607..b6cc1f4ee 100644 --- a/front/salix/components/bank-entity/index.html +++ b/front/salix/components/bank-entity/index.html @@ -14,8 +14,6 @@ ng-model="$ctrl.data.name" required="true"> - - - + + + + - + - + \ No newline at end of file diff --git a/front/salix/components/bank-entity/locale/es.yml b/front/salix/components/bank-entity/locale/es.yml index fe5160572..874a42393 100644 --- a/front/salix/components/bank-entity/locale/es.yml +++ b/front/salix/components/bank-entity/locale/es.yml @@ -9,4 +9,5 @@ The country can't be empty: El país no puede quedar vacío The postcode has been created. You can save the data now: Se ha creado el código postal. Ahora puedes guardar los datos The city has been created: Se ha creado la ciudad The province has been created: Se ha creado la provincia -The bank entity has been created. You can save the data now: Se ha creado la entidad bancaria. Puedes guardar los datos ahora \ No newline at end of file +The bank entity has been created. You can save the data now: Se ha creado la entidad bancaria. Puedes guardar los datos ahora +Entity code: Código de la entidad \ No newline at end of file From d8a2302b181ae0d75dd00426f7ae55342ecb060e Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 15 Sep 2021 13:25:26 +0200 Subject: [PATCH 07/13] refactor(newbankentity): both client.billingdata and supplier.account now use newbankentity component --- modules/client/front/billing-data/index.html | 55 ++----------------- modules/client/front/billing-data/index.js | 7 +-- .../client/front/billing-data/index.spec.js | 18 ++---- .../client/front/billing-data/locale/es.yml | 3 +- modules/supplier/front/account/index.html | 1 + modules/supplier/front/account/index.spec.js | 2 +- 6 files changed, 16 insertions(+), 70 deletions(-) diff --git a/modules/client/front/billing-data/index.html b/modules/client/front/billing-data/index.html index b9c20ec24..ae1ad85a5 100644 --- a/modules/client/front/billing-data/index.html +++ b/modules/client/front/billing-data/index.html @@ -108,53 +108,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/client/front/billing-data/index.js b/modules/client/front/billing-data/index.js index 2dda347b9..dd43a661e 100644 --- a/modules/client/front/billing-data/index.js +++ b/modules/client/front/billing-data/index.js @@ -42,12 +42,11 @@ export default class Controller extends Section { this.newBankEntity = { countryFk: Number.parseInt(this.client.countryFk) }; - this.$.bankEntityDialog.show(); + this.$.bankEntity.open(); } - onBankEntityAccept() { - return this.$http.post(`BankEntities`, this.newBankEntity) - .then(res => this.client.bankEntityFk = res.data.id); + onResponse(response) { + this.client.bankEntityFk = response.id; } get ibanCountry() { diff --git a/modules/client/front/billing-data/index.spec.js b/modules/client/front/billing-data/index.spec.js index 95700cb5a..60cc4025c 100644 --- a/modules/client/front/billing-data/index.spec.js +++ b/modules/client/front/billing-data/index.spec.js @@ -35,20 +35,12 @@ describe('Client', () => { }); }); - describe('onBankEntityAccept()', () => { - it('should request to create a new bank entity', () => { - let newBankEntity = { - name: 'My new bank entity', - bic: 'ES123', - countryFk: 1, - id: 999 - }; - controller.newBankEntity = newBankEntity; - $httpBackend.expectPOST('BankEntities', newBankEntity).respond({id: 999}); - controller.onBankEntityAccept(); - $httpBackend.flush(); + describe('onResponse()', () => { + it('should assign the response id to the client bankEntityFk', () => { + const expectedResponse = {id: 999}; + controller.onResponse(expectedResponse); - expect(controller.client.bankEntityFk).toEqual(newBankEntity.id); + expect(controller.client.bankEntityFk).toEqual(expectedResponse.id); }); }); diff --git a/modules/client/front/billing-data/locale/es.yml b/modules/client/front/billing-data/locale/es.yml index a7ecbbdae..0052ee403 100644 --- a/modules/client/front/billing-data/locale/es.yml +++ b/modules/client/front/billing-data/locale/es.yml @@ -14,5 +14,4 @@ Received core VNL: Recibido core VNL Received B2B VNL: Recibido B2B VNL Save: Guardar New bank entity: Nueva entidad bancaria -Name can't be empty: El nombre no puede quedar vacío -Entity Code: Código \ No newline at end of file +Name can't be empty: El nombre no puede quedar vacío \ No newline at end of file diff --git a/modules/supplier/front/account/index.html b/modules/supplier/front/account/index.html index 7264f6f2c..c8ec8ba31 100644 --- a/modules/supplier/front/account/index.html +++ b/modules/supplier/front/account/index.html @@ -65,6 +65,7 @@ + { expect(controller.$.bankEntity.open).toHaveBeenCalledWith(); }); - it('should request to create a new bank entity', () => { + it('should now request to create a new bank entity', () => { controller.bankEntity = { name: 'My new bank entity', bic: 'ES1234', From e81c1046f6999918cbc201c98a688229e39ef8ed Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 15 Sep 2021 13:26:08 +0200 Subject: [PATCH 08/13] test(e2e): e2e and selectors amended according to newbankentity refactor --- e2e/helpers/selectors.js | 7 ++++--- e2e/paths/02-client/04_edit_billing_data.spec.js | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 6f257774a..f63d67f8b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -186,9 +186,10 @@ export default { receivedB2BVNLCheckbox: 'vn-client-billing-data vn-check[label="Received B2B VNL"]', swiftBic: 'vn-client-billing-data vn-autocomplete[ng-model="$ctrl.client.bankEntityFk"]', newBankEntityButton: 'vn-client-billing-data vn-icon-button[vn-tooltip="New bank entity"] > button', - newBankEntityName: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newBankEntity.name"]', - newBankEntityBIC: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newBankEntity.bic"]', - newBankEntityCode: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newBankEntity.id"]', + newBankEntityName: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.data.name"]', + newBankEntityBIC: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.data.bic"]', + newBankEntityCountry: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.data.countryFk"]', + newBankEntityCode: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.data.id"]', acceptBankEntityButton: '.vn-dialog.shown button[response="accept"]', saveButton: 'vn-client-billing-data button[type=submit]', watcher: 'vn-client-billing-data vn-watcher' diff --git a/e2e/paths/02-client/04_edit_billing_data.spec.js b/e2e/paths/02-client/04_edit_billing_data.spec.js index 208345457..6bc48093e 100644 --- a/e2e/paths/02-client/04_edit_billing_data.spec.js +++ b/e2e/paths/02-client/04_edit_billing_data.spec.js @@ -34,8 +34,9 @@ describe('Client Edit billing data path', () => { it(`should create a new BIC code`, async() => { await page.waitToClick(selectors.clientBillingData.newBankEntityButton); await page.write(selectors.clientBillingData.newBankEntityName, 'Gotham City Bank'); - await page.write(selectors.clientBillingData.newBankEntityCode, '9999'); await page.write(selectors.clientBillingData.newBankEntityBIC, 'GTHMCT'); + await page.autocompleteSearch(selectors.clientBillingData.newBankEntityCountry, 'España'); + await page.write(selectors.clientBillingData.newBankEntityCode, '9999'); await page.waitToClick(selectors.clientBillingData.acceptBankEntityButton); await page.waitForTextInField(selectors.clientBillingData.swiftBic, 'Gotham City Bank'); const newcode = await page.waitToGetProperty(selectors.clientBillingData.swiftBic, 'value'); From 47e70f7c3c86c73c803b4837159aeda0f0993e7f Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 15 Sep 2021 15:54:54 +0200 Subject: [PATCH 09/13] refactor(newbankentity): the component now extends from Dialog --- front/salix/components/bank-entity/index.html | 95 +++++++++---------- front/salix/components/bank-entity/index.js | 34 +++---- 2 files changed, 57 insertions(+), 72 deletions(-) diff --git a/front/salix/components/bank-entity/index.html b/front/salix/components/bank-entity/index.html index b6cc1f4ee..211b77317 100644 --- a/front/salix/components/bank-entity/index.html +++ b/front/salix/components/bank-entity/index.html @@ -1,49 +1,46 @@ - - -

Please, ensure you put the correct data!

- - - - - - - - - - - - -
- - - - -
\ No newline at end of file + + New bank entity + + +

Please, ensure you put the correct data!

+ + + + + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/front/salix/components/bank-entity/index.js b/front/salix/components/bank-entity/index.js index 192ebe046..154e39fc4 100644 --- a/front/salix/components/bank-entity/index.js +++ b/front/salix/components/bank-entity/index.js @@ -1,35 +1,23 @@ import ngModule from '../../module'; -import Component from 'core/lib/component'; +import Dialog from 'core/components/dialog'; import './style.scss'; -class Controller extends Component { - open() { - this.$.bankEntityDialog.show(); - } +class Controller extends Dialog { + responseHandler(response) { + if (response !== 'accept') + return super.responseHandler(response); - resetData() { - this.data = {}; - } + if (!this.data.countryFk) + throw new Error(`The country can't be empty`); - onAccept() { - try { - if (!this.data.countryFk) - throw new Error(`The country can't be empty`); - - this.$http.post(`bankEntities`, this.data).then(res => { - this.vnApp.showMessage(this.$t('The bank entity has been created. You can save the data now')); - this.emit('response', {$response: res.data}); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - return true; + return this.$http.post(`bankEntities`, this.data) + .then(res => super.responseHandler(response)) + .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); } } ngModule.vnComponent('vnNewBankEntity', { - template: require('./index.html'), + slotTemplate: require('./index.html'), controller: Controller, bindings: { data: '<', From 34038b885c6f291b8cde321ffb0653e11769cc27 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 15 Sep 2021 17:58:58 +0200 Subject: [PATCH 10/13] refactor(newBankEntity): client.billingData and supplier.account refactor to use newBankEntity Dialog --- front/salix/components/bank-entity/index.js | 2 +- .../components/bank-entity/index.spec.js | 45 ++++++----------- modules/client/front/billing-data/index.html | 4 +- modules/client/front/billing-data/index.js | 12 +---- .../client/front/billing-data/index.spec.js | 4 +- modules/supplier/front/account/index.html | 7 +-- modules/supplier/front/account/index.js | 21 ++------ modules/supplier/front/account/index.spec.js | 50 ++++--------------- 8 files changed, 39 insertions(+), 106 deletions(-) diff --git a/front/salix/components/bank-entity/index.js b/front/salix/components/bank-entity/index.js index 154e39fc4..d4ac8030a 100644 --- a/front/salix/components/bank-entity/index.js +++ b/front/salix/components/bank-entity/index.js @@ -11,7 +11,7 @@ class Controller extends Dialog { throw new Error(`The country can't be empty`); return this.$http.post(`bankEntities`, this.data) - .then(res => super.responseHandler(response)) + .then(() => super.responseHandler(response)) .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); } } diff --git a/front/salix/components/bank-entity/index.spec.js b/front/salix/components/bank-entity/index.spec.js index c288c3052..3c3de4c40 100644 --- a/front/salix/components/bank-entity/index.spec.js +++ b/front/salix/components/bank-entity/index.spec.js @@ -5,49 +5,34 @@ describe('Salix Component vnNewBankEntity', () => { let $httpBackend; let $scope; let $element; - let vnApp; beforeEach(ngModule('salix')); - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; - vnApp = _vnApp_; - jest.spyOn(vnApp, 'showError'); $scope = $rootScope.$new(); - $element = angular.element(''); - controller = $componentController('vnNewBankEntity', {$element, $scope}); + $element = angular.element(''); + const $transclude = { + $$boundTransclude: { + $$slots: [] + } + }; + controller = $componentController('vnNewBankEntity', {$element, $scope, $transclude}); + controller.vnApp = {showSuccess: jest.fn()}; })); - describe('resetData()', () => { - it('should reset the location in the controller', () => { - expect(controller.data).toBeUndefined(); - - controller.resetData(); - - expect(controller.data).toEqual({}); - }); - }); - - describe('onAccept()', () => { - it('should throw an error if there is no country id in the location', () => { - jest.spyOn(controller.vnApp, 'showMessage'); - - controller.data = {}; - - controller.onAccept(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The country can't be empty`); - }); - - it('should do add the new bank entity', () => { + describe('responseHandler()', () => { + it('should show a success message after the query to bankEntities', () => { controller.data = { countryFk: 1 }; - $httpBackend.expectPOST('bankEntities', controller.data).respond(200, controller.data); + $httpBackend.expectPOST('bankEntities', controller.data).respond(200); - controller.onAccept(); + controller.responseHandler('accept'); $httpBackend.flush(); + + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); }); }); }); diff --git a/modules/client/front/billing-data/index.html b/modules/client/front/billing-data/index.html index ae1ad85a5..ff2e2f157 100644 --- a/modules/client/front/billing-data/index.html +++ b/modules/client/front/billing-data/index.html @@ -66,7 +66,7 @@ @@ -111,5 +111,5 @@ + on-accept="$ctrl.onAccept($data)"> \ No newline at end of file diff --git a/modules/client/front/billing-data/index.js b/modules/client/front/billing-data/index.js index dd43a661e..7056fa566 100644 --- a/modules/client/front/billing-data/index.js +++ b/modules/client/front/billing-data/index.js @@ -37,16 +37,8 @@ export default class Controller extends Section { return payMethod || iban || dueDay; } - onAddEntityClick(event) { - event.preventDefault(); - this.newBankEntity = { - countryFk: Number.parseInt(this.client.countryFk) - }; - this.$.bankEntity.open(); - } - - onResponse(response) { - this.client.bankEntityFk = response.id; + onAccept(data) { + this.client.bankEntityFk = data.id; } get ibanCountry() { diff --git a/modules/client/front/billing-data/index.spec.js b/modules/client/front/billing-data/index.spec.js index 60cc4025c..2e9e8ba97 100644 --- a/modules/client/front/billing-data/index.spec.js +++ b/modules/client/front/billing-data/index.spec.js @@ -35,10 +35,10 @@ describe('Client', () => { }); }); - describe('onResponse()', () => { + describe('onAccept()', () => { it('should assign the response id to the client bankEntityFk', () => { const expectedResponse = {id: 999}; - controller.onResponse(expectedResponse); + controller.onAccept(expectedResponse); expect(controller.client.bankEntityFk).toEqual(expectedResponse.id); }); diff --git a/modules/supplier/front/account/index.html b/modules/supplier/front/account/index.html index c8ec8ba31..cdaf79e8c 100644 --- a/modules/supplier/front/account/index.html +++ b/modules/supplier/front/account/index.html @@ -30,9 +30,10 @@ + vn-click-stop="bankEntity.show({index: $index})" + vn-tooltip="New bank entity"> + on-accept="$ctrl.onAccept($data)"> \ No newline at end of file diff --git a/modules/supplier/front/account/index.js b/modules/supplier/front/account/index.js index 26f4af988..1e21b983e 100644 --- a/modules/supplier/front/account/index.js +++ b/modules/supplier/front/account/index.js @@ -18,23 +18,10 @@ class Controller extends Section { }); } - onResponse(response) { - const data = this.$.model.data; - const supplierAccount = data[this.currentRowIndex]; - supplierAccount.bankEntityFk = response.id; - } - - showBankEntity(event, $index) { - if (event.defaultPrevented) return; - event.preventDefault(); - this.currentRowIndex = $index; - this.$.bankEntity.open(); - } - - onBankEntityAccept() { - const query = `SupplierAccounts/${this.$params.id}/createBankEntity`; - return this.$http.patch(query, this.newBankEntity) - .then(res => this.supplierAccount.bankEntityFk = res.data.id); + onAccept(data) { + const accounts = this.supplierAccounts; + const targetAccount = accounts[data.index]; + targetAccount.bankEntityFk = data.id; } onSubmit() { diff --git a/modules/supplier/front/account/index.spec.js b/modules/supplier/front/account/index.spec.js index cb206429b..77d135f24 100644 --- a/modules/supplier/front/account/index.spec.js +++ b/modules/supplier/front/account/index.spec.js @@ -4,11 +4,9 @@ describe('Supplier Component vnSupplierAccount', () => { let $scope; let $element; let controller; - let $httpBackend; beforeEach(ngModule('supplier')); beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.bankEntity = { open: () => {} @@ -21,50 +19,20 @@ describe('Supplier Component vnSupplierAccount', () => { }; })); - describe('showBankEntity()', () => { - it('should do nothing if it default is prevented', () => { - const event = { - defaultPrevented: true, - preventDefault: () => {} - }; - jest.spyOn(event, 'preventDefault'); - jest.spyOn(controller.$.bankEntity, 'open'); + describe('onAccept()', () => { + it('should set the created bank entity id into the target account', () => { + controller.supplierAccounts = [{}, {}, {}]; - controller.showBankEntity(event); - - expect(event.preventDefault).not.toHaveBeenCalledWith(); - expect(controller.$.bankEntity.open).not.toHaveBeenCalledWith(); - }); - - it('should call preventDefault() and open() when the default is not prevented', () => { - const event = { - defaultPrevented: false, - preventDefault: () => {} + const data = { + id: 999, + index: 1 }; - jest.spyOn(event, 'preventDefault'); - jest.spyOn(controller.$.bankEntity, 'open'); + controller.onAccept(data); - controller.showBankEntity(event); + const targetAccount = controller.supplierAccounts[data.index]; - expect(event.preventDefault).toHaveBeenCalledWith(); - expect(controller.$.bankEntity.open).toHaveBeenCalledWith(); - }); - - it('should now request to create a new bank entity', () => { - controller.bankEntity = { - name: 'My new bank entity', - bic: 'ES1234', - countryFk: 1, - id: 2200 - }; - - const query = `SupplierAccounts/${controller.$.bankEntity.id}/createBankEntity`; - $httpBackend.expectPATCH(query).respond({id: 2200}); - controller.onBankEntityAccept(); - $httpBackend.flush(); - - expect(controller.supplierAccount.bankEntityFk).toEqual(controller.bankEntity.id); + expect(targetAccount.bankEntityFk).toEqual(data.id); }); }); }); From 079f99ca0d75ba8f6848e149a11cf088d35e7a1b Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 17 Sep 2021 08:50:22 +0200 Subject: [PATCH 11/13] fix(tickets): fixed ticket duplications on ticket summary and ticket index caused by pagination Refs: 3093 --- modules/client/front/summary/index.html | 6 +++--- modules/ticket/front/main/index.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/client/front/summary/index.html b/modules/client/front/summary/index.html index 81f80d370..146bd16e5 100644 --- a/modules/client/front/summary/index.html +++ b/modules/client/front/summary/index.html @@ -5,7 +5,7 @@ filter="::$ctrl.ticketFilter" limit="5" data="tickets" - order="shipped DESC"> + order="shipped DESC, id">
@@ -293,7 +293,7 @@ Id Nickname Agency - Route + Route Packages Date State @@ -314,7 +314,7 @@ {{::ticket.nickname}} - + {{::ticket.agencyMode.name}} diff --git a/modules/ticket/front/main/index.html b/modules/ticket/front/main/index.html index 8e9af1e12..590d33887 100644 --- a/modules/ticket/front/main/index.html +++ b/modules/ticket/front/main/index.html @@ -2,7 +2,7 @@ vn-id="model" url="Tickets/filter" limit="20" - order="shippedDate DESC, shippedHour ASC, zoneLanding ASC"> + order="shippedDate DESC, shippedHour ASC, zoneLanding ASC, id"> Date: Fri, 17 Sep 2021 11:34:26 +0200 Subject: [PATCH 12/13] Removed unused translation --- .../email/claim-pickup-order/locale/es.yml | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/print/templates/email/claim-pickup-order/locale/es.yml b/print/templates/email/claim-pickup-order/locale/es.yml index 1d49b2b2b..fe08fb0a8 100644 --- a/print/templates/email/claim-pickup-order/locale/es.yml +++ b/print/templates/email/claim-pickup-order/locale/es.yml @@ -2,22 +2,4 @@ subject: Orden de recogida title: Orden de recogida description: dear: Estimado cliente - instructions: Aqui tienes tu orden de recogida. -sections: - howToBuy: - title: Cómo hacer un pedido - description: 'Para realizar un pedido en nuestra web, debes configurarlo indicando:' - requeriments: - - Si quieres recibir el pedido (por agencia o por nuestro propio reparto) o si - lo prefieres recoger en alguno de nuestros almacenes. - - La fecha en la que quieres recibir el pedido (se preparará el día anterior). - - La dirección de entrega o el almacén donde quieres recoger el pedido. - stock: En nuestra web y aplicaciones puedes visualizar el stock disponible de - flor cortada, verdes, plantas, complementos y artificial. Ten en cuenta que - dicho stock puede variar en función de la fecha seleccionada al configurar el - pedido. Es importante CONFIRMAR los pedidos para que la mercancía quede reservada. - delivery: El reparto se realiza de lunes a sábado según la zona en la que te encuentres. - Por regla general, los pedidos que se entregan por agencia, deben estar confirmados - y pagados antes de las 17h del día en que se preparan (el día anterior a recibirlos), - aunque esto puede variar si el pedido se envía a través de nuestro reparto y - según la zona. + instructions: Aqui tienes tu orden de recogida. \ No newline at end of file From 22cbe4875f5773e85490e1bb0621556fbd53eece Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 17 Sep 2021 12:56:12 +0200 Subject: [PATCH 13/13] fix(upload-photo): Updated translation --- front/salix/components/upload-photo/index.html | 2 +- front/salix/components/upload-photo/locale/es.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/front/salix/components/upload-photo/index.html b/front/salix/components/upload-photo/index.html index a9b674f42..3dd6cdb27 100644 --- a/front/salix/components/upload-photo/index.html +++ b/front/salix/components/upload-photo/index.html @@ -22,7 +22,7 @@ diff --git a/front/salix/components/upload-photo/locale/es.yml b/front/salix/components/upload-photo/locale/es.yml index fca0a4ac3..bcc3801d8 100644 --- a/front/salix/components/upload-photo/locale/es.yml +++ b/front/salix/components/upload-photo/locale/es.yml @@ -4,5 +4,5 @@ File name: Nombre del fichero Rotate left: Girar a la izquierda Rotate right: Girar a la derecha Panoramic: Panorámico -Select from computer: Seleccionar foto desde ordenador +Select from computer: Seleccionar desde ordenador Import from external URL: Importar desde URL externa \ No newline at end of file