From 8e274f4f17efc5b441213e7e5293ffa443a9b4bc Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 24 Dec 2021 10:10:28 +0100 Subject: [PATCH 01/49] refactor(travel): deprecated travelThermograph.temperature --- .../10400-christmas/00-travelThermograph.sql | 16 ++++++++++++++++ .../travel/back/models/travel-thermograph.json | 3 --- modules/travel/front/summary/index.html | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 db/changes/10400-christmas/00-travelThermograph.sql diff --git a/db/changes/10400-christmas/00-travelThermograph.sql b/db/changes/10400-christmas/00-travelThermograph.sql new file mode 100644 index 000000000..9c1fe3544 --- /dev/null +++ b/db/changes/10400-christmas/00-travelThermograph.sql @@ -0,0 +1,16 @@ +DROP TRIGGER `vn`.`travelThermograph_beforeInsert`; + +CREATE OR REPLACE +ALGORITHM = UNDEFINED VIEW `vn2008`.`travel_thermograph` AS +select + `tt`.`thermographFk` AS `thermograph_id`, + `tt`.`created` AS `odbc_date`, + `tt`.`warehouseFk` AS `warehouse_id`, + `tt`.`travelFk` AS `travel_id`, + `tt`.`temperatureFk` AS `temperature`, + `tt`.`result` AS `result`, + `tt`.`dmsFk` AS `gestdoc_id` +from + `vn`.`travelThermograph` `tt`; + +ALTER TABLE `vn`.`travelThermograph` CHANGE temperature temperature__ enum('COOL','WARM','DRY') CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL NULL; diff --git a/modules/travel/back/models/travel-thermograph.json b/modules/travel/back/models/travel-thermograph.json index 1e6dd1905..754df1c3e 100644 --- a/modules/travel/back/models/travel-thermograph.json +++ b/modules/travel/back/models/travel-thermograph.json @@ -20,9 +20,6 @@ "created": { "type": "date" }, - "temperature": { - "type": "string" - }, "temperatureFk": { "type": "string", "required": true diff --git a/modules/travel/front/summary/index.html b/modules/travel/front/summary/index.html index 90a2ea27f..98143a110 100644 --- a/modules/travel/front/summary/index.html +++ b/modules/travel/front/summary/index.html @@ -158,7 +158,7 @@ {{thermograph.thermographFk}} - {{thermograph.temperature}} + {{thermograph.temperatureFk}} {{thermograph.result}} {{thermograph.warehouse.name}} {{thermograph.created | date: 'dd/MM/yyyy'}} From d7f252a57d732365fef7509eee88a3b5497f7303 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 16 Feb 2022 10:30:56 +0100 Subject: [PATCH 02/49] feat(invoiceIn): add section intrastat --- .../10420-valentines/00-aclIntrastat.sql | 3 + .../00-invoiceInIntrastat.sql | 22 ++++ .../back/methods/invoice-in/summary.js | 28 +++++ modules/invoiceIn/back/model-config.json | 3 + .../back/models/invoice-in-intrastat.json | 50 +++++++++ modules/invoiceIn/back/models/invoice-in.json | 5 + modules/invoiceIn/front/index.js | 1 + modules/invoiceIn/front/intrastat/index.html | 102 ++++++++++++++++++ modules/invoiceIn/front/intrastat/index.js | 60 +++++++++++ .../invoiceIn/front/intrastat/index.spec.js | 55 ++++++++++ modules/invoiceIn/front/locale/es.yml | 6 +- modules/invoiceIn/front/routes.json | 14 +++ modules/invoiceIn/front/summary/index.html | 31 ++++++ 13 files changed, 379 insertions(+), 1 deletion(-) create mode 100644 db/changes/10420-valentines/00-aclIntrastat.sql create mode 100644 db/changes/10420-valentines/00-invoiceInIntrastat.sql create mode 100644 modules/invoiceIn/back/models/invoice-in-intrastat.json create mode 100644 modules/invoiceIn/front/intrastat/index.html create mode 100644 modules/invoiceIn/front/intrastat/index.js create mode 100644 modules/invoiceIn/front/intrastat/index.spec.js diff --git a/db/changes/10420-valentines/00-aclIntrastat.sql b/db/changes/10420-valentines/00-aclIntrastat.sql new file mode 100644 index 000000000..59805ed3f --- /dev/null +++ b/db/changes/10420-valentines/00-aclIntrastat.sql @@ -0,0 +1,3 @@ +INSERT INTO salix.ACL +(model, property, accessType, permission, principalType, principalId) +VALUES('InvoiceInIntrastat', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10420-valentines/00-invoiceInIntrastat.sql b/db/changes/10420-valentines/00-invoiceInIntrastat.sql new file mode 100644 index 000000000..5a25940fb --- /dev/null +++ b/db/changes/10420-valentines/00-invoiceInIntrastat.sql @@ -0,0 +1,22 @@ +DROP VIEW `vn`.`invoiceInIntrastat__`; +RENAME TABLE `vn`.`invoiceInIntrastat` TO `vn`.`invoiceInIntrastat__`; + +CREATE OR REPLACE +ALGORITHM = UNDEFINED +DEFINER=`root`@`localhost` +VIEW `vn`.`invoiceInIntrastat` AS +SELECT + `id`.`id` AS `id`, + `id`.`recibida_id` AS `invoiceInFk`, + `id`.`neto` AS `net`, + `id`.`intrastat_id` AS `intrastatFk`, + `id`.`importe` AS `amount`, + `id`.`unidades` AS `stems`, + `id`.`Paises_Id` AS `countryFk`, + `id`.`odbc_date` AS `dated`, + `id`.`valorestadistico` AS `statisticalValue` +FROM + `vn2008`.`intrastat_data` `id`; + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'); \ No newline at end of file diff --git a/modules/invoiceIn/back/methods/invoice-in/summary.js b/modules/invoiceIn/back/methods/invoice-in/summary.js index acabe29d9..0e55eeaac 100644 --- a/modules/invoiceIn/back/methods/invoice-in/summary.js +++ b/modules/invoiceIn/back/methods/invoice-in/summary.js @@ -64,6 +64,34 @@ module.exports = Self => { }] } }, + { + relation: 'invoiceInIntrastat', + scope: { + fields: [ + 'id', + 'invoiceInFk', + 'net', + 'intrastatFk', + 'amount', + 'stems', + 'countryFk', + 'statisticalValue'], + include: [{ + relation: 'intrastat', + scope: { + fields: [ + 'id', + 'description'] + } + }, + { + relation: 'country', + scope: { + fields: ['code'] + } + }] + } + }, { relation: 'invoiceInTax', scope: { diff --git a/modules/invoiceIn/back/model-config.json b/modules/invoiceIn/back/model-config.json index f0745f53b..6765ae81c 100644 --- a/modules/invoiceIn/back/model-config.json +++ b/modules/invoiceIn/back/model-config.json @@ -8,6 +8,9 @@ "InvoiceInDueDay": { "dataSource": "vn" }, + "InvoiceInIntrastat": { + "dataSource": "vn" + }, "InvoiceInLog": { "dataSource": "vn" } diff --git a/modules/invoiceIn/back/models/invoice-in-intrastat.json b/modules/invoiceIn/back/models/invoice-in-intrastat.json new file mode 100644 index 000000000..65ab1f36a --- /dev/null +++ b/modules/invoiceIn/back/models/invoice-in-intrastat.json @@ -0,0 +1,50 @@ +{ + "name": "InvoiceInIntrastat", + "base": "VnModel", + "options": { + "mysql": { + "table": "invoiceInIntrastat" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "invoiceInFk": { + "type": "number" + }, + "net": { + "type": "number" + }, + "intrastatFk": { + "type": "number" + }, + "amount": { + "type": "number" + }, + "stems": { + "type": "number" + }, + "countryFk": { + "type": "number" + }, + "statisticalValue": { + "type": "number" + } + }, + "relations": { + "intrastat": { + "type": "belongsTo", + "model": "Intrastat", + "foreignKey": "intrastatFk" + }, + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" + } + } + +} \ No newline at end of file diff --git a/modules/invoiceIn/back/models/invoice-in.json b/modules/invoiceIn/back/models/invoice-in.json index feb2d9aec..c6a736b06 100644 --- a/modules/invoiceIn/back/models/invoice-in.json +++ b/modules/invoiceIn/back/models/invoice-in.json @@ -64,6 +64,11 @@ "model": "InvoiceInDueDay", "foreignKey": "invoiceInFk" }, + "invoiceInIntrastat": { + "type": "hasMany", + "model": "InvoiceInIntrastat", + "foreignKey": "invoiceInFk" + }, "invoiceInTax": { "type": "hasMany", "model": "InvoiceInTax", diff --git a/modules/invoiceIn/front/index.js b/modules/invoiceIn/front/index.js index 18e9d73c2..7b6d6a77c 100644 --- a/modules/invoiceIn/front/index.js +++ b/modules/invoiceIn/front/index.js @@ -10,5 +10,6 @@ import './summary'; import './basic-data'; import './tax'; import './dueDay'; +import './intrastat'; import './create'; import './log'; diff --git a/modules/invoiceIn/front/intrastat/index.html b/modules/invoiceIn/front/intrastat/index.html new file mode 100644 index 000000000..e59d9c1f6 --- /dev/null +++ b/modules/invoiceIn/front/intrastat/index.html @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + +
+ + + + {{id | zeroFill:8}}: {{description}} + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/invoiceIn/front/intrastat/index.js b/modules/invoiceIn/front/intrastat/index.js new file mode 100644 index 000000000..b2062e7f7 --- /dev/null +++ b/modules/invoiceIn/front/intrastat/index.js @@ -0,0 +1,60 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +class Controller extends Section { + set invoceInIntrastat(value) { + this._invoceInIntrastat = value; + + if (value) this.calculateTotals(); + } + + get invoceInIntrastat() { + return this._invoceInIntrastat; + } + + calculateTotals() { + this.amountTotal = 0.0; + this.netTotal = 0.0; + this.stemsTotal = 0.0; + if (!this._invoceInIntrastat) return; + + this._invoceInIntrastat.forEach(intrastat => { + this.amountTotal += intrastat.amount; + this.netTotal += intrastat.net; + this.stemsTotal += intrastat.stems; + }); + } + + add() { + this.$.model.insert({}); + } + + deleteIntrastat($index) { + this.$.model.remove($index); + this.$.model.save().then(() => { + this.vnApp.showSuccess(this.$t('Data saved!')); + this.calculateTotals(); + }); + } + + onSubmit() { + this.$.watcher.check(); + this.$.model.save().then(() => { + this.$.watcher.notifySaved(); + this.$.watcher.updateOriginalData(); + this.calculateTotals(); + this.card.reload(); + }); + } +} + +ngModule.vnComponent('vnInvoiceInIntrastat', { + template: require('./index.html'), + controller: Controller, + require: { + card: '^vnInvoiceInCard' + }, + bindings: { + invoiceIn: '<' + } +}); diff --git a/modules/invoiceIn/front/intrastat/index.spec.js b/modules/invoiceIn/front/intrastat/index.spec.js new file mode 100644 index 000000000..d0db17904 --- /dev/null +++ b/modules/invoiceIn/front/intrastat/index.spec.js @@ -0,0 +1,55 @@ +import './index.js'; +import watcher from 'core/mocks/watcher'; +import crudModel from 'core/mocks/crud-model'; + +describe('InvoiceIn', () => { + describe('Component intrastat', () => { + let controller; + let $scope; + let vnApp; + + beforeEach(ngModule('invoiceIn')); + + beforeEach(inject(($componentController, $rootScope, _vnApp_) => { + vnApp = _vnApp_; + jest.spyOn(vnApp, 'showError'); + $scope = $rootScope.$new(); + $scope.model = crudModel; + $scope.watcher = watcher; + + const $element = angular.element(''); + controller = $componentController('vnInvoiceInIntrastat', {$element, $scope}); + controller.invoiceIn = {id: 1}; + })); + + describe('calculateTotals()', () => { + it('should set amountTotal, netTotal and stemsTotal to 0 if salesClaimed has no data', () => { + controller.invoceInIntrastat = []; + controller.calculateTotals(); + + expect(controller.amountTotal).toEqual(0); + expect(controller.netTotal).toEqual(0); + expect(controller.stemsTotal).toEqual(0); + }); + }); + + describe('onSubmit()', () => { + it('should make HTTP POST request to save intrastat values', () => { + controller.card = {reload: () => {}}; + jest.spyOn($scope.watcher, 'check'); + jest.spyOn($scope.watcher, 'notifySaved'); + jest.spyOn($scope.watcher, 'updateOriginalData'); + jest.spyOn(controller.card, 'reload'); + jest.spyOn($scope.model, 'save'); + + controller.onSubmit(); + + expect($scope.model.save).toHaveBeenCalledWith(); + expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); + expect($scope.watcher.check).toHaveBeenCalledWith(); + expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); + expect(controller.card.reload).toHaveBeenCalledWith(); + }); + }); + }); +}); diff --git a/modules/invoiceIn/front/locale/es.yml b/modules/invoiceIn/front/locale/es.yml index 1ebfa8fe2..bf93da9b8 100644 --- a/modules/invoiceIn/front/locale/es.yml +++ b/modules/invoiceIn/front/locale/es.yml @@ -9,10 +9,14 @@ InvoiceIn cloned: Factura clonada InvoiceIn deleted: Factura eliminada Invoice list: Listado de facturas recibidas InvoiceIn booked: Factura contabilizada +Net: Neto Remove tax: Quitar iva Remove due day: Quitar vencimiento Sage tax: Sage iva Sage transaction: Sage transaccion Search invoices in by reference: Buscar facturas recibidas por referencia To book: Contabilizar - +Total amount: Total importe +Total net: Total neto +Total stems: Total unidades +Units: Unidades diff --git a/modules/invoiceIn/front/routes.json b/modules/invoiceIn/front/routes.json index 0eb6258d3..4867b7db9 100644 --- a/modules/invoiceIn/front/routes.json +++ b/modules/invoiceIn/front/routes.json @@ -27,6 +27,10 @@ "state": "invoiceIn.card.dueDay", "icon": "icon-calendar" }, + { + "state": "invoiceIn.card.intrastat", + "icon": "icon-lines" + }, { "state": "invoiceIn.card.log", "icon": "history" @@ -109,6 +113,16 @@ }, "acl": ["administrative"] }, + { + "url": "/intrastat", + "state": "invoiceIn.card.intrastat", + "component": "vn-invoice-in-intrastat", + "description": "Intrastat", + "params": { + "invoice-in": "$ctrl.invoiceIn" + }, + "acl": ["administrative"] + }, { "url": "/log", "state": "invoiceIn.card.log", diff --git a/modules/invoiceIn/front/summary/index.html b/modules/invoiceIn/front/summary/index.html index ae6d985f8..cb7834c95 100644 --- a/modules/invoiceIn/front/summary/index.html +++ b/modules/invoiceIn/front/summary/index.html @@ -120,6 +120,37 @@ + + +

+ + Intrastat + +

+ + + + Code + Amount + Net + Units + Country + + + + + {{::intrastat.intrastatFk | zeroFill:8}}: {{::intrastat.intrastat.description}} + {{::intrastat.amount | currency: 'EUR':2}} + {{::intrastat.net}} + {{::intrastat.stems}} + {{::intrastat.country.code}} + + + +
+
From 062a3146a3c49904635cb03161bba7008c654e8c Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 17 Feb 2022 10:03:04 +0100 Subject: [PATCH 03/49] fix: modify intrastat.sql to show "neto" field --- print/templates/reports/invoice/sql/intrastat.sql | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/print/templates/reports/invoice/sql/intrastat.sql b/print/templates/reports/invoice/sql/intrastat.sql index e391056ec..6bf72c158 100644 --- a/print/templates/reports/invoice/sql/intrastat.sql +++ b/print/templates/reports/invoice/sql/intrastat.sql @@ -2,9 +2,13 @@ SELECT ir.id AS code, ir.description AS description, CAST(SUM(IFNULL(i.stems,1) * s.quantity) AS DECIMAL(10,2)) as stems, - CAST(SUM( weight) AS DECIMAL(10,2)) as netKg, + CAST(SUM(IF(sv.physicalWeight, sv.physicalWeight, i.density * sub.cm3delivery/1000000)) AS DECIMAL(10,2)) netKg, CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) AS subtotal - FROM vn.sale s + FROM vn.sale s + LEFT JOIN (SELECT ic.itemFk, ic.cm3, ic.cm3delivery + FROM vn.itemCost ic + WHERE ic.cm3 + GROUP BY ic.itemFk) sub ON s.itemFk = sub.itemFk LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id LEFT JOIN vn.ticket t ON t.id = s.ticketFk LEFT JOIN vn.invoiceOut io ON io.ref = t.refFk From a152e22f6e34953cd9c88e60c0c63821f93fc9bf Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 18 Feb 2022 12:26:16 +0100 Subject: [PATCH 04/49] update sql changes --- .../00-invoiceInIntrastat.sql | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/db/changes/10420-valentines/00-invoiceInIntrastat.sql b/db/changes/10420-valentines/00-invoiceInIntrastat.sql index 5a25940fb..689db6913 100644 --- a/db/changes/10420-valentines/00-invoiceInIntrastat.sql +++ b/db/changes/10420-valentines/00-invoiceInIntrastat.sql @@ -1,22 +1,2 @@ -DROP VIEW `vn`.`invoiceInIntrastat__`; -RENAME TABLE `vn`.`invoiceInIntrastat` TO `vn`.`invoiceInIntrastat__`; - -CREATE OR REPLACE -ALGORITHM = UNDEFINED -DEFINER=`root`@`localhost` -VIEW `vn`.`invoiceInIntrastat` AS -SELECT - `id`.`id` AS `id`, - `id`.`recibida_id` AS `invoiceInFk`, - `id`.`neto` AS `net`, - `id`.`intrastat_id` AS `intrastatFk`, - `id`.`importe` AS `amount`, - `id`.`unidades` AS `stems`, - `id`.`Paises_Id` AS `countryFk`, - `id`.`odbc_date` AS `dated`, - `id`.`valorestadistico` AS `statisticalValue` -FROM - `vn2008`.`intrastat_data` `id`; - INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'); \ No newline at end of file From 84ebeed8efbc320a068b1dd2c32cb7adea8d3bd9 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 21 Mar 2022 13:04:25 +0100 Subject: [PATCH 05/49] add fixtures --- db/dump/fixtures.sql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 07eaf23fd..fd97e9441 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2395,6 +2395,13 @@ INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenceFk`, `for (6, 29.95, '7001000000', NULL, 7, 20), (7, 58.64, '6210000567', NULL, 8, 20); +INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amount`, `stems`, `countryFk`) + VALUES + (1, 30.50, 5080000, 10.00, 162, 5), + (1, 10, 6021010, 20.00, 205, 5), + (2, 13.20, 5080000, 15.00, 580, 5), + (2, 16.10, 6021010, 25.00, 80, 5); + INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) SELECT `id` FROM `vn`.`ticket` t From 05be19de2dd65ccd528615df179c8866f544a65b Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 22 Mar 2022 10:03:56 +0100 Subject: [PATCH 06/49] fix(zone_delivery-days): agencyModeName and defaulter pagination --- modules/client/back/methods/defaulter/filter.js | 1 + modules/zone/front/delivery-days/index.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 095b9b1c1..813d63d3f 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -80,6 +80,7 @@ module.exports = Self => { stmt.merge(conn.makeWhere(filter.where)); stmt.merge(`GROUP BY d.clientFk`); stmt.merge(conn.makeOrderBy(filter.order)); + stmt.merge(conn.makeLimit(filter)); const itemsIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); diff --git a/modules/zone/front/delivery-days/index.html b/modules/zone/front/delivery-days/index.html index 1c1a9b1b3..a3bed71d0 100644 --- a/modules/zone/front/delivery-days/index.html +++ b/modules/zone/front/delivery-days/index.html @@ -78,7 +78,7 @@ class="clickable search-result"> {{::zone.id}} {{::zone.name}} - {{::zone.agencyMode.name}} + {{::zone.agencyModeName}} {{::zone.hour | date: 'HH:mm'}} {{::zone.price | currency: 'EUR':2}} From c8ae5bca829d07f8c3fd65ac4efd4512c680e8a7 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 23 Mar 2022 12:19:49 +0100 Subject: [PATCH 07/49] check if email, phone or mobile already exists in another client --- modules/client/back/models/client.js | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 9ec45f58d..a14631c22 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -304,6 +304,42 @@ module.exports = Self => { const assignmentChanged = workerIdBefore != workerIdAfter; if (assignmentChanged) await Self.notifyAssignment(instance, workerIdBefore, workerIdAfter); + + const emails = instance.email ? instance.email.split(',') : null; + + const findParams = []; + if (emails.length) { + for (let email of emails) + findParams.push({email: email}); + } + + if (instance.phone) + findParams.push({phone: instance.phone}); + + if (instance.mobile) + findParams.push({mobile: instance.mobile}); + + const filterObj = { + where: { + and: [ + {or: findParams}, + {id: {neq: instance.id}} + ] + } + }; + + const clientSameData = await Self.findOne(filterObj); + + if (clientSameData) { + await Self.app.models.Mail.create({ + receiver: 'direccioncomercial@verdnatura.es', + subject: `Cliente con email/teléfono/móvil duplicados`, + body: 'El cliente ' + instance.id + ' comparte alguno de estos datos con el cliente ' + clientSameData.id + + '\n- Email: ' + instance.email + + '\n- Teléfono: ' + instance.phone + + '\n- Móvil: ' + instance.mobile + }); + } }); // Send notification on client worker assignment From 7cd33619e3ca13bed0238a5fedc8b579da708f20 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 28 Mar 2022 11:47:20 +0200 Subject: [PATCH 08/49] change db version --- .../00-travelThermograph.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename db/changes/{10400-christmas => 10440-fallas}/00-travelThermograph.sql (67%) diff --git a/db/changes/10400-christmas/00-travelThermograph.sql b/db/changes/10440-fallas/00-travelThermograph.sql similarity index 67% rename from db/changes/10400-christmas/00-travelThermograph.sql rename to db/changes/10440-fallas/00-travelThermograph.sql index 9c1fe3544..f76f070a0 100644 --- a/db/changes/10400-christmas/00-travelThermograph.sql +++ b/db/changes/10440-fallas/00-travelThermograph.sql @@ -1,5 +1,7 @@ DROP TRIGGER `vn`.`travelThermograph_beforeInsert`; +ALTER TABLE `vn`.`travelThermograph` CHANGE `temperature` `temperature__` enum('COOL','WARM','DRY') CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL NULL; + CREATE OR REPLACE ALGORITHM = UNDEFINED VIEW `vn2008`.`travel_thermograph` AS select @@ -11,6 +13,4 @@ select `tt`.`result` AS `result`, `tt`.`dmsFk` AS `gestdoc_id` from - `vn`.`travelThermograph` `tt`; - -ALTER TABLE `vn`.`travelThermograph` CHANGE temperature temperature__ enum('COOL','WARM','DRY') CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL NULL; + `vn`.`travelThermograph` `tt`; \ No newline at end of file From a5ca116571be6bf2fbb331edc0aded119feb7739 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 29 Mar 2022 13:42:37 +0200 Subject: [PATCH 09/49] feat(ticket_sale): add mana options --- db/changes/10440-fallas/00-component.sql | 2 ++ .../back/methods/ticket/updateDiscount.js | 10 ++++++-- modules/ticket/front/sale/index.html | 23 ++++++++++++++++++- modules/ticket/front/sale/index.js | 19 ++++++++++++++- modules/ticket/front/sale/locale/es.yml | 4 +++- 5 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 db/changes/10440-fallas/00-component.sql diff --git a/db/changes/10440-fallas/00-component.sql b/db/changes/10440-fallas/00-component.sql new file mode 100644 index 000000000..34810280b --- /dev/null +++ b/db/changes/10440-fallas/00-component.sql @@ -0,0 +1,2 @@ +INSERT INTO `vn`.`component` (`name`,`typeFk`,`classRate`,`isRenewable`,`code`,`isRequired`) + VALUES ('maná reclamacion',7,4,0,'mana claim',0); \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index cf217348a..a5550cbb3 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -23,6 +23,12 @@ module.exports = Self => { description: 'The new discount', type: 'number', required: true + }, + { + arg: 'manaType', + description: 'The type of mana', + type: 'string', + required: true } ], returns: { @@ -35,7 +41,7 @@ module.exports = Self => { } }); - Self.updateDiscount = async(ctx, id, salesIds, newDiscount, options) => { + Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaType, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; const myOptions = {}; @@ -98,7 +104,7 @@ module.exports = Self => { }, fields: 'amount'}, myOptions); - const componentCode = usesMana ? 'mana' : 'buyerDiscount'; + const componentCode = usesMana ? manaType : 'buyerDiscount'; const discountComponent = await models.Component.findOne({ where: {code: componentCode}}, myOptions); diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 5dc3c9428..7cad8e98a 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -285,10 +285,21 @@ vn-focus label="Discount" ng-model="$ctrl.edit.discount" - on-change="$ctrl.changeDiscount()" clear-disabled="true" suffix="%"> + + + + + +

New price

@@ -297,6 +308,16 @@

+ + + + + + diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 54167ce96..5aae9e1dd 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -6,6 +6,15 @@ class Controller extends Section { constructor($element, $) { super($element, $); this._sales = []; + this.manaType = 'mana'; + } + + get manaType() { + return this._manaType; + } + + set manaType(value) { + this._manaType = value; } get ticket() { @@ -273,7 +282,7 @@ class Controller extends Section { return sale.id; }); - const params = {salesIds: saleIds, newDiscount: this.edit.discount}; + const params = {salesIds: saleIds, newDiscount: this.edit.discount, manaType: this.manaType}; const query = `Tickets/${this.$params.id}/updateDiscount`; this.$http.post(query, params).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); @@ -479,6 +488,14 @@ class Controller extends Section { ? {id: $search} : {name: {like: '%' + $search + '%'}}; } + + save() { + this.changeDiscount(); + } + + cancel() { + this.$.editDiscount.hide(); + } } ngModule.vnComponent('vnTicketSale', { diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index e4152600f..7edb0a626 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -36,4 +36,6 @@ Warehouse: Almacen Agency: Agencia Shipped: F. envio Packaging: Encajado -Pay Back: Abono \ No newline at end of file +Pay Back: Abono +Promotion mana: Maná promoción +Claim mana: Maná reclamación \ No newline at end of file From c15aea213f96945dca7f5224da28bc5c2982b54d Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 29 Mar 2022 13:42:56 +0200 Subject: [PATCH 10/49] feat(ticket_sale): add front test --- modules/ticket/front/sale/index.spec.js | 30 +++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 15ce1798b..68d62204c 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -43,7 +43,7 @@ describe('Ticket', () => { $scope.sms = {open: () => {}}; $scope.ticket = ticket; $scope.model = crudModel; - $scope.editDiscount = {relocate: () => {}}; + $scope.editDiscount = {relocate: () => {}, hide: () => {}}; $scope.editPricePopover = {relocate: () => {}}; $httpBackend = _$httpBackend_; Object.defineProperties($state.params, { @@ -63,6 +63,14 @@ describe('Ticket', () => { controller._sales = sales; })); + describe('manaType() setter/getter', () => { + it('should set the manaType data', () => { + controller.manaType = 'mana claim'; + + expect(controller.manaType).toEqual('mana claim'); + }); + }); + describe('ticket() setter', () => { it('should set the ticket data an then call the isTicketEditable() and isTicketLocked() methods', () => { jest.spyOn(controller, 'isTicketEditable').mockReturnThis(); @@ -446,7 +454,7 @@ describe('Ticket', () => { const expectedSales = [firstSelectedSale, secondSelectedSale]; const expectedSaleIds = [firstSelectedSale.id, secondSelectedSale.id]; - const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount}; + const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount, manaType: 'mana'}; $httpBackend.expect('POST', `Tickets/1/updateDiscount`, expectedParams).respond(200, {discount: 10}); controller.updateDiscount(expectedSales); $httpBackend.flush(); @@ -732,5 +740,23 @@ describe('Ticket', () => { expect(result).toEqual({name: {like: '%' + itemName + '%'}}); }); }); + + describe('save()', () => { + it('should call changeDiscount()', () => { + jest.spyOn(controller, 'changeDiscount').mockReturnThis(); + controller.save(); + + expect(controller.changeDiscount).toHaveBeenCalledWith(); + }); + }); + + describe('cancel()', () => { + it('should call hide()', () => { + jest.spyOn(controller.$.editDiscount, 'hide').mockReturnThis(); + controller.cancel(); + + expect(controller.$.editDiscount.hide).toHaveBeenCalledWith(); + }); + }); }); }); From 86350b2afadb0f1d6d331c3400ea851549fc3091 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 29 Mar 2022 14:00:53 +0200 Subject: [PATCH 11/49] feat(ticket_sale): add backTest --- .../ticket/specs/updateDiscount.spec.js | 45 ++++++++++++++++++- .../back/methods/ticket/updateDiscount.js | 2 +- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js index ae79185e4..1a20b0753 100644 --- a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js +++ b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js @@ -90,7 +90,7 @@ describe('sale updateDiscount()', () => { expect(error.message).toEqual(`The sales of this ticket can't be modified`); }); - it('should update the discount if the salesPerson has mana', async() => { + it('should update the discount if the salesPerson has mana and manaType = "mana"', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -108,8 +108,49 @@ describe('sale updateDiscount()', () => { const newDiscount = 100; const manaDiscount = await models.Component.findOne({where: {code: 'mana'}}, options); const componentId = manaDiscount.id; + const manaType = 'mana'; - await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, options); + await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options); + + const updatedSale = await models.Sale.findById(originalSaleId, null, options); + const createdSaleComponent = await models.SaleComponent.findOne({ + where: { + componentFk: componentId, + saleFk: originalSaleId + } + }, options); + + expect(createdSaleComponent.componentFk).toEqual(componentId); + expect(updatedSale.discount).toEqual(100); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should update the discount if the salesPerson has mana and manaType = "mana claim"', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ctx = { + req: { + accessToken: {userId: 18}, + headers: {origin: 'localhost:5000'}, + __: () => {} + } + }; + const ticketId = 11; + const sales = [originalSaleId]; + const newDiscount = 100; + const manaDiscount = await models.Component.findOne({where: {code: 'mana claim'}}, options); + const componentId = manaDiscount.id; + const manaType = 'mana claim'; + + await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options); const updatedSale = await models.Sale.findById(originalSaleId, null, options); const createdSaleComponent = await models.SaleComponent.findOne({ diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index a5550cbb3..9726dae1a 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -28,7 +28,7 @@ module.exports = Self => { arg: 'manaType', description: 'The type of mana', type: 'string', - required: true + required: false } ], returns: { From 63a857a6169dba35435df15dc012d2e281b5cb79 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 29 Mar 2022 14:33:22 +0200 Subject: [PATCH 12/49] fix: updated test e2e --- e2e/helpers/selectors.js | 1 + e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js | 1 + 2 files changed, 2 insertions(+) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 21ed27158..56902e58d 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -586,6 +586,7 @@ export default { firstSalePriceInput: '.vn-popover.shown input[ng-model="$ctrl.field"]', firstSaleDiscount: 'vn-ticket-sale vn-table vn-tr:nth-child(1) > vn-td:nth-child(10) > span', firstSaleDiscountInput: '.vn-popover.shown [ng-model="$ctrl.field"]', + saveSaleDiscountButton: '.vn-popover.shown vn-button[label="Save"]', firstSaleImport: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(11)', firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(3)', firstSaleColour: 'vn-ticket-sale vn-tr:nth-child(1) vn-fetched-tags section', diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 5078d5b91..f22d1af30 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -176,6 +176,7 @@ describe('Ticket Edit sale path', () => { await page.waitToClick(selectors.ticketSales.firstSaleDiscount); await page.waitForSelector(selectors.ticketSales.firstSaleDiscountInput); await page.type(selectors.ticketSales.firstSaleDiscountInput, '50\u000d'); + await page.waitToClick(selectors.ticketSales.saveSaleDiscountButton); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); From e0244f388c869ef813c1433b77db181f01be51c9 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 07:39:42 +0200 Subject: [PATCH 13/49] refator: single quotes in sql files --- db/changes/10420-valentines/00-aclIntrastat.sql | 4 ++-- db/changes/10420-valentines/00-invoiceInIntrastat.sql | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/changes/10420-valentines/00-aclIntrastat.sql b/db/changes/10420-valentines/00-aclIntrastat.sql index 59805ed3f..16410814d 100644 --- a/db/changes/10420-valentines/00-aclIntrastat.sql +++ b/db/changes/10420-valentines/00-aclIntrastat.sql @@ -1,3 +1,3 @@ -INSERT INTO salix.ACL -(model, property, accessType, permission, principalType, principalId) +INSERT INTO `salix`.`ACL` +(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES('InvoiceInIntrastat', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10420-valentines/00-invoiceInIntrastat.sql b/db/changes/10420-valentines/00-invoiceInIntrastat.sql index 689db6913..8f65fac29 100644 --- a/db/changes/10420-valentines/00-invoiceInIntrastat.sql +++ b/db/changes/10420-valentines/00-invoiceInIntrastat.sql @@ -1,2 +1,2 @@ -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'); \ No newline at end of file From 572cc30a4ee4d3f82acdc3bc3f496752a796b800 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 07:53:00 +0200 Subject: [PATCH 14/49] refactor: updated translate --- modules/invoiceIn/front/intrastat/index.html | 2 +- modules/invoiceIn/front/locale/es.yml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/invoiceIn/front/intrastat/index.html b/modules/invoiceIn/front/intrastat/index.html index e59d9c1f6..c58839e38 100644 --- a/modules/invoiceIn/front/intrastat/index.html +++ b/modules/invoiceIn/front/intrastat/index.html @@ -63,7 +63,7 @@ vn-focus> diff --git a/modules/invoiceIn/front/locale/es.yml b/modules/invoiceIn/front/locale/es.yml index bf93da9b8..4f36b33fa 100644 --- a/modules/invoiceIn/front/locale/es.yml +++ b/modules/invoiceIn/front/locale/es.yml @@ -18,5 +18,4 @@ Search invoices in by reference: Buscar facturas recibidas por referencia To book: Contabilizar Total amount: Total importe Total net: Total neto -Total stems: Total unidades -Units: Unidades +Total stems: Total tallos From 5b1d610f2ff9a71c1fbec8aab1b3a943bfa4a40b Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 07:55:37 +0200 Subject: [PATCH 15/49] refator: updated translate --- modules/invoiceIn/front/summary/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/invoiceIn/front/summary/index.html b/modules/invoiceIn/front/summary/index.html index cb7834c95..3a826eeb7 100644 --- a/modules/invoiceIn/front/summary/index.html +++ b/modules/invoiceIn/front/summary/index.html @@ -135,7 +135,7 @@ Code Amount Net - Units + Stems Country
From 98fb3c1a67094943bc4b9f3b6e8717de9ad50c8b Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 08:09:52 +0200 Subject: [PATCH 16/49] refactor(client_updatePorfolio): included backTest --- .../client/back/methods/client/specs/updatePortfolio.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/back/methods/client/specs/updatePortfolio.spec.js b/modules/client/back/methods/client/specs/updatePortfolio.spec.js index 7983bb2ff..2554daf3d 100644 --- a/modules/client/back/methods/client/specs/updatePortfolio.spec.js +++ b/modules/client/back/methods/client/specs/updatePortfolio.spec.js @@ -26,8 +26,8 @@ describe('Client updatePortfolio', () => { throw e; } }); - // 3742 first have to migrate vn2008.Clientes_cedidos to vn - xit('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => { + + it('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => { const salesPersonId = 19; const tx = await models.Client.beginTransaction({}); From e29f820e607cff608333470b7f43e5ab22bc2f77 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 08:56:35 +0200 Subject: [PATCH 17/49] feat(ticket_line): new table ticketRefund and update proc ticket_doRefund --- db/changes/10440-fallas/00-ticketRefund.sql | 149 ++++++++++++++++++++ db/dump/fixtures.sql | 12 -- loopback/locale/es.json | 3 +- 3 files changed, 151 insertions(+), 13 deletions(-) create mode 100644 db/changes/10440-fallas/00-ticketRefund.sql diff --git a/db/changes/10440-fallas/00-ticketRefund.sql b/db/changes/10440-fallas/00-ticketRefund.sql new file mode 100644 index 000000000..66de21e91 --- /dev/null +++ b/db/changes/10440-fallas/00-ticketRefund.sql @@ -0,0 +1,149 @@ +DROP PROCEDURE IF EXISTS `vn`.`ticket_doRefund`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(IN vOriginTicket INT, OUT vNewTicket INT) +BEGIN + + DECLARE vDone BIT DEFAULT 0; + DECLARE vCustomer MEDIUMINT; + DECLARE vWarehouse TINYINT; + DECLARE vCompany MEDIUMINT; + DECLARE vAddress MEDIUMINT; + DECLARE vRefundAgencyMode INT; + DECLARE vItemFk INT; + DECLARE vQuantity DECIMAL (10,2); + DECLARE vConcept VARCHAR(50); + DECLARE vPrice DECIMAL (10,2); + DECLARE vDiscount TINYINT; + DECLARE vSaleNew INT; + DECLARE vSaleMain INT; + DECLARE vZoneFk INT; + + DECLARE vRsMainTicket CURSOR FOR + SELECT * + FROM tmp.sale; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; + + SELECT id INTO vRefundAgencyMode + FROM agencyMode WHERE `name` = 'ABONO'; + + SELECT clientFk, warehouseFk, companyFk, addressFk + INTO vCustomer, vWarehouse, vCompany, vAddress + FROM ticket + WHERE id = vOriginTicket; + + SELECT id INTO vZoneFk + FROM zone WHERE agencyModeFk = vRefundAgencyMode + LIMIT 1; + + INSERT INTO vn.ticket ( + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + warehouseFk, + companyFk, + landed, + zoneFk + ) + SELECT + vCustomer, + CURDATE(), + vAddress, + vRefundAgencyMode, + a.nickname, + vWarehouse, + vCompany, + CURDATE(), + vZoneFk + FROM address a + WHERE a.id = vAddress; + + SET vNewTicket = LAST_INSERT_ID(); + + SET vDone := 0; + OPEN vRsMainTicket ; + FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; + + WHILE NOT vDone DO + + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount) + VALUES( vNewTicket, vItemFk, vQuantity, vConcept, vPrice, vDiscount ); + + SET vSaleNew = LAST_INSERT_ID(); + + INSERT INTO vn.saleComponent(saleFk,componentFk,`value`) + SELECT vSaleNew,componentFk,`value` + FROM vn.saleComponent + WHERE saleFk = vSaleMain; + + FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; + + END WHILE; + CLOSE vRsMainTicket; + + INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk) + VALUES(vNewTicket, vOriginTicket); + +END$$ +DELIMITER ; + +CREATE TABLE `vn`.`ticketRefund` ( + `id` INT auto_increment NULL, + `refundTicketFk` INT NOT NULL, + `originalTicketFk` INT NOT NULL, + CONSTRAINT `ticketRefund_PK` PRIMARY KEY (id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_unicode_ci; + +ALTER TABLE `vn`.`ticketRefund` ADD CONSTRAINT `ticketRefund_FK` FOREIGN KEY (`refundTicketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `vn`.`ticketRefund` ADD CONSTRAINT `ticketRefund_FK_1` FOREIGN KEY (`originalTicketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeInsert` + BEFORE INSERT ON `ticketRefund` + FOR EACH ROW +BEGIN + DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE; + + IF NEW.refundTicketFk = NEW.originalTicketFk THEN + CALL util.throw('Original ticket and refund ticket has same id'); + END IF; + + SELECT COUNT(*) INTO vAlreadyExists + FROM ticketRefund + WHERE refundTicketFk = NEW.originalTicketFk; + + IF vAlreadyExists > 0 THEN + CALL util.throw('This ticket is already a refund'); + END IF; +END$$ +DELIMITER ; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeUpdate` + BEFORE UPDATE ON `ticketRefund` + FOR EACH ROW +BEGIN + DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE; + + IF NEW.refundTicketFk = NEW.originalTicketFk THEN + CALL util.throw('Original ticket and refund ticket has same id'); + END IF; + + SELECT COUNT(*) INTO vAlreadyExists + FROM ticketRefund + WHERE refundTicketFk = NEW.originalTicketFk; + + IF vAlreadyExists > 0 THEN + CALL util.throw('This ticket is already a refund'); + END IF; +END$$ +DELIMITER ; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index aa03c39b5..e8302b1a2 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2477,18 +2477,6 @@ INSERT INTO `bs`.`defaulter` (`clientFk`, `amount`, `created`, `defaulterSinced` (1107, 500, CURDATE(), CURDATE()), (1109, 500, CURDATE(), CURDATE()); -UPDATE `vn`.`agency` - SET `supplierFk`=1 - WHERE `id`=1; - -UPDATE `vn`.`agency` - SET `supplierFk`=1 - WHERE `id`=2; - -UPDATE `vn`.`agency` - SET `supplierFk`=2 - WHERE `id`=3; - UPDATE `vn`.`route` SET `invoiceInFk`=1 WHERE `id`=1; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index f7c0dad54..9310ae436 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -223,5 +223,6 @@ "The item is required": "El artículo es requerido", "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", "date in the future": "Fecha en el futuro", - "reference duplicated": "Referencia duplicada" + "reference duplicated": "Referencia duplicada", + "This ticket is already a refund": "Este ticket ya es un abono" } \ No newline at end of file From b78ecc06d21fa60c78ed2f8e00745c8273264b59 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 09:29:57 +0200 Subject: [PATCH 18/49] fix(ticker_sale): only show mana options if currentWorker has mana --- modules/ticket/front/sale/index.html | 2 +- modules/ticket/front/sale/index.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 7cad8e98a..3643113bc 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -288,7 +288,7 @@ clear-disabled="true" suffix="%"> - + { + this.currentWorkerMana = res.data; + }); } /** From 23cb8c1215a6d9562bb18977a93d9a1a84edd757 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 09:54:01 +0200 Subject: [PATCH 19/49] refactor(ticket_sale): update frontTest --- modules/ticket/front/sale/index.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 68d62204c..a1088c0cc 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -123,10 +123,12 @@ describe('Ticket', () => { const expectedAmount = 250; $httpBackend.expect('GET', 'Tickets/1/getSalesPersonMana').respond(200, expectedAmount); + $httpBackend.expect('GET', 'WorkerManas/getCurrentWorkerMana').respond(200, expectedAmount); controller.getMana(); $httpBackend.flush(); expect(controller.edit.mana).toEqual(expectedAmount); + expect(controller.currentWorkerMana).toEqual(expectedAmount); }); }); From 3bf2b46689e49d07e55ae5fcb413cb53b88d469b Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 10:09:01 +0200 Subject: [PATCH 20/49] feat(ticket_line): update workerMana if check claimMana option --- .../10440-fallas/00-manaCustomerUpdate.sql | 106 ++++++++++++++++++ .../10440-fallas/00-manaSpellersRequery.sql | 75 +++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 db/changes/10440-fallas/00-manaCustomerUpdate.sql create mode 100644 db/changes/10440-fallas/00-manaSpellersRequery.sql diff --git a/db/changes/10440-fallas/00-manaCustomerUpdate.sql b/db/changes/10440-fallas/00-manaCustomerUpdate.sql new file mode 100644 index 000000000..6a714f81e --- /dev/null +++ b/db/changes/10440-fallas/00-manaCustomerUpdate.sql @@ -0,0 +1,106 @@ +DROP PROCEDURE IF EXISTS `bs`.`manaCustomerUpdate`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `bs`.`manaCustomerUpdate`() +BEGIN + DECLARE vToDated DATE; + DECLARE vFromDated DATE; + DECLARE vForDeleteDated DATE; + DECLARE vManaId INT; + DECLARE vManaAutoId INT; + DECLARE vClaimManaId INT; + DECLARE vManaBankId INT; + DECLARE vManaGreugeTypeId INT; + + SELECT id INTO vManaId + FROM `component` WHERE code = 'mana'; + + SELECT id INTO vManaAutoId + FROM `component` WHERE code = 'autoMana'; + + SELECT id INTO vClaimManaId + FROM `component` WHERE code = 'mana claim'; + + SELECT id INTO vManaBankId + FROM `bank` WHERE code = 'mana'; + + SELECT id INTO vManaGreugeTypeId + FROM `greugeType` WHERE code = 'mana'; + + SELECT IFNULL(max(dated), '2016-01-01') + INTO vFromDated + FROM bs.manaCustomer; + + DELETE + FROM bs.manaCustomer + WHERE dated = vFromDated; + + SELECT IFNULL(max(dated), '2016-01-01') + INTO vFromDated + FROM bs.manaCustomer; + + WHILE timestampadd(DAY,30,vFromDated) < CURDATE() DO + + SELECT + timestampadd(DAY,30,vFromDated), + timestampadd(DAY,-90,vFromDated) + INTO + vToDated, + vForDeleteDated; + + DELETE FROM bs.manaCustomer + WHERE dated <= vForDeleteDated; + + + INSERT INTO bs.manaCustomer(Id_Cliente, Mana, dated) + + SELECT + Id_Cliente, + cast(sum(mana) as decimal(10,2)) as mana, + vToDated as dated + FROM + + ( + SELECT cs.Id_Cliente, Cantidad * Valor as mana + FROM vn2008.Tickets t + JOIN vn2008.Consignatarios cs using(Id_Consigna) + JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento + WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId) + AND t.Fecha > vFromDated + AND date(t.Fecha) <= vToDated + + + UNION ALL + + SELECT r.Id_Cliente, - Entregado + FROM vn2008.Recibos r + WHERE Id_Banco = vManaBankId + AND Fechacobro > vFromDated + AND Fechacobro <= vToDated + + UNION ALL + + SELECT g.Id_Cliente, g.Importe + FROM vn2008.Greuges g + WHERE Greuges_type_id = vManaGreugeTypeId + AND Fecha > vFromDated + AND Fecha <= vToDated + + UNION ALL + + SELECT Id_Cliente, mana + FROM bs.manaCustomer + WHERE dated = vFromDated + ) sub + + GROUP BY Id_Cliente + HAVING Id_Cliente; + + SET vFromDated = vToDated; + + END WHILE; + +END$$ +DELIMITER ; diff --git a/db/changes/10440-fallas/00-manaSpellersRequery.sql b/db/changes/10440-fallas/00-manaSpellersRequery.sql new file mode 100644 index 000000000..1a0a03ddb --- /dev/null +++ b/db/changes/10440-fallas/00-manaSpellersRequery.sql @@ -0,0 +1,75 @@ +DROP PROCEDURE IF EXISTS `vn`.`manaSpellersRequery`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`manaSpellersRequery`(vWorkerFk INTEGER) +BEGIN +/** + * Recalcula el mana consumido por un trabajador + * + * @param vWorkerFk Id Trabajador + */ + DECLARE vWorkerIsExcluded BOOLEAN; + DECLARE vFromDated DATE; + DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE()); + DECLARE vMana INT; + DECLARE vAutoMana INT; + DECLARE vClaimMana INT; + DECLARE vManaBank INT; + DECLARE vManaGreugeType INT; + + SELECT COUNT(*) INTO vWorkerIsExcluded + FROM workerManaExcluded + WHERE workerFk = vWorkerFk; + + IF NOT vWorkerIsExcluded THEN + SELECT id INTO vMana + FROM `component` WHERE code = 'mana'; + + SELECT id INTO vAutoMana + FROM `component` WHERE code = 'autoMana'; + + SELECT id INTO vClaimMana + FROM `component` WHERE code = 'mana claim'; + + SELECT id INTO vManaBank + FROM `bank` WHERE code = 'mana'; + + SELECT id INTO vManaGreugeType + FROM `greugeType` WHERE code = 'mana'; + + SELECT max(dated) INTO vFromDated + FROM clientManaCache; + + REPLACE workerMana (workerFk, amount) + SELECT vWorkerFk, sum(mana) FROM + ( + SELECT s.quantity * sc.value as mana + FROM ticket t + JOIN address a ON a.id = t.addressFk + JOIN client c ON c.id = a.clientFk + JOIN sale s ON s.ticketFk = t.id + JOIN saleComponent sc ON sc.saleFk = s.id + WHERE c.salesPersonFk = vWorkerFk AND sc.componentFk IN (vMana, vAutoMana, vClaimMana) + AND t.shipped > vFromDated AND t.shipped < vToDated + UNION ALL + SELECT - r.amountPaid + FROM receipt r + JOIN client c ON c.id = r.clientFk + WHERE c.salesPersonFk = vWorkerFk AND bankFk = vManaBank + AND payed > vFromDated + UNION ALL + SELECT g.amount + FROM greuge g + JOIN client c ON c.id = g.clientFk + WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType + AND g.shipped > vFromDated and g.shipped < CURDATE() + UNION ALL + SELECT cc.mana + FROM clientManaCache cc + JOIN client c ON c.id = cc.clientFk + WHERE c.salesPersonFk = vWorkerFk AND cc.dated = vFromDated + ) sub; + END IF; +END$$ +DELIMITER ; From da14d6064b6433c6d83a482dbb3444a4887083a1 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 1 Apr 2022 10:02:23 +0200 Subject: [PATCH 21/49] refactor(client_create): deteled checks on hook --- modules/client/back/models/client.js | 37 +--------------------------- 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index a14631c22..5ccc1ec64 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -30,6 +30,7 @@ module.exports = Self => { require('../methods/client/consumption')(Self); require('../methods/client/createReceipt')(Self); require('../methods/client/updatePortfolio')(Self); + require('../methods/client/checkDuplicated')(Self); // Validations @@ -304,42 +305,6 @@ module.exports = Self => { const assignmentChanged = workerIdBefore != workerIdAfter; if (assignmentChanged) await Self.notifyAssignment(instance, workerIdBefore, workerIdAfter); - - const emails = instance.email ? instance.email.split(',') : null; - - const findParams = []; - if (emails.length) { - for (let email of emails) - findParams.push({email: email}); - } - - if (instance.phone) - findParams.push({phone: instance.phone}); - - if (instance.mobile) - findParams.push({mobile: instance.mobile}); - - const filterObj = { - where: { - and: [ - {or: findParams}, - {id: {neq: instance.id}} - ] - } - }; - - const clientSameData = await Self.findOne(filterObj); - - if (clientSameData) { - await Self.app.models.Mail.create({ - receiver: 'direccioncomercial@verdnatura.es', - subject: `Cliente con email/teléfono/móvil duplicados`, - body: 'El cliente ' + instance.id + ' comparte alguno de estos datos con el cliente ' + clientSameData.id + - '\n- Email: ' + instance.email + - '\n- Teléfono: ' + instance.phone + - '\n- Móvil: ' + instance.mobile - }); - } }); // Send notification on client worker assignment From 3de9ea2ce5a34300d1af6981989cb4acc8297f42 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 1 Apr 2022 10:04:15 +0200 Subject: [PATCH 22/49] refactor(client_create): added checks on back route --- .../back/methods/client/checkDuplicated.js | 64 +++++++++++++++++++ modules/client/front/basic-data/index.js | 1 + modules/client/front/create/index.js | 6 +- 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 modules/client/back/methods/client/checkDuplicated.js diff --git a/modules/client/back/methods/client/checkDuplicated.js b/modules/client/back/methods/client/checkDuplicated.js new file mode 100644 index 000000000..acaffbf42 --- /dev/null +++ b/modules/client/back/methods/client/checkDuplicated.js @@ -0,0 +1,64 @@ +module.exports = Self => { + Self.remoteMethod('checkDuplicatedData', { + description: 'Checks if a client has same email, mobile or phone than other client and send an email', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The client id' + }], + returns: { + type: 'object', + root: true + }, + http: { + verb: 'GET', + path: '/:id/checkDuplicatedData' + } + }); + + Self.checkDuplicatedData = async function(id, options) { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const client = await Self.app.models.Client.findById(id, myOptions); + + const emails = client.email ? client.email.split(',') : null; + + const findParams = []; + if (emails.length) { + for (let email of emails) + findParams.push({email: email}); + } + + if (client.phone) + findParams.push({phone: client.phone}); + + if (client.mobile) + findParams.push({mobile: client.mobile}); + + const filterObj = { + where: { + and: [ + {or: findParams}, + {id: {neq: client.id}} + ] + } + }; + + const clientSameData = await Self.findOne(filterObj, myOptions); + + if (clientSameData) { + await Self.app.models.Mail.create({ + receiver: 'direccioncomercial@verdnatura.es', + subject: `Cliente con email/teléfono/móvil duplicados`, + body: 'El cliente ' + client.id + ' comparte alguno de estos datos con el cliente ' + clientSameData.id + + '\n- Email: ' + client.email + + '\n- Teléfono: ' + client.phone + + '\n- Móvil: ' + client.mobile + }, myOptions); + } + }; +}; diff --git a/modules/client/front/basic-data/index.js b/modules/client/front/basic-data/index.js index 055733289..418663952 100644 --- a/modules/client/front/basic-data/index.js +++ b/modules/client/front/basic-data/index.js @@ -12,6 +12,7 @@ export default class Controller extends Section { return this.$.watcher.submit().then(() => { const query = `Clients/updatePortfolio`; this.$http.get(query); + this.$http.get(`Clients/${this.$params.id}/checkDuplicatedData`); }); } } diff --git a/modules/client/front/create/index.js b/modules/client/front/create/index.js index 1aa21c91e..fb864282e 100644 --- a/modules/client/front/create/index.js +++ b/modules/client/front/create/index.js @@ -10,9 +10,9 @@ export default class Controller extends Section { } onSubmit() { - return this.$.watcher.submit().then( - json => this.$state.go('client.card.basicData', {id: json.data.id}) - ); + return this.$.watcher.submit() + .then(json => this.$state.go('client.card.basicData', {id: json.data.id})) + .then(() => this.$http.get(`Clients/${this.client.id}/checkDuplicatedData`)); } get province() { From d4136cde0b8d3502b985df738a79032f7fb8d7e2 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 1 Apr 2022 11:22:38 +0200 Subject: [PATCH 23/49] fix: excluded backTest --- .../client/back/methods/client/specs/updatePortfolio.spec.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/client/back/methods/client/specs/updatePortfolio.spec.js b/modules/client/back/methods/client/specs/updatePortfolio.spec.js index 2554daf3d..4830156fc 100644 --- a/modules/client/back/methods/client/specs/updatePortfolio.spec.js +++ b/modules/client/back/methods/client/specs/updatePortfolio.spec.js @@ -26,10 +26,9 @@ describe('Client updatePortfolio', () => { throw e; } }); - - it('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => { + // task 3817 + xit('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => { const salesPersonId = 19; - const tx = await models.Client.beginTransaction({}); try { From 86b24ecd1d916257adbcc3f1b8604a38e0c0582e Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 1 Apr 2022 12:13:24 +0200 Subject: [PATCH 24/49] feat(client): add backTest --- .../client/specs/checkDuplicated.spec.js | 24 +++++++++++++++++++ modules/client/front/create/index.js | 7 +++--- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 modules/client/back/methods/client/specs/checkDuplicated.spec.js diff --git a/modules/client/back/methods/client/specs/checkDuplicated.spec.js b/modules/client/back/methods/client/specs/checkDuplicated.spec.js new file mode 100644 index 000000000..1b682ca35 --- /dev/null +++ b/modules/client/back/methods/client/specs/checkDuplicated.spec.js @@ -0,0 +1,24 @@ +const models = require('vn-loopback/server/server').models; + +describe('client checkDuplicated()', () => { + it('should send an mail if mobile/phone/email is duplicated', async() => { + const tx = await models.Client.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const id = 1110; + const mailModel = models.Mail; + spyOn(mailModel, 'create'); + + await models.Client.checkDuplicatedData(id, options); + + expect(mailModel.create).toHaveBeenCalled(); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/client/front/create/index.js b/modules/client/front/create/index.js index fb864282e..9ca58ed10 100644 --- a/modules/client/front/create/index.js +++ b/modules/client/front/create/index.js @@ -10,9 +10,10 @@ export default class Controller extends Section { } onSubmit() { - return this.$.watcher.submit() - .then(json => this.$state.go('client.card.basicData', {id: json.data.id})) - .then(() => this.$http.get(`Clients/${this.client.id}/checkDuplicatedData`)); + return this.$.watcher.submit().then(json => { + this.$state.go('client.card.basicData', {id: json.data.id}); + this.$http.get(`Clients/${this.client.id}/checkDuplicatedData`); + }); } get province() { From fdf285dd5f15806e377126d29090167fbd335946 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 4 Apr 2022 10:31:28 +0200 Subject: [PATCH 25/49] fix(worker_timeControl): corrected db procedure --- .../10450-april/00-timeControl_getError.sql | 73 +++++++++++++++++++ e2e/paths/03-worker/04_time_control.spec.js | 4 +- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 db/changes/10450-april/00-timeControl_getError.sql diff --git a/db/changes/10450-april/00-timeControl_getError.sql b/db/changes/10450-april/00-timeControl_getError.sql new file mode 100644 index 000000000..0caf8ab62 --- /dev/null +++ b/db/changes/10450-april/00-timeControl_getError.sql @@ -0,0 +1,73 @@ +DROP PROCEDURE IF EXISTS vn.timeControl_getError; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN +/* + * @param vDatedFrom + * @param vDatedTo + * @table tmp.`user`(userFk) + * Fichadas incorrectas de las cuales no se puede calcular horas trabajadas + * @return tmp.timeControlError (id) + */ + DECLARE vDayMaxTime INTEGER; + + SET @journeyCounter := 0; + SET @lastUserFk := NULL; + + SELECT dayMaxTime INTO vDayMaxTime + FROM workerTimeControlConfig LIMIT 1; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControl; + CREATE TEMPORARY TABLE tmp.timeControl + (INDEX(id), INDEX(journeyCounter)) + ENGINE = MEMORY + SELECT sub.id, + sub.direction, + sub.timed, + IF(sub.direction = 'in' OR @hasOut OR sub.userFk <> @lastUserFk, @journeyCounter := @journeyCounter + 1, @journeyCounter) journeyCounter, + @lastUserFk := sub.userFk workerFk, + IF(sub.direction = 'out', @hasOut:= TRUE, @hasOut:= FALSE) + FROM ( + SELECT DISTINCT wtc.id, + wtc.direction, + wtc.timed, + wtc.userFk + FROM workerTimeControl wtc + JOIN tmp.`user` w ON w.userFk = wtc.userFk + WHERE wtc.timed BETWEEN DATE_SUB(vDatedFrom, INTERVAL 1 DAY) AND DATE_ADD(vDatedTo, INTERVAL 1 DAY) + ORDER BY wtc.userFk, wtc.timed + ) sub; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux; + CREATE TEMPORARY TABLE tmp.timeControlAux + (INDEX(id), INDEX(journeyCounter)) + ENGINE = MEMORY + SELECT * FROM tmp.timeControl; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlError; + CREATE TEMPORARY TABLE tmp.timeControlError + (INDEX(id)) + ENGINE = MEMORY + SELECT id + FROM tmp.timeControlAux tca + JOIN (SELECT journeyCounter, + UNIX_TIMESTAMP(MAX(timed)) - UNIX_TIMESTAMP(MIN(timed)) timeWork, + SUM(direction = 'in') totalIn, + SUM(direction = 'out') totalOut, + timed + FROM tmp.timeControl + GROUP BY journeyCounter + HAVING COUNT(*) MOD 2 = 1 + OR totalIn <> 1 + OR totalOut <> 1 + OR timeWork >= vDayMaxTime + )sub ON sub.journeyCounter = tca.journeyCounter + WHERE sub.timed BETWEEN vDatedFrom AND vDatedTo; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControl; + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux; + +END$$ +DELIMITER ; diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js index 137d94c74..5709e6207 100644 --- a/e2e/paths/03-worker/04_time_control.spec.js +++ b/e2e/paths/03-worker/04_time_control.spec.js @@ -99,8 +99,8 @@ describe('Worker time control path', () => { expect(result).toEqual(scanTime); }); - // 3736 check proc vn.timeControl_calculate - xit(`should check Hank Pym worked 6:40 hours`, async() => { + + it(`should check Hank Pym worked 6:40 hours`, async() => { await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '06:40 h.'); }); }); From 7a8dbdfb1693b825ddeb14c355457ec984595a76 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 5 Apr 2022 09:56:39 +0200 Subject: [PATCH 26/49] Updated SQL files --- db/changes/10420-valentines/00-ImportTicketAcl.sql | 2 +- db/changes/10420-valentines/00-aclCollection.sql | 2 +- db/changes/10420-valentines/00-aclDocuware.sql | 2 +- db/changes/10420-valentines/00-defaultViewConfig.sql | 2 +- db/changes/10430-ash/00-aclAgency.sql | 2 +- db/changes/10430-ash/00-aclAgencyTerm.sql | 2 +- db/changes/10430-ash/00-deliveryBoss.sql | 4 +--- package.json | 2 +- 8 files changed, 8 insertions(+), 10 deletions(-) diff --git a/db/changes/10420-valentines/00-ImportTicketAcl.sql b/db/changes/10420-valentines/00-ImportTicketAcl.sql index 98192a39c..df61fd5b8 100644 --- a/db/changes/10420-valentines/00-ImportTicketAcl.sql +++ b/db/changes/10420-valentines/00-ImportTicketAcl.sql @@ -1,2 +1,2 @@ -DELETE FROM salix.ACL +DELETE FROM `salix`.`ACL` WHERE model = 'ClaimEnd' AND property = 'importTicketSales'; diff --git a/db/changes/10420-valentines/00-aclCollection.sql b/db/changes/10420-valentines/00-aclCollection.sql index 81e53049c..57774ba29 100644 --- a/db/changes/10420-valentines/00-aclCollection.sql +++ b/db/changes/10420-valentines/00-aclCollection.sql @@ -1,3 +1,3 @@ -INSERT INTO salix.ACL +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES('Collection', 'setSaleQuantity', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10420-valentines/00-aclDocuware.sql b/db/changes/10420-valentines/00-aclDocuware.sql index 21ed66c4c..c2d47d4ea 100644 --- a/db/changes/10420-valentines/00-aclDocuware.sql +++ b/db/changes/10420-valentines/00-aclDocuware.sql @@ -1,3 +1,3 @@ -INSERT INTO salix.ACL +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES('Docuware', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10420-valentines/00-defaultViewConfig.sql b/db/changes/10420-valentines/00-defaultViewConfig.sql index c65c1f403..e0d75e9d4 100644 --- a/db/changes/10420-valentines/00-defaultViewConfig.sql +++ b/db/changes/10420-valentines/00-defaultViewConfig.sql @@ -1,3 +1,3 @@ -UPDATE salix.defaultViewConfig +UPDATE `salix`.`defaultViewConfig` SET `columns`='{"intrastat":false,"stemMultiplier":false,"landed":false,"producer":false}' WHERE tableCode ='itemsIndex'; diff --git a/db/changes/10430-ash/00-aclAgency.sql b/db/changes/10430-ash/00-aclAgency.sql index 2134285cb..88afd53fe 100644 --- a/db/changes/10430-ash/00-aclAgency.sql +++ b/db/changes/10430-ash/00-aclAgency.sql @@ -1,2 +1,2 @@ -INSERT INTO salix.ACL (id, model, property, accessType, permission, principalType, principalId) +INSERT INTO `salix`.`ACL` (id, model, property, accessType, permission, principalType, principalId) VALUES(301, 'Agency', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/changes/10430-ash/00-aclAgencyTerm.sql b/db/changes/10430-ash/00-aclAgencyTerm.sql index d3e11e53e..c43965ed0 100644 --- a/db/changes/10430-ash/00-aclAgencyTerm.sql +++ b/db/changes/10430-ash/00-aclAgencyTerm.sql @@ -1,2 +1,2 @@ -INSERT INTO salix.ACL (model,property,accessType,principalId) +INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) VALUES ('AgencyTerm','*','*','administrative'); diff --git a/db/changes/10430-ash/00-deliveryBoss.sql b/db/changes/10430-ash/00-deliveryBoss.sql index a4bcdcd0c..ac07bfa31 100644 --- a/db/changes/10430-ash/00-deliveryBoss.sql +++ b/db/changes/10430-ash/00-deliveryBoss.sql @@ -1,3 +1 @@ -UPDATE `account`.`user` -SET `role` = 57 -WHERE id IN (2294, 4365, 7294); \ No newline at end of file +UPDATE `account`.`user` SET `role` = 57 WHERE id IN (2294, 4365, 7294); \ No newline at end of file diff --git a/package.json b/package.json index e5b817e20..935147d88 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "test": "jest --watch", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "lint": "eslint ./ --cache --ignore-pattern .gitignore", - "docker": "docker build -t salix-db ./db" + "docker": "docker build --progress=plain -t salix-db ./db" }, "jest": { "projects": [ From 4be3f9c00f9eaf6e85d424a350325c118d6ea88a Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 5 Apr 2022 09:58:15 +0200 Subject: [PATCH 27/49] Open client summary --- modules/client/front/notification/index.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/client/front/notification/index.html b/modules/client/front/notification/index.html index f503c95c8..49e4e3c3f 100644 --- a/modules/client/front/notification/index.html +++ b/modules/client/front/notification/index.html @@ -67,7 +67,7 @@ {{::client.id}} @@ -83,7 +83,9 @@ - + +
@@ -153,3 +155,6 @@ + + \ No newline at end of file From ade5e9256dc87d80d71a440040e881620159ca67 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 5 Apr 2022 15:21:20 +0200 Subject: [PATCH 28/49] feat(client_search-panel): add zone and province --- .../methods/client/getPostCodeFromZone.js | 38 +++++++++++++++++++ modules/client/back/models/client.js | 1 + modules/client/front/main/index.js | 17 ++++++++- modules/client/front/search-panel/index.html | 16 ++++++++ modules/zone/back/models/zone-geo.json | 12 ++++++ modules/zone/back/models/zone.json | 14 ++++++- 6 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 modules/client/back/methods/client/getPostCodeFromZone.js diff --git a/modules/client/back/methods/client/getPostCodeFromZone.js b/modules/client/back/methods/client/getPostCodeFromZone.js new file mode 100644 index 000000000..79d8de357 --- /dev/null +++ b/modules/client/back/methods/client/getPostCodeFromZone.js @@ -0,0 +1,38 @@ +module.exports = Self => { + Self.remoteMethod('getPostCodeFromZone', { + description: 'CHANGEEEEEEEEEEEEEEE', + accessType: 'READ', + accepts: [{ + arg: 'zoneId', + type: 'number', + required: true, + description: 'zone id' + }], + returns: { + type: 'number', + root: true + }, + http: { + path: `/getPostCodeFromZone`, + verb: 'GET' + } + }); + + Self.getPostCodeFromZone = async(zoneId, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const query = ` + SELECT p.code + FROM postCode p + JOIN zoneIncluded z ON z.geoFk = p.geoFk + WHERE z.zoneFk = ?`; + const postCodes = await Self.rawSql(query, [zoneId], myOptions); + const postCodeIds = []; + postCodes.map(postCode => postCodeIds.push(postCode.code)); + console.log(postCodeIds); + return postCodeIds; + }; +}; diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 9ec45f58d..9785703d3 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -30,6 +30,7 @@ module.exports = Self => { require('../methods/client/consumption')(Self); require('../methods/client/createReceipt')(Self); require('../methods/client/updatePortfolio')(Self); + require('../methods/client/getPostCodeFromZone')(Self); // Validations diff --git a/modules/client/front/main/index.js b/modules/client/front/main/index.js index 61cde8b22..04f357261 100644 --- a/modules/client/front/main/index.js +++ b/modules/client/front/main/index.js @@ -2,7 +2,7 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Client extends ModuleMain { - exprBuilder(param, value) { + async exprBuilder(param, value) { switch (param) { case 'search': return /^\d+$/.test(value) @@ -15,6 +15,10 @@ export default class Client extends ModuleMain { {mobile: value} ] }; + case 'zoneFk': + await this.getPostCodesFromZone(value); + console.log(this.postCodeIds); + return {postcode: {inq: this.postCodeIds}}; case 'name': case 'socialName': case 'city': @@ -23,10 +27,21 @@ export default class Client extends ModuleMain { case 'id': case 'fi': case 'postcode': + case 'provinceFk': case 'salesPersonFk': return {[param]: value}; } } + + async getPostCodesFromZone(zoneId) { + const params = { + zoneId: zoneId + }; + this.$http.get('Clients/getPostCodeFromZone', {params}) + .then(res => { + this.postCodeIds = res.data; + }); + } } ngModule.vnComponent('vnClient', { diff --git a/modules/client/front/search-panel/index.html b/modules/client/front/search-panel/index.html index 9caf4185b..a02f93882 100644 --- a/modules/client/front/search-panel/index.html +++ b/modules/client/front/search-panel/index.html @@ -50,6 +50,22 @@ ng-model="filter.postcode"> + + + + + + Date: Wed, 6 Apr 2022 11:48:12 +0200 Subject: [PATCH 29/49] refactor: delete item.compression --- e2e/helpers/selectors.js | 1 - e2e/paths/04-item/02_basic_data.spec.js | 9 --------- modules/item/back/models/item.json | 3 --- modules/item/front/basic-data/index.html | 8 -------- modules/item/front/locale/es.yml | 1 - modules/item/front/summary/index.html | 3 --- 6 files changed, 25 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 21ed27158..62c32434a 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -392,7 +392,6 @@ export default { name: 'vn-item-basic-data vn-textfield[ng-model="$ctrl.item.name"]', relevancy: 'vn-item-basic-data vn-input-number[ng-model="$ctrl.item.relevancy"]', origin: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]', - compression: 'vn-item-basic-data vn-input-number[ng-model="$ctrl.item.compression"]', generic: 'vn-autocomplete[ng-model="$ctrl.item.genericFk"]', isFragile: 'vn-check[ng-model="$ctrl.item.isFragile"]', longName: 'vn-textfield[ng-model="$ctrl.item.longName"]', diff --git a/e2e/paths/04-item/02_basic_data.spec.js b/e2e/paths/04-item/02_basic_data.spec.js index 0bbb6ad12..a663ea3bb 100644 --- a/e2e/paths/04-item/02_basic_data.spec.js +++ b/e2e/paths/04-item/02_basic_data.spec.js @@ -30,8 +30,6 @@ describe('Item Edit basic data path', () => { await page.autocompleteSearch(selectors.itemBasicData.origin, 'Spain'); await page.clearInput(selectors.itemBasicData.relevancy); await page.write(selectors.itemBasicData.relevancy, '1'); - await page.clearInput(selectors.itemBasicData.compression); - await page.write(selectors.itemBasicData.compression, '2'); await page.clearInput(selectors.itemBasicData.generic); await page.autocompleteSearch(selectors.itemBasicData.generic, '16'); await page.waitToClick(selectors.itemBasicData.isActiveCheckbox); @@ -96,13 +94,6 @@ describe('Item Edit basic data path', () => { expect(result).toEqual('Spain'); }); - it(`should confirm the item compression was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.itemBasicData.compression, 'value'); - - expect(result).toEqual('2'); - }); - it(`should confirm the item generic was edited`, async() => { const result = await page .waitToGetProperty(selectors.itemBasicData.generic, 'value'); diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index 9b78264f7..efde2690f 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -112,9 +112,6 @@ "itemPackingTypeFk": { "type": "string" }, - "compression": { - "type": "number" - }, "hasKgPrice": { "type": "boolean", "description": "Price per Kg" diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html index b7db41094..22fd33a07 100644 --- a/modules/item/front/basic-data/index.html +++ b/modules/item/front/basic-data/index.html @@ -129,14 +129,6 @@ ng-model="$ctrl.item.density" rule> - - - - From dd9a38d1bfc8746be0bd5d843b6b874bc5c619cc Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 6 Apr 2022 12:29:00 +0200 Subject: [PATCH 30/49] feat(client_search-panel): filter by province --- db/dump/fixtures.sql | 8 ++-- .../methods/client/getPostCodeFromZone.js | 38 ------------------- modules/client/back/models/client.js | 1 - modules/client/front/main/index.js | 16 +------- modules/client/front/search-panel/index.html | 7 ---- modules/zone/back/models/zone-geo.json | 12 ------ modules/zone/back/models/zone.json | 5 --- 7 files changed, 5 insertions(+), 82 deletions(-) delete mode 100644 modules/client/back/methods/client/getPostCodeFromZone.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index e8302b1a2..5bd89ebd2 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -292,10 +292,10 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`) VALUES (1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), + (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), (1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'), (1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Silla', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'), (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'), diff --git a/modules/client/back/methods/client/getPostCodeFromZone.js b/modules/client/back/methods/client/getPostCodeFromZone.js deleted file mode 100644 index 79d8de357..000000000 --- a/modules/client/back/methods/client/getPostCodeFromZone.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('getPostCodeFromZone', { - description: 'CHANGEEEEEEEEEEEEEEE', - accessType: 'READ', - accepts: [{ - arg: 'zoneId', - type: 'number', - required: true, - description: 'zone id' - }], - returns: { - type: 'number', - root: true - }, - http: { - path: `/getPostCodeFromZone`, - verb: 'GET' - } - }); - - Self.getPostCodeFromZone = async(zoneId, options) => { - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - const query = ` - SELECT p.code - FROM postCode p - JOIN zoneIncluded z ON z.geoFk = p.geoFk - WHERE z.zoneFk = ?`; - const postCodes = await Self.rawSql(query, [zoneId], myOptions); - const postCodeIds = []; - postCodes.map(postCode => postCodeIds.push(postCode.code)); - console.log(postCodeIds); - return postCodeIds; - }; -}; diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 9785703d3..9ec45f58d 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -30,7 +30,6 @@ module.exports = Self => { require('../methods/client/consumption')(Self); require('../methods/client/createReceipt')(Self); require('../methods/client/updatePortfolio')(Self); - require('../methods/client/getPostCodeFromZone')(Self); // Validations diff --git a/modules/client/front/main/index.js b/modules/client/front/main/index.js index 04f357261..1069d3487 100644 --- a/modules/client/front/main/index.js +++ b/modules/client/front/main/index.js @@ -2,7 +2,7 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Client extends ModuleMain { - async exprBuilder(param, value) { + exprBuilder(param, value) { switch (param) { case 'search': return /^\d+$/.test(value) @@ -15,10 +15,6 @@ export default class Client extends ModuleMain { {mobile: value} ] }; - case 'zoneFk': - await this.getPostCodesFromZone(value); - console.log(this.postCodeIds); - return {postcode: {inq: this.postCodeIds}}; case 'name': case 'socialName': case 'city': @@ -32,16 +28,6 @@ export default class Client extends ModuleMain { return {[param]: value}; } } - - async getPostCodesFromZone(zoneId) { - const params = { - zoneId: zoneId - }; - this.$http.get('Clients/getPostCodeFromZone', {params}) - .then(res => { - this.postCodeIds = res.data; - }); - } } ngModule.vnComponent('vnClient', { diff --git a/modules/client/front/search-panel/index.html b/modules/client/front/search-panel/index.html index a02f93882..234cb6f53 100644 --- a/modules/client/front/search-panel/index.html +++ b/modules/client/front/search-panel/index.html @@ -58,13 +58,6 @@ value-field="id" label="Province"> - - Date: Wed, 6 Apr 2022 12:38:49 +0200 Subject: [PATCH 31/49] remove relation --- modules/zone/back/models/zone.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/zone/back/models/zone.json b/modules/zone/back/models/zone.json index 6bdb1b5b5..1e97c1bad 100644 --- a/modules/zone/back/models/zone.json +++ b/modules/zone/back/models/zone.json @@ -67,11 +67,6 @@ "type": "hasMany", "model": "ZoneClosure", "foreignKey": "zoneFk" - }, - "provinces": { - "type": "hasMany", - "model": "Province", - "foreignKey": "zoneFk" - } + } } } \ No newline at end of file From cd098235bbbb11490935a9318e5b7d13928805d2 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 6 Apr 2022 13:44:11 +0200 Subject: [PATCH 32/49] fix(sms): send response when de recipient is the same as the emisor --- back/methods/chat/send.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index 67e0dbb87..9429c935c 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -32,6 +32,8 @@ module.exports = Self => { if (sender.name != recipient) return sendMessage(sender, to, message); + + return false; }; async function sendMessage(sender, channel, message) { From 3ed116d6146906aa7404217fb2f9c60d445cae97 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 6 Apr 2022 14:06:53 +0200 Subject: [PATCH 33/49] Always return a value instead of a promise --- back/methods/chat/send.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index 9429c935c..e9f1a87ca 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -30,8 +30,11 @@ module.exports = Self => { const sender = await models.Account.findById(accessToken.userId); const recipient = to.replace('@', ''); - if (sender.name != recipient) - return sendMessage(sender, to, message); + if (sender.name != recipient) { + await sendMessage(sender, to, message); + + return true; + } return false; }; From afc03fc60e6189558b528e6c4cc284256fc955ee Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 6 Apr 2022 14:48:22 +0200 Subject: [PATCH 34/49] feat(client_address): add LogifloraIsAllowed --- .../client/specs/updateAddress.spec.js | 62 +++++++++++++++++++ .../back/methods/client/updateAddress.js | 9 +++ modules/client/back/models/address.json | 3 + modules/client/front/address/edit/index.html | 8 ++- modules/client/front/address/index/index.html | 5 ++ modules/client/front/address/index/index.js | 1 + modules/client/front/address/locale/es.yml | 3 +- 7 files changed, 89 insertions(+), 2 deletions(-) diff --git a/modules/client/back/methods/client/specs/updateAddress.spec.js b/modules/client/back/methods/client/specs/updateAddress.spec.js index efaa1b93c..101038f9d 100644 --- a/modules/client/back/methods/client/specs/updateAddress.spec.js +++ b/modules/client/back/methods/client/specs/updateAddress.spec.js @@ -15,6 +15,9 @@ describe('Address updateAddress', () => { try { const options = {transaction: tx}; const ctx = { + req: { + accessToken: {userId: 1} + }, args: { provinceFk: provinceId, customsAgentFk: customAgentOneId @@ -41,6 +44,9 @@ describe('Address updateAddress', () => { try { const options = {transaction: tx}; const ctx = { + req: { + accessToken: {userId: 1} + }, args: { provinceFk: provinceId, incotermsFk: incotermsId @@ -67,6 +73,9 @@ describe('Address updateAddress', () => { const expectedResult = 'My edited address'; const ctx = { + req: { + accessToken: {userId: 1} + }, args: { provinceFk: provinceId, nickname: expectedResult, @@ -88,6 +97,56 @@ describe('Address updateAddress', () => { } }); + it('should return an error for a user without enough privileges', async() => { + const tx = await models.Client.beginTransaction({}); + + try { + const options = {transaction: tx}; + const ctx = { + req: { + accessToken: {userId: 1} + }, + args: { + isLogifloraAllowed: true + } + }; + + await models.Client.updateAddress(ctx, clientId, addressId, options); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toEqual(`You don't have enough privileges`); + }); + + it('should update isLogifloraAllowed', async() => { + const tx = await models.Client.beginTransaction({}); + + try { + const options = {transaction: tx}; + const ctx = { + req: { + accessToken: {userId: 21} + }, + args: { + isLogifloraAllowed: true + } + }; + + await models.Client.updateAddress(ctx, clientId, addressId, options); + const address = await models.Address.findById(addressId, null, options); + + expect(address.isLogifloraAllowed).toEqual(true); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + it('should update the address', async() => { const tx = await models.Client.beginTransaction({}); @@ -96,6 +155,9 @@ describe('Address updateAddress', () => { const expectedResult = 'My second time edited address'; const ctx = { + req: { + accessToken: {userId: 1} + }, args: { nickname: expectedResult } diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index d1a498fe7..f7d1c1288 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -68,6 +68,10 @@ module.exports = function(Self) { { arg: 'isEqualizated', type: 'boolean' + }, + { + arg: 'isLogifloraAllowed', + type: 'boolean' } ], returns: { @@ -83,11 +87,16 @@ module.exports = function(Self) { Self.updateAddress = async(ctx, clientId, addressId, options) => { const models = Self.app.models; const args = ctx.args; + const userId = ctx.req.accessToken.userId; const myOptions = {}; + const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant', myOptions); if (typeof options == 'object') Object.assign(myOptions, options); + if (ctx.args.isLogifloraAllowed && !isSalesAssistant) + throw new UserError(`You don't have enough privileges`); + const address = await models.Address.findOne({ where: { id: addressId, diff --git a/modules/client/back/models/address.json b/modules/client/back/models/address.json index 8daac0466..dd533cb32 100644 --- a/modules/client/back/models/address.json +++ b/modules/client/back/models/address.json @@ -50,6 +50,9 @@ }, "isEqualizated": { "type": "boolean" + }, + "isLogifloraAllowed": { + "type": "boolean" } }, "validations": [], diff --git a/modules/client/front/address/edit/index.html b/modules/client/front/address/edit/index.html index 83f251de5..1f0b7d30a 100644 --- a/modules/client/front/address/edit/index.html +++ b/modules/client/front/address/edit/index.html @@ -38,7 +38,13 @@ label="Is equalizated" ng-model="$ctrl.address.isEqualizated" vn-acl="administrative, salesAssistant"> - + + + + + Date: Wed, 6 Apr 2022 14:55:59 +0200 Subject: [PATCH 35/49] refactor(client_updateAddress): refactor ctx variable --- .../client/specs/updateAddress.spec.js | 70 ++++++------------- 1 file changed, 23 insertions(+), 47 deletions(-) diff --git a/modules/client/back/methods/client/specs/updateAddress.spec.js b/modules/client/back/methods/client/specs/updateAddress.spec.js index 101038f9d..7aea6fcd7 100644 --- a/modules/client/back/methods/client/specs/updateAddress.spec.js +++ b/modules/client/back/methods/client/specs/updateAddress.spec.js @@ -6,6 +6,11 @@ describe('Address updateAddress', () => { const provinceId = 5; const incotermsId = 'FAS'; const customAgentOneId = 1; + const ctx = { + req: { + accessToken: {userId: 1} + } + }; it('should throw the non uee member error if no incoterms is defined', async() => { const tx = await models.Client.beginTransaction({}); @@ -14,14 +19,9 @@ describe('Address updateAddress', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 1} - }, - args: { - provinceFk: provinceId, - customsAgentFk: customAgentOneId - } + ctx.args = { + provinceFk: provinceId, + customsAgentFk: customAgentOneId }; await models.Client.updateAddress(ctx, clientId, addressId, options); @@ -43,14 +43,9 @@ describe('Address updateAddress', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 1} - }, - args: { - provinceFk: provinceId, - incotermsFk: incotermsId - } + ctx.args = { + provinceFk: provinceId, + incotermsFk: incotermsId }; await models.Client.updateAddress(ctx, clientId, addressId, options); @@ -72,16 +67,11 @@ describe('Address updateAddress', () => { const options = {transaction: tx}; const expectedResult = 'My edited address'; - const ctx = { - req: { - accessToken: {userId: 1} - }, - args: { - provinceFk: provinceId, - nickname: expectedResult, - incotermsFk: incotermsId, - customsAgentFk: customAgentOneId - } + ctx.args = { + provinceFk: provinceId, + nickname: expectedResult, + incotermsFk: incotermsId, + customsAgentFk: customAgentOneId }; await models.Client.updateAddress(ctx, clientId, addressId, options); @@ -102,13 +92,8 @@ describe('Address updateAddress', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 1} - }, - args: { - isLogifloraAllowed: true - } + ctx.args = { + isLogifloraAllowed: true }; await models.Client.updateAddress(ctx, clientId, addressId, options); @@ -126,13 +111,9 @@ describe('Address updateAddress', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 21} - }, - args: { - isLogifloraAllowed: true - } + ctx.req.accessToken.userId = 21; + ctx.args = { + isLogifloraAllowed: true }; await models.Client.updateAddress(ctx, clientId, addressId, options); @@ -154,13 +135,8 @@ describe('Address updateAddress', () => { const options = {transaction: tx}; const expectedResult = 'My second time edited address'; - const ctx = { - req: { - accessToken: {userId: 1} - }, - args: { - nickname: expectedResult - } + ctx.args = { + nickname: expectedResult }; await models.Client.updateAddress(ctx, clientId, addressId, options); From e44de0246deeb3a0d2ee4f6dda8e99a3d62b04c6 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 6 Apr 2022 14:58:17 +0200 Subject: [PATCH 36/49] extract ids to variable --- .../client/back/methods/client/specs/updateAddress.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/client/back/methods/client/specs/updateAddress.spec.js b/modules/client/back/methods/client/specs/updateAddress.spec.js index 7aea6fcd7..5597c6e5a 100644 --- a/modules/client/back/methods/client/specs/updateAddress.spec.js +++ b/modules/client/back/methods/client/specs/updateAddress.spec.js @@ -6,9 +6,10 @@ describe('Address updateAddress', () => { const provinceId = 5; const incotermsId = 'FAS'; const customAgentOneId = 1; + const employeeId = 1; const ctx = { req: { - accessToken: {userId: 1} + accessToken: {userId: employeeId} } }; @@ -108,10 +109,11 @@ describe('Address updateAddress', () => { it('should update isLogifloraAllowed', async() => { const tx = await models.Client.beginTransaction({}); + const salesAssistantId = 21; try { const options = {transaction: tx}; - ctx.req.accessToken.userId = 21; + ctx.req.accessToken.userId = salesAssistantId; ctx.args = { isLogifloraAllowed: true }; From 4350ea0af52d7e97ed9f352aeb83220137bc2634 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 7 Apr 2022 08:32:31 +0200 Subject: [PATCH 37/49] refactor: changed default date to tomorrow --- modules/client/front/balance/create/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 591af2839..454e5e44d 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -6,8 +6,11 @@ class Controller extends Dialog { super($element, $, $transclude); this.vnReport = vnReport; + + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); this.receipt = { - payed: new Date() + payed: tomorrow }; } From 0e75555bcd64d7a11a6be8dbbf7735cfe7d259c1 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 7 Apr 2022 08:51:07 +0200 Subject: [PATCH 38/49] Updated unit tests --- back/methods/chat/send.js | 6 +++--- modules/client/back/methods/client/specs/sendSms.spec.js | 2 -- modules/ticket/back/methods/ticket/specs/sendSms.spec.js | 2 -- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index e9f1a87ca..51ecb801a 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -31,9 +31,9 @@ module.exports = Self => { const recipient = to.replace('@', ''); if (sender.name != recipient) { - await sendMessage(sender, to, message); - - return true; + const request = await sendMessage(sender, to, message); + + return request ? request : false; } return false; diff --git a/modules/client/back/methods/client/specs/sendSms.spec.js b/modules/client/back/methods/client/specs/sendSms.spec.js index 121d427ce..47e788184 100644 --- a/modules/client/back/methods/client/specs/sendSms.spec.js +++ b/modules/client/back/methods/client/specs/sendSms.spec.js @@ -1,9 +1,7 @@ const models = require('vn-loopback/server/server').models; -const soap = require('soap'); describe('client sendSms()', () => { it('should now send a message and log it', async() => { - spyOn(soap, 'createClientAsync').and.returnValue('a so fake client'); const tx = await models.Client.beginTransaction({}); try { diff --git a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js index 8ec4ca487..f50253b10 100644 --- a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js +++ b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js @@ -1,5 +1,4 @@ const models = require('vn-loopback/server/server').models; -const soap = require('soap'); describe('ticket sendSms()', () => { it('should send a message and log it', async() => { @@ -8,7 +7,6 @@ describe('ticket sendSms()', () => { try { const options = {transaction: tx}; - spyOn(soap, 'createClientAsync').and.returnValue('a so fake client'); const ctx = {req: {accessToken: {userId: 9}}}; const id = 11; const destination = 222222222; From 287aa0c3c66bec8bdb7bb57cffdcf9f375e28d49 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 7 Apr 2022 08:51:07 +0200 Subject: [PATCH 39/49] Updated unit tests --- back/methods/chat/send.js | 6 +++--- modules/client/back/methods/client/specs/sendSms.spec.js | 2 -- modules/ticket/back/methods/ticket/specs/sendSms.spec.js | 2 -- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index e9f1a87ca..51ecb801a 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -31,9 +31,9 @@ module.exports = Self => { const recipient = to.replace('@', ''); if (sender.name != recipient) { - await sendMessage(sender, to, message); - - return true; + const request = await sendMessage(sender, to, message); + + return request ? request : false; } return false; diff --git a/modules/client/back/methods/client/specs/sendSms.spec.js b/modules/client/back/methods/client/specs/sendSms.spec.js index 54fe802e3..72d21827d 100644 --- a/modules/client/back/methods/client/specs/sendSms.spec.js +++ b/modules/client/back/methods/client/specs/sendSms.spec.js @@ -1,10 +1,8 @@ const models = require('vn-loopback/server/server').models; -const soap = require('soap'); // #3673 sendSms tests excluded xdescribe('client sendSms()', () => { it('should now send a message and log it', async() => { - spyOn(soap, 'createClientAsync').and.returnValue('a so fake client'); const tx = await models.Client.beginTransaction({}); try { diff --git a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js index 46ae23702..0de32aedc 100644 --- a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js +++ b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js @@ -1,5 +1,4 @@ const models = require('vn-loopback/server/server').models; -const soap = require('soap'); // #3673 sendSms tests excluded xdescribe('ticket sendSms()', () => { @@ -9,7 +8,6 @@ xdescribe('ticket sendSms()', () => { try { const options = {transaction: tx}; - spyOn(soap, 'createClientAsync').and.returnValue('a so fake client'); const ctx = {req: {accessToken: {userId: 9}}}; const id = 11; const destination = 222222222; From 0a4b7bd0003a4b87ebde4bc6a6207e5c00cf147d Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 7 Apr 2022 10:31:15 +0200 Subject: [PATCH 40/49] Added new version folder --- db/changes/10450-april/delete.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 db/changes/10450-april/delete.keep diff --git a/db/changes/10450-april/delete.keep b/db/changes/10450-april/delete.keep new file mode 100644 index 000000000..e69de29bb From fa58280e4ecc40010ec21451d5ea9954d616631f Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 7 Apr 2022 11:54:08 +0200 Subject: [PATCH 41/49] Rocket fix --- back/methods/chat/send.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index 51ecb801a..fcb49f4b8 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -31,9 +31,9 @@ module.exports = Self => { const recipient = to.replace('@', ''); if (sender.name != recipient) { - const request = await sendMessage(sender, to, message); + await sendMessage(sender, to, message); - return request ? request : false; + return true; } return false; From c312eff12eb5acb452e5ab9e0ea7106f381b15ff Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 7 Apr 2022 12:09:11 +0200 Subject: [PATCH 42/49] fix(claim_search-panel): filter --- modules/claim/back/methods/claim/filter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index f4eecae6d..17e07d67c 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -97,11 +97,16 @@ module.exports = Self => { {'cl.socialName': {like: `%${value}%`}} ] }; + case 'client': + return {'cl.socialName': {like: `%${value}%`}}; + case 'clientFk': + return {'cl.clientFk': value}; case 'id': case 'claimStateFk': case 'priority': return {[`cl.${param}`]: value}; case 'salesPersonFk': + return {'cl.salesPersonFk': value}; case 'attenderFk': return {'cl.workerFk': value}; case 'created': @@ -129,7 +134,8 @@ module.exports = Self => { cs.description, cl.created, cs.priority, - cl.claimStateFk + cl.claimStateFk, + c.salesPersonFk FROM claim cl LEFT JOIN client c ON c.id = cl.clientFk LEFT JOIN worker w ON w.id = cl.workerFk From 479e345ef072289373df8b7a6e5bce0611cfd8ba Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 7 Apr 2022 13:08:53 +0200 Subject: [PATCH 43/49] Param name rollback --- back/methods/chat/sendCheckingPresence.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 429ecdab0..5c27d72fd 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -5,7 +5,7 @@ module.exports = Self => { description: 'Sends a RocketChat message to a connected user or department channel', accessType: 'WRITE', accepts: [{ - arg: 'recipientId', + arg: 'workerId', type: 'number', required: true, description: 'The recipient user id' From 7186e846876c08111e02b953e069c406ca745668 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 7 Apr 2022 13:09:50 +0200 Subject: [PATCH 44/49] Send response --- back/methods/chat/send.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index fcb49f4b8..51ecb801a 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -31,9 +31,9 @@ module.exports = Self => { const recipient = to.replace('@', ''); if (sender.name != recipient) { - await sendMessage(sender, to, message); + const request = await sendMessage(sender, to, message); - return true; + return request ? request : false; } return false; From 763d4f2677c0c6ffac3d801152728437e1a653ec Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 7 Apr 2022 13:20:09 +0200 Subject: [PATCH 45/49] Rollback --- back/methods/chat/send.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index 51ecb801a..fcb49f4b8 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -31,9 +31,9 @@ module.exports = Self => { const recipient = to.replace('@', ''); if (sender.name != recipient) { - const request = await sendMessage(sender, to, message); + await sendMessage(sender, to, message); - return request ? request : false; + return true; } return false; From 238a9fd5da9aede0318a47dc24852ac6b5c99738 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 8 Apr 2022 08:52:21 +0200 Subject: [PATCH 46/49] feat(client.defaulter&claim): change socialName to name --- e2e/paths/02-client/21_defaulter.spec.js | 2 +- modules/claim/back/methods/claim/filter.js | 10 ++++----- .../back/methods/claim/specs/filter.spec.js | 2 +- modules/claim/front/index/index.html | 8 +++---- modules/claim/front/index/index.js | 21 ++++++------------- modules/claim/front/search-panel/index.html | 2 +- .../client/back/methods/defaulter/filter.js | 2 +- .../methods/defaulter/specs/filter.spec.js | 4 ++-- modules/client/front/defaulter/index.html | 2 +- modules/client/front/defaulter/index.js | 8 +++---- modules/client/front/defaulter/index.spec.js | 8 +++---- 11 files changed, 30 insertions(+), 39 deletions(-) diff --git a/e2e/paths/02-client/21_defaulter.spec.js b/e2e/paths/02-client/21_defaulter.spec.js index d51f2113f..c7640d028 100644 --- a/e2e/paths/02-client/21_defaulter.spec.js +++ b/e2e/paths/02-client/21_defaulter.spec.js @@ -28,7 +28,7 @@ describe('Client defaulter path', () => { const salesPersonName = await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText'); - expect(clientName).toEqual('Batman'); + expect(clientName).toEqual('Ororo Munroe'); expect(salesPersonName).toEqual('salesPersonNick'); }); diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index 17e07d67c..e86830200 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -27,7 +27,7 @@ module.exports = Self => { http: {source: 'query'} }, { - arg: 'client', + arg: 'clientName', type: 'string', description: 'The worker name', http: {source: 'query'} @@ -94,11 +94,11 @@ module.exports = Self => { ? {'cl.id': value} : { or: [ - {'cl.socialName': {like: `%${value}%`}} + {'cl.clientName': {like: `%${value}%`}} ] }; - case 'client': - return {'cl.socialName': {like: `%${value}%`}}; + case 'clientName': + return {'cl.clientName': {like: `%${value}%`}}; case 'clientFk': return {'cl.clientFk': value}; case 'id': @@ -128,7 +128,7 @@ module.exports = Self => { SELECT cl.id, cl.clientFk, - c.socialName, + c.name AS clientName, cl.workerFk, u.name AS workerName, cs.description, diff --git a/modules/claim/back/methods/claim/specs/filter.spec.js b/modules/claim/back/methods/claim/specs/filter.spec.js index c54318e45..b26afe8c4 100644 --- a/modules/claim/back/methods/claim/specs/filter.spec.js +++ b/modules/claim/back/methods/claim/specs/filter.spec.js @@ -25,7 +25,7 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, search: 'Iron man'}}, null, options); + const result = await app.models.Claim.filter({args: {filter: {}, search: 'Tony Stark'}}, null, options); expect(result.length).toEqual(1); expect(result[0].id).toEqual(4); diff --git a/modules/claim/front/index/index.html b/modules/claim/front/index/index.html index 341d6eb2f..102e27245 100644 --- a/modules/claim/front/index/index.html +++ b/modules/claim/front/index/index.html @@ -10,16 +10,16 @@ - - - diff --git a/modules/claim/front/index/index.js b/modules/claim/front/index/index.js index bf0cb25c0..084618e16 100644 --- a/modules/claim/front/index/index.js +++ b/modules/claim/front/index/index.js @@ -11,11 +11,11 @@ class Controller extends Section { }, columns: [ { - field: 'clientFk', + field: 'clientName', autocomplete: { url: 'Clients', - showField: 'socialName', - valueField: 'socialName' + showField: 'name', + valueField: 'name' } }, { @@ -46,21 +46,12 @@ class Controller extends Section { exprBuilder(param, value) { switch (param) { + case 'clientName': + return {'cl.clientName': {like: `%${value}%`}}; case 'clientFk': - return {['cl.socialName']: value}; - case 'id': case 'claimStateFk': - case 'priority': + case 'workerFk': return {[`cl.${param}`]: value}; - case 'salesPersonFk': - case 'attenderFk': - return {'cl.workerFk': value}; - case 'created': - value.setHours(0, 0, 0, 0); - to = new Date(value); - to.setHours(23, 59, 59, 999); - - return {'cl.created': {between: [value, to]}}; } } diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index 22faf9ec4..d522763a1 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -18,7 +18,7 @@ + ng-model="filter.clientName"> diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 813d63d3f..ec38c0821 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -56,7 +56,7 @@ module.exports = Self => { FROM ( SELECT DISTINCT c.id clientFk, - c.socialName clientName, + c.name clientName, c.salesPersonFk, u.nickname salesPersonName, d.amount, diff --git a/modules/client/back/methods/defaulter/specs/filter.spec.js b/modules/client/back/methods/defaulter/specs/filter.spec.js index ca14d1e43..0a970823e 100644 --- a/modules/client/back/methods/defaulter/specs/filter.spec.js +++ b/modules/client/back/methods/defaulter/specs/filter.spec.js @@ -47,12 +47,12 @@ describe('defaulter filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'spider'}}; + const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'Petter Parker'}}; const result = await models.Defaulter.filter(ctx, null, options); const firstRow = result[0]; - expect(firstRow.clientName).toEqual('Spider man'); + expect(firstRow.clientName).toEqual('Petter Parker'); await tx.rollback(); } catch (e) { diff --git a/modules/client/front/defaulter/index.html b/modules/client/front/defaulter/index.html index 59f7b7d67..92664079c 100644 --- a/modules/client/front/defaulter/index.html +++ b/modules/client/front/defaulter/index.html @@ -49,7 +49,7 @@ model="model"> -
+ Id + Client Created + Worker @@ -40,7 +40,7 @@ - {{::claim.socialName}} + {{::claim.clientName}} {{::claim.created | date:'dd/MM/yyyy'}} + Client diff --git a/modules/client/front/defaulter/index.js b/modules/client/front/defaulter/index.js index 82719bef0..80f510bf2 100644 --- a/modules/client/front/defaulter/index.js +++ b/modules/client/front/defaulter/index.js @@ -13,11 +13,11 @@ export default class Controller extends Section { }, columns: [ { - field: 'clientName', + field: 'clientFk', autocomplete: { url: 'Clients', - showField: 'socialName', - valueField: 'socialName' + showField: 'name', + valueField: 'id' } }, { @@ -114,7 +114,7 @@ export default class Controller extends Section { switch (param) { case 'creditInsurance': case 'amount': - case 'clientName': + case 'clientFk': case 'workerFk': case 'salesPersonFk': return {[`d.${param}`]: value}; diff --git a/modules/client/front/defaulter/index.spec.js b/modules/client/front/defaulter/index.spec.js index d7d1a684d..5801fa1f8 100644 --- a/modules/client/front/defaulter/index.spec.js +++ b/modules/client/front/defaulter/index.spec.js @@ -104,15 +104,15 @@ describe('client defaulter', () => { describe('exprBuilder()', () => { it('should search by sales person', () => { - let expr = controller.exprBuilder('salesPersonFk', '5'); + const expr = controller.exprBuilder('salesPersonFk', '5'); expect(expr).toEqual({'d.salesPersonFk': '5'}); }); - it('should search by client name', () => { - let expr = controller.exprBuilder('clientName', '1foo'); + it('should search by client', () => { + const expr = controller.exprBuilder('clientFk', '5'); - expect(expr).toEqual({'d.clientName': '1foo'}); + expect(expr).toEqual({'d.clientFk': '5'}); }); }); }); From 90a19d52fb60fbf0fbdc07a107c1a58b06ce4a64 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 8 Apr 2022 09:02:27 +0200 Subject: [PATCH 47/49] use variable --- modules/client/back/methods/client/updateAddress.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index f7d1c1288..d7e20b876 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -89,12 +89,12 @@ module.exports = function(Self) { const args = ctx.args; const userId = ctx.req.accessToken.userId; const myOptions = {}; - const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant', myOptions); + const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions); if (typeof options == 'object') Object.assign(myOptions, options); - if (ctx.args.isLogifloraAllowed && !isSalesAssistant) + if (args.isLogifloraAllowed && !isSalesAssistant) throw new UserError(`You don't have enough privileges`); const address = await models.Address.findOne({ From d8a1bd1b1c22b834da3d2717c5ac36f747cda737 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 11 Apr 2022 08:23:54 +0200 Subject: [PATCH 48/49] fix: pull request changes --- .../00-aclIntrastat.sql | 0 .../00-invoiceInIntrastat.sql | 0 modules/invoiceIn/front/intrastat/index.html | 12 ++++---- modules/invoiceIn/front/intrastat/index.js | 4 +-- .../invoiceIn/front/intrastat/index.spec.js | 30 +++++++++++++++++++ 5 files changed, 37 insertions(+), 9 deletions(-) rename db/changes/{10420-valentines => 10440-fallas}/00-aclIntrastat.sql (100%) rename db/changes/{10420-valentines => 10440-fallas}/00-invoiceInIntrastat.sql (100%) diff --git a/db/changes/10420-valentines/00-aclIntrastat.sql b/db/changes/10440-fallas/00-aclIntrastat.sql similarity index 100% rename from db/changes/10420-valentines/00-aclIntrastat.sql rename to db/changes/10440-fallas/00-aclIntrastat.sql diff --git a/db/changes/10420-valentines/00-invoiceInIntrastat.sql b/db/changes/10440-fallas/00-invoiceInIntrastat.sql similarity index 100% rename from db/changes/10420-valentines/00-invoiceInIntrastat.sql rename to db/changes/10440-fallas/00-invoiceInIntrastat.sql diff --git a/modules/invoiceIn/front/intrastat/index.html b/modules/invoiceIn/front/intrastat/index.html index c58839e38..cb447132d 100644 --- a/modules/invoiceIn/front/intrastat/index.html +++ b/modules/invoiceIn/front/intrastat/index.html @@ -45,28 +45,26 @@ data="intrastats" ng-model="intrastat.intrastatFk" show-field="description" - rule> + rule + vn-focus> {{id | zeroFill:8}}: {{description}} + rule> + rule> + rule> { + this.invoceInIntrastat.forEach(intrastat => { this.amountTotal += intrastat.amount; this.netTotal += intrastat.net; this.stemsTotal += intrastat.stems; diff --git a/modules/invoiceIn/front/intrastat/index.spec.js b/modules/invoiceIn/front/intrastat/index.spec.js index d0db17904..d7d50ac5b 100644 --- a/modules/invoiceIn/front/intrastat/index.spec.js +++ b/modules/invoiceIn/front/intrastat/index.spec.js @@ -31,6 +31,36 @@ describe('InvoiceIn', () => { expect(controller.netTotal).toEqual(0); expect(controller.stemsTotal).toEqual(0); }); + + it('should set amountTotal, netTotal and stemsTotal', () => { + controller.invoceInIntrastat = [ + { + id: 1, + invoiceInFk: 1, + net: 30.5, + intrastatFk: 5080000, + amount: 10, + stems: 162, + countryFk: 5, + statisticalValue: 0 + }, + { + id: 2, + invoiceInFk: 1, + net: 10, + intrastatFk: 6021010, + amount: 20, + stems: 205, + countryFk: 5, + statisticalValue: 0 + } + ]; + controller.calculateTotals(); + + expect(controller.amountTotal).toEqual(30); + expect(controller.netTotal).toEqual(40.5); + expect(controller.stemsTotal).toEqual(367); + }); }); describe('onSubmit()', () => { From 655db502f7ec205716112aec9fe97569ceeaf0c0 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 11 Apr 2022 09:04:05 +0200 Subject: [PATCH 49/49] refactor: pull request changes --- db/changes/10440-fallas/00-component.sql | 2 +- .../10440-fallas/00-manaCustomerUpdate.sql | 2 +- .../10440-fallas/00-manaSpellersRequery.sql | 2 +- .../05-ticket/01-sale/02_edit_sale.spec.js | 2 +- .../ticket/specs/updateDiscount.spec.js | 14 +++++++------- .../back/methods/ticket/updateDiscount.js | 6 +++--- modules/ticket/front/sale/index.html | 6 +++--- modules/ticket/front/sale/index.js | 12 ++++++------ modules/ticket/front/sale/index.spec.js | 19 +------------------ 9 files changed, 24 insertions(+), 41 deletions(-) diff --git a/db/changes/10440-fallas/00-component.sql b/db/changes/10440-fallas/00-component.sql index 34810280b..8d2dd6517 100644 --- a/db/changes/10440-fallas/00-component.sql +++ b/db/changes/10440-fallas/00-component.sql @@ -1,2 +1,2 @@ INSERT INTO `vn`.`component` (`name`,`typeFk`,`classRate`,`isRenewable`,`code`,`isRequired`) - VALUES ('maná reclamacion',7,4,0,'mana claim',0); \ No newline at end of file + VALUES ('maná reclamacion',7,4,0,'manaClaim',0); \ No newline at end of file diff --git a/db/changes/10440-fallas/00-manaCustomerUpdate.sql b/db/changes/10440-fallas/00-manaCustomerUpdate.sql index 6a714f81e..80838bca2 100644 --- a/db/changes/10440-fallas/00-manaCustomerUpdate.sql +++ b/db/changes/10440-fallas/00-manaCustomerUpdate.sql @@ -20,7 +20,7 @@ BEGIN FROM `component` WHERE code = 'autoMana'; SELECT id INTO vClaimManaId - FROM `component` WHERE code = 'mana claim'; + FROM `component` WHERE code = 'manaClaim'; SELECT id INTO vManaBankId FROM `bank` WHERE code = 'mana'; diff --git a/db/changes/10440-fallas/00-manaSpellersRequery.sql b/db/changes/10440-fallas/00-manaSpellersRequery.sql index 1a0a03ddb..9c1a10c6a 100644 --- a/db/changes/10440-fallas/00-manaSpellersRequery.sql +++ b/db/changes/10440-fallas/00-manaSpellersRequery.sql @@ -30,7 +30,7 @@ BEGIN FROM `component` WHERE code = 'autoMana'; SELECT id INTO vClaimMana - FROM `component` WHERE code = 'mana claim'; + FROM `component` WHERE code = 'manaClaim'; SELECT id INTO vManaBank FROM `bank` WHERE code = 'mana'; diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index f22d1af30..972684708 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -175,7 +175,7 @@ describe('Ticket Edit sale path', () => { it('should update the discount', async() => { await page.waitToClick(selectors.ticketSales.firstSaleDiscount); await page.waitForSelector(selectors.ticketSales.firstSaleDiscountInput); - await page.type(selectors.ticketSales.firstSaleDiscountInput, '50\u000d'); + await page.type(selectors.ticketSales.firstSaleDiscountInput, '50'); await page.waitToClick(selectors.ticketSales.saveSaleDiscountButton); const message = await page.waitForSnackbar(); diff --git a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js index 1a20b0753..1873207aa 100644 --- a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js +++ b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js @@ -90,7 +90,7 @@ describe('sale updateDiscount()', () => { expect(error.message).toEqual(`The sales of this ticket can't be modified`); }); - it('should update the discount if the salesPerson has mana and manaType = "mana"', async() => { + it('should update the discount if the salesPerson has mana and manaCode = "mana"', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -108,9 +108,9 @@ describe('sale updateDiscount()', () => { const newDiscount = 100; const manaDiscount = await models.Component.findOne({where: {code: 'mana'}}, options); const componentId = manaDiscount.id; - const manaType = 'mana'; + const manaCode = 'mana'; - await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options); + await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options); const updatedSale = await models.Sale.findById(originalSaleId, null, options); const createdSaleComponent = await models.SaleComponent.findOne({ @@ -130,7 +130,7 @@ describe('sale updateDiscount()', () => { } }); - it('should update the discount if the salesPerson has mana and manaType = "mana claim"', async() => { + it('should update the discount if the salesPerson has mana and manaCode = "manaClaim"', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -146,11 +146,11 @@ describe('sale updateDiscount()', () => { const ticketId = 11; const sales = [originalSaleId]; const newDiscount = 100; - const manaDiscount = await models.Component.findOne({where: {code: 'mana claim'}}, options); + const manaDiscount = await models.Component.findOne({where: {code: 'manaClaim'}}, options); const componentId = manaDiscount.id; - const manaType = 'mana claim'; + const manaCode = 'manaClaim'; - await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options); + await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options); const updatedSale = await models.Sale.findById(originalSaleId, null, options); const createdSaleComponent = await models.SaleComponent.findOne({ diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 9726dae1a..b1291a45b 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -25,7 +25,7 @@ module.exports = Self => { required: true }, { - arg: 'manaType', + arg: 'manaCode', description: 'The type of mana', type: 'string', required: false @@ -41,7 +41,7 @@ module.exports = Self => { } }); - Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaType, options) => { + Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaCode, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; const myOptions = {}; @@ -104,7 +104,7 @@ module.exports = Self => { }, fields: 'amount'}, myOptions); - const componentCode = usesMana ? manaType : 'buyerDiscount'; + const componentCode = usesMana ? manaCode : 'buyerDiscount'; const discountComponent = await models.Component.findOne({ where: {code: componentCode}}, myOptions); diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 3643113bc..18905f859 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -292,12 +292,12 @@ + ng-model="$ctrl.manaCode"> + val="manaClaim" + ng-model="$ctrl.manaCode">
diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index b953db9c4..a60c9cb96 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -6,15 +6,15 @@ class Controller extends Section { constructor($element, $) { super($element, $); this._sales = []; - this.manaType = 'mana'; + this.manaCode = 'mana'; } - get manaType() { - return this._manaType; + get manaCode() { + return this._manaCode; } - set manaType(value) { - this._manaType = value; + set manaCode(value) { + this._manaCode = value; } get ticket() { @@ -290,7 +290,7 @@ class Controller extends Section { return sale.id; }); - const params = {salesIds: saleIds, newDiscount: this.edit.discount, manaType: this.manaType}; + const params = {salesIds: saleIds, newDiscount: this.edit.discount, manaCode: this.manaCode}; const query = `Tickets/${this.$params.id}/updateDiscount`; this.$http.post(query, params).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index a1088c0cc..fc4d1b4f3 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -63,14 +63,6 @@ describe('Ticket', () => { controller._sales = sales; })); - describe('manaType() setter/getter', () => { - it('should set the manaType data', () => { - controller.manaType = 'mana claim'; - - expect(controller.manaType).toEqual('mana claim'); - }); - }); - describe('ticket() setter', () => { it('should set the ticket data an then call the isTicketEditable() and isTicketLocked() methods', () => { jest.spyOn(controller, 'isTicketEditable').mockReturnThis(); @@ -456,7 +448,7 @@ describe('Ticket', () => { const expectedSales = [firstSelectedSale, secondSelectedSale]; const expectedSaleIds = [firstSelectedSale.id, secondSelectedSale.id]; - const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount, manaType: 'mana'}; + const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount, manaCode: 'mana'}; $httpBackend.expect('POST', `Tickets/1/updateDiscount`, expectedParams).respond(200, {discount: 10}); controller.updateDiscount(expectedSales); $httpBackend.flush(); @@ -743,15 +735,6 @@ describe('Ticket', () => { }); }); - describe('save()', () => { - it('should call changeDiscount()', () => { - jest.spyOn(controller, 'changeDiscount').mockReturnThis(); - controller.save(); - - expect(controller.changeDiscount).toHaveBeenCalledWith(); - }); - }); - describe('cancel()', () => { it('should call hide()', () => { jest.spyOn(controller.$.editDiscount, 'hide').mockReturnThis();