From ca3ac64072f0480650b7f9dd623e99b1d75172a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 1 Oct 2024 16:37:12 +0200 Subject: [PATCH 001/108] feat: refs #4460 invoiceIn refund --- db/routines/sage/procedures/invoiceIn_add.sql | 18 +++---- .../sage/procedures/invoiceOut_add.sql | 5 +- .../00-firstScript.sql | 47 +++++++++++++++++++ 3 files changed, 59 insertions(+), 11 deletions(-) create mode 100644 db/versions/11266-goldenChrysanthemum/00-firstScript.sql diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index 0898d6810..ba7a0c6c0 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -4,10 +4,10 @@ BEGIN /** * Traslada la info de contabilidad relacionada con las facturas recibidas * - * @vInvoiceInFk Factura recibida - * @vXDiarioFk Id tabla XDiario + * @param vInvoiceInFk Factura recibida + * @param vXDiarioFk Id tabla XDiario */ - DECLARE vInvoiceInOriginalFk INT; + DECLARE vInvoiceInOriginalFk INT; DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBase DOUBLE; DECLARE vVat DOUBLE; @@ -204,9 +204,9 @@ BEGIN WHERE correctingFk = vInvoiceInFk; IF vInvoiceInOriginalFk THEN - UPDATE movContaIVA mci - JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk + JOIN vn.invoiceInCorrection iic ON iic.correctingFk = vInvoiceInFk + JOIN vn.siiTypeInvoiceOut st ON st.id = iic.siiTypeInvoiceOutFk JOIN (SELECT issued, SUM(sub.taxableBase) taxableBase, SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat @@ -215,20 +215,20 @@ BEGIN ti.PorcentajeIva FROM vn.invoiceIn i JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id - JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk + JOIN TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk WHERE i.id = vInvoiceInOriginalFk GROUP BY ti.CodigoIva)sub )invoiceInOriginal JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' - SET mci.TipoRectificativa = iir.refundCategoryFk, - mci.ClaseAbonoRectificativas = iir.refundType, + SET mci.TipoRectificativa = iic.cplusRectificationTypeFk, + mci.ClaseAbonoRectificativas = REGEXP_REPLACE(st.`code`, '[^0-9]', ''), mci.FechaFacturaOriginal = invoiceInOriginal.issued, mci.FechaOperacion = invoiceInOriginal.issued, mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, mci.CuotaIvaOriginal = invoiceInOriginal.vat, mci.ClaveOperacionFactura = co.ClaveOperacionFactura_ WHERE mci.id = vXDiarioFk; - END IF; END$$ +$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/sage/procedures/invoiceOut_add.sql b/db/routines/sage/procedures/invoiceOut_add.sql index 95d6a56dd..f9c6f6b87 100644 --- a/db/routines/sage/procedures/invoiceOut_add.sql +++ b/db/routines/sage/procedures/invoiceOut_add.sql @@ -169,6 +169,7 @@ BEGIN UPDATE movContaIVA mci JOIN vn.invoiceOut i ON i.id = vInvoiceOutCorrectedFk JOIN vn.invoiceCorrection ic ON ic.correctedFk = vInvoiceOutCorrectedFk + JOIN vn.siiTypeInvoiceOut st ON st.id = ic.siiTypeInvoiceOutFk JOIN (SELECT SUM(IF(IFNULL(e.vatFk, TRUE), iot.taxableBase, 0)) taxableBase, SUM(IF(IFNULL(e.vatFk, TRUE), iot.vat, 0)) vat, SUM(IF(IFNULL(e.vatFk, TRUE), 0, iot.vat)) equ @@ -177,8 +178,8 @@ BEGIN WHERE iot.invoiceOutFk = vInvoiceOutCorrectedFk ) tax JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' - SET mci.TipoRectificativa = 2, - mci.ClaseAbonoRectificativas = 1, + SET mci.TipoRectificativa = ic.cplusRectificationTypeFk, + mci.ClaseAbonoRectificativas = REGEXP_REPLACE(st.`code`, '[^0-9]', ''), mci.FechaFacturaOriginal = i.issued, mci.FechaOperacion = i.issued, mci.BaseImponibleOriginal = tax.taxableBase, diff --git a/db/versions/11266-goldenChrysanthemum/00-firstScript.sql b/db/versions/11266-goldenChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..37143c99b --- /dev/null +++ b/db/versions/11266-goldenChrysanthemum/00-firstScript.sql @@ -0,0 +1,47 @@ + USE vn; + + DROP TRIGGER IF EXISTS invoiceIn_beforeUpdate; + + UPDATE vn.invoiceIn + SET cplusRectificationTypeFk = NULL + WHERE cplusRectificationTypeFk = 1; + + DELETE IGNORE FROM vn.cplusRectificationType WHERE id = 1; + + UPDATE vn.cplusRectificationType + SET id = 1 + WHERE id = 3; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdate` + BEFORE UPDATE ON `invoiceIn` + FOR EACH ROW +BEGIN + DECLARE vWithholdingSageFk INT; + + IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN + CALL util.throw('The invoiceIn reference contains invalid characters'); + END IF; + + SET NEW.editorFk = account.myUser_getId(); + + IF (SELECT COUNT(*) FROM vn.invoiceIn + WHERE supplierRef = NEW.supplierRef + AND supplierFk = NEW.supplierFk + AND YEAR(issued) = YEAR(NEW.issued) + AND id <> NEW.id + ) THEN + CALL util.throw('reference duplicated'); + END IF; + + IF NEW.supplierFk != OLD.supplierFk THEN + CALL supplier_checkIsActive(NEW.supplierFk); + SELECT withholdingSageFk INTO vWithholdingSageFk + FROM vn.supplier + WHERE id = NEW.supplierFk; + SET NEW.withholdingSageFk = vWithholdingSageFk; + END IF; + +END$$ +DELIMITER ; + From 2a1fa8ca68d34e67767c954fa808c1f51d5e728b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 1 Oct 2024 18:55:29 +0200 Subject: [PATCH 002/108] feat: refs #4466 invoiceIn refund --- db/routines/vn/procedures/invoiceIn_booking.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index 36189afcc..3d1ca402a 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -43,7 +43,7 @@ BEGIN ii.cplusTaxBreakFk, ii.cplusSubjectOpFk, ii.siiTypeInvoiceInFk, - ii.cplusRectificationTypeFk, + ic.cplusRectificationTypeFk, ii.booked, IFNULL(a.isUeeMember, c.isUeeMember) isUeeMember, (c.id = cc.id) isSameCountry, @@ -66,6 +66,7 @@ BEGIN e.name expenseName FROM invoiceIn ii JOIN supplier s ON s.id = ii.supplierFk + LEFT JOIN invoiceInCorrection ic ON ic.correctingFk = ii.id LEFT JOIN province p ON p.id = s.provinceFk LEFT JOIN autonomy a ON a.id = p.autonomyFk JOIN country c ON c.id = s.countryFk From bca22e8ad3ce93392f5701cb347bdf9a772fed90 Mon Sep 17 00:00:00 2001 From: carlossa Date: Sun, 20 Oct 2024 15:17:17 +0200 Subject: [PATCH 003/108] fix: refs #6389 saleMonitor filter --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 927f49999..0fa2e60e5 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -194,6 +194,7 @@ module.exports = Self => { u.name userName, c.salesPersonFk, c.credit, + pm.name payMethod, z.hour zoneLanding, z.name zoneName, z.id zoneFk, @@ -211,6 +212,7 @@ module.exports = Self => { LEFT JOIN ticketState ts ON ts.ticketFk = t.id LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN payMethod pm ON pm.id = c.payMethodFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = wk.id LEFT JOIN ( From dfdd8f28d41783e399123c60c6a1e9cbf8d268bd Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 23 Oct 2024 12:23:31 +0200 Subject: [PATCH 004/108] fix: refs #6389 filter --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 0fa2e60e5..9bfb69b65 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -199,6 +199,8 @@ module.exports = Self => { z.name zoneName, z.id zoneFk, st.classColor, + d.id departmentFk, + d.name department, TIME_FORMAT(t.shipped, '%H:%i') preparationHour, TIME_FORMAT(z.hour, '%H:%i') theoreticalhour, TIME_FORMAT(zed.etc, '%H:%i') practicalHour @@ -214,6 +216,8 @@ module.exports = Self => { LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN payMethod pm ON pm.id = c.payMethodFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk + LEFT JOIN workerDepartment wd ON wd.workerFk = wk.id + LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN account.user u ON u.id = wk.id LEFT JOIN ( SELECT zoneFk, From 99bec3e7fe8d5179d5f8ba8ca8d61c2b0f9435cb Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 23 Oct 2024 14:58:20 +0200 Subject: [PATCH 005/108] fix: refs #6389 salesFilter --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 9bfb69b65..5a0ea8d9d 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -169,7 +169,7 @@ module.exports = Self => { stmt = new ParameterizedSQL(` CREATE OR REPLACE TEMPORARY TABLE tmp.filter (PRIMARY KEY (id)) - ENGINE = MEMORY + ENGINE = InnoDB SELECT t.id, t.shipped, CAST(DATE(t.shipped) AS CHAR) shippedDate, @@ -201,6 +201,11 @@ module.exports = Self => { st.classColor, d.id departmentFk, d.name department, + (SELECT GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ',') + FROM sale s + JOIN item i ON i.id = s.itemFk + WHERE s.ticketFk = t.id + ) AS packing, TIME_FORMAT(t.shipped, '%H:%i') preparationHour, TIME_FORMAT(z.hour, '%H:%i') theoreticalhour, TIME_FORMAT(zed.etc, '%H:%i') practicalHour From 55483f8e6ba8ef2293ecd59ab3ae370a0243c5ba Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 28 Oct 2024 09:01:10 +0100 Subject: [PATCH 006/108] fix: refs #6389 packing --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 5a0ea8d9d..30df9c0cc 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -88,6 +88,11 @@ module.exports = Self => { arg: 'alertLevel', type: 'number', description: `The alert level of the tickets` + }, + { + arg: 'packing', + type: 'string', + description: `The packing of the items` } ], returns: { @@ -155,6 +160,9 @@ module.exports = Self => { case 'clientFk': param = `t.${param}`; return {[param]: value}; + case 'packing': + param = `i.${param}`; + return {[param]: value}; } }); From f1370d69603c64fb099f6277f6a600a4c962cd3e Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 29 Oct 2024 12:13:25 +0100 Subject: [PATCH 007/108] feat: refs#8174 simSupplier --- .../11327-maroonOak/00-firstScript.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 db/versions/11327-maroonOak/00-firstScript.sql diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql new file mode 100644 index 000000000..973050fba --- /dev/null +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -0,0 +1,19 @@ +CREATE TABLE IF NOT EXISTS `vn`.`simSupplier` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `line` int(9) unsigned DEFAULT NULL, + `ext` int(10) unsigned DEFAULT NULL, + `pin` int(4) unsigned DEFAULT NULL, + `sim` VARCHAR(25), + `puk` int(10) unsigned DEFAULT NULL, + `statusWeb` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `sim_UNIQUE` (`sim`) +) ENGINE=InnoDB AUTO_INCREMENT=1 + DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +ALTER TABLE `deviceProductionUser` +MODIFY `simSerialNumber` VARCHAR(25); + +ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK + FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim); + From 679dd6929bfde285fe1a501f9199dbcd5fd26af2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 6 Nov 2024 13:42:36 +0100 Subject: [PATCH 008/108] feat: refs #6583 add new opt in where builder --- modules/ticket/back/methods/ticket/getTicketsAdvance.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index 41f3ee79a..6abac455f 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -55,6 +55,11 @@ module.exports = Self => { type: 'number', description: 'Department identifier' }, + { + arg: 'onlyWithDestination', + type: 'Boolean', + description: 'True when only tickets with destination are returned' + }, { arg: 'filter', type: 'object', @@ -103,6 +108,9 @@ module.exports = Self => { return {'f.isFullMovable': value}; case 'departmentFk': return {'f.departmentFk': value}; + case 'onlyWithDestination': + if (!value) return; + return {'f.id': {neq: null}}; } }); From 611cd12392f80e6833c14f4763b956c044a27465 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 7 Nov 2024 16:16:40 +0100 Subject: [PATCH 009/108] feat: refs #6583 retrieve cloned sale --- db/routines/vn/procedures/ticket_canAdvance.sql | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index e8fc70bba..cee706e08 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -52,7 +52,8 @@ BEGIN IFNULL(dest.nickname, origin.nickname) nickname, dest.landed, dest.preparation, - origin.departmentFk + origin.departmentFk, + origin.saleClonedFk FROM ( SELECT s.ticketFk, c.salesPersonFk workerFk, @@ -73,11 +74,13 @@ BEGIN t.warehouseFk, t.companyFk, t.agencyModeFk, - wd.departmentFk + wd.departmentFk, + sc.saleClonedFk FROM ticket t JOIN client c ON c.id = t.clientFk JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk JOIN sale s ON s.ticketFk = t.id + LEFT JOIN saleCloned sc ON sc.saleClonedFk = s.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk JOIN ticketState ts ON ts.ticketFk = t.id From 41512a0516294d2709b3836585d5239c2b84c97e Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 16:09:26 +0100 Subject: [PATCH 010/108] refactor: refs #6583 entry report table style --- .../reports/entry-order/assets/css/style.css | 5 +++ .../reports/entry-order/entry-order.html | 44 +++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css index 767b1185a..1a5ea3eb6 100644 --- a/print/templates/reports/entry-order/assets/css/style.css +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -17,4 +17,9 @@ h3 { .tags { font-size: 10px; margin: 0; +} + +.column-oriented th, +.column-oriented td{ + padding: 5px } \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index e5d3bfb6d..77545ef9b 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -41,36 +41,36 @@ + - + - - - - - - - - + + + + + + + + - - - - - + + + - - - - - + + + + From 3db6ab07789540c213a2403c7223ea040c6841c6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 16:10:49 +0100 Subject: [PATCH 011/108] feat: refs #6583 rollback --- .../reports/entry-order/assets/css/style.css | 5 +++ .../reports/entry-order/entry-order.html | 44 +++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css index 767b1185a..1a5ea3eb6 100644 --- a/print/templates/reports/entry-order/assets/css/style.css +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -17,4 +17,9 @@ h3 { .tags { font-size: 10px; margin: 0; +} + +.column-oriented th, +.column-oriented td{ + padding: 5px } \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index e5d3bfb6d..77545ef9b 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -41,36 +41,36 @@
{{$t('reference')}} {{$t('boxes')}} {{$t('packing')}}{{$t('concept')}}{{$t('reference')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}{{$t('concept')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
{{buy.comment}} {{buy.stickers}}x{{buy.packing}}{{buy.name}}{{buy.comment}} - {{buy.tag5}} → {{buy.value5}} - {{buy.tag6}} → {{buy.value6}} - {{buy.tag7}} → {{buy.value7}} + x{{buy.packing}}{{buy.name}} + {{buy.tag5}} → {{buy.value5}} + {{buy.tag6}} → {{buy.value6}} + {{buy.tag7}} → {{buy.value7}} {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= + {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= {{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}
+ - + - - - - - - - - + + + + + + + + - - - - - + + + - - - - - + + + + From 2f3efa15ba8e2a832aff010ddc114c39192576b9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 16:13:25 +0100 Subject: [PATCH 012/108] feat: refs #6583 rollback --- .../reports/entry-order/assets/css/style.css | 5 --- .../reports/entry-order/entry-order.html | 44 +++++++++---------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css index 1a5ea3eb6..767b1185a 100644 --- a/print/templates/reports/entry-order/assets/css/style.css +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -17,9 +17,4 @@ h3 { .tags { font-size: 10px; margin: 0; -} - -.column-oriented th, -.column-oriented td{ - padding: 5px } \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index 77545ef9b..e5d3bfb6d 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -41,36 +41,36 @@
{{$t('reference')}} {{$t('boxes')}} {{$t('packing')}}{{$t('concept')}}{{$t('reference')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}{{$t('concept')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
{{buy.comment}} {{buy.stickers}}x{{buy.packing}}{{buy.name}}{{buy.comment}} - {{buy.tag5}} → {{buy.value5}} - {{buy.tag6}} → {{buy.value6}} - {{buy.tag7}} → {{buy.value7}} + x{{buy.packing}}{{buy.name}} + {{buy.tag5}} → {{buy.value5}} + {{buy.tag6}} → {{buy.value6}} + {{buy.tag7}} → {{buy.value7}} {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= + {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= {{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}
- - + - - - - - - - + + + + + + + + - - - - - + + + + - - - - - + + + + From 1c49c073eebf29a7da16101f6bce11ed1eaa37ad Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 15:45:06 +0100 Subject: [PATCH 013/108] feat: refs #8002 drop support btn --- front/core/components/snackbar/snackbar.js | 11 +---------- front/core/components/support-dialog/index.js | 12 ++++++------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index b380c47c3..49d784067 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -27,17 +27,8 @@ export default class Controller extends Component { setTimeout(() => element.classList.add('shown'), 30); shape.element = element; - if (data.additionalData && this.vnToken.token) { + if (data.additionalData && this.vnToken.token) this.additionalData = data.additionalData; - let supportButton = document.createElement('i'); - supportButton.setAttribute('class', 'material-icons clickable'); - supportButton.addEventListener('click', () => this.$.supportDialog.show()); - element.appendChild(supportButton); - - let buttonIcon = 'support_agent'; - buttonIcon = document.createTextNode(buttonIcon); - supportButton.appendChild(buttonIcon); - } if (shape.type) element.classList.add(shape.type); diff --git a/front/core/components/support-dialog/index.js b/front/core/components/support-dialog/index.js index d15c14b4a..45a8147fe 100644 --- a/front/core/components/support-dialog/index.js +++ b/front/core/components/support-dialog/index.js @@ -10,12 +10,12 @@ export default class Controller extends Dialog { if (response !== 'accept') return super.responseHandler(response); - this.$http.post('Ostickets/send-to-support', { - reason: this.reason, - additionalData: this.additionalData - }) - .then(() => super.responseHandler(response)) - .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); + // this.$http.post('Ostickets/send-to-support', { + // reason: this.reason, + // additionalData: this.additionalData + // }) + // .then(() => super.responseHandler(response)) + // .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); } } From b75b369716ded8737a6f32d65ec6c93e0f0c25ad Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 17:35:27 +0100 Subject: [PATCH 014/108] feat: refs #8002 adjust to lilium --- back/methods/osticket/sendToSupport.js | 37 ++++++++++++-------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js index e17093839..d05f1a82e 100644 --- a/back/methods/osticket/sendToSupport.js +++ b/back/methods/osticket/sendToSupport.js @@ -29,35 +29,32 @@ module.exports = Self => { }); Self.sendToSupport = async(ctx, reason, additionalData) => { + const userId = ctx.req.accessToken.userId; const emailUser = - await Self.app.models.EmailUser.findById(ctx.req.accessToken.userId, {fields: ['email']}); + await Self.app.models.EmailUser.findById(userId, {fields: ['email']}); + const {code, message, path, request, status, statusText, config: errConfig, name} = additionalData; - let html = `Motivo:
${reason}
`; - html += `Usuario:
${ctx.req.accessToken.userId} ${emailUser.email}
`; + let html = `

Motivo: ${reason}

`; + html += `

Usuario: ${userId} ${emailUser.email}

`; + html += `

Additional Data:

`; + html += `
  • Code: ${code}
  • `; + html += `
  • Message: ${message}
  • `; + html += `
  • Path: ${path}
  • `; + html += `
  • Request: ${request}
  • `; + html += `
  • Status: ${status}
  • `; + html += `
  • StatusText: ${statusText}
  • `; + html += `
  • Config:
    • `; + for (const [key, val] of Object.entries(errConfig)) html += `
    • ${key}: ${parse(val)}
    • `; + html += '
'; - delete additionalData.backError.config.headers.Authorization; - const httpRequest = JSON.parse(additionalData?.httpRequest); - - if (httpRequest) - delete httpRequest.config.headers.Authorization; - additionalData.httpRequest = httpRequest; - - for (const data in additionalData) - html += `${data}:
${tryParse(additionalData[data])}
`; - - const subjectReason = httpRequest?.data?.error; await smtp.send({ to: `${config.app.reportEmail}, ${emailUser.email}`, - subject: - '[Support-Salix] ' + - additionalData?.frontPath + ' ' + - subjectReason?.name + ':' + - subjectReason?.message, + subject: `[Support-Salix] ${path} ${name}: ${message}`, html }); }; - function tryParse(value) { + function parse(value) { try { try { value = JSON.parse(value); From 873b91f1130beb17cc05367d8aecea310914c386 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 17:45:15 +0100 Subject: [PATCH 015/108] chore: refs #8002 drop comments --- front/core/components/support-dialog/index.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/front/core/components/support-dialog/index.js b/front/core/components/support-dialog/index.js index 45a8147fe..82f086184 100644 --- a/front/core/components/support-dialog/index.js +++ b/front/core/components/support-dialog/index.js @@ -9,13 +9,6 @@ export default class Controller extends Dialog { responseHandler(response) { if (response !== 'accept') return super.responseHandler(response); - - // this.$http.post('Ostickets/send-to-support', { - // reason: this.reason, - // additionalData: this.additionalData - // }) - // .then(() => super.responseHandler(response)) - // .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); } } From 285fe67ca5f64c4db744ace0ded4a95d1332372a Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 10:38:44 +0100 Subject: [PATCH 016/108] chore: refs #8002 drop useless code --- front/core/components/snackbar/snackbar.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index 49d784067..cce285d14 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -27,9 +27,6 @@ export default class Controller extends Component { setTimeout(() => element.classList.add('shown'), 30); shape.element = element; - if (data.additionalData && this.vnToken.token) - this.additionalData = data.additionalData; - if (shape.type) element.classList.add(shape.type); From dbf5953d69f55e5f7bb866318fd01aff6de2a98b Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 10:47:39 +0100 Subject: [PATCH 017/108] refactor: refs #8002 use loop wip --- back/methods/osticket/sendToSupport.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js index d05f1a82e..dabd35f80 100644 --- a/back/methods/osticket/sendToSupport.js +++ b/back/methods/osticket/sendToSupport.js @@ -32,21 +32,23 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const emailUser = await Self.app.models.EmailUser.findById(userId, {fields: ['email']}); - const {code, message, path, request, status, statusText, config: errConfig, name} = additionalData; let html = `

Motivo: ${reason}

`; html += `

Usuario: ${userId} ${emailUser.email}

`; html += `

Additional Data:

`; - html += `
  • Code: ${code}
  • `; - html += `
  • Message: ${message}
  • `; - html += `
  • Path: ${path}
  • `; - html += `
  • Request: ${request}
  • `; - html += `
  • Status: ${status}
  • `; - html += `
  • StatusText: ${statusText}
  • `; - html += `
  • Config:
    • `; - for (const [key, val] of Object.entries(errConfig)) html += `
    • ${key}: ${parse(val)}
    • `; - html += '
'; + html += '
    '; + for (const [key, val] of Object.entries(additionalData)) { + if (key !== 'config') html += `
  • ${key}: ${parse(val)}
  • `; + else { + html += `
  • ${key}:
    • `; + for (const [confKey, confVal] of Object.entries(val)) + html += `
    • ${confKey}: ${parse(confVal)}
    • `; + html += '
    '; + } + } + html += '
'; + const {message, path, name} = additionalData; await smtp.send({ to: `${config.app.reportEmail}, ${emailUser.email}`, subject: `[Support-Salix] ${path} ${name}: ${message}`, From 69314171ea7c8425343dca993c2de5b8b79c138d Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 14 Nov 2024 12:11:14 +0100 Subject: [PATCH 018/108] feat: refs #8190 entry_getCommission --- .../vn/functions/entry_getCommission.sql | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 4a19f4e63..0d294fe24 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -7,41 +7,46 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCommission`(v NOT DETERMINISTIC READS SQL DATA BEGIN - DECLARE vCommission INT; - DECLARE vCurrentCommission INT; - DECLARE vIsCurrencyUsd INT; - DECLARE vLastEntryFk INT; - - SELECT count(*) INTO vIsCurrencyUsd - FROM currency c - WHERE c.code = 'USD' AND id = vCurrencyFk; - - IF NOT vIsCurrencyUsd THEN - + DECLARE vCommission INT; + DECLARE vCurrentCommission INT; + DECLARE vIsCurrencyUsd INT; + DECLARE vLastEntryFk INT; + DECLARE vTravelFkLanded INT; + + SELECT count(*) INTO vIsCurrencyUsd + FROM currency c + WHERE c.code = 'USD' AND id = vCurrencyFk; + + IF NOT vIsCurrencyUsd THEN + SELECT landed INTO vTravelFkLanded + FROM travel + WHERE id = vTravelFk; + SELECT e.id INTO vLastEntryFk - FROM vn.entry e - JOIN vn.travel tr ON tr.id = e.travelFk - WHERE e.supplierFk = vSupplierFk - ORDER BY tr.landed DESC - LIMIT 1; - - IF vLastEntryFk THEN - + FROM entry e + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.landed < vTravelFkLanded + AND e.supplierFk = vSupplierFk + ORDER BY (vTravelFkLanded - tr.landed) ASC, tr.landed DESC + LIMIT 1; + + IF vLastEntryFk THEN + SELECT commission INTO vCurrentCommission FROM vn.entry - WHERE id = vLastEntryFk; - - ELSE - + WHERE id = vLastEntryFk; + + ELSE + SELECT commission INTO vCurrentCommission FROM supplier s WHERE s.id = vSupplierFk; - + END IF; - - RETURN vCurrentCommission; - - ELSE + + RETURN vCurrentCommission; + + ELSE SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission FROM travel t @@ -49,10 +54,10 @@ BEGIN WHERE t.id = vTravelFk ORDER BY r.`dated` DESC LIMIT 1; - + RETURN IFNULL(vCommission, 0); - + END IF; - + END$$ DELIMITER ; From c63dfba7da99f9ad7e28d2d38a282f10d64ceb99 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 21 Nov 2024 10:18:09 +0100 Subject: [PATCH 019/108] feat: refs #7301 add inventory-config and acl --- db/dump/fixtures.before.sql | 10 ++++++++-- .../11352-blackErica/00-firstScript.sql | 3 +++ modules/entry/back/model-config.json | 3 +++ .../entry/back/models/inventory-config.json | 18 ++++++++++++++++++ .../back/methods/item/lastEntriesFilter.js | 3 ++- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 db/versions/11352-blackErica/00-firstScript.sql create mode 100644 modules/entry/back/models/inventory-config.json diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index eb376b6c6..32653f3c2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1530,6 +1530,7 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1,''), (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, ''), (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, ''), + (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, ''), (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, ''); INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) @@ -1570,7 +1571,8 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), - (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'); + (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'), + (17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH); INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) VALUES @@ -4027,4 +4029,8 @@ INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) (8, '1183'); INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) - VALUES ('saysimle-url-mock', 1320); \ No newline at end of file + VALUES ('saysimle-url-mock', 1320); + +INSERT IGNORE INTO vn.inventoryConfig + SET id = 1, + supplierFk = 4; \ No newline at end of file diff --git a/db/versions/11352-blackErica/00-firstScript.sql b/db/versions/11352-blackErica/00-firstScript.sql new file mode 100644 index 000000000..4e17c94c5 --- /dev/null +++ b/db/versions/11352-blackErica/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId, editorFk) + VALUES('InventoryConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer', 100); \ No newline at end of file diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index 5c45b6e07..49c2df2db 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -28,5 +28,8 @@ }, "StockBought": { "dataSource": "vn" + }, + "InventoryConfig": { + "dataSource": "vn" } } diff --git a/modules/entry/back/models/inventory-config.json b/modules/entry/back/models/inventory-config.json new file mode 100644 index 000000000..caa39db88 --- /dev/null +++ b/modules/entry/back/models/inventory-config.json @@ -0,0 +1,18 @@ +{ + "name": "InventoryConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "inventoryConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "supplierFk": { + "type": "number" + } + } +} diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js index 5aafbb4f6..06c60162f 100644 --- a/modules/item/back/methods/item/lastEntriesFilter.js +++ b/modules/item/back/methods/item/lastEntriesFilter.js @@ -54,7 +54,8 @@ module.exports = Self => { b.packageValue, b.packagingFk , s.id AS supplierFk, - s.name AS supplier + s.name AS supplier, + b.printedStickers FROM itemType it RIGHT JOIN (entry e LEFT JOIN supplier s ON s.id = e.supplierFk From e92ce939b85ef5b3ffab66648ff2ce6f2ff699e9 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 22 Nov 2024 06:27:00 +0100 Subject: [PATCH 020/108] refactor: refs #7301 update entry and item filter tests to validate results against specific criteria --- .../back/methods/entry/specs/filter.spec.js | 10 +++++--- .../item/specs/lastEntriesFilter.spec.js | 25 +++++++++++++++++-- .../methods/travel/specs/getEntries.spec.js | 5 ++-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/modules/entry/back/methods/entry/specs/filter.spec.js b/modules/entry/back/methods/entry/specs/filter.spec.js index 4bf5127b0..b139b00b6 100644 --- a/modules/entry/back/methods/entry/specs/filter.spec.js +++ b/modules/entry/back/methods/entry/specs/filter.spec.js @@ -38,8 +38,9 @@ describe('Entry filter()', () => { }; const result = await models.Entry.filter(ctx, options); + const resultWithCurrency = result.filter(entry => entry.currencyFk === 1); - expect(result.length).toEqual(12); + expect(result.length).toEqual(resultWithCurrency.length); await tx.rollback(); } catch (e) { @@ -141,18 +142,21 @@ describe('Entry filter()', () => { it('should return the entry matching the company', async() => { const tx = await models.Entry.beginTransaction({}); const options = {transaction: tx}; + const companyFk = 442; try { const ctx = { args: { - companyFk: 442 + companyFk }, req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(11); + const resultWithCurrency = result.filter(entry => entry.companyFk === companyFk); + + expect(result.length).toEqual(resultWithCurrency.length); await tx.rollback(); } catch (e) { diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index 2fd30c2ca..d4429e158 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -34,10 +34,31 @@ describe('item lastEntriesFilter()', () => { const options = {transaction: tx}; try { - const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}}; + const itemFk = 1; + const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; const result = await models.Item.lastEntriesFilter(filter, options); + const minDateUtc = new Date(minDate).getTime(); + const maxDateUtc = new Date(maxDate).getTime(); - expect(result.length).toEqual(6); + const resultMatch = ( + await Promise.all( + result.map(async item => { + const itemRecord = await models.Buy.findOne({ + fields: ['id'], + where: {id: item.id}, + options, + }); + + const isItemFkValid = itemRecord?.id === itemFk; + const landedDate = new Date(item.landed).getTime(); + const isLandedValid = landedDate >= minDateUtc && landedDate <= maxDateUtc; + + return isItemFkValid && isLandedValid; + }) + ) + ).filter(Boolean).length; + + expect(result.length).toEqual(resultMatch); await tx.rollback(); } catch (e) { diff --git a/modules/travel/back/methods/travel/specs/getEntries.spec.js b/modules/travel/back/methods/travel/specs/getEntries.spec.js index fcaa80d02..9286a9d55 100644 --- a/modules/travel/back/methods/travel/specs/getEntries.spec.js +++ b/modules/travel/back/methods/travel/specs/getEntries.spec.js @@ -3,9 +3,10 @@ const models = require('vn-loopback/server/server').models; describe('travel getEntries()', () => { const travelId = 1; it('should check the response contains the id', async() => { - const entries = await models.Travel.getEntries(travelId); + const result = await models.Travel.getEntries(travelId); + const entries = await models.Entry.find({where: {travelFk: travelId}}); - expect(entries.length).toEqual(1); + expect(entries.length).toEqual(result.length); expect(entries[0].id).toEqual(1); }); From 5a92fe16914a906362173f735b01652eece6c395 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 26 Nov 2024 11:57:24 +0100 Subject: [PATCH 021/108] feat: refs #8190 entry_getCommission --- db/routines/vn/functions/entry_getCommission.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 0d550358f..9e2b53e5e 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -34,9 +34,8 @@ BEGIN SELECT e.id INTO vLastEntryFk FROM `entry` e JOIN travel tr ON tr.id = e.travelFk - WHERE tr.landed < vTravelFkLanded - AND e.supplierFk = vSupplierFk - ORDER BY (vTravelFkLanded - tr.landed) ASC, tr.landed DESC + WHERE e.supplierFk = vSupplierFk + ORDER BY (vTravelFkLanded <= tr.landed) ASC, tr.landed DESC LIMIT 1; IF vLastEntryFk THEN From 9a645c3288bb2db2bcb5604c0500d4c2a283a422 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 26 Nov 2024 16:56:39 +0100 Subject: [PATCH 022/108] fix: refs #7936 add IF NOT EXISTS to isRaid column in travel table --- db/versions/11332-tealErica/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11332-tealErica/00-firstScript.sql b/db/versions/11332-tealErica/00-firstScript.sql index 6358695b2..957aa57e2 100644 --- a/db/versions/11332-tealErica/00-firstScript.sql +++ b/db/versions/11332-tealErica/00-firstScript.sql @@ -1,4 +1,4 @@ -ALTER TABLE vn.travel ADD isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; +ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada'; From a68e287b23cfc568574a215562a629562e2d0465 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 26 Nov 2024 17:01:50 +0100 Subject: [PATCH 023/108] refactor: refs #7936 remove old trigger and add isRaid column to travel table --- db/versions/11332-tealErica/00-firstScript.sql | 2 +- .../00-firstScript.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename db/versions/{11266-goldenChrysanthemum => 11368-whiteAspidistra}/00-firstScript.sql (99%) diff --git a/db/versions/11332-tealErica/00-firstScript.sql b/db/versions/11332-tealErica/00-firstScript.sql index 957aa57e2..6358695b2 100644 --- a/db/versions/11332-tealErica/00-firstScript.sql +++ b/db/versions/11332-tealErica/00-firstScript.sql @@ -1,4 +1,4 @@ -ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; +ALTER TABLE vn.travel ADD isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada'; diff --git a/db/versions/11266-goldenChrysanthemum/00-firstScript.sql b/db/versions/11368-whiteAspidistra/00-firstScript.sql similarity index 99% rename from db/versions/11266-goldenChrysanthemum/00-firstScript.sql rename to db/versions/11368-whiteAspidistra/00-firstScript.sql index 37143c99b..333fa1315 100644 --- a/db/versions/11266-goldenChrysanthemum/00-firstScript.sql +++ b/db/versions/11368-whiteAspidistra/00-firstScript.sql @@ -45,3 +45,4 @@ BEGIN END$$ DELIMITER ; + From 6ab25c2ff588c82db06cde389ccdc4fd73efff58 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 26 Nov 2024 17:06:45 +0100 Subject: [PATCH 024/108] fix: refs #7936 add IF NOT EXISTS to isRaid column in travel table --- db/versions/11332-tealErica/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11332-tealErica/00-firstScript.sql b/db/versions/11332-tealErica/00-firstScript.sql index 6358695b2..a7870632f 100644 --- a/db/versions/11332-tealErica/00-firstScript.sql +++ b/db/versions/11332-tealErica/00-firstScript.sql @@ -1,4 +1,4 @@ -ALTER TABLE vn.travel ADD isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; +ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL - COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada'; + COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada'; \ No newline at end of file From d9aa11b3e9c91e8912c8f7ac23f20c9b28b5e01a Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 27 Nov 2024 07:27:47 +0100 Subject: [PATCH 025/108] feat: refs #8190 entry_getCommission change request --- db/routines/vn/functions/entry_getCommission.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 9e2b53e5e..f8c1ce3b4 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -11,7 +11,7 @@ BEGIN DECLARE vCurrentCommission INT; DECLARE vIsNotEUR INT; DECLARE vLastEntryFk INT; - DECLARE vTravelFkLanded INT; + DECLARE vLanded INT; SELECT count(*) INTO vIsNotEUR FROM currency c @@ -27,7 +27,7 @@ BEGIN RETURN IFNULL(vCommission, 0); ELSE - SELECT landed INTO vTravelFkLanded + SELECT landed INTO vLanded FROM travel WHERE id = vTravelFk; @@ -35,7 +35,7 @@ BEGIN FROM `entry` e JOIN travel tr ON tr.id = e.travelFk WHERE e.supplierFk = vSupplierFk - ORDER BY (vTravelFkLanded <= tr.landed) ASC, tr.landed DESC + ORDER BY (vLanded <= tr.landed), tr.landed DESC LIMIT 1; IF vLastEntryFk THEN From 5db1262e082d52d2f5333f7c452aa30a5d69d723 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 27 Nov 2024 10:24:13 +0100 Subject: [PATCH 026/108] feat: refs #7936 add company filter --- .../invoiceIn/back/methods/invoice-in/filter.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 936f7bb6c..c549769ab 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -91,6 +91,10 @@ module.exports = Self => { { arg: 'supplierActivityFk', type: 'string', + }, + { + arg: 'companyFk', + type: 'number', } ], returns: { @@ -161,8 +165,8 @@ module.exports = Self => { : {'ii.id': {nin: correcteds.map(x => x.correctingFk)}}; case 'correctedFk': return {'ii.id': {inq: correctings.map(x => x.correctingFk)}}; - case 'supplierActivityFk': - return {'s.supplierActivityFk': value}; + case 'companyFk': + return {'ii.companyFk': value}; } }); @@ -184,7 +188,8 @@ module.exports = Self => { s.name supplierName, s.account, SUM(iid.amount) amount, - sub.code awbCode + sub.code awbCode, + c.code FROM invoiceIn ii JOIN supplier s ON s.id = ii.supplierFk LEFT JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id @@ -199,7 +204,8 @@ module.exports = Self => { GROUP BY de.duaFk ) sub ON sub.duaFk = d.id LEFT JOIN company co ON co.id = ii.companyFk - LEFT JOIN dms dm ON dm.id = ii.docFk` + LEFT JOIN dms dm ON dm.id = ii.docFk + JOIN company c ON c.id = ii.companyFk`, ); const sqlWhere = conn.makeWhere(filter.where); From ba51052d8836ab43df51f36baa21bc62392329fd Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 27 Nov 2024 17:52:45 +0100 Subject: [PATCH 027/108] feat: refs #7936 add SiiTypeInvoiceIn model and update invoice correction logic --- db/routines/sage/procedures/invoiceIn_add.sql | 2 +- db/versions/11368-whiteAspidistra/01-acls.sql | 23 +++++++++++++++++++ .../back/methods/invoice-in/corrective.js | 2 +- .../invoice-in/specs/corrective.spec.js | 2 +- .../back/models/invoice-in-correction.json | 7 +++--- modules/invoiceOut/back/model-config.json | 5 +++- .../back/models/sii-type-invoice-in.json | 22 ++++++++++++++++++ .../back/models/sii-type-invoice-out.json | 5 +--- 8 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 db/versions/11368-whiteAspidistra/01-acls.sql create mode 100644 modules/invoiceOut/back/models/sii-type-invoice-in.json diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index a3de50d6a..eeeb28143 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -207,7 +207,7 @@ BEGIN IF vInvoiceInOriginalFk THEN UPDATE movContaIVA mci JOIN vn.invoiceInCorrection iic ON iic.correctingFk = vInvoiceInFk - JOIN vn.siiTypeInvoiceOut st ON st.id = iic.siiTypeInvoiceOutFk + JOIN vn.siiTypeInvoiceIn st ON st.id = iic.siiTypeInvoiceInFk JOIN (SELECT issued, SUM(sub.taxableBase) taxableBase, SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat diff --git a/db/versions/11368-whiteAspidistra/01-acls.sql b/db/versions/11368-whiteAspidistra/01-acls.sql new file mode 100644 index 000000000..6ac98db43 --- /dev/null +++ b/db/versions/11368-whiteAspidistra/01-acls.sql @@ -0,0 +1,23 @@ +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES('SiiTypeInvoiceIn', 'find', 'READ', 'ALLOW', 'ROLE', 'salesPerson'); + +DROP TABLE IF EXISTS vn.invoiceInCorrection; + +CREATE TABLE `invoiceInCorrection` ( + `correctingFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificativa', + `correctedFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificada', + `cplusRectificationTypeFk` int(10) unsigned NOT NULL, + `siiTypeInvoiceInFk` int(10) unsigned NOT NULL, + `invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT 3, + PRIMARY KEY (`correctingFk`), + KEY `invoiceInCorrection_correctedFk` (`correctedFk`), + KEY `invoiceInCorrection_cplusRectificationTypeFk` (`cplusRectificationTypeFk`), + KEY `invoiceInCorrection_siiTypeInvoiceIn` (`siiTypeInvoiceInFk`), + KEY `invoiceInCorrection_invoiceCorrectionTypeFk` (`invoiceCorrectionTypeFk`), + CONSTRAINT `invoiceInCorrection_correctedFk` FOREIGN KEY (`correctedFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `invoiceInCorrection_correctingFk` FOREIGN KEY (`correctingFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `invoiceInCorrection_cplusRectificationTypeFk` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `cplusRectificationType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInCorrection_invoiceCorrectionTypeFk` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `invoiceCorrectionType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInCorrection_siiTypeInvoiceIn` FOREIGN KEY (`siiTypeInvoiceInFk`) REFERENCES `siiTypeInvoiceIn` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + diff --git a/modules/invoiceIn/back/methods/invoice-in/corrective.js b/modules/invoiceIn/back/methods/invoice-in/corrective.js index 05f632bcd..e7088d201 100644 --- a/modules/invoiceIn/back/methods/invoice-in/corrective.js +++ b/modules/invoiceIn/back/methods/invoice-in/corrective.js @@ -44,7 +44,7 @@ module.exports = Self => { correctingFk: clone.id, correctedFk: id, cplusRectificationTypeFk: invoiceType, - siiTypeInvoiceOutFk: invoiceClass, + siiTypeInvoiceInFk: invoiceClass, invoiceCorrectionTypeFk: invoiceReason }, myOptions); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js index c63f02439..9f085694b 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js @@ -30,7 +30,7 @@ describe('invoiceIn corrective()', () => { }, options); expect(correction.cplusRectificationTypeFk).toEqual(invoiceType); - expect(correction.siiTypeInvoiceOutFk).toEqual(invoiceClass); + expect(correction.siiTypeInvoiceInFk).toEqual(invoiceClass); expect(correction.invoiceCorrectionTypeFk).toEqual(invoiceReason); }); }); diff --git a/modules/invoiceIn/back/models/invoice-in-correction.json b/modules/invoiceIn/back/models/invoice-in-correction.json index 52e16d420..d353f9e98 100644 --- a/modules/invoiceIn/back/models/invoice-in-correction.json +++ b/modules/invoiceIn/back/models/invoice-in-correction.json @@ -28,11 +28,10 @@ "model": "InvoiceCorrectionType", "foreignKey": "invoiceCorrectionTypeFk" }, - "siiTypeInvoiceOut": { + "siiTypeInvoiceIn": { "type": "belongsTo", - "model": "SiiTypeInvoiceOut", - "foreignKey": "siiTypeInvoiceOutFk" + "model": "SiiTypeInvoiceIn", + "foreignKey": "siiTypeInvoiceInFk" } - } } \ No newline at end of file diff --git a/modules/invoiceOut/back/model-config.json b/modules/invoiceOut/back/model-config.json index 9c7512429..710d824c3 100644 --- a/modules/invoiceOut/back/model-config.json +++ b/modules/invoiceOut/back/model-config.json @@ -43,5 +43,8 @@ }, "SiiTypeInvoiceOut": { "dataSource": "vn" + }, + "SiiTypeInvoiceIn": { + "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/invoiceOut/back/models/sii-type-invoice-in.json b/modules/invoiceOut/back/models/sii-type-invoice-in.json new file mode 100644 index 000000000..a191febb9 --- /dev/null +++ b/modules/invoiceOut/back/models/sii-type-invoice-in.json @@ -0,0 +1,22 @@ +{ + "name": "SiiTypeInvoiceIn", + "base": "VnModel", + "options": { + "mysql": { + "table": "siiTypeInvoiceIn" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "code": { + "type": "string" + }, + "description": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/modules/invoiceOut/back/models/sii-type-invoice-out.json b/modules/invoiceOut/back/models/sii-type-invoice-out.json index 37fd39c38..89f01bd74 100644 --- a/modules/invoiceOut/back/models/sii-type-invoice-out.json +++ b/modules/invoiceOut/back/models/sii-type-invoice-out.json @@ -17,9 +17,6 @@ }, "description": { "type": "string" - }, - "code": { - "type": "string" } } -} +} \ No newline at end of file From d5693291f033303d9c1156c09c676a9a30bfe5c6 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 28 Nov 2024 09:24:02 +0100 Subject: [PATCH 028/108] refactor: refs #8004 simplify SQL query by removing redundant aliases --- modules/item/back/methods/item/filter.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index 54dd975a4..a7fde1e6c 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -178,17 +178,18 @@ module.exports = Self => { i.isFloramondo, i.recycledPlastic, i.nonRecycledPlastic, - pr.name AS producer, - it.name AS typeName, - it.workerFk AS buyerFk, - u.name AS userName, - ori.code AS origin, - ic.name AS category, + pr.name producer, + it.name typeName, + it.workerFk buyerFk, + u.name userName, + ori.code origin, + ic.name category, i.intrastatFk, - intr.description AS intrastat, + intr.description intrastat, b.grouping, b.packing, - lb.landing AS landed + lb.landing landed, + it.name typeName FROM item i LEFT JOIN itemType it ON it.id = i.typeFk LEFT JOIN itemCategory ic ON ic.id = it.categoryFk From 7d5ae9dfbd4a0ba3a6ec4b34a46473ab475f4e1b Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 28 Nov 2024 14:52:41 +0100 Subject: [PATCH 029/108] feat: refs #7936 add reference rates for currency in fixtures --- db/dump/fixtures.before.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index e5d5f53dc..542d3dfe9 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4033,3 +4033,8 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate) VALUES (1106,'26493101E','2019-09-20'); + +INSERT INTO vn.referenceRate (currencyFk, dated, value) + VALUES (2, '2000-12-01', 1.0495), + (2, '2001-01-01', 1.0531), + (2, '2001-02-01', 7.6347); \ No newline at end of file From 1f6e401e39c45fbb404b8c9434b0f9cb3d052169 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 11:53:07 +0100 Subject: [PATCH 030/108] feat: refs #7936 add save validation --- .../invoiceIn/back/methods/invoice-in/toUnbook.js | 3 ++- .../back/methods/invoice-in/updateInvoiceIn.js | 3 ++- modules/invoiceIn/back/models/invoice-in.js | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/toUnbook.js b/modules/invoiceIn/back/methods/invoice-in/toUnbook.js index a697e9ddc..c27354d73 100644 --- a/modules/invoiceIn/back/methods/invoice-in/toUnbook.js +++ b/modules/invoiceIn/back/methods/invoice-in/toUnbook.js @@ -52,7 +52,8 @@ module.exports = Self => { accountingEntries = await models.Xdiario.count({ASIEN: asien}, myOptions); await models.Xdiario.destroyAll({ASIEN: asien}, myOptions); - await Self.updateAll({id: invoiceInId}, {isBooked: false}, myOptions); + const invoiceIn = await Self.findById(invoiceInId, myOptions); + await invoiceIn.updateAttribute('isBooked', false, myOptions); } else { const linkedBookEntry = await models.Xdiario.findOne({ fields: ['ASIEN'], diff --git a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js index 92a1ba8ee..2f1b4caca 100644 --- a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js +++ b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js @@ -82,7 +82,7 @@ module.exports = Self => { try { const invoiceIn = await Self.findById(id, null, myOptions); - invoiceIn.updateAttributes({supplierFk, + await invoiceIn.updateAttributes({supplierFk, supplierRef, issued, operated, @@ -94,6 +94,7 @@ module.exports = Self => { companyFk, withholdingSageFk }, myOptions); + if (tx) await tx.commit(); return invoiceIn; } catch (e) { diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 1e69c0ef8..21aa230c5 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -19,4 +19,19 @@ module.exports = Self => { return new UserError(`This invoice has a linked vehicle.`); return err; }); + + Self.observe('before save', async function(ctx) { + if (ctx.newInstance) return; + + const changes = ctx.data || ctx.instance; + const orgData = ctx.currentInstance; + let isNotEditable = orgData.isBooked || (!orgData.isBooked && changes.isBooked); + + if (isNotEditable) { + for (const [key, value] of Object.entries(changes)) { + if (key !== 'isBooked' && value !== orgData[key]) + throw new UserError('InvoiceIn is already booked'); + } + } + }); }; From 332e1c62d9e1361df960d2a0e99033c4b5263e74 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 12:22:01 +0100 Subject: [PATCH 031/108] feat: refs #7936 add validation to InvoiceIn & InvoiceInTax --- .../invoiceIn/back/models/invoice-in-tax.js | 18 ++++++++++++++++++ modules/invoiceIn/back/models/invoice-in.js | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 modules/invoiceIn/back/models/invoice-in-tax.js diff --git a/modules/invoiceIn/back/models/invoice-in-tax.js b/modules/invoiceIn/back/models/invoice-in-tax.js new file mode 100644 index 000000000..a9d16ec42 --- /dev/null +++ b/modules/invoiceIn/back/models/invoice-in-tax.js @@ -0,0 +1,18 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.observe('before save', async function(ctx) { + if (ctx.newInstance) return; + + const models = Self.app.models; + const invoiceIn = await models.InvoiceIn.findById(ctx.currentInstance.invoiceInFk); + if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); + }); + + Self.observe('before delete', async function(ctx) { + const models = Self.app.models; + const invoiceInTax = await models.InvoiceInTax.findById(ctx.where.id); + const invoiceIn = await models.InvoiceIn.findById(invoiceInTax.invoiceInFk); + if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); + }); +}; diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 21aa230c5..ff5d1ba86 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -34,4 +34,10 @@ module.exports = Self => { } } }); + + Self.observe('before delete', async function(ctx) { + const invoiceIn = await Self.findById(ctx.where.id); + if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); + }); }; + From 9ece52c5cecf15fa6d7350999f27cc3dd68d1b71 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 12:42:15 +0100 Subject: [PATCH 032/108] feat: refs #7936 add currency check to updateInvoiceIn --- .../back/methods/invoice-in/updateInvoiceIn.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js index 2f1b4caca..2b059f07b 100644 --- a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js +++ b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js @@ -72,6 +72,7 @@ module.exports = Self => { ) => { let tx; const myOptions = {userId: ctx.req.accessToken.userId}; + const models = Self.app.models; if (typeof options == 'object') Object.assign(myOptions, options); @@ -95,6 +96,17 @@ module.exports = Self => { withholdingSageFk }, myOptions); + if (currencyFk) { + const currency = await models.Currency.findById(currencyFk, null, myOptions); + if (currency.code === 'EUR') { + const invoiceInTaxes = await models.InvoiceInTax.find( + {where: {invoiceInFk: id}}, myOptions); + + for (const invoiceInTax of invoiceInTaxes) + await invoiceInTax.updateAttribute('foreignValue', null, myOptions); + } + } + if (tx) await tx.commit(); return invoiceIn; } catch (e) { From 163c6ddd20b2846cff8a01d2415aa0fb317facf0 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 13:44:42 +0100 Subject: [PATCH 033/108] feat: refs #7936 add currency handling in invoiceIn trigger --- .../vn/triggers/invoiceIn_afterUpdate.sql | 18 ++++++++++++------ .../back/methods/invoice-in/updateInvoiceIn.js | 11 ----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql index 95b1d98a9..8f0a63465 100644 --- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql @@ -3,24 +3,30 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate` AFTER UPDATE ON `invoiceIn` FOR EACH ROW BEGIN - IF NEW.issued != OLD.issued - OR NEW.currencyFk != OLD.currencyFk THEN + DECLARE vIsEuro BOOL; + + SELECT if(`code` = 'EUR', TRUE, FALSE) INTO vIsEuro + FROM currency + WHERE id = NEW.currencyFk; + + IF (NOT NEW.issued <=> OLD.issued + OR NEW.currencyFk <> OLD.currencyFk) THEN UPDATE invoiceInTax iit JOIN invoiceIn ii ON ii.id = iit.invoiceInFk LEFT JOIN referenceRate rr ON rr.dated = ii.issued AND rr.currencyFk = ii.currencyFk - SET iit.taxableBase = IF(iit.foreignValue IS NULL, iit.taxableBase, iit.foreignValue / rr.value) + SET iit.taxableBase = IF(vIsEuro, iit.taxableBase, iit.foreignValue / rr.value), + iit.foreignValue = IF(vIsEuro, NULL, iit.foreignValue) WHERE ii.id = NEW.id; UPDATE invoiceInDueDay iidd JOIN invoiceIn ii ON ii.id = iidd.invoiceInFk LEFT JOIN referenceRate rr ON rr.dated = ii.issued AND rr.currencyFk = ii.currencyFk - SET iidd.amount = IF(iidd.foreignValue IS NULL, iidd.amount, iidd.foreignValue / rr.value) + SET iidd.amount = IF(vIsEuro, iidd.amount, iidd.foreignValue / rr.value), + iidd.foreignValue = IF(vIsEuro, NULL, iidd.foreignValue) WHERE ii.id = NEW.id; - END IF; - END$$ DELIMITER ; diff --git a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js index 2b059f07b..6006b1b14 100644 --- a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js +++ b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js @@ -96,17 +96,6 @@ module.exports = Self => { withholdingSageFk }, myOptions); - if (currencyFk) { - const currency = await models.Currency.findById(currencyFk, null, myOptions); - if (currency.code === 'EUR') { - const invoiceInTaxes = await models.InvoiceInTax.find( - {where: {invoiceInFk: id}}, myOptions); - - for (const invoiceInTax of invoiceInTaxes) - await invoiceInTax.updateAttribute('foreignValue', null, myOptions); - } - } - if (tx) await tx.commit(); return invoiceIn; } catch (e) { From c9cf96676b15f0d2d45469a3fbda417422008b8d Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 14:32:12 +0100 Subject: [PATCH 034/108] fix: refs #7936 check if insert in hook & change test description --- .../back/methods/invoice-in/specs/corrective.spec.js | 4 ++-- modules/invoiceIn/back/models/invoice-in-tax.js | 2 +- modules/invoiceIn/back/models/invoice-in.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js index 9f085694b..aee8d3f2c 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js @@ -15,11 +15,11 @@ describe('invoiceIn corrective()', () => { await tx.rollback(); }); - it('La función corrective debería devolver un id cuando se ejecuta correctamente', async() => { + it('should return an id when executed correctly', async() => { const originalId = 1; const invoiceReason = 3; const invoiceType = 2; - const invoiceClass = 1; + const invoiceClass = 8; const cloneId = await models.InvoiceIn.corrective(ctx, originalId, invoiceReason, invoiceType, invoiceClass, options); diff --git a/modules/invoiceIn/back/models/invoice-in-tax.js b/modules/invoiceIn/back/models/invoice-in-tax.js index a9d16ec42..0449d7719 100644 --- a/modules/invoiceIn/back/models/invoice-in-tax.js +++ b/modules/invoiceIn/back/models/invoice-in-tax.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.observe('before save', async function(ctx) { - if (ctx.newInstance) return; + if (ctx.isNewInstance) return; const models = Self.app.models; const invoiceIn = await models.InvoiceIn.findById(ctx.currentInstance.invoiceInFk); diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index ff5d1ba86..ac197e904 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -21,7 +21,7 @@ module.exports = Self => { }); Self.observe('before save', async function(ctx) { - if (ctx.newInstance) return; + if (ctx.isNewInstance) return; const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; From ac87905351ef6dbebaaee042f3c78132c44706d8 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 15:49:14 +0100 Subject: [PATCH 035/108] feat: refs #7936 add back test for updateInvoiceIn --- .../invoice-in/specs/updateInvoiceIn.spec.js | 59 +++++++++++++++++++ .../methods/invoice-in/updateInvoiceIn.js | 1 - 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js new file mode 100644 index 000000000..4e856ec71 --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js @@ -0,0 +1,59 @@ +const models = require('vn-loopback/server/server').models; + +const invoiceInId = 1; +const supplierId = 791; +fdescribe('invoiceIn updateInvoiceIn()', () => { + const ctx = beforeAll.getCtx(); + let options; + let tx; + + beforeEach(async() => { + options = {transaction: tx}; + tx = await models.Sale.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should update the invoice', async() => { + const invoiceBefore = await models.InvoiceIn.findById(invoiceInId, null, options); + await update(ctx, options); + const invoiceAfter = await models.InvoiceIn.findById(invoiceInId, null, options); + + expect(invoiceAfter.supplierFk).not.toBe(invoiceBefore.supplierFk); + expect(invoiceAfter.supplierFk).toBe(supplierId); + }); + + it('should not update the invoice if is booked', async() => { + let error; + try { + await models.InvoiceIn.toBook(ctx, invoiceInId, options); + await update(ctx, options); + } catch (e) { + error = e; + } + + expect(error.message).toBe('InvoiceIn is already booked'); + }); +}); + +async function update(ctx, opts) { + const supplierRef = 'mockRef'; + const currencyId = 1; + await models.InvoiceIn.updateInvoiceIn(ctx, + invoiceInId, + supplierId, + supplierRef, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + currencyId, + undefined, + undefined, + opts); +} diff --git a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js index 6006b1b14..2f1b4caca 100644 --- a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js +++ b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js @@ -72,7 +72,6 @@ module.exports = Self => { ) => { let tx; const myOptions = {userId: ctx.req.accessToken.userId}; - const models = Self.app.models; if (typeof options == 'object') Object.assign(myOptions, options); From 59b5dd5a3627c08c8e1a5d0be468d00833cf68af Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 16:25:47 +0100 Subject: [PATCH 036/108] feat: refs #7936 add tests for invoiceIn --- .../invoice-in/specs/invoiceIn.spec.js | 66 +++++++++++++++++++ .../invoice-in/specs/updateInvoiceIn.spec.js | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js new file mode 100644 index 000000000..4e2ee36d5 --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js @@ -0,0 +1,66 @@ +const models = require('vn-loopback/server/server').models; + +fdescribe('invoiceIn', () => { + let options; + let tx; + const invoiceId = 1; + const supplierId = 791; + const currencyId = 1; + const companyId = 442; + + beforeEach(async() => { + options = {transaction: tx}; + tx = await models.InvoiceIn.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should allow insert for new instance', async() => { + const newInvoice = { + supplierFk: supplierId, + issued: Date.vnNew(), + operated: Date.vnNew(), + currencyFk: currencyId, + companyFk: companyId, + isBooked: false + }; + + const createdInvoice = await models.InvoiceIn.create(newInvoice, options); + + expect(createdInvoice).toBeDefined(); + expect(createdInvoice.id).toBeDefined(); + }); + + it('should throw an error if trying to update a booked invoice', async() => { + const invoice = await models.InvoiceIn.findById(invoiceId, null, options); + await invoice.updateAttribute('isBooked', true, options); + + let error; + try { + await invoice.updateAttribute('supplierFk', supplierId, options); + } catch (err) { + error = err; + } + + expect(error).toBeDefined(); + expect(error.message).toBe('InvoiceIn is already booked'); + }); + + it('should throw an error if trying to delete a booked invoice', async() => { + const invoice = await models.InvoiceIn.findById(invoiceId, null, options); + await invoice.updateAttribute('isBooked', true, options); + + let error; + try { + await models.InvoiceIn.deleteById(invoiceId, options); + } catch (err) { + error = err; + } + + expect(error).toBeDefined(); + expect(error.sqlMessage).toBe('InvoiceIn is already booked'); + }); +}); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js index 4e856ec71..773e2ac2f 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js @@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models; const invoiceInId = 1; const supplierId = 791; -fdescribe('invoiceIn updateInvoiceIn()', () => { +describe('invoiceIn updateInvoiceIn()', () => { const ctx = beforeAll.getCtx(); let options; let tx; From 00085f2b99d61086908ee29975cd731cbcf5b2c9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 17:05:13 +0100 Subject: [PATCH 037/108] feat: refs #7936 add tests for invoiceIn filter --- .../methods/invoice-in/specs/filter.spec.js | 17 +++++++++++++++++ .../methods/invoice-in/specs/invoiceIn.spec.js | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js index 48310b32a..beaa608e6 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -166,4 +166,21 @@ describe('InvoiceIn filter()', () => { throw e; } }); + + it('should return the invoice in matching companyFk', async() => { + const tx = await models.InvoiceIn.beginTransaction({}); + const options = {transaction: tx}; + + try { + const company = await models.Company.findOne({}, options); + const invoicesByCompany = await models.InvoiceIn.find({where: {companyFk: company.id}}, options); + const filteredInvoices = await models.InvoiceIn.filter({args: {companyFk: company.id}}, {}, options); + + expect(filteredInvoices.length).toEqual(invoicesByCompany.length); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js index 4e2ee36d5..69038d9fd 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('invoiceIn', () => { +describe('invoiceIn', () => { let options; let tx; const invoiceId = 1; From 5b04debfb157b6240e4e1ba2f6bf32814930b91b Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 17:48:40 +0100 Subject: [PATCH 038/108] refactor: refs #7936 add transaction & tests --- .../invoice-in/specs/invoiceIn.spec.js | 7 +- .../invoice-in/specs/invoiceInTax.spec.js | 74 +++++++++++++++++++ .../invoiceIn/back/models/invoice-in-tax.js | 6 +- modules/invoiceIn/back/models/invoice-in.js | 2 +- 4 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 modules/invoiceIn/back/methods/invoice-in/specs/invoiceInTax.spec.js diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js index 69038d9fd..a83aad3b2 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js @@ -9,9 +9,8 @@ describe('invoiceIn', () => { const companyId = 442; beforeEach(async() => { - options = {transaction: tx}; tx = await models.InvoiceIn.beginTransaction({}); - options.transaction = tx; + options = {transaction: tx}; }); afterEach(async() => { @@ -45,7 +44,6 @@ describe('invoiceIn', () => { error = err; } - expect(error).toBeDefined(); expect(error.message).toBe('InvoiceIn is already booked'); }); @@ -60,7 +58,6 @@ describe('invoiceIn', () => { error = err; } - expect(error).toBeDefined(); - expect(error.sqlMessage).toBe('InvoiceIn is already booked'); + expect(error.message).toBe('InvoiceIn is already booked'); }); }); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceInTax.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceInTax.spec.js new file mode 100644 index 000000000..e822189bd --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceInTax.spec.js @@ -0,0 +1,74 @@ +const models = require('vn-loopback/server/server').models; + +describe('invoiceInTax', () => { + let options; + let tx; + const invoiceInId = 1; + const invoiceInTaxId = 1; + beforeEach(async() => { + tx = await models.InvoiceInTax.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should throw an error if trying to save a tax from a booked invoice', async() => { + const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options); + await invoiceIn.updateAttributes({isBooked: true}, options); + const invoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); + let error; + try { + await invoiceInTax.updateAttribute('taxableBase', 100, options); + } catch (err) { + error = err; + } + + expect(error.message).toBe('InvoiceIn is already booked'); + }); + + it('should allow save if the invoice is not booked', async() => { + const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options); + await invoiceIn.updateAttribute('isBooked', false, options); + + const invoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); + await invoiceInTax.updateAttribute('taxableBase', 100, options); + + const updatedInvoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); + + expect(updatedInvoiceInTax.taxableBase).toBe(100); + }); + + it('should throw an error if trying to delete a tax from a booked invoice', async() => { + const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options); + await invoiceIn.updateAttribute('isBooked', true, options); + + let error; + try { + await models.InvoiceInTax.destroyById(invoiceInTaxId, options); + } catch (err) { + error = err; + } + + expect(error).toBeDefined(); + expect(error.message).toBe('InvoiceIn is already booked'); + }); + + it('should allow delete if the invoice is not booked', async() => { + const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options); + await invoiceIn.updateAttribute('isBooked', false, options); + + let error; + try { + await models.InvoiceInTax.destroyById(invoiceInTaxId, options); + } catch (err) { + error = err; + } + + const deletedInvoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); + + expect(error).toBeUndefined(); + expect(deletedInvoiceInTax).toBeNull(); + }); +}); diff --git a/modules/invoiceIn/back/models/invoice-in-tax.js b/modules/invoiceIn/back/models/invoice-in-tax.js index 0449d7719..ce33fe18f 100644 --- a/modules/invoiceIn/back/models/invoice-in-tax.js +++ b/modules/invoiceIn/back/models/invoice-in-tax.js @@ -5,14 +5,14 @@ module.exports = Self => { if (ctx.isNewInstance) return; const models = Self.app.models; - const invoiceIn = await models.InvoiceIn.findById(ctx.currentInstance.invoiceInFk); + const invoiceIn = await models.InvoiceIn.findById(ctx.currentInstance.invoiceInFk, null, ctx.options); if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); }); Self.observe('before delete', async function(ctx) { const models = Self.app.models; - const invoiceInTax = await models.InvoiceInTax.findById(ctx.where.id); - const invoiceIn = await models.InvoiceIn.findById(invoiceInTax.invoiceInFk); + const invoiceInTax = await Self.findById(ctx.where.id, null, ctx.options); + const invoiceIn = await models.InvoiceIn.findById(invoiceInTax.invoiceInFk, null, ctx.options); if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); }); }; diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index ac197e904..ca506b54d 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -36,7 +36,7 @@ module.exports = Self => { }); Self.observe('before delete', async function(ctx) { - const invoiceIn = await Self.findById(ctx.where.id); + const invoiceIn = await Self.findById(ctx.where.id, null, ctx.options); if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); }); }; From a85d797edc8eb25a8e83a049b4ab808ae20762af Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 3 Dec 2024 08:40:26 +0100 Subject: [PATCH 039/108] chore: pullinfo --- db/.pullinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 5b75584d1..b890ffc31 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "99f75145ac2e7b612a6d71e74b6e55f194a465780fd9875a15eb01e6596b447e" + "expeditionPallet_Print": "04fc5f2967ce53bfbb85f7f48b9a3dca4a4f7111ac41e1775f4cc7d6538774b2" } } } From 424a0c80794f622cf6e481116a3db2688582dd58 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 3 Dec 2024 12:25:39 +0100 Subject: [PATCH 040/108] fix: refs #6389 packing --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 5eba78887..acd5635f6 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -161,8 +161,7 @@ module.exports = Self => { param = `t.${param}`; return {[param]: value}; case 'packing': - param = `i.${param}`; - return {[param]: value}; + return {'packing': value}; } }); From 71da7772d9636976dfefce8915be7d00df2c23fc Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 3 Dec 2024 14:33:42 +0100 Subject: [PATCH 041/108] build: new version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ef1dd8f89..4e823eaad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.50.0", + "version": "24.52.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 123c0db1267763302c808aa9f44f60593d69c7b6 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 4 Dec 2024 11:58:17 +0100 Subject: [PATCH 042/108] feat: modified data to be equal as the updated back --- db/dump/.dump/data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 4700d0066..a1d9a44a7 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -2110,7 +2110,7 @@ INSERT INTO `ACL` VALUES (746,'Claim','getSummary','READ','ALLOW','ROLE','claimV INSERT INTO `ACL` VALUES (747,'CplusRectificationType','*','READ','ALLOW','ROLE','administrative',NULL); INSERT INTO `ACL` VALUES (748,'SiiTypeInvoiceOut','*','READ','ALLOW','ROLE','salesPerson',NULL); INSERT INTO `ACL` VALUES (749,'InvoiceCorrectionType','*','READ','ALLOW','ROLE','salesPerson',NULL); -INSERT INTO `ACL` VALUES (750,'InvoiceOut','transferInvoice','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (750,'InvoiceOut','transfer','WRITE','ALLOW','ROLE','administrative',NULL); INSERT INTO `ACL` VALUES (751,'Application','executeProc','*','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (752,'Application','executeFunc','*','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (753,'NotificationSubscription','getList','READ','ALLOW','ROLE','employee',NULL); From fad6f33b7c981536f23ce4d85cd397ee6c61e8c2 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 4 Dec 2024 12:33:17 +0100 Subject: [PATCH 043/108] fix: refs #7031 remove check --- db/versions/11376-pinkBamboo/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11376-pinkBamboo/00-firstScript.sql diff --git a/db/versions/11376-pinkBamboo/00-firstScript.sql b/db/versions/11376-pinkBamboo/00-firstScript.sql new file mode 100644 index 000000000..607a22b4d --- /dev/null +++ b/db/versions/11376-pinkBamboo/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE `zone` MODIFY COLUMN `price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 CHECK (`price` > 0); + From 41a3f9ae949f87186f2e2e52f625539cda16a421 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 4 Dec 2024 13:19:14 +0100 Subject: [PATCH 044/108] refactor: refs #8272 delete bi.rotacion --- db/routines/bi/views/rotacion.sql | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 db/routines/bi/views/rotacion.sql diff --git a/db/routines/bi/views/rotacion.sql b/db/routines/bi/views/rotacion.sql deleted file mode 100644 index 65a5db923..000000000 --- a/db/routines/bi/views/rotacion.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `bi`.`rotacion` -AS SELECT `ic`.`itemFk` AS `Id_Article`, - `ic`.`warehouseFk` AS `warehouse_id`, - `ic`.`quantity` AS `total`, - `ic`.`rotation` AS `rotacion`, - `ic`.`cm3` AS `cm3`, - `ic`.`storage` AS `almacenaje`, - `ic`.`handling` AS `manipulacion`, - `ic`.`extraCharge` AS `auxiliar`, - `ic`.`wasted` AS `mermas`, - `ic`.`cm3delivery` AS `cm3reparto`, - `ic`.`grams` AS `grams` -FROM `vn`.`itemCost` `ic` From 483966501a2b6e46ade7e13d79c334df1fa9d565 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 5 Dec 2024 08:31:09 +0100 Subject: [PATCH 045/108] fix: refs #7031 fix vnPrice --- db/versions/11376-pinkBamboo/00-firstScript.sql | 2 +- loopback/locale/en.json | 7 ++++--- loopback/locale/es.json | 10 +++++----- modules/zone/back/models/zone.js | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/db/versions/11376-pinkBamboo/00-firstScript.sql b/db/versions/11376-pinkBamboo/00-firstScript.sql index 607a22b4d..0c1e71a2f 100644 --- a/db/versions/11376-pinkBamboo/00-firstScript.sql +++ b/db/versions/11376-pinkBamboo/00-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE `zone` MODIFY COLUMN `price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 CHECK (`price` > 0); +ALTER TABLE vn.`zone` MODIFY COLUMN `price` DECIMAL(10,2); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ff0281d4a..af07b29fa 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -246,6 +246,7 @@ "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", "The raid information is not correct": "The raid information is not correct", "Payment method is required": "Payment method is required", - "Sales already moved": "Sales already moved", - "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first" -} + "Sales already moved": "Sales already moved", + "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first", + "Price cannot be blank": "Price cannot be blank" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 1eb953d89..37572de03 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,8 +388,8 @@ "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "The web user's email already exists": "El correo del usuario web ya existe", - "Sales already moved": "Ya han sido transferidas", - "The raid information is not correct": "La información de la redada no es correcta", - "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" -} - + "Sales already moved": "Ya han sido transferidas", + "The raid information is not correct": "La información de la redada no es correcta", + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", + "Price cannot be blank": "Price cannot be blank" +} \ No newline at end of file diff --git a/modules/zone/back/models/zone.js b/modules/zone/back/models/zone.js index 6d5a6cdca..7b5cb4301 100644 --- a/modules/zone/back/models/zone.js +++ b/modules/zone/back/models/zone.js @@ -14,4 +14,18 @@ module.exports = Self => { Self.validatesPresenceOf('agencyModeFk', { message: `Agency cannot be blank` }); + + Self.validatesPresenceOf('price', { + message: 'Price cannot be blank' + }); + Self.validateAsync('price', priceIsValid, { + message: 'Price must be greater than 0' + }); + + async function priceIsValid(err, done) { + if (this.price <= 0) + err(); + + done(); + } }; From 97f08542be35bbac00c38ba5d6c5b3e94107c75a Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 5 Dec 2024 10:28:57 +0100 Subject: [PATCH 046/108] feat: added translations and show error in item-type --- loopback/locale/es.json | 3 ++- modules/item/back/locale/item-minimum-quantity/en.yml | 5 +++++ modules/item/back/locale/item-minimum-quantity/es.yml | 5 +++++ modules/item/back/locale/item/en.yml | 2 +- modules/item/back/locale/item/es.yml | 2 +- modules/item/back/models/item-type.js | 9 +++++++++ 6 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 modules/item/back/locale/item-minimum-quantity/en.yml create mode 100644 modules/item/back/locale/item-minimum-quantity/es.yml create mode 100644 modules/item/back/models/item-type.js diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 1eb953d89..e4bdd035e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -390,6 +390,7 @@ "The web user's email already exists": "El correo del usuario web ya existe", "Sales already moved": "Ya han sido transferidas", "The raid information is not correct": "La información de la redada no es correcta", - "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", + "An item type with the same code already exists": "Un tipo con el mismo código ya existe" } diff --git a/modules/item/back/locale/item-minimum-quantity/en.yml b/modules/item/back/locale/item-minimum-quantity/en.yml new file mode 100644 index 000000000..206b1d96b --- /dev/null +++ b/modules/item/back/locale/item-minimum-quantity/en.yml @@ -0,0 +1,5 @@ +name: Minimum Quantity +columns: + ended: Ended + code: Code + started: Started \ No newline at end of file diff --git a/modules/item/back/locale/item-minimum-quantity/es.yml b/modules/item/back/locale/item-minimum-quantity/es.yml new file mode 100644 index 000000000..68c67eeff --- /dev/null +++ b/modules/item/back/locale/item-minimum-quantity/es.yml @@ -0,0 +1,5 @@ +name: Cantidad Mínima +columns: + ended: Finaliza + quantity: Cantidad + started: Comienza diff --git a/modules/item/back/locale/item/en.yml b/modules/item/back/locale/item/en.yml index ea40fd34b..f5e6fcf9a 100644 --- a/modules/item/back/locale/item/en.yml +++ b/modules/item/back/locale/item/en.yml @@ -46,4 +46,4 @@ columns: itemFk: item density: density compression: compression - + minQuantity: min quantity diff --git a/modules/item/back/locale/item/es.yml b/modules/item/back/locale/item/es.yml index 973f5e94f..68020d452 100644 --- a/modules/item/back/locale/item/es.yml +++ b/modules/item/back/locale/item/es.yml @@ -46,4 +46,4 @@ columns: itemFk: artículo density: densidad compression: compresión - + minQuantity: Cantidad mínima diff --git a/modules/item/back/models/item-type.js b/modules/item/back/models/item-type.js new file mode 100644 index 000000000..4dc8adfc9 --- /dev/null +++ b/modules/item/back/models/item-type.js @@ -0,0 +1,9 @@ +let UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError(`An item type with the same code already exists`); + return err; + }); +}; From 04a96e87d644c66124436b07c421a089b1df6479 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 8 Dec 2024 07:28:29 +0100 Subject: [PATCH 047/108] refactor: refs #7882 Deleted quadminds files --- .../quadminds-api-config/sendOrders.js | 88 ------------------- back/methods/quadminds-api-config/sendPois.js | 87 ------------------ back/model-config.json | 3 - back/models/quadminds-api-config.js | 4 - back/models/quadminds-api-config.json | 34 ------- .../11378-orangeAsparagus/00-firstScript.sql | 1 + 6 files changed, 1 insertion(+), 216 deletions(-) delete mode 100644 back/methods/quadminds-api-config/sendOrders.js delete mode 100644 back/methods/quadminds-api-config/sendPois.js delete mode 100644 back/models/quadminds-api-config.js delete mode 100644 back/models/quadminds-api-config.json create mode 100644 db/versions/11378-orangeAsparagus/00-firstScript.sql diff --git a/back/methods/quadminds-api-config/sendOrders.js b/back/methods/quadminds-api-config/sendOrders.js deleted file mode 100644 index 760d622b6..000000000 --- a/back/methods/quadminds-api-config/sendOrders.js +++ /dev/null @@ -1,88 +0,0 @@ -const axios = require('axios'); -const UserError = require('vn-loopback/util/user-error'); -const moment = require('moment'); - -module.exports = Self => { - Self.remoteMethod('sendOrders', { - description: 'Sends a set of orders', - accessType: 'WRITE', - accepts: [{ - arg: 'tickets', - type: ['number'], - required: true - } - ], - returns: { - type: 'string', - root: true - }, - http: { - path: `/sendOrders`, - verb: 'POST' - } - }); - Self.sendOrders = async tickets => { - const config = await Self.app.models.QuadmindsApiConfig.findOne(); - if (!config) throw new UserError('Config params not set'); - - if (tickets.length > config.maxObjects) - throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`); - - let poisData = []; - let isOk; - for (let offset = 0; !isOk; offset = offset + config.limit) { - const pois = await axios.get(`${config.url}pois/search?limit=${config.limit}&offset=${offset}`, { - headers: { - 'Accept': 'application/json', - 'X-Saas-Apikey': config.key - } - }); - pois.data.data.length ? poisData.push(...pois.data.data) : isOk = true; - } - - const poiMap = new Map(poisData.map(poi => [poi.code, poi._id])); - - let orders = await Self.rawSql(` - SELECT a.id poiCode, - t.id code, - t.shipped date, - 'PEDIDO' operation, - t.totalWithVat totalAmount, - t.totalWithoutVat totalAmountWithoutTaxes, - SUM(sv.volume) volume - FROM ticket t - JOIN address a ON a.id = t.addressFk - JOIN saleVolume sv ON sv.ticketFk = t.id - WHERE t.id IN (?) - GROUP BY t.id - `, [tickets]); - - // Transformo code en string ya que lo obtenermos como integer - orders = orders.map(order => { - return { - ...order, - poiId: poiMap.get(order.poiCode.toString()) || undefined, - code: order.code.toString(), - date: moment(order.date).format('YYYY-MM-DD'), - totalAmount: order.totalAmount || undefined, - totalAmountWithoutTaxes: order.totalAmountWithoutTaxes || undefined, - timeWindow: [{ - from: config.orderTimeFrom, - to: config.orderTimeTo - }], - orderMeasures: [{ - constraintId: 3, // Volumen - value: order.volume - }] - }; - }); - - await axios.post(`${config.url}orders`, orders, { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'X-Saas-Apikey': config.key - } - }); - }; -}; diff --git a/back/methods/quadminds-api-config/sendPois.js b/back/methods/quadminds-api-config/sendPois.js deleted file mode 100644 index cb5eef93e..000000000 --- a/back/methods/quadminds-api-config/sendPois.js +++ /dev/null @@ -1,87 +0,0 @@ -const axios = require('axios'); -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethod('sendPois', { - description: 'Sends a set of pois', - accessType: 'WRITE', - accepts: [{ - arg: 'tickets', - type: ['number'], - required: true - } - ], - returns: { - type: 'string', - root: true - }, - http: { - path: `/sendPois`, - verb: 'POST' - } - }); - Self.sendPois = async tickets => { - const config = await Self.app.models.QuadmindsApiConfig.findOne(); - if (!config) throw new UserError('Config params not set'); - - if (tickets.length > config.maxObjects) - throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`); - - let pois = await Self.rawSql(` - WITH deliveryNotes AS ( - SELECT t.id, t.routeFk, tn.description - FROM ticket t - JOIN ticketObservation tn ON tn.ticketFk = t.id - JOIN observationType ot ON ot.id = tn.observationTypeFk - WHERE ot.code = 'delivery' - ) - SELECT a.id code, - c.socialName name, - IF(ABS(a.latitude - ROUND(a.latitude)) < 0.000001, NULL, a.latitude) latitude, - IF(ABS(a.longitude - ROUND(a.longitude)) < 0.000001, NULL, a.longitude) longitude, - a.street, - a.city locality, - p.name state, - co.name country, - CONCAT_WS(', ', IFNULL(a.street, ''), IFNULL(a.city, ''), IFNULL(p.name, '')) longAddress, - CONCAT(IFNULL(a.mobile, c.mobile)) phoneNumber, - dn.description poiDeliveryComments, - c.email email - FROM ticket t - JOIN address a ON a.id = t.addressFk - JOIN province p ON p.id = a.provinceFk - JOIN country co ON co.id = p.countryFk - JOIN client c ON c.id = t.clientFk - LEFT JOIN deliveryNotes dn ON dn.id = t.id - WHERE t.id IN (?) - GROUP BY t.id - `, [tickets]); - - // Transformo code en string ya que lo obtenermos como integer - pois = pois.map(poi => { - return { - ...poi, - code: poi.code.toString(), - latitude: poi.latitude || undefined, - longitude: poi.longitude || undefined, - address: { - street: poi.street || undefined, - locality: poi.locality || undefined, - state: poi.state || undefined, - country: poi.country || undefined - }, - poiDeliveryComments: poi.poiDeliveryComments || undefined, - phoneNumber: poi.phoneNumber || undefined, - email: poi.email || undefined - }; - }); - - await axios.post(`${config.url}pois`, pois, { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'X-Saas-Apikey': config.key - } - }); - }; -}; diff --git a/back/model-config.json b/back/model-config.json index 55c34ff64..c1682f29a 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -121,9 +121,6 @@ "Province": { "dataSource": "vn" }, - "QuadmindsApiConfig": { - "dataSource": "vn" - }, "Autonomy": { "dataSource": "vn" }, diff --git a/back/models/quadminds-api-config.js b/back/models/quadminds-api-config.js deleted file mode 100644 index c2773fa0b..000000000 --- a/back/models/quadminds-api-config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = Self => { - require('../methods/quadminds-api-config/sendPois')(Self); - require('../methods/quadminds-api-config/sendOrders')(Self); -}; diff --git a/back/models/quadminds-api-config.json b/back/models/quadminds-api-config.json deleted file mode 100644 index 4001badf3..000000000 --- a/back/models/quadminds-api-config.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "QuadmindsApiConfig", - "base": "VnModel", - "options": { - "mysql": { - "table": "quadmindsApiConfig" - } - }, - "properties": { - "id": { - "type": "number", - "id": true, - "required": true - }, - "url": { - "type": "string" - }, - "key": { - "type": "string" - }, - "maxObjects": { - "type": "number" - }, - "limit": { - "type": "number" - }, - "orderTimeFrom": { - "type": "string" - }, - "orderTimeTo": { - "type": "string" - } - } -} diff --git a/db/versions/11378-orangeAsparagus/00-firstScript.sql b/db/versions/11378-orangeAsparagus/00-firstScript.sql new file mode 100644 index 000000000..a030b7e05 --- /dev/null +++ b/db/versions/11378-orangeAsparagus/00-firstScript.sql @@ -0,0 +1 @@ +DROP TABLE vn.quadmindsApiConfig; From 8960b546649da0a6ff99df0836d76784bdd25509 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 8 Dec 2024 14:30:05 +0100 Subject: [PATCH 048/108] feat: refs #7882 Added locationiq service --- back/methods/locationiq-config/optimize.js | 77 +++++++++++++++++++ back/model-config.json | 3 + back/models/locationiq-config.js | 4 + back/models/locationiq-config.json | 28 +++++++ .../11379-yellowCordyline/00-firstScript.sql | 8 ++ loopback/locale/es.json | 11 +-- 6 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 back/methods/locationiq-config/optimize.js create mode 100644 back/models/locationiq-config.js create mode 100644 back/models/locationiq-config.json create mode 100644 db/versions/11379-yellowCordyline/00-firstScript.sql diff --git a/back/methods/locationiq-config/optimize.js b/back/methods/locationiq-config/optimize.js new file mode 100644 index 000000000..cd1f6e7ff --- /dev/null +++ b/back/methods/locationiq-config/optimize.js @@ -0,0 +1,77 @@ +const UserError = require('vn-loopback/util/user-error'); +const axios = require('axios'); + +module.exports = Self => { + Self.remoteMethod('optimize', { + description: 'Return optimized coords', + accessType: 'READ', + accepts: [{ + arg: 'addressIds', + type: 'array', + required: true + }], + returns: { + type: 'string', + root: true + }, + http: { + path: `/optimize`, + verb: 'GET' + } + }); + + Self.optimize = async addressIds => { + const models = Self.app.models; + try { + const locationiqConfig = await models.LocationiqConfig.findOne(); + if (!locationiqConfig) throw new UserError(`LocationIQ service is not configured`); + + let coords = []; + for (const addressId of addressIds) { + const address = await models.Address.findById(addressId); + coords.push({ + addressId, + latitude: address.latitude.toFixed(6), + longitude: address.longitude.toFixed(6) + }); + } + const concatCoords = coords + .map(coord => `${coord.longitude},${coord.latitude}`) + .join(';'); + const response = await axios.post(`${locationiqConfig.url}${concatCoords}?key=${locationiqConfig.key}`); + const tolerance = locationiqConfig.tolerance; + + for (waypoint of response.data.waypoints) { + const longitude = waypoint.location[0]; + const latitude = waypoint.location[1]; + + const matchedAddress = coords.find(coord => + Math.abs(coord.latitude - latitude) <= tolerance && + Math.abs(coord.longitude - longitude) <= tolerance + ); + if (matchedAddress) matchedAddress.position = waypoint.waypoint_index; + } + coords.sort((a, b) => { + const posA = a.position !== undefined ? a.position : Infinity; + const posB = b.position !== undefined ? b.position : Infinity; + return posA - posB; + }); + // Temporal para abrir en maps + const coordsString = coords + .map(item => `${item.latitude},${item.longitude}`) + .join('/'); + console.log(`https://www.google.es/maps/dir/${coordsString}`); + // --------- + return coords; + } catch (err) { + switch (err.response?.data?.code) { + case 'NoTrips': + throw new UserError('No trips found because input coordinates are not connected'); + case 'NotImplemented': + throw new UserError('This request is not supported'); + default: + throw err; + } + } + }; +}; diff --git a/back/model-config.json b/back/model-config.json index c1682f29a..f48e5f2eb 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -88,6 +88,9 @@ "Language": { "dataSource": "vn" }, + "LocationiqConfig": { + "dataSource": "vn" + }, "Machine": { "dataSource": "vn" }, diff --git a/back/models/locationiq-config.js b/back/models/locationiq-config.js new file mode 100644 index 000000000..e0fe736bb --- /dev/null +++ b/back/models/locationiq-config.js @@ -0,0 +1,4 @@ +module.exports = Self => { + require('../methods/locationiq-config/optimize')(Self); +}; + diff --git a/back/models/locationiq-config.json b/back/models/locationiq-config.json new file mode 100644 index 000000000..624341615 --- /dev/null +++ b/back/models/locationiq-config.json @@ -0,0 +1,28 @@ +{ + "name": "LocationiqConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "locationiqConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "required": true + }, + "url": { + "type": "string", + "required": true + }, + "key": { + "type": "string", + "required": true + }, + "tolerance": { + "type": "number", + "required": false + } + } +} diff --git a/db/versions/11379-yellowCordyline/00-firstScript.sql b/db/versions/11379-yellowCordyline/00-firstScript.sql new file mode 100644 index 000000000..001ef6049 --- /dev/null +++ b/db/versions/11379-yellowCordyline/00-firstScript.sql @@ -0,0 +1,8 @@ +CREATE TABLE `vn`.`locationiqConfig` ( + `id` int(10) unsigned NOT NULL, + `url` varchar(100) NOT NULL, + `key` varchar(100) NOT NULL, + `tolerance` decimal(6,6) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + CONSTRAINT `locationiqConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 1eb953d89..fb495dfb1 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,8 +388,9 @@ "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "The web user's email already exists": "El correo del usuario web ya existe", - "Sales already moved": "Ya han sido transferidas", - "The raid information is not correct": "La información de la redada no es correcta", - "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" -} - + "Sales already moved": "Ya han sido transferidas", + "The raid information is not correct": "La información de la redada no es correcta", + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", + "No trips found because input coordinates are not connected": "No se encontraron rutas porque las coordenadas de entrada no están conectadas", + "This request is not supported": "Esta solicitud no es compatible" +} \ No newline at end of file From 0bb9282953cacb199b6451e778fb22bda28baeae Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Dec 2024 09:11:55 +0100 Subject: [PATCH 049/108] feat: refs #7882 Added locationiq service --- back/methods/locationiq-config/optimize.js | 18 +++++++++++++----- .../11379-yellowCordyline/00-firstScript.sql | 7 ++++--- loopback/locale/es.json | 3 ++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/back/methods/locationiq-config/optimize.js b/back/methods/locationiq-config/optimize.js index cd1f6e7ff..97ea33089 100644 --- a/back/methods/locationiq-config/optimize.js +++ b/back/methods/locationiq-config/optimize.js @@ -38,7 +38,9 @@ module.exports = Self => { const concatCoords = coords .map(coord => `${coord.longitude},${coord.latitude}`) .join(';'); - const response = await axios.post(`${locationiqConfig.url}${concatCoords}?key=${locationiqConfig.key}`); + const response = await axios.post(` + ${locationiqConfig.url}optimize/driving/${concatCoords}?key=${locationiqConfig.key} + `); const tolerance = locationiqConfig.tolerance; for (waypoint of response.data.waypoints) { @@ -46,10 +48,14 @@ module.exports = Self => { const latitude = waypoint.location[1]; const matchedAddress = coords.find(coord => + !coord.position && Math.abs(coord.latitude - latitude) <= tolerance && Math.abs(coord.longitude - longitude) <= tolerance ); - if (matchedAddress) matchedAddress.position = waypoint.waypoint_index; + if (matchedAddress) + matchedAddress.position = waypoint.waypoint_index; + else + console.log(`Las coordenadas no se han podido asociar: ${latitude} | ${longitude}`); } coords.sort((a, b) => { const posA = a.position !== undefined ? a.position : Infinity; @@ -58,9 +64,9 @@ module.exports = Self => { }); // Temporal para abrir en maps const coordsString = coords - .map(item => `${item.latitude},${item.longitude}`) - .join('/'); - console.log(`https://www.google.es/maps/dir/${coordsString}`); + .map(item => `point=${item.latitude},${item.longitude}`) + .join('&'); + console.log(`https://graphhopper.com/maps/?${coordsString}&profile=small_truck`); // --------- return coords; } catch (err) { @@ -69,6 +75,8 @@ module.exports = Self => { throw new UserError('No trips found because input coordinates are not connected'); case 'NotImplemented': throw new UserError('This request is not supported'); + case 'InvalidOptions': + throw new UserError('Invalid options or too many coordinates'); default: throw err; } diff --git a/db/versions/11379-yellowCordyline/00-firstScript.sql b/db/versions/11379-yellowCordyline/00-firstScript.sql index 001ef6049..363c32dfa 100644 --- a/db/versions/11379-yellowCordyline/00-firstScript.sql +++ b/db/versions/11379-yellowCordyline/00-firstScript.sql @@ -1,8 +1,9 @@ CREATE TABLE `vn`.`locationiqConfig` ( `id` int(10) unsigned NOT NULL, - `url` varchar(100) NOT NULL, - `key` varchar(100) NOT NULL, - `tolerance` decimal(6,6) NOT NULL DEFAULT 0, + `url` varchar(100) NOT NULL COMMENT 'Dirección base de la API', + `key` varchar(100) NOT NULL COMMENT 'Access token', + `tolerance` decimal(6,6) NOT NULL DEFAULT 0 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas', + `maxCoordsRequest` int(10) unsigned DEFAULT NULL COMMENT 'Número máximo de coordenadas por petición', PRIMARY KEY (`id`), CONSTRAINT `locationiqConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index fb495dfb1..8013a7fe6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -392,5 +392,6 @@ "The raid information is not correct": "La información de la redada no es correcta", "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", "No trips found because input coordinates are not connected": "No se encontraron rutas porque las coordenadas de entrada no están conectadas", - "This request is not supported": "Esta solicitud no es compatible" + "This request is not supported": "Esta solicitud no es compatible", + "Invalid options or too many coordinates": "Opciones invalidas o demasiadas coordenadas" } \ No newline at end of file From e279cc4b471c8e2d2efe85d32e25897d615a860d Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Dec 2024 10:01:59 +0100 Subject: [PATCH 050/108] feat: refs #7882 Added osrm service --- .../{locationiq-config => osrm-config}/optimize.js | 9 ++++----- back/model-config.json | 2 +- back/models/locationiq-config.js | 4 ---- back/models/osrm-config.js | 4 ++++ back/models/{locationiq-config.json => osrm-config.json} | 8 ++------ db/versions/11379-yellowCordyline/00-firstScript.sql | 6 ++---- 6 files changed, 13 insertions(+), 20 deletions(-) rename back/methods/{locationiq-config => osrm-config}/optimize.js (89%) delete mode 100644 back/models/locationiq-config.js create mode 100644 back/models/osrm-config.js rename back/models/{locationiq-config.json => osrm-config.json} (69%) diff --git a/back/methods/locationiq-config/optimize.js b/back/methods/osrm-config/optimize.js similarity index 89% rename from back/methods/locationiq-config/optimize.js rename to back/methods/osrm-config/optimize.js index 97ea33089..9440800f6 100644 --- a/back/methods/locationiq-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -23,8 +23,8 @@ module.exports = Self => { Self.optimize = async addressIds => { const models = Self.app.models; try { - const locationiqConfig = await models.LocationiqConfig.findOne(); - if (!locationiqConfig) throw new UserError(`LocationIQ service is not configured`); + const osrmConfig = await models.OsrmConfig.findOne(); + if (!osrmConfig) throw new UserError(`OSRM service is not configured`); let coords = []; for (const addressId of addressIds) { @@ -39,10 +39,9 @@ module.exports = Self => { .map(coord => `${coord.longitude},${coord.latitude}`) .join(';'); const response = await axios.post(` - ${locationiqConfig.url}optimize/driving/${concatCoords}?key=${locationiqConfig.key} + ${osrmConfig.url}/trip/v1/driving/${concatCoords} `); - const tolerance = locationiqConfig.tolerance; - + const tolerance = osrmConfig.tolerance; for (waypoint of response.data.waypoints) { const longitude = waypoint.location[0]; const latitude = waypoint.location[1]; diff --git a/back/model-config.json b/back/model-config.json index f48e5f2eb..2ced867f7 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -88,7 +88,7 @@ "Language": { "dataSource": "vn" }, - "LocationiqConfig": { + "OsrmConfig": { "dataSource": "vn" }, "Machine": { diff --git a/back/models/locationiq-config.js b/back/models/locationiq-config.js deleted file mode 100644 index e0fe736bb..000000000 --- a/back/models/locationiq-config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = Self => { - require('../methods/locationiq-config/optimize')(Self); -}; - diff --git a/back/models/osrm-config.js b/back/models/osrm-config.js new file mode 100644 index 000000000..f738f305c --- /dev/null +++ b/back/models/osrm-config.js @@ -0,0 +1,4 @@ +module.exports = Self => { + require('../methods/osrm-config/optimize')(Self); +}; + diff --git a/back/models/locationiq-config.json b/back/models/osrm-config.json similarity index 69% rename from back/models/locationiq-config.json rename to back/models/osrm-config.json index 624341615..ae712ba05 100644 --- a/back/models/locationiq-config.json +++ b/back/models/osrm-config.json @@ -1,9 +1,9 @@ { - "name": "LocationiqConfig", + "name": "OsrmConfig", "base": "VnModel", "options": { "mysql": { - "table": "locationiqConfig" + "table": "osrmConfig" } }, "properties": { @@ -16,10 +16,6 @@ "type": "string", "required": true }, - "key": { - "type": "string", - "required": true - }, "tolerance": { "type": "number", "required": false diff --git a/db/versions/11379-yellowCordyline/00-firstScript.sql b/db/versions/11379-yellowCordyline/00-firstScript.sql index 363c32dfa..6c0263f7f 100644 --- a/db/versions/11379-yellowCordyline/00-firstScript.sql +++ b/db/versions/11379-yellowCordyline/00-firstScript.sql @@ -1,9 +1,7 @@ -CREATE TABLE `vn`.`locationiqConfig` ( +CREATE TABLE `vn`.`osrmConfig` ( `id` int(10) unsigned NOT NULL, `url` varchar(100) NOT NULL COMMENT 'Dirección base de la API', - `key` varchar(100) NOT NULL COMMENT 'Access token', `tolerance` decimal(6,6) NOT NULL DEFAULT 0 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas', - `maxCoordsRequest` int(10) unsigned DEFAULT NULL COMMENT 'Número máximo de coordenadas por petición', PRIMARY KEY (`id`), - CONSTRAINT `locationiqConfig_check` CHECK (`id` = 1) + CONSTRAINT `osrmConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file From 85baf151d9a8cab26aa57116a040232cd10a0d32 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Dec 2024 10:21:23 +0100 Subject: [PATCH 051/108] feat: refs #7882 Fixed problems osrm service --- back/methods/osrm-config/optimize.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index 9440800f6..a7c81f33a 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -47,27 +47,26 @@ module.exports = Self => { const latitude = waypoint.location[1]; const matchedAddress = coords.find(coord => - !coord.position && + coord.position === undefined && Math.abs(coord.latitude - latitude) <= tolerance && Math.abs(coord.longitude - longitude) <= tolerance ); if (matchedAddress) matchedAddress.position = waypoint.waypoint_index; - else - console.log(`Las coordenadas no se han podido asociar: ${latitude} | ${longitude}`); } coords.sort((a, b) => { const posA = a.position !== undefined ? a.position : Infinity; const posB = b.position !== undefined ? b.position : Infinity; return posA - posB; }); - // Temporal para abrir en maps + const coordsString = coords .map(item => `point=${item.latitude},${item.longitude}`) .join('&'); - console.log(`https://graphhopper.com/maps/?${coordsString}&profile=small_truck`); - // --------- - return coords; + return { + coords, + view: `https://graphhopper.com/maps/?${coordsString}&profile=small_truck` + }; } catch (err) { switch (err.response?.data?.code) { case 'NoTrips': From f69dfbd5aa89463c52e315f9a6c35e8c863524d3 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 9 Dec 2024 14:03:45 +0100 Subject: [PATCH 052/108] refactor: refs #7936 remove schema --- db/routines/vn/triggers/invoiceIn_afterUpdate.sql | 2 +- db/versions/11368-whiteAspidistra/00-firstScript.sql | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql index 8f0a63465..8c2785e38 100644 --- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate` BEGIN DECLARE vIsEuro BOOL; - SELECT if(`code` = 'EUR', TRUE, FALSE) INTO vIsEuro + SELECT `code` = 'EUR' INTO vIsEuro FROM currency WHERE id = NEW.currencyFk; diff --git a/db/versions/11368-whiteAspidistra/00-firstScript.sql b/db/versions/11368-whiteAspidistra/00-firstScript.sql index 333fa1315..f36832805 100644 --- a/db/versions/11368-whiteAspidistra/00-firstScript.sql +++ b/db/versions/11368-whiteAspidistra/00-firstScript.sql @@ -2,13 +2,13 @@ DROP TRIGGER IF EXISTS invoiceIn_beforeUpdate; - UPDATE vn.invoiceIn + UPDATE invoiceIn SET cplusRectificationTypeFk = NULL WHERE cplusRectificationTypeFk = 1; - DELETE IGNORE FROM vn.cplusRectificationType WHERE id = 1; + DELETE IGNORE FROM cplusRectificationType WHERE id = 1; - UPDATE vn.cplusRectificationType + UPDATE cplusRectificationType SET id = 1 WHERE id = 3; @@ -25,7 +25,7 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); - IF (SELECT COUNT(*) FROM vn.invoiceIn + IF (SELECT COUNT(*) FROM invoiceIn WHERE supplierRef = NEW.supplierRef AND supplierFk = NEW.supplierFk AND YEAR(issued) = YEAR(NEW.issued) @@ -37,7 +37,7 @@ BEGIN IF NEW.supplierFk != OLD.supplierFk THEN CALL supplier_checkIsActive(NEW.supplierFk); SELECT withholdingSageFk INTO vWithholdingSageFk - FROM vn.supplier + FROM supplier WHERE id = NEW.supplierFk; SET NEW.withholdingSageFk = vWithholdingSageFk; END IF; From cba5d88c5e36c92f7a35d6c48091cc0754f8e83f Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Dec 2024 14:45:31 +0100 Subject: [PATCH 053/108] feat: refs #7882 Osrm service --- back/methods/osrm-config/optimize.js | 20 ++++++++++++--- .../route/back/methods/route/optimizeStops.js | 25 +++++++++++++++++++ modules/route/back/models/route.js | 1 + 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 modules/route/back/methods/route/optimizeStops.js diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index a7c81f33a..0c570b95a 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -27,19 +27,31 @@ module.exports = Self => { if (!osrmConfig) throw new UserError(`OSRM service is not configured`); let coords = []; - for (const addressId of addressIds) { - const address = await models.Address.findById(addressId); + + const address = await models.Address.findById(32308); // Aquí irá el address asociada a la zona + if (address.latitude && address.longitude) { coords.push({ - addressId, + addressId: address.id, latitude: address.latitude.toFixed(6), longitude: address.longitude.toFixed(6) }); } + + for (const addressId of addressIds) { + const address = await models.Address.findById(addressId); + if (address.latitude && address.longitude) { + coords.push({ + addressId, + latitude: address.latitude.toFixed(6), + longitude: address.longitude.toFixed(6) + }); + } + } const concatCoords = coords .map(coord => `${coord.longitude},${coord.latitude}`) .join(';'); const response = await axios.post(` - ${osrmConfig.url}/trip/v1/driving/${concatCoords} + ${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&roundtrip=true `); const tolerance = osrmConfig.tolerance; for (waypoint of response.data.waypoints) { diff --git a/modules/route/back/methods/route/optimizeStops.js b/modules/route/back/methods/route/optimizeStops.js new file mode 100644 index 000000000..9666f201e --- /dev/null +++ b/modules/route/back/methods/route/optimizeStops.js @@ -0,0 +1,25 @@ +module.exports = Self => { + Self.remoteMethod('optimizeStops', { + description: 'Updates the ticket priority of tickets without priority', + accepts: [ + { + arg: 'routeFk', + type: 'number', + required: true + } + ], + returns: { + type: 'object', + root: true + }, + http: { + path: '/optimizeStops', + verb: 'post' + } + }); + + Self.optimizeStops = async(routeFk, options) => { + return; + }; +}; + diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index cd8685cec..e28b19a61 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -16,4 +16,5 @@ module.exports = Self => { require('../methods/route/downloadZip')(Self); require('../methods/route/getExpeditionSummary')(Self); require('../methods/route/getByWorker')(Self); + require('../methods/route/optimizeStops')(Self); }; From 46448d5fc20d5346c1cd0a70888b00f91f5d3172 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Dec 2024 10:27:35 +0100 Subject: [PATCH 054/108] fix: refs #7936 change type --- modules/invoiceIn/back/models/invoice-in-tax.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/invoiceIn/back/models/invoice-in-tax.json b/modules/invoiceIn/back/models/invoice-in-tax.json index 53b5548b6..256ee0553 100644 --- a/modules/invoiceIn/back/models/invoice-in-tax.json +++ b/modules/invoiceIn/back/models/invoice-in-tax.json @@ -22,12 +22,11 @@ "type": "number" }, "expenseFk": { - "type": "number" + "type": "string" }, "created": { "type": "date" } - }, "relations": { "invoiceIn": { @@ -51,4 +50,4 @@ "foreignKey": "transactionTypeSageFk" } } -} +} \ No newline at end of file From 391f1d8c975d8740563e6182f73c103f1fca9f14 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 10 Dec 2024 12:04:03 +0100 Subject: [PATCH 055/108] fix: refs #7028 fix confirm deny --- .../back/methods/ticket-request/confirm.js | 15 +++-- .../back/methods/ticket-request/deny.js | 56 ++++++++++++------- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index 7c17d0010..56ee14a73 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -54,9 +54,17 @@ module.exports = Self => { throw new UserError(`That item doesn't exists`); const request = await models.TicketRequest.findById(ctx.args.id, { - include: {relation: 'ticket'} + include: { + relation: 'ticket', + scope: { + include: { + relation: 'client', + scope: { + fields: ['id', 'name', 'salesPersonFk'] + } + } + }} }, myOptions); - const itemStock = await models.Item.getVisibleAvailable( ctx.args.itemFk, request.ticket().warehouseFk, @@ -90,8 +98,7 @@ module.exports = Self => { await Self.rawSql(query, [sale.id], myOptions); const url = await Self.app.models.Url.getUrl(); - const requesterId = request.requesterFk; - + const requesterId = request.ticket().client().salesPersonFk; const message = $t('Bought units from buy request', { quantity: sale.quantity, concept: sale.concept, diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index 44f1e48a1..cb13c2728 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -1,18 +1,21 @@ module.exports = Self => { Self.remoteMethodCtx('deny', { - description: 'sets a ticket request to denied and returns the changes', + description: 'Sets a ticket request to denied and returns the changes', accessType: 'WRITE', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'The request ID', - }, { - arg: 'observation', - type: 'String', - required: true, - description: 'The request observation', - }], + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The request ID', + }, + { + arg: 'observation', + type: 'string', + required: true, + description: 'The request observation', + } + ], returns: { type: 'number', root: true @@ -29,7 +32,7 @@ module.exports = Self => { const myOptions = {}; let tx; - if (typeof options == 'object') + if (typeof options === 'object') Object.assign(myOptions, options); if (!myOptions.transaction) { @@ -39,7 +42,8 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; - const worker = await Self.app.models.Worker.findOne({where: {id: userId}}, myOptions); + const worker = await models.Worker.findOne({where: {id: userId}}, myOptions); + if (!worker) throw new Error('Worker not found'); const params = { isOk: false, @@ -47,19 +51,33 @@ module.exports = Self => { response: ctx.args.observation, }; - const request = await Self.app.models.TicketRequest.findById(ctx.args.id, null, myOptions); - await request.updateAttributes(params, myOptions); + const request = await models.TicketRequest.findById(ctx.args.id, { + include: { + relation: 'ticket', + scope: { + include: { + relation: 'client', + scope: { + fields: ['id', 'name', 'salesPersonFk'] + } + } + } + } + }, myOptions); - const url = await Self.app.models.Url.getUrl(); - const requesterId = request.requesterFk; + if (!request || !request.ticket() || !request.ticket().client()) + throw new Error('Invalid request or related ticket/client data'); + const url = await models.Url.getUrl(); + const requesterId = request.ticket().client().salesPersonFk; const message = $t('Deny buy request', { ticketId: request.ticketFk, url: `${url}ticket/${request.ticketFk}/request/index`, observation: params.response }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + await models.Chat.sendCheckingPresence(ctx, requesterId, message); + await request.updateAttributes(params, myOptions); if (tx) await tx.commit(); From 10558853a2b2304c8732cfe1854e2bcb7ccbd211 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 10 Dec 2024 13:41:45 +0100 Subject: [PATCH 056/108] feat: refs #8174 create table simsupplier --- .../11327-maroonOak/00-firstScript.sql | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 973050fba..2ad44f700 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -17,3 +17,162 @@ MODIFY `simSerialNumber` VARCHAR(25); ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim); +INSERT IGNORE INTO `vn`.`simSupplier` (`line`, `ext`, `pin`, `sim`, `puk`, `statusWeb`) +VALUES +(621188151, 2209, 1486, 3456985220092508,14213470, 'OK'), +(621188152, 2210, 8765, 3456985220092509,99473093, 'OK'), +(621188153, 2211, 3064, 3456985220092510,52967210, 'OK'), +(621188759, 2081, 3700, 3456985220123637,56600999, 'OK'), +(621188760, 2082, 3259, 345698522023638,87492404, 'OK'), +(621188761, 2083, 2790, 3456985220123639,94009456, 'OK'), +(621188762, 2084, 2480, 3456985220123644,1484999, 'OK'), +(621188763, 2085, 6876, 3456985220123641,36577064, 'OK'), +(621188766, 2086, 7775, 3456985220123642,80761698, 'OK'), +(621188769, 2088, 4027, 3456985220123643,37921712, 'OK'), +(621188771, 2089, 8797, 3456985220123640,63092540, 'OK'), +(621188772, 2090, 8404, 3456985220123645,21014997, 'OK'), +(621188773, 2091, 5481, 3456985220123646,16317277, 'OK'), +(621188774, 2092, 9632, 3456985220123647,22235994, 'OK'), +(621188775, 2093, 4654, 3456985220123648,28506486, 'OK'), +(621188838, 2094, 1392, 3456985220123649,29498627, 'OK'), +(621188839, 2095, 7774, 3456985220123650,46263490, 'OK'), +(621188840, 2096, 7304, 3456985220123658,8212044, 'OK'), +(621188841, 2097, 5569, 3456985220123652,81597658, 'OK'), +(621188842, 2098, 4944, 3456985220123653,24961501, 'OK'), +(621188843, 2099, 5142, 3456985220123654,17035634, 'OK'), +(621188844, 2111, 7245, 3456985220123655,90231951, 'OK'), +(621188846, 2110, 6590, 3456985220123656,72201537, 'OK'), +(667680207, 2564, 4042, 34569832200759166,48401979, 'OK'), +(667680315, 2565, 7143, 34569832200759372,32143252, 'OK'), +(667680318, 2566, 6342, 34569832200759364,39597112, 'OK'), +(667680413, 2567, 5580, 34569832200759356,32786992, 'OK'), +(667680463, 2568, 0171, 34569832200759349,34240853, 'OK'), +(667688217, 2569, 2500, 34569832200759331,5687589, 'OK'), +(633603945, 2212, 7129, 34569832200759323,51554019, 'OK'), +(622130186, 2213, 4826, 34569832200759307,19623551, 'OK'), +(633973424, 2214, 8535, 34569832200759299,94619307, 'OK'), +(633703828, 2215, 8628, 34569832200759281,22468012, 'OK'), +(622025110, 2216, 2399, 34569832200759273,34602918, 'OK'), +(622924867, 2217, 5665, 34569832200759265,26920216, 'OK'), +(722409630, 2218, 5211, 34569832200759240,93750137, 'OK'), +(623590529, 2219, 0493, 34569832200759208,47077088, 'OK'), +(633243462, 2220, 6902, 34569832200759174,6421962, 'OK'), +(633047286, 2221, 5592, 34569832200759182,32069439, 'OK'), +(744716801, 2112, 9184, 34569832200759190,57049814, 'OK'), +(655995021, 2131, 8896, 34569852202049093,19497356, 'OK'), +(685522718, 2132, 1955, 34569852202049101,28519879, 'OK'), +(674587213, 2994, 2006, 34569332200223743,62360135, 'OK'), +(674587227, 2993, 9271, 34569332200223750,81628192, 'OK'), +(674587229, 2993, 0900, 34569332200223768,91119071, 'OK'), +(674587231, 2992, 5007, 34569332200223776,45826232, 'OK'), +(674587234, 2991, 1378, 34569332200223784,91245744, 'OK'), +(674587240, 2990, 0905, 34569332200223792,13083224, 'OK'), +(674587245, 2989, 9059, 34569332200223800,15291807, 'OK'), +(674587250, 2988, 8188, 34569332200223818,83017918, 'OK'), +(674587254, 2987, 2962, 34569332200223826,92809271, 'OK'), +(674587256, 2986, 0358, 34569332200223834,81067040, 'OK'), +(674592713, 2570, 2537, 34569332200230672,82325850, 'OK'), +(697832478, 2579, 0936, 34568732200494825,49658372, 'OK'), +(697832176, 2571, 5944, 34568732200494742,19039461, 'OK'), +(697832477, 2572, 5138, 34568732200494759,25712504, 'OK'), +(697832178, 2573, 4597, 34568732200494767,66241760, 'OK'), +(697832182, 2574, 9241, 34568732200494775,07342562, 'OK'), +(697832196, 2575, 2995, 34568732200494783,53929026, 'OK'), +(697832214, 2576, 7434, 34568732200494791,49698432, 'OK'), +(697832230, 2577, 7004, 34568732200494809,21578612, 'OK'), +(697832235, 2578, 9674, 34568732200494817,93090700, 'OK'), +(673420375, 2599, 5430, 34562052300117259,35911412, 'OK'), +(673420367, 2598, 8402, 34562052300117242,924654, 'OK'), +(673420361, 2597, 5125, 34562052300117234,12027970, 'OK'), +(673420355, 2596, 5069, 34562052300117226,34978149, 'OK'), +(673420348, 2595, 8911, 34562052300117218,4228121, 'OK'), +(673420346, 2594, 2461, 34562052300117200,67670772, 'OK'), +(673420345, 2593, 2226, 34562052300117192,90586404, 'OK'), +(673420306, 2592, 3355, 34562052300117184,97850017, 'OK'), +(673420257, 2591, 9395, 34562052300117176,50713786, 'OK'), +(673420231, 2590, 1378, 34562052300117168,50151763, 'OK'), +(673420223, 2589, 9580, 34562052300117150,99534550, 'OK'), +(673420216, 2588, 4955, 34562052300117143,317554, 'OK'), +(673420203, 2587, 6742, 34562052300117135,69321531, 'OK'), +(673420201, 2586, 1659, 34562052300117127,54720480, 'OK'), +(673420199, 2585, 7823, 34562052300117119,22923796, 'OK'), +(673420198, 2584, 1787, 34562052300117101,54414630, 'OK'), +(673420168, 2583, 6334, 34562052300117093,50694894, 'OK'), +(673420147, 2582, 8951, 34562052300117085,1402535, 'OK'), +(673420125, 2581, 3068, 34562052300117077,86216200, 'OK'), +(673420124, 2580, 9517, 34562052300117069,42504099, 'OK'), +(600294609, 2715, 7474, 34569832304894588,55923317, 'OK'), +(600084713, 2703, 8342, 34569832304894570,8392636, 'OK'), +(600084732, 2704, 1625, 34569832304894513,75477452, 'OK'), +(600084850, 2705, 9896, 34569832304894653,28589813, 'OK'), +(600084951, 2706, 5520, 34569832304894661,75353012, 'OK'), +(600084978, 2707, 2698, 34569832304894679,9005523, 'OK'), +(600085403, 2708, 0837, 34569832304894646,77051152, 'OK'), +(600085513, 2709, 3106, 34569832304894687,41571002, 'OK'), +(600293916, 2712, 8990, 34569832304894620,95188676, 'OK'), +(600294160, 2714, 6376, 34569832304894703,79879896, 'OK'), +(671919529, 2975, 9184, 34569832304806236,7535392, 'OK'), +(671919942, 2981, 0328, 34569832304806269,31052894, 'OK'), +(671919530, 2976, 0344, 34569832304806251,89860304, 'OK'), +(671919533, 2977, 0668, 34569832304806244,42921771, 'OK'), +(671919535, 2978, 0105, 34569832304806277,31009417, 'OK'), +(671919537, 2979, 0881, 34569832304806285,33479769, 'OK'), +(671919540, 2980, 9874, 34569832304806293,14103929, 'OK'), +(671919525, 2972, 2089, 34569832304806301,45903729, 'OK'), +(671919527, 2973, 8206, 34569832304806368,1586035, 'OK'), +(671919528, 2974, 2532, 34569832304806327,62310124, 'OK'), +(673668717, 2836, 7973, 34562032301044223,15635496, 'OK'), +(673668734, 2837, 4457, 34562032301044231,18313118, 'OK'), +(673668738, 2824, 2911, 34562032301044249,30875583, 'OK'), +(673668745, 2838, 7253, 34562032301044256,62754222, 'OK'), +(673668796, 2839, 0068, 34562032301044264,15556829, 'OK'), +(673668803, 2840, 2386, 34562032301044272,17572287, 'OK'), +(673669591, 2850, 3833, 34562032301044280,34828896, 'OK'), +(673668808, 2841, 3584, 34562032301044298,16234497, 'OK'), +(673670102, 2851, 3554, 34562032301044306,23652625, 'OK'), +(673670131, 2852, 4412, 34562032301044314,88611709, 'OK'), +(673670135, 2827, 6058, 34562032301044322,53918579, 'OK'), +(673670201, 2828, 8066, 34562032301044330,92369343, 'OK'), +(673670225, 2829, 4592, 34562032301044348,24126635, 'OK'), +(673670236, 2830, 2974, 34562032301044355,88608465, 'OK'), +(673671485, 2849, 0349, 34562032301044363,44944874, 'OK'), +(673461977, 2871, 1728, 34562032400157090,46975780, 'OK'), +(673461975, 2870, 4734, 34562032400157082,69628432, 'OK'), +(673461972, 2867, 6276, 34562032400157058,53338365, 'OK'), +(673461979, 2872, 6043, 34562032400157108,36525197, 'OK'), +(673461958, 2859, 3164, 34562032400156977,58947831, 'OK'), +(673461957, 2857, 8685, 34562032400156969,15826386, 'OK'), +(673461944, 2853, 1073, 34562032400156910,20452195, 'OK'), +(673461974, 2869, 7121, 34562032400157074,32044645, 'OK'), +(673461973, 2868, 8022, 34562032400157066,29282044, 'OK'), +(673461971, 2866, 3089, 34562032400157041,66149978, 'OK'), +(673461969, 2865, 7555, 34562032400157033,78391293, 'OK'), +(673461960, 2860, 5203, 34562032400156985,37138232, 'OK'), +(673461952, 2855, 6915, 34562032400156936,62724661, 'OK'), +(673461949, 2854, 8706, 34562032400156928,5594345, 'OK'), +(673461966, 2863, 2496, 34562032400157017,93450666, 'OK'), +(673461968, 2864, 3703, 34562032400157025,23208841, 'OK'), +(673461963, 2862, 9364, 34562032400157009,29712130, 'OK'), +(673462719, 2873, 9387, 34562032400156951,50434348, 'OK'), +(673461962, 2861, 8441, 34562032400156993,39686909, 'OK'), +(673461956, 2826, 5392, 34562032400156944,5496107, 'OK'), +(673465284, 2694, 1523, 34562032400171349,14554994, 'OK'), +(673465282, 2692, 4645, 34562032400171323,24871187, 'OK'), +(673465283, 2693, 5253, 34562032400171331,28303238, 'OK'), +(673465841, 2696, 0849, 34562032400171257,21673222, 'OK'), +(673465258, 2679, 4140, 34562032400171174,39793881, 'OK'), +(673465263, 2680, 6922, 34562032400171182,12253261, 'OK'), +(673465265, 2681, 9112, 34562032400171190,93894366, 'OK'), +(673465267, 2682, 3259, 34562032400171208,2342189, 'OK'), +(673465268, 2683, 8540, 34562032400171216,63886925, 'OK'), +(673465285, 2695, 4167, 34562032400171356,79227618, 'OK'), +(673465270, 2684, 4292, 34562032400171224,19216349, 'OK'), +(673465272, 2685, 4007, 34562032400171232,14396903, 'OK'), +(673465273, 2686, 6894, 34562032400171240,13569394, 'OK'), +(673465274, 2687, 5268, 34562032400171265,59453667, 'OK'), +(673465275, 2688, 0232, 34562032400171273,62324713, 'OK'), +(673465276, 2689, 2720, 34562032400171281,65977200, 'OK'), +(673465843, 2698, 4773, 34562032400171364,78387158, 'OK'), +(673465842, 2697, 3729, 34562032400171315,94201789, 'OK'), +(673465280, 2691, 0503, 34562032400171307,12298533, 'OK'), +(673465279, 2690, 8239, 34562032400171299,76183877, 'OK'); \ No newline at end of file From 87976351012fa275b41a4c46e2a31299ebe77f9f Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 10 Dec 2024 13:46:03 +0100 Subject: [PATCH 057/108] feat: refs #8174 fix --- db/versions/11327-maroonOak/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 2ad44f700..eda1f5e97 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`simSupplier` ( ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -ALTER TABLE `deviceProductionUser` +ALTER TABLE `vn`.`deviceProductionUser` MODIFY `simSerialNumber` VARCHAR(25); ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK From c8ec94bed9116fa3242c566e36eb1335b51834d0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Dec 2024 09:03:14 +0100 Subject: [PATCH 058/108] feat: refs #7882 Osrm service --- back/methods/osrm-config/optimize.js | 28 +++-- .../11379-yellowCordyline/00-firstScript.sql | 25 +++- loopback/locale/es.json | 3 +- .../back/methods/route/optimizePriority.js | 119 ++++++++++++++++++ .../route/back/methods/route/optimizeStops.js | 25 ---- modules/route/back/models/route.js | 2 +- modules/zone/back/model-config.json | 3 + modules/zone/back/models/zone-config.json | 28 +++++ modules/zone/back/models/zone.json | 37 +++--- 9 files changed, 211 insertions(+), 59 deletions(-) create mode 100644 modules/route/back/methods/route/optimizePriority.js delete mode 100644 modules/route/back/methods/route/optimizeStops.js create mode 100644 modules/zone/back/models/zone-config.json diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index 0c570b95a..c03b70315 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -9,9 +9,13 @@ module.exports = Self => { arg: 'addressIds', type: 'array', required: true + }, { + arg: 'firstAddressId', + type: 'number', + required: false }], returns: { - type: 'string', + type: 'object', root: true }, http: { @@ -20,21 +24,22 @@ module.exports = Self => { } }); - Self.optimize = async addressIds => { + Self.optimize = async(addressIds, firstAddressId) => { const models = Self.app.models; try { const osrmConfig = await models.OsrmConfig.findOne(); if (!osrmConfig) throw new UserError(`OSRM service is not configured`); let coords = []; - - const address = await models.Address.findById(32308); // Aquí irá el address asociada a la zona - if (address.latitude && address.longitude) { - coords.push({ - addressId: address.id, - latitude: address.latitude.toFixed(6), - longitude: address.longitude.toFixed(6) - }); + if (firstAddressId) { + const firstAddress = await models.Address.findById(firstAddressId); + if (firstAddress.latitude && firstAddress.longitude) { + coords.push({ + addressId: firstAddress.id, + latitude: firstAddress.latitude.toFixed(6), + longitude: firstAddress.longitude.toFixed(6) + }); + } } for (const addressId of addressIds) { @@ -47,6 +52,9 @@ module.exports = Self => { }); } } + + if (!coords.length) throw new UserError('No address has coordinates'); + const concatCoords = coords .map(coord => `${coord.longitude},${coord.latitude}`) .join(';'); diff --git a/db/versions/11379-yellowCordyline/00-firstScript.sql b/db/versions/11379-yellowCordyline/00-firstScript.sql index 6c0263f7f..8d90ee90c 100644 --- a/db/versions/11379-yellowCordyline/00-firstScript.sql +++ b/db/versions/11379-yellowCordyline/00-firstScript.sql @@ -1,7 +1,20 @@ CREATE TABLE `vn`.`osrmConfig` ( - `id` int(10) unsigned NOT NULL, - `url` varchar(100) NOT NULL COMMENT 'Dirección base de la API', - `tolerance` decimal(6,6) NOT NULL DEFAULT 0 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas', - PRIMARY KEY (`id`), - CONSTRAINT `osrmConfig_check` CHECK (`id` = 1) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file + `id` int(10) unsigned NOT NULL, + `url` varchar(100) NOT NULL COMMENT 'Dirección base de la API', + `tolerance` decimal(6,6) NOT NULL DEFAULT 0 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas', + PRIMARY KEY (`id`), + CONSTRAINT `osrmConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +-- Para que no de error al añadir la FK de zone +UPDATE vn.zone + SET price = 0.1 + WHERE price = 0; + +ALTER TABLE vn.`zone` + ADD addressFk int(11) DEFAULT NULL COMMENT 'Punto de distribución de donde salen para repartir', + ADD CONSTRAINT zone_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE vn.zoneConfig + ADD defaultAddressFk int(11) DEFAULT NULL NULL COMMENT 'Punto de distribución por defecto', + ADD CONSTRAINT zoneConfig_address_FK FOREIGN KEY (defaultAddressFk) REFERENCES vn.address(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8013a7fe6..03cccbe1a 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -393,5 +393,6 @@ "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", "No trips found because input coordinates are not connected": "No se encontraron rutas porque las coordenadas de entrada no están conectadas", "This request is not supported": "Esta solicitud no es compatible", - "Invalid options or too many coordinates": "Opciones invalidas o demasiadas coordenadas" + "Invalid options or too many coordinates": "Opciones invalidas o demasiadas coordenadas", + "No address has coordinates": "Ninguna dirección tiene coordenadas" } \ No newline at end of file diff --git a/modules/route/back/methods/route/optimizePriority.js b/modules/route/back/methods/route/optimizePriority.js new file mode 100644 index 000000000..f84af50f8 --- /dev/null +++ b/modules/route/back/methods/route/optimizePriority.js @@ -0,0 +1,119 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('optimizePriority', { + description: 'Updates the ticket priority of tickets without priority', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'Route id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: '/:id/optimizePriority', + verb: 'POST' + } + }); + + Self.optimizePriority = async(id, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const ticketsIds = await models.Ticket.find({ + where: {routeFk: id} + }, myOptions); + + let ticketAddress = []; + for (const ticketId of ticketsIds) { + ticketAddress.push({ + ticketId: ticketId.id, + addressId: ticketId.addressFk, + zoneId: ticketId.zoneFk, + priority: ticketId.priority + }); + } + + // Igualamos los priority del mismo addressId + const addressPriorityMap = ticketAddress.reduce((acc, {addressId, priority}) => { + if (priority !== null) { + acc[addressId] = acc[addressId] === undefined + ? priority + : Math.max(acc[addressId], priority); + } + return acc; + }); + ticketAddress.forEach(item => { + const maxPriority = addressPriorityMap[item.addressId]; + if (maxPriority) item.priority = maxPriority; + }); + + // Añadimos las direcciones a optimizar + let addressIds = []; + ticketAddress.forEach(h => { + if (!addressIds.includes(h.addressId) && !h.priority) + addressIds.push(h.addressId); + }); + if (!addressIds.length) throw new UserError('All tickets have a route order'); + + // Obtenemos el zoneId más frecuente + const zoneFrequency = ticketAddress.reduce((acc, {zoneId}) => { + if (zoneId != null) acc[zoneId] = (acc[zoneId] || 0) + 1; + return acc; + }, {}); + const [mostFrequentZoneId] = Object.entries(zoneFrequency) + .reduce((maxEntry, entry) => entry[1] > maxEntry[1] ? entry : maxEntry, [null, 0]); + const zone = await models.Zone.findById(mostFrequentZoneId, myOptions); + let firstAddress = zone.addressFk; + if (!firstAddress) firstAddress = (await models.ZoneConfig.findOne()).defaultAddressFk; + + // Revisamos las coincidencias y actualizamos la prioridad en el array + const addressPositions = await models.OsrmConfig.optimize(addressIds, firstAddress, myOptions); + const maxPosition = Math.max(...ticketAddress.map(g => g.priority)); + await Promise.all(ticketAddress.map(async i => { + const foundPosition = addressPositions.coords.find(item => item.addressId === i.addressId); + if (foundPosition) i.priority = foundPosition.position + (maxPosition + 1); + })); + + // Suavizado de prioridad para que no hayan escalones + const allPriorities = ticketAddress + .map(item => item.priority) + .filter(p => p !== null); + const uniquePriorities = [...new Set(allPriorities)].sort((a, b) => a - b); + const priorityMap = {}; + uniquePriorities.forEach((p, index) => { + priorityMap[p] = index + 1; + }); + ticketAddress.forEach(item => { + if (item.priority !== null) item.priority = priorityMap[item.priority]; + }); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + // Realizamos el update en la base de datos + try { + await Promise.all(ticketAddress.map(async y => { + if (y.priority) { + const ticket = await models.Ticket.findById(y.ticketId); + await ticket.updateAttribute('priority', y.priority, myOptions); + } + })); + if (tx) await tx.commit(); + return; + } catch (err) { + if (tx) await tx.rollback(); + throw err; + } + }; +}; diff --git a/modules/route/back/methods/route/optimizeStops.js b/modules/route/back/methods/route/optimizeStops.js deleted file mode 100644 index 9666f201e..000000000 --- a/modules/route/back/methods/route/optimizeStops.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('optimizeStops', { - description: 'Updates the ticket priority of tickets without priority', - accepts: [ - { - arg: 'routeFk', - type: 'number', - required: true - } - ], - returns: { - type: 'object', - root: true - }, - http: { - path: '/optimizeStops', - verb: 'post' - } - }); - - Self.optimizeStops = async(routeFk, options) => { - return; - }; -}; - diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index e28b19a61..f73ff3e51 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -16,5 +16,5 @@ module.exports = Self => { require('../methods/route/downloadZip')(Self); require('../methods/route/getExpeditionSummary')(Self); require('../methods/route/getByWorker')(Self); - require('../methods/route/optimizeStops')(Self); + require('../methods/route/optimizePriority')(Self); }; diff --git a/modules/zone/back/model-config.json b/modules/zone/back/model-config.json index 3bbbe0d1b..2cd3f9d01 100644 --- a/modules/zone/back/model-config.json +++ b/modules/zone/back/model-config.json @@ -17,6 +17,9 @@ "ZoneClosure": { "dataSource": "vn" }, + "ZoneConfig": { + "dataSource": "vn" + }, "ZoneEvent": { "dataSource": "vn" }, diff --git a/modules/zone/back/models/zone-config.json b/modules/zone/back/models/zone-config.json new file mode 100644 index 000000000..a5da7fe55 --- /dev/null +++ b/modules/zone/back/models/zone-config.json @@ -0,0 +1,28 @@ +{ + "name": "ZoneConfig", + "options": { + "mysql": { + "table": "zoneConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "scope": { + "type": "number" + }, + "forwardDays": { + "type": "number" + } + }, + "relations": { + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "defaultAddressFk" + } + } +} diff --git a/modules/zone/back/models/zone.json b/modules/zone/back/models/zone.json index 5b25e40d1..141b28750 100644 --- a/modules/zone/back/models/zone.json +++ b/modules/zone/back/models/zone.json @@ -1,9 +1,9 @@ { "name": "Zone", "base": "VnModel", - "mixins": { - "Loggable": true - }, + "mixins": { + "Loggable": true + }, "options": { "mysql": { "table": "zone" @@ -48,30 +48,35 @@ } }, "relations": { - "agencyMode": { - "type": "belongsTo", - "model": "AgencyMode", - "foreignKey": "agencyModeFk" + "agencyMode": { + "type": "belongsTo", + "model": "AgencyMode", + "foreignKey": "agencyModeFk" }, "events": { - "type": "hasMany", - "model": "ZoneEvent", - "foreignKey": "zoneFk" - }, + "type": "hasMany", + "model": "ZoneEvent", + "foreignKey": "zoneFk" + }, "exclusions": { - "type": "hasMany", - "model": "ZoneExclusion", + "type": "hasMany", + "model": "ZoneExclusion", "foreignKey": "zoneFk" }, "warehouses": { "type": "hasMany", "model": "ZoneWarehouse", "foreignKey": "zoneFk" - }, + }, "closures": { "type": "hasMany", "model": "ZoneClosure", "foreignKey": "zoneFk" - } - } + }, + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "addressFk" + } + } } From 34da78e1ba11e89dc613952519b55b10f4d7cd7f Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 11 Dec 2024 09:58:51 +0100 Subject: [PATCH 059/108] fix: refs #6389 back --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 44eafc8c8..6c98f6cd7 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -166,7 +166,7 @@ module.exports = Self => { param = `t.${param}`; return {[param]: value}; case 'packing': - return {'packing': value}; + return {'i.itemPackingTypeFk': value}; } }); From 28ab6b2266620feace9b03ffb66c83f7a5cd167e Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 11 Dec 2024 11:20:15 +0100 Subject: [PATCH 060/108] feat: refs #8174 fix --- .../11327-maroonOak/00-firstScript.sql | 327 +++++++++--------- 1 file changed, 163 insertions(+), 164 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index eda1f5e97..250a2fc8b 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -1,11 +1,10 @@ CREATE TABLE IF NOT EXISTS `vn`.`simSupplier` ( - `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `line` int(9) unsigned DEFAULT NULL, - `ext` int(10) unsigned DEFAULT NULL, - `pin` int(4) unsigned DEFAULT NULL, + `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `line` INT(9) unsigned NOT NULL, + `ext` CHAR(4) NOT NULL CHECK (ext REGEXP '^[0-9]{4}$'), + `pin` CHAR(4) NOT NULL CHECK (pin REGEXP '^[0-9]{4}$'), `sim` VARCHAR(25), - `puk` int(10) unsigned DEFAULT NULL, - `statusWeb` varchar(50) DEFAULT NULL, + `puk` INT(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `sim_UNIQUE` (`sim`) ) ENGINE=InnoDB AUTO_INCREMENT=1 @@ -17,162 +16,162 @@ MODIFY `simSerialNumber` VARCHAR(25); ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim); -INSERT IGNORE INTO `vn`.`simSupplier` (`line`, `ext`, `pin`, `sim`, `puk`, `statusWeb`) +INSERT IGNORE INTO `vn`.`simSupplier` (`line`, `ext`, `pin`, `sim`, `puk`) VALUES -(621188151, 2209, 1486, 3456985220092508,14213470, 'OK'), -(621188152, 2210, 8765, 3456985220092509,99473093, 'OK'), -(621188153, 2211, 3064, 3456985220092510,52967210, 'OK'), -(621188759, 2081, 3700, 3456985220123637,56600999, 'OK'), -(621188760, 2082, 3259, 345698522023638,87492404, 'OK'), -(621188761, 2083, 2790, 3456985220123639,94009456, 'OK'), -(621188762, 2084, 2480, 3456985220123644,1484999, 'OK'), -(621188763, 2085, 6876, 3456985220123641,36577064, 'OK'), -(621188766, 2086, 7775, 3456985220123642,80761698, 'OK'), -(621188769, 2088, 4027, 3456985220123643,37921712, 'OK'), -(621188771, 2089, 8797, 3456985220123640,63092540, 'OK'), -(621188772, 2090, 8404, 3456985220123645,21014997, 'OK'), -(621188773, 2091, 5481, 3456985220123646,16317277, 'OK'), -(621188774, 2092, 9632, 3456985220123647,22235994, 'OK'), -(621188775, 2093, 4654, 3456985220123648,28506486, 'OK'), -(621188838, 2094, 1392, 3456985220123649,29498627, 'OK'), -(621188839, 2095, 7774, 3456985220123650,46263490, 'OK'), -(621188840, 2096, 7304, 3456985220123658,8212044, 'OK'), -(621188841, 2097, 5569, 3456985220123652,81597658, 'OK'), -(621188842, 2098, 4944, 3456985220123653,24961501, 'OK'), -(621188843, 2099, 5142, 3456985220123654,17035634, 'OK'), -(621188844, 2111, 7245, 3456985220123655,90231951, 'OK'), -(621188846, 2110, 6590, 3456985220123656,72201537, 'OK'), -(667680207, 2564, 4042, 34569832200759166,48401979, 'OK'), -(667680315, 2565, 7143, 34569832200759372,32143252, 'OK'), -(667680318, 2566, 6342, 34569832200759364,39597112, 'OK'), -(667680413, 2567, 5580, 34569832200759356,32786992, 'OK'), -(667680463, 2568, 0171, 34569832200759349,34240853, 'OK'), -(667688217, 2569, 2500, 34569832200759331,5687589, 'OK'), -(633603945, 2212, 7129, 34569832200759323,51554019, 'OK'), -(622130186, 2213, 4826, 34569832200759307,19623551, 'OK'), -(633973424, 2214, 8535, 34569832200759299,94619307, 'OK'), -(633703828, 2215, 8628, 34569832200759281,22468012, 'OK'), -(622025110, 2216, 2399, 34569832200759273,34602918, 'OK'), -(622924867, 2217, 5665, 34569832200759265,26920216, 'OK'), -(722409630, 2218, 5211, 34569832200759240,93750137, 'OK'), -(623590529, 2219, 0493, 34569832200759208,47077088, 'OK'), -(633243462, 2220, 6902, 34569832200759174,6421962, 'OK'), -(633047286, 2221, 5592, 34569832200759182,32069439, 'OK'), -(744716801, 2112, 9184, 34569832200759190,57049814, 'OK'), -(655995021, 2131, 8896, 34569852202049093,19497356, 'OK'), -(685522718, 2132, 1955, 34569852202049101,28519879, 'OK'), -(674587213, 2994, 2006, 34569332200223743,62360135, 'OK'), -(674587227, 2993, 9271, 34569332200223750,81628192, 'OK'), -(674587229, 2993, 0900, 34569332200223768,91119071, 'OK'), -(674587231, 2992, 5007, 34569332200223776,45826232, 'OK'), -(674587234, 2991, 1378, 34569332200223784,91245744, 'OK'), -(674587240, 2990, 0905, 34569332200223792,13083224, 'OK'), -(674587245, 2989, 9059, 34569332200223800,15291807, 'OK'), -(674587250, 2988, 8188, 34569332200223818,83017918, 'OK'), -(674587254, 2987, 2962, 34569332200223826,92809271, 'OK'), -(674587256, 2986, 0358, 34569332200223834,81067040, 'OK'), -(674592713, 2570, 2537, 34569332200230672,82325850, 'OK'), -(697832478, 2579, 0936, 34568732200494825,49658372, 'OK'), -(697832176, 2571, 5944, 34568732200494742,19039461, 'OK'), -(697832477, 2572, 5138, 34568732200494759,25712504, 'OK'), -(697832178, 2573, 4597, 34568732200494767,66241760, 'OK'), -(697832182, 2574, 9241, 34568732200494775,07342562, 'OK'), -(697832196, 2575, 2995, 34568732200494783,53929026, 'OK'), -(697832214, 2576, 7434, 34568732200494791,49698432, 'OK'), -(697832230, 2577, 7004, 34568732200494809,21578612, 'OK'), -(697832235, 2578, 9674, 34568732200494817,93090700, 'OK'), -(673420375, 2599, 5430, 34562052300117259,35911412, 'OK'), -(673420367, 2598, 8402, 34562052300117242,924654, 'OK'), -(673420361, 2597, 5125, 34562052300117234,12027970, 'OK'), -(673420355, 2596, 5069, 34562052300117226,34978149, 'OK'), -(673420348, 2595, 8911, 34562052300117218,4228121, 'OK'), -(673420346, 2594, 2461, 34562052300117200,67670772, 'OK'), -(673420345, 2593, 2226, 34562052300117192,90586404, 'OK'), -(673420306, 2592, 3355, 34562052300117184,97850017, 'OK'), -(673420257, 2591, 9395, 34562052300117176,50713786, 'OK'), -(673420231, 2590, 1378, 34562052300117168,50151763, 'OK'), -(673420223, 2589, 9580, 34562052300117150,99534550, 'OK'), -(673420216, 2588, 4955, 34562052300117143,317554, 'OK'), -(673420203, 2587, 6742, 34562052300117135,69321531, 'OK'), -(673420201, 2586, 1659, 34562052300117127,54720480, 'OK'), -(673420199, 2585, 7823, 34562052300117119,22923796, 'OK'), -(673420198, 2584, 1787, 34562052300117101,54414630, 'OK'), -(673420168, 2583, 6334, 34562052300117093,50694894, 'OK'), -(673420147, 2582, 8951, 34562052300117085,1402535, 'OK'), -(673420125, 2581, 3068, 34562052300117077,86216200, 'OK'), -(673420124, 2580, 9517, 34562052300117069,42504099, 'OK'), -(600294609, 2715, 7474, 34569832304894588,55923317, 'OK'), -(600084713, 2703, 8342, 34569832304894570,8392636, 'OK'), -(600084732, 2704, 1625, 34569832304894513,75477452, 'OK'), -(600084850, 2705, 9896, 34569832304894653,28589813, 'OK'), -(600084951, 2706, 5520, 34569832304894661,75353012, 'OK'), -(600084978, 2707, 2698, 34569832304894679,9005523, 'OK'), -(600085403, 2708, 0837, 34569832304894646,77051152, 'OK'), -(600085513, 2709, 3106, 34569832304894687,41571002, 'OK'), -(600293916, 2712, 8990, 34569832304894620,95188676, 'OK'), -(600294160, 2714, 6376, 34569832304894703,79879896, 'OK'), -(671919529, 2975, 9184, 34569832304806236,7535392, 'OK'), -(671919942, 2981, 0328, 34569832304806269,31052894, 'OK'), -(671919530, 2976, 0344, 34569832304806251,89860304, 'OK'), -(671919533, 2977, 0668, 34569832304806244,42921771, 'OK'), -(671919535, 2978, 0105, 34569832304806277,31009417, 'OK'), -(671919537, 2979, 0881, 34569832304806285,33479769, 'OK'), -(671919540, 2980, 9874, 34569832304806293,14103929, 'OK'), -(671919525, 2972, 2089, 34569832304806301,45903729, 'OK'), -(671919527, 2973, 8206, 34569832304806368,1586035, 'OK'), -(671919528, 2974, 2532, 34569832304806327,62310124, 'OK'), -(673668717, 2836, 7973, 34562032301044223,15635496, 'OK'), -(673668734, 2837, 4457, 34562032301044231,18313118, 'OK'), -(673668738, 2824, 2911, 34562032301044249,30875583, 'OK'), -(673668745, 2838, 7253, 34562032301044256,62754222, 'OK'), -(673668796, 2839, 0068, 34562032301044264,15556829, 'OK'), -(673668803, 2840, 2386, 34562032301044272,17572287, 'OK'), -(673669591, 2850, 3833, 34562032301044280,34828896, 'OK'), -(673668808, 2841, 3584, 34562032301044298,16234497, 'OK'), -(673670102, 2851, 3554, 34562032301044306,23652625, 'OK'), -(673670131, 2852, 4412, 34562032301044314,88611709, 'OK'), -(673670135, 2827, 6058, 34562032301044322,53918579, 'OK'), -(673670201, 2828, 8066, 34562032301044330,92369343, 'OK'), -(673670225, 2829, 4592, 34562032301044348,24126635, 'OK'), -(673670236, 2830, 2974, 34562032301044355,88608465, 'OK'), -(673671485, 2849, 0349, 34562032301044363,44944874, 'OK'), -(673461977, 2871, 1728, 34562032400157090,46975780, 'OK'), -(673461975, 2870, 4734, 34562032400157082,69628432, 'OK'), -(673461972, 2867, 6276, 34562032400157058,53338365, 'OK'), -(673461979, 2872, 6043, 34562032400157108,36525197, 'OK'), -(673461958, 2859, 3164, 34562032400156977,58947831, 'OK'), -(673461957, 2857, 8685, 34562032400156969,15826386, 'OK'), -(673461944, 2853, 1073, 34562032400156910,20452195, 'OK'), -(673461974, 2869, 7121, 34562032400157074,32044645, 'OK'), -(673461973, 2868, 8022, 34562032400157066,29282044, 'OK'), -(673461971, 2866, 3089, 34562032400157041,66149978, 'OK'), -(673461969, 2865, 7555, 34562032400157033,78391293, 'OK'), -(673461960, 2860, 5203, 34562032400156985,37138232, 'OK'), -(673461952, 2855, 6915, 34562032400156936,62724661, 'OK'), -(673461949, 2854, 8706, 34562032400156928,5594345, 'OK'), -(673461966, 2863, 2496, 34562032400157017,93450666, 'OK'), -(673461968, 2864, 3703, 34562032400157025,23208841, 'OK'), -(673461963, 2862, 9364, 34562032400157009,29712130, 'OK'), -(673462719, 2873, 9387, 34562032400156951,50434348, 'OK'), -(673461962, 2861, 8441, 34562032400156993,39686909, 'OK'), -(673461956, 2826, 5392, 34562032400156944,5496107, 'OK'), -(673465284, 2694, 1523, 34562032400171349,14554994, 'OK'), -(673465282, 2692, 4645, 34562032400171323,24871187, 'OK'), -(673465283, 2693, 5253, 34562032400171331,28303238, 'OK'), -(673465841, 2696, 0849, 34562032400171257,21673222, 'OK'), -(673465258, 2679, 4140, 34562032400171174,39793881, 'OK'), -(673465263, 2680, 6922, 34562032400171182,12253261, 'OK'), -(673465265, 2681, 9112, 34562032400171190,93894366, 'OK'), -(673465267, 2682, 3259, 34562032400171208,2342189, 'OK'), -(673465268, 2683, 8540, 34562032400171216,63886925, 'OK'), -(673465285, 2695, 4167, 34562032400171356,79227618, 'OK'), -(673465270, 2684, 4292, 34562032400171224,19216349, 'OK'), -(673465272, 2685, 4007, 34562032400171232,14396903, 'OK'), -(673465273, 2686, 6894, 34562032400171240,13569394, 'OK'), -(673465274, 2687, 5268, 34562032400171265,59453667, 'OK'), -(673465275, 2688, 0232, 34562032400171273,62324713, 'OK'), -(673465276, 2689, 2720, 34562032400171281,65977200, 'OK'), -(673465843, 2698, 4773, 34562032400171364,78387158, 'OK'), -(673465842, 2697, 3729, 34562032400171315,94201789, 'OK'), -(673465280, 2691, 0503, 34562032400171307,12298533, 'OK'), -(673465279, 2690, 8239, 34562032400171299,76183877, 'OK'); \ No newline at end of file +(621188151, '2209', '1486', 3456985220092508,14213470), +(621188152, '2210', '8765', 3456985220092509,99473093), +(621188153, '2211', '3064', 3456985220092510,52967210), +(621188759, '2081', '3700', 3456985220123637,56600999), +(621188760, '2082', '3259', 345698522023638,87492404), +(621188761, '2083', '2790', 3456985220123639,94009456), +(621188762, '2084', '2480', 3456985220123644,1484999), +(621188763, '2085', '6876', 3456985220123641,36577064), +(621188766, '2086', '7775', 3456985220123642,80761698), +(621188769, '2088', '4027', 3456985220123643,37921712), +(621188771, '2089', '8797', 3456985220123640,63092540), +(621188772, '2090', '8404', 3456985220123645,21014997), +(621188773, '2091', '5481', 3456985220123646,16317277), +(621188774, '2092', '9632', 3456985220123647,22235994), +(621188775, '2093', '4654', 3456985220123648,28506486), +(621188838, '2094', '1392', 3456985220123649,29498627), +(621188839, '2095', '7774', 3456985220123650,46263490), +(621188840, '2096', '7304', 3456985220123658,8212044), +(621188841, '2097', '5569', 3456985220123652,81597658), +(621188842, '2098', '4944', 3456985220123653,24961501), +(621188843, '2099', '5142', 3456985220123654,17035634), +(621188844, '2111', '7245', 3456985220123655,90231951), +(621188846, '2110', '6590', 3456985220123656,72201537), +(667680207, '2564', '4042', 34569832200759166,48401979), +(667680315, '2565', '7143', 34569832200759372,32143252), +(667680318, '2566', '6342', 34569832200759364,39597112), +(667680413, '2567', '5580', 34569832200759356,32786992), +(667680463, '2568', '0171', 34569832200759349,34240853), +(667688217, '2569', '2500', 34569832200759331,5687589), +(633603945, '2212', '7129', 34569832200759323,51554019), +(622130186, '2213', '4826', 34569832200759307,19623551), +(633973424, '2214', '8535', 34569832200759299,94619307), +(633703828, '2215', '8628', 34569832200759281,22468012), +(622025110, '2216', '2399', 34569832200759273,34602918), +(622924867, '2217', '5665', 34569832200759265,26920216), +(722409630, '2218', '5211', 34569832200759240,93750137), +(623590529, '2219', '0493', 34569832200759208,47077088), +(633243462, '2220', '6902', 34569832200759174,6421962), +(633047286, '2221', '5592', 34569832200759182,32069439), +(744716801, '2112', '9184', 34569832200759190,57049814), +(655995021, '2131', '8896', 34569852202049093,19497356), +(685522718, '2132', '1955', 34569852202049101,28519879), +(674587213, '2994', '2006', 34569332200223743,62360135), +(674587227, '2993', '9271', 34569332200223750,81628192), +(674587229, '2993', '0900', 34569332200223768,91119071), +(674587231, '2992', '5007', 34569332200223776,45826232), +(674587234, '2991', '1378', 34569332200223784,91245744), +(674587240, '2990', '0905', 34569332200223792,13083224), +(674587245, '2989', '9059', 34569332200223800,15291807), +(674587250, '2988', '8188', 34569332200223818,83017918), +(674587254, '2987', '2962', 34569332200223826,92809271), +(674587256, '2986', '0358', 34569332200223834,81067040), +(674592713, '2570', '2537', 34569332200230672,82325850), +(697832478, '2579', '0936', 34568732200494825,49658372), +(697832176, '2571', '5944', 34568732200494742,19039461), +(697832477, '2572', '5138', 34568732200494759,25712504), +(697832178, '2573', '4597', 34568732200494767,66241760), +(697832182, '2574', '9241', 34568732200494775,07342562), +(697832196, '2575', '2995', 34568732200494783,53929026), +(697832214, '2576', '7434', 34568732200494791,49698432), +(697832230, '2577', '7004', 34568732200494809,21578612), +(697832235, '2578', '9674', 34568732200494817,93090700), +(673420375, '2599', '5430', 34562052300117259,35911412), +(673420367, '2598', '8402', 34562052300117242,924654), +(673420361, '2597', '5125', 34562052300117234,12027970), +(673420355, '2596', '5069', 34562052300117226,34978149), +(673420348, '2595', '8911', 34562052300117218,4228121), +(673420346, '2594', '2461', 34562052300117200,67670772), +(673420345, '2593', '2226', 34562052300117192,90586404), +(673420306, '2592', '3355', 34562052300117184,97850017), +(673420257, '2591', '9395', 34562052300117176,50713786), +(673420231, '2590', '1378', 34562052300117168,50151763), +(673420223, '2589', '9580', 34562052300117150,99534550), +(673420216, '2588', '4955', 34562052300117143,317554), +(673420203, '2587', '6742', 34562052300117135,69321531), +(673420201, '2586', '1659', 34562052300117127,54720480), +(673420199, '2585', '7823', 34562052300117119,22923796), +(673420198, '2584', '1787', 34562052300117101,54414630), +(673420168, '2583', '6334', 34562052300117093,50694894), +(673420147, '2582', '8951', 34562052300117085,1402535), +(673420125, '2581', '3068', 34562052300117077,86216200), +(673420124, '2580', '9517', 34562052300117069,42504099), +(600294609, '2715', '7474', 34569832304894588,55923317), +(600084713, '2703', '8342', 34569832304894570,8392636), +(600084732, '2704', '1625', 34569832304894513,75477452), +(600084850, '2705', '9896', 34569832304894653,28589813), +(600084951, '2706', '5520', 34569832304894661,75353012), +(600084978, '2707', '2698', 34569832304894679,9005523), +(600085403, '2708', '0837', 34569832304894646,77051152), +(600085513, '2709', '3106', 34569832304894687,41571002), +(600293916, '2712', '8990', 34569832304894620,95188676), +(600294160, '2714', '6376', 34569832304894703,79879896), +(671919529, '2975', '9184', 34569832304806236,7535392), +(671919942, '2981', '0328', 34569832304806269,31052894), +(671919530, '2976', '0344', 34569832304806251,89860304), +(671919533, '2977', '0668', 34569832304806244,42921771), +(671919535, '2978', '0105', 34569832304806277,31009417), +(671919537, '2979', '0881', 34569832304806285,33479769), +(671919540, '2980', '9874', 34569832304806293,14103929), +(671919525, '2972', '2089', 34569832304806301,45903729), +(671919527, '2973', '8206', 34569832304806368,1586035), +(671919528, '2974', '2532', 34569832304806327,62310124), +(673668717, '2836', '7973', 34562032301044223,15635496), +(673668734, '2837', '4457', 34562032301044231,18313118), +(673668738, '2824', '2911', 34562032301044249,30875583), +(673668745, '2838', '7253', 34562032301044256,62754222), +(673668796, '2839', '0068', 34562032301044264,15556829), +(673668803, '2840', '2386', 34562032301044272,17572287), +(673669591, '2850', '3833', 34562032301044280,34828896), +(673668808, '2841', '3584', 34562032301044298,16234497), +(673670102, '2851', '3554', 34562032301044306,23652625), +(673670131, '2852', '4412', 34562032301044314,88611709), +(673670135, '2827', '6058', 34562032301044322,53918579), +(673670201, '2828', '8066', 34562032301044330,92369343), +(673670225, '2829', '4592', 34562032301044348,24126635), +(673670236, '2830', '2974', 34562032301044355,88608465), +(673671485, '2849', '0349', 34562032301044363,44944874), +(673461977, '2871', '1728', 34562032400157090,46975780), +(673461975, '2870', '4734', 34562032400157082,69628432), +(673461972, '2867', '6276', 34562032400157058,53338365), +(673461979, '2872', '6043', 34562032400157108,36525197), +(673461958, '2859', '3164', 34562032400156977,58947831), +(673461957, '2857', '8685', 34562032400156969,15826386), +(673461944, '2853', '1073', 34562032400156910,20452195), +(673461974, '2869', '7121', 34562032400157074,32044645), +(673461973, '2868', '8022', 34562032400157066,29282044), +(673461971, '2866', '3089', 34562032400157041,66149978), +(673461969, '2865', '7555', 34562032400157033,78391293), +(673461960, '2860', '5203', 34562032400156985,37138232), +(673461952, '2855', '6915', 34562032400156936,62724661), +(673461949, '2854', '8706', 34562032400156928,5594345), +(673461966, '2863', '2496', 34562032400157017,93450666), +(673461968, '2864', '3703', 34562032400157025,23208841), +(673461963, '2862', '9364', 34562032400157009,29712130), +(673462719, '2873', '9387', 34562032400156951,50434348), +(673461962, '2861', '8441', 34562032400156993,39686909), +(673461956, '2826', '5392', 34562032400156944,5496107), +(673465284, '2694', '1523', 34562032400171349,14554994), +(673465282, '2692', '4645', 34562032400171323,24871187), +(673465283, '2693', '5253', 34562032400171331,28303238), +(673465841, '2696', '0849', 34562032400171257,21673222), +(673465258, '2679', '4140', 34562032400171174,39793881), +(673465263, '2680', '6922', 34562032400171182,12253261), +(673465265, '2681', '9112', 34562032400171190,93894366), +(673465267, '2682', '3259', 34562032400171208,2342189), +(673465268, '2683', '8540', 34562032400171216,63886925), +(673465285, '2695', '4167', 34562032400171356,79227618), +(673465270, '2684', '4292', 34562032400171224,19216349), +(673465272, '2685', '4007', 34562032400171232,14396903), +(673465273, '2686', '6894', 34562032400171240,13569394), +(673465274, '2687', '5268', 34562032400171265,59453667), +(673465275, '2688', '0232', 34562032400171273,62324713), +(673465276, '2689', '2720', 34562032400171281,65977200), +(673465843, '2698', '4773', 34562032400171364,78387158), +(673465842, '2697', '3729', 34562032400171315,94201789), +(673465280, '2691', '0503', 34562032400171307,12298533), +(673465279, '2690', '8239', 34562032400171299,76183877); \ No newline at end of file From 252a029c988453229b53008e1902d2b276414ce3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Dec 2024 11:41:42 +0100 Subject: [PATCH 061/108] feat: refs #7882 Osrm service --- modules/client/back/methods/client/updateAddress.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index 7342b28f1..797aefe11 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -72,6 +72,14 @@ module.exports = function(Self) { { arg: 'isLogifloraAllowed', type: 'boolean' + }, + { + arg: 'longitude', + type: 'number', + }, + { + arg: 'latitude', + type: 'number', } ], returns: { From 093fdb6cb328aadaf1e3b6d20d4392f64f0db483 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 11 Dec 2024 11:50:16 +0100 Subject: [PATCH 062/108] fix: refs #6389 back --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 6c98f6cd7..95713f9fb 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -165,8 +165,6 @@ module.exports = Self => { case 'clientFk': param = `t.${param}`; return {[param]: value}; - case 'packing': - return {'i.itemPackingTypeFk': value}; } }); @@ -380,6 +378,7 @@ module.exports = Self => { } case 'agencyModeFk': case 'warehouseFk': + case 'packing': case 'countryFk': param = `f.${param}`; return {[param]: value}; From 186ef5251832650c939f7437fd6d740857801370 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Dec 2024 14:55:26 +0100 Subject: [PATCH 063/108] feat: refs #7882 Osrm service --- back/methods/osrm-config/optimize.js | 15 +++++++++++++-- loopback/locale/es.json | 6 +++--- .../route/back/methods/route/optimizePriority.js | 13 ++++++++----- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index c03b70315..ae700d1cc 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -24,7 +24,7 @@ module.exports = Self => { } }); - Self.optimize = async(addressIds, firstAddressId) => { + Self.optimize = async(addressIds, firstAddressId, lastAddressId) => { const models = Self.app.models; try { const osrmConfig = await models.OsrmConfig.findOne(); @@ -53,13 +53,24 @@ module.exports = Self => { } } + if (lastAddressId) { + const firstAddress = await models.Address.findById(lastAddressId); + if (firstAddress.latitude && firstAddress.longitude) { + coords.push({ + addressId: firstAddress.id, + latitude: firstAddress.latitude.toFixed(6), + longitude: firstAddress.longitude.toFixed(6) + }); + } + } + if (!coords.length) throw new UserError('No address has coordinates'); const concatCoords = coords .map(coord => `${coord.longitude},${coord.latitude}`) .join(';'); const response = await axios.post(` - ${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&roundtrip=true + ${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&destination=last&roundtrip=true `); const tolerance = osrmConfig.tolerance; for (waypoint of response.data.waypoints) { diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 7e2253059..5f595e1ae 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -396,6 +396,6 @@ "Invalid options or too many coordinates": "Opciones invalidas o demasiadas coordenadas", "No address has coordinates": "Ninguna dirección tiene coordenadas", "An item type with the same code already exists": "Un tipo con el mismo código ya existe", - "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles" -} - + "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", + "All tickets have a route order": "Todos los tickets tienen orden de ruta" +} \ No newline at end of file diff --git a/modules/route/back/methods/route/optimizePriority.js b/modules/route/back/methods/route/optimizePriority.js index f84af50f8..c31913c66 100644 --- a/modules/route/back/methods/route/optimizePriority.js +++ b/modules/route/back/methods/route/optimizePriority.js @@ -71,13 +71,16 @@ module.exports = Self => { }, {}); const [mostFrequentZoneId] = Object.entries(zoneFrequency) .reduce((maxEntry, entry) => entry[1] > maxEntry[1] ? entry : maxEntry, [null, 0]); - const zone = await models.Zone.findById(mostFrequentZoneId, myOptions); - let firstAddress = zone.addressFk; - if (!firstAddress) firstAddress = (await models.ZoneConfig.findOne()).defaultAddressFk; + + // Obtenemos los address inicio y fin + const maxPosition = Math.max(...ticketAddress.map(g => g.priority)); + let firstAddress = (await models.Zone.findById(mostFrequentZoneId, myOptions))?.addressFk + || (await models.ZoneConfig.findOne())?.defaultAddressFk; + const lastAddress = firstAddress; + if (maxPosition) firstAddress = ticketAddress.find(g => g.priority === maxPosition)?.addressId; // Revisamos las coincidencias y actualizamos la prioridad en el array - const addressPositions = await models.OsrmConfig.optimize(addressIds, firstAddress, myOptions); - const maxPosition = Math.max(...ticketAddress.map(g => g.priority)); + const addressPositions = await models.OsrmConfig.optimize(addressIds, firstAddress, lastAddress, myOptions); await Promise.all(ticketAddress.map(async i => { const foundPosition = addressPositions.coords.find(item => item.addressId === i.addressId); if (foundPosition) i.priority = foundPosition.position + (maxPosition + 1); From addb093b6b37a76c19bce6b299cd0eb25c65b589 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 11 Dec 2024 17:42:03 +0100 Subject: [PATCH 064/108] feat: refs #7936 add minimum due date --- modules/invoiceIn/back/methods/invoice-in/filter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index c549769ab..f081368e4 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -189,7 +189,8 @@ module.exports = Self => { s.account, SUM(iid.amount) amount, sub.code awbCode, - c.code + c.code, + MIN(iid.dueDated) dueDated FROM invoiceIn ii JOIN supplier s ON s.id = ii.supplierFk LEFT JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id From aba2bf60828eec96019c90d728c259b687677fb3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 12 Dec 2024 08:12:16 +0100 Subject: [PATCH 065/108] fix: refs #8251 add eng template --- .../incoterms-authorization/locale/en.yml | 6 +++ .../balance-compensation/locale/en.yml | 16 ++++++++ .../incoterms-authorization/locale/en.yml | 39 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 print/templates/email/incoterms-authorization/locale/en.yml create mode 100644 print/templates/reports/balance-compensation/locale/en.yml create mode 100644 print/templates/reports/incoterms-authorization/locale/en.yml diff --git a/print/templates/email/incoterms-authorization/locale/en.yml b/print/templates/email/incoterms-authorization/locale/en.yml new file mode 100644 index 000000000..7e1402575 --- /dev/null +++ b/print/templates/email/incoterms-authorization/locale/en.yml @@ -0,0 +1,6 @@ +subject: Incoterms Authorization +title: Incoterms Authorization +description: + dear: Dear customer + instructions: Please find attached the Incoterms authorization form, which you must complete and sign. + conclusion: Thank you for your attention! diff --git a/print/templates/reports/balance-compensation/locale/en.yml b/print/templates/reports/balance-compensation/locale/en.yml new file mode 100644 index 000000000..824127482 --- /dev/null +++ b/print/templates/reports/balance-compensation/locale/en.yml @@ -0,0 +1,16 @@ +reportName: balance-compensation +Place: Algemesí, on +Compensation: Compensation of debtor and creditor balances +In one hand: On one hand +CIF: with CIF +NIF: with NIF +Home: and address located at +In other hand: On the other hand +Sr: Mr./Ms. +Agree: Agree +Date: On the date of +Compensate: the balance of has been compensated +From client: from the client/supplier +Against the balance of: against the balance of +Reception: Please confirm receipt of this compensation at the email +Greetings: Best regards, diff --git a/print/templates/reports/incoterms-authorization/locale/en.yml b/print/templates/reports/incoterms-authorization/locale/en.yml new file mode 100644 index 000000000..eb6a8a513 --- /dev/null +++ b/print/templates/reports/incoterms-authorization/locale/en.yml @@ -0,0 +1,39 @@ +reportName: autorization-incoterms +description: '{socialName} a duly constituted and responsible company limited +and registered under corporate law {country} and here represented by {socialName}, with address in {address}, +CIF {fiscalID}. Hereinafter referred to as {name}.' +issued: 'In {0}, on {1} of {2} of {3}' +client: 'Customer {0}' +declaration: '{socialName} hereby declares that:' +declarations: + - 'All purchases made by {socialName} with {companyName} They are delivered according to the conditions defined in the Incoterm.' + - '{socialName} recognizes that it is important for {companyName} have +proof of intra-community delivery of the goods to {destinationCountry} to +be able to invoice with 0% VAT.' + - 'Therefore, by signing this agreement, {socialName} declares that all goods +purchased from {companyName} will be delivered to {destinationCountry}.' + - 'Besides, {socialName} shall, at the first request of {companyName}, +provide proof that all products purchased from {companyName} have +been delivered in {destinationCountry}.' + - 'In addition to the above, {companyName} will provide to {socialName} +a monthly summary that includes all bills (and corresponding deliveries). +{socialName} will sign and return the monthly summary to {companyName}, +S.L. within 5 days of receiving the summary.' +signer: + representative: Representative + representativeRole: Position of the representative + signed: Date of signature +manager: Manager +months: + - 'January' + - 'February' + - 'March' + - 'April' + - 'May' + - 'June' + - 'July' + - 'August' + - 'September' + - 'October' + - 'November' + - 'December' From 65e195d77d7bd51c451677e45d162fd5ef08d7b0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Dec 2024 08:23:02 +0100 Subject: [PATCH 066/108] feat: refs #7882 Requested changes --- back/methods/osrm-config/optimize.js | 12 ++++++------ modules/client/back/methods/client/updateAddress.js | 4 ++-- modules/route/back/methods/route/optimizePriority.js | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index ae700d1cc..3a68c7ef4 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -32,12 +32,12 @@ module.exports = Self => { let coords = []; if (firstAddressId) { - const firstAddress = await models.Address.findById(firstAddressId); - if (firstAddress.latitude && firstAddress.longitude) { + const address = await models.Address.findById(firstAddressId); + if (address.latitude && address.longitude) { coords.push({ - addressId: firstAddress.id, - latitude: firstAddress.latitude.toFixed(6), - longitude: firstAddress.longitude.toFixed(6) + addressId: address.id, + latitude: address.latitude.toFixed(6), + longitude: address.longitude.toFixed(6) }); } } @@ -73,7 +73,7 @@ module.exports = Self => { ${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&destination=last&roundtrip=true `); const tolerance = osrmConfig.tolerance; - for (waypoint of response.data.waypoints) { + for (const waypoint of response.data.waypoints) { const longitude = waypoint.location[0]; const latitude = waypoint.location[1]; diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index 797aefe11..efef83d6b 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -75,11 +75,11 @@ module.exports = function(Self) { }, { arg: 'longitude', - type: 'number', + type: 'any', }, { arg: 'latitude', - type: 'number', + type: 'any', } ], returns: { diff --git a/modules/route/back/methods/route/optimizePriority.js b/modules/route/back/methods/route/optimizePriority.js index c31913c66..f0ac76d8a 100644 --- a/modules/route/back/methods/route/optimizePriority.js +++ b/modules/route/back/methods/route/optimizePriority.js @@ -28,17 +28,17 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const ticketsIds = await models.Ticket.find({ + const tickets = await models.Ticket.find({ where: {routeFk: id} }, myOptions); let ticketAddress = []; - for (const ticketId of ticketsIds) { + for (const ticket of tickets) { ticketAddress.push({ - ticketId: ticketId.id, - addressId: ticketId.addressFk, - zoneId: ticketId.zoneFk, - priority: ticketId.priority + ticketId: ticket.id, + addressId: ticket.addressFk, + zoneId: ticket.zoneFk, + priority: ticket.priority }); } From c8f26bbbab67cc82117baa7846a4bf5c2ef1417d Mon Sep 17 00:00:00 2001 From: Jtubau Date: Thu, 12 Dec 2024 08:42:10 +0100 Subject: [PATCH 067/108] refactor: refs #8266 changed expedition item name --- modules/ticket/back/methods/expedition/filter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js index 43be14349..bd2012668 100644 --- a/modules/ticket/back/methods/expedition/filter.js +++ b/modules/ticket/back/methods/expedition/filter.js @@ -49,7 +49,8 @@ module.exports = Self => { es.workerFk expeditionScanWorkerFk, su.name scannerUserName, es.scanned, - est.description state + est.description state, + de.longName FROM vn.expedition e LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk INNER JOIN vn.item i1 ON i1.id = e.freightItemFk @@ -59,6 +60,7 @@ module.exports = Self => { LEFT JOIN account.user u ON u.id = e.workerFk LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id LEFT JOIN account.user su ON su.id = es.workerFk + LEFT JOIN dipole.expedition_PrintOut de ON de.expeditionFk = e.id ) e `); stmt.merge(conn.makeWhere(filter.where)); From b5d4d31abbefcc2fa0ef44ab57d87cc374c31cf5 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 12 Dec 2024 09:25:51 +0100 Subject: [PATCH 068/108] fix: refs #7301 update ACL insertion to use INSERT IGNORE and refine property value --- db/versions/11352-blackErica/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11352-blackErica/00-firstScript.sql b/db/versions/11352-blackErica/00-firstScript.sql index 4e17c94c5..659f50161 100644 --- a/db/versions/11352-blackErica/00-firstScript.sql +++ b/db/versions/11352-blackErica/00-firstScript.sql @@ -1,3 +1,3 @@ -- Place your SQL code here -INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId, editorFk) - VALUES('InventoryConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer', 100); \ No newline at end of file +INSERT IGNORE INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES('InventoryConfig', 'find', 'READ', 'ALLOW', 'ROLE', 'buyer'); \ No newline at end of file From efcf4d225b5e0aae5f9f68957bd2defd0e913bf5 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 12 Dec 2024 09:30:22 +0100 Subject: [PATCH 069/108] fix: refs #7028 fix pr --- loopback/locale/es.json | 3 ++- modules/ticket/back/methods/ticket-request/deny.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 0dc8e53a8..b4b5ee7c6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -392,6 +392,7 @@ "The raid information is not correct": "La información de la redada no es correcta", "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", "An item type with the same code already exists": "Un tipo con el mismo código ya existe", - "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles" + "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", + "Worker not found": "Trabajador no encontrado" } diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index cb13c2728..2f710ad3a 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -42,7 +42,7 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; - const worker = await models.Worker.findOne({where: {id: userId}}, myOptions); + const worker = await models.Worker.findById({where: {id: userId}}, myOptions); if (!worker) throw new Error('Worker not found'); const params = { @@ -76,7 +76,7 @@ module.exports = Self => { observation: params.response }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message); + await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); await request.updateAttributes(params, myOptions); if (tx) await tx.commit(); From 1970b9c0db6cb4c5f6285c2e9cbca9a1c83822a5 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 12 Dec 2024 10:04:31 +0100 Subject: [PATCH 070/108] fix: refs #7028 fix tback findById --- modules/ticket/back/methods/ticket-request/deny.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index 2f710ad3a..f151afd6b 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -42,7 +42,7 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; - const worker = await models.Worker.findById({where: {id: userId}}, myOptions); + const worker = await models.Worker.findById(userId, myOptions); if (!worker) throw new Error('Worker not found'); const params = { From cd214b3526d204581562730405e17451b7897122 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 12 Dec 2024 11:11:22 +0100 Subject: [PATCH 071/108] fix: refs #7028 fix userError --- loopback/locale/es.json | 4 +++- modules/ticket/back/methods/ticket-request/deny.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e0b180544..d7fcb8805 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -394,5 +394,7 @@ "Price cannot be blank": "Price cannot be blank", "An item type with the same code already exists": "Un tipo con el mismo código ya existe", "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", - "Worker not found": "Trabajador no encontrado" + "Worker not found": "Trabajador no encontrado", + "Invalid request or related ticket/client data": "Solicitud no válida o datos de ticket/cliente relacionados" + } diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index f151afd6b..c6a1d35af 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('deny', { description: 'Sets a ticket request to denied and returns the changes', @@ -43,7 +44,7 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; const worker = await models.Worker.findById(userId, myOptions); - if (!worker) throw new Error('Worker not found'); + if (!worker) throw new UserError('Worker not found'); const params = { isOk: false, @@ -66,7 +67,7 @@ module.exports = Self => { }, myOptions); if (!request || !request.ticket() || !request.ticket().client()) - throw new Error('Invalid request or related ticket/client data'); + throw new UserError('Invalid request or related ticket/client data'); const url = await models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk; From c83f34859a02228e273b267e0e8717c5cc87df9e Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 12 Dec 2024 11:20:23 +0100 Subject: [PATCH 072/108] feat: refs #7936 return country code & is vies fields --- modules/invoiceIn/back/methods/invoice-in/summary.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/summary.js b/modules/invoiceIn/back/methods/invoice-in/summary.js index fe198b2b4..b3fd9ee97 100644 --- a/modules/invoiceIn/back/methods/invoice-in/summary.js +++ b/modules/invoiceIn/back/methods/invoice-in/summary.js @@ -37,7 +37,13 @@ module.exports = Self => { { relation: 'supplier', scope: { - fields: ['id', 'name'] + fields: ['id', 'name', 'isVies', 'countryFk'], + include: [{ + relation: 'country', + scope: { + fields: ['id', 'code'] + } + }] } }, { From 05ba85219b5f91a2351eb4256c11f3211bad0838 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Dec 2024 14:35:58 +0100 Subject: [PATCH 073/108] feat: refs #7882 Osrm service --- back/methods/osrm-config/optimize.js | 8 +------- db/dump/fixtures.before.sql | 3 +++ modules/route/back/methods/route/optimizePriority.js | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index 3a68c7ef4..5d2ade935 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -91,13 +91,7 @@ module.exports = Self => { return posA - posB; }); - const coordsString = coords - .map(item => `point=${item.latitude},${item.longitude}`) - .join('&'); - return { - coords, - view: `https://graphhopper.com/maps/?${coordsString}&profile=small_truck` - }; + return coords; } catch (err) { switch (err.response?.data?.code) { case 'NoTrips': diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 663705ff5..84e007695 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4035,3 +4035,6 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate) VALUES (1106,'26493101E','2019-09-20'); + +INSERT INTO vn.osrmConfig (id,url,tolerance) + VALUES (1,'https://router.project-osrm.org', 0.002); diff --git a/modules/route/back/methods/route/optimizePriority.js b/modules/route/back/methods/route/optimizePriority.js index f0ac76d8a..56db4ffb5 100644 --- a/modules/route/back/methods/route/optimizePriority.js +++ b/modules/route/back/methods/route/optimizePriority.js @@ -82,7 +82,7 @@ module.exports = Self => { // Revisamos las coincidencias y actualizamos la prioridad en el array const addressPositions = await models.OsrmConfig.optimize(addressIds, firstAddress, lastAddress, myOptions); await Promise.all(ticketAddress.map(async i => { - const foundPosition = addressPositions.coords.find(item => item.addressId === i.addressId); + const foundPosition = addressPositions.find(item => item.addressId === i.addressId); if (foundPosition) i.priority = foundPosition.position + (maxPosition + 1); })); From 00b5333ab7edbb02d04df8ca053217462e79147b Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 13 Dec 2024 08:07:13 +0100 Subject: [PATCH 074/108] feat: refs #7882 Added tests --- .../osrm-config/specs/optimize.spec.js | 33 +++++++++++++++++ db/dump/fixtures.before.sql | 10 +++--- .../route/specs/optimizePriority.spec.js | 36 +++++++++++++++++++ 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 back/methods/osrm-config/specs/optimize.spec.js create mode 100644 modules/route/back/methods/route/specs/optimizePriority.spec.js diff --git a/back/methods/osrm-config/specs/optimize.spec.js b/back/methods/osrm-config/specs/optimize.spec.js new file mode 100644 index 000000000..9f2adccc6 --- /dev/null +++ b/back/methods/osrm-config/specs/optimize.spec.js @@ -0,0 +1,33 @@ +const models = require('vn-loopback/server/server').models; + +describe('osrmConfig optimize()', function() { + it('should send coords, receive OSRM response, and return a correctly ordered result', async function() { + const result = await models.OsrmConfig.optimize([4, 3], 1, 2); + + // Verifications + expect(Array.isArray(result)).toBe(true); + expect(result.length).toBe(4); + + // Check the order + expect(result[0].addressId).toBe(1); + expect(result[1].addressId).toBe(4); + expect(result[2].addressId).toBe(3); + expect(result[3].addressId).toBe(2); + + // Check the coordinates format + expect(result[0].latitude).toBe('10.111111'); + expect(result[0].longitude).toBe('-74.111111'); + }); + + it('should throw an error if no addresses are provided', async function() { + let error; + try { + await models.OsrmConfig.optimize([], null); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + expect(error.message).toBe('No address has coordinates'); + }); +}); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index d3823a5b7..c108bc0f6 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -428,10 +428,10 @@ INSERT INTO `vn`.`clientConfig`(`id`, `riskTolerance`, `maxCreditRows`, `maxPric INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`) VALUES - (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1), - (2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1), - (3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1), - (4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1 , 1104, 2, NULL, NULL, 0, 1), + (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, -74.1111111, 10.1111111, 0, 1), + (2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, -74.2222222, 10.2222222, 0, 1), + (3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, -74.3333333, 10.3333333, 0, 1), + (4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1 , 1104, 2, -74.4444444, 10.4444444, 0, 1), (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1), (6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1), (7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1), @@ -462,7 +462,7 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr (120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), (121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0), (122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0), - (123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0), + (123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, -74.555555, 10.555555, 0, 0), (124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0), (125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0), (126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0), diff --git a/modules/route/back/methods/route/specs/optimizePriority.spec.js b/modules/route/back/methods/route/specs/optimizePriority.spec.js new file mode 100644 index 000000000..c1c2dc45e --- /dev/null +++ b/modules/route/back/methods/route/specs/optimizePriority.spec.js @@ -0,0 +1,36 @@ +const models = require('vn-loopback/server/server').models; +const routeId = 1; + +describe('route optimizePriority())', function() { + it('should execute without throwing errors', async function() { + const tx = await models.Route.beginTransaction({}); + let error; + try { + const options = {transaction: tx}; + await models.Ticket.updateAll( + {routeFk: routeId}, + {priority: null}, + options + ); + await models.Route.optimizePriority(routeId, options); + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error).toBeUndefined(); + }); + + it('should execute with error', async function() { + let error; + try { + await models.Route.optimizePriority(routeId); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + expect(error.message).toBe('All tickets have a route order'); + }); +}); From ec2b6dd0c2fbf3605cd594e7a00375ff43cdf5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 13 Dec 2024 14:55:03 +0000 Subject: [PATCH 075/108] Actualizar db/versions/11327-maroonOak/00-firstScript.sql --- db/versions/11327-maroonOak/00-firstScript.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 250a2fc8b..35ec989e7 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -13,9 +13,6 @@ CREATE TABLE IF NOT EXISTS `vn`.`simSupplier` ( ALTER TABLE `vn`.`deviceProductionUser` MODIFY `simSerialNumber` VARCHAR(25); -ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK - FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim); - INSERT IGNORE INTO `vn`.`simSupplier` (`line`, `ext`, `pin`, `sim`, `puk`) VALUES (621188151, '2209', '1486', 3456985220092508,14213470), @@ -174,4 +171,7 @@ VALUES (673465843, '2698', '4773', 34562032400171364,78387158), (673465842, '2697', '3729', 34562032400171315,94201789), (673465280, '2691', '0503', 34562032400171307,12298533), -(673465279, '2690', '8239', 34562032400171299,76183877); \ No newline at end of file +(673465279, '2690', '8239', 34562032400171299,76183877); + +ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK + FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file From 233f45a07a1e45493dd8a360d83758e06bcbc2fb Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 07:15:47 +0100 Subject: [PATCH 076/108] feat: refs #7882 Reequested changes --- back/methods/osrm-config/optimize.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index 5d2ade935..e0412c74c 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -13,6 +13,10 @@ module.exports = Self => { arg: 'firstAddressId', type: 'number', required: false + }, { + arg: 'lastAddressId', + type: 'number', + required: false }], returns: { type: 'object', From 9c32dc5707630b5c67a183409465015946348e61 Mon Sep 17 00:00:00 2001 From: Jtubau Date: Mon, 16 Dec 2024 08:34:53 +0100 Subject: [PATCH 077/108] feat: refs #8293 include zone data --- modules/claim/back/methods/claim/filter.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index f60b6572e..bacdd4021 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -80,6 +80,12 @@ module.exports = Self => { description: 'The claimResponsible id', http: {source: 'query'} }, + { + arg: 'zoneFk', + type: 'string', + description: 'The zone name', + http: {source: 'query'} + }, { arg: 'myTeam', type: 'boolean', @@ -174,6 +180,8 @@ module.exports = Self => { to.setHours(23, 59, 59, 999); return {'cl.created': {between: [value, to]}}; + case 'zoneFk': + return {'t.zoneFk': value}; case 'myTeam': if (value) return {'cl.workerFk': {inq: teamMembersId}}; @@ -195,11 +203,15 @@ module.exports = Self => { u.name AS workerName, cs.code stateCode, cs.description stateDescription, - cl.created + cl.created, + z.name zoneName, + z.id zoneId FROM claim cl LEFT JOIN client c ON c.id = cl.clientFk LEFT JOIN account.user u ON u.id = cl.workerFk - LEFT JOIN claimState cs ON cs.id = cl.claimStateFk` + LEFT JOIN claimState cs ON cs.id = cl.claimStateFk + LEFT JOIN ticket t ON t.id = cl.ticketFk + LEFT JOIN zone z ON z.id = t.zoneFk` ); stmt.merge(conn.makeSuffix(filter)); From 57c3cc854622b3f64c721fa78b049d19e8549a75 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 09:01:10 +0100 Subject: [PATCH 078/108] feat: refs #8174 Created table sim --- .../11327-maroonOak/00-firstScript.sql | 354 +++++++++--------- 1 file changed, 180 insertions(+), 174 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 35ec989e7..7c9d8e6e8 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -1,177 +1,183 @@ -CREATE TABLE IF NOT EXISTS `vn`.`simSupplier` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `line` INT(9) unsigned NOT NULL, - `ext` CHAR(4) NOT NULL CHECK (ext REGEXP '^[0-9]{4}$'), - `pin` CHAR(4) NOT NULL CHECK (pin REGEXP '^[0-9]{4}$'), - `sim` VARCHAR(25), - `puk` INT(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `sim_UNIQUE` (`sim`) -) ENGINE=InnoDB AUTO_INCREMENT=1 - DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +CREATE TABLE IF NOT EXISTS `vn`.`sim` ( + `id` BIGINT UNSIGNED, + `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), + `ext` INT(4) NOT NULL, + `pin` INT(4) NOT NULL, + `puk` INT(15) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -ALTER TABLE `vn`.`deviceProductionUser` -MODIFY `simSerialNumber` VARCHAR(25); +ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk BIGINT unsigned DEFAULT NULL NULL; +ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk BIGINT unsigned DEFAULT NULL NULL; -INSERT IGNORE INTO `vn`.`simSupplier` (`line`, `ext`, `pin`, `sim`, `puk`) -VALUES -(621188151, '2209', '1486', 3456985220092508,14213470), -(621188152, '2210', '8765', 3456985220092509,99473093), -(621188153, '2211', '3064', 3456985220092510,52967210), -(621188759, '2081', '3700', 3456985220123637,56600999), -(621188760, '2082', '3259', 345698522023638,87492404), -(621188761, '2083', '2790', 3456985220123639,94009456), -(621188762, '2084', '2480', 3456985220123644,1484999), -(621188763, '2085', '6876', 3456985220123641,36577064), -(621188766, '2086', '7775', 3456985220123642,80761698), -(621188769, '2088', '4027', 3456985220123643,37921712), -(621188771, '2089', '8797', 3456985220123640,63092540), -(621188772, '2090', '8404', 3456985220123645,21014997), -(621188773, '2091', '5481', 3456985220123646,16317277), -(621188774, '2092', '9632', 3456985220123647,22235994), -(621188775, '2093', '4654', 3456985220123648,28506486), -(621188838, '2094', '1392', 3456985220123649,29498627), -(621188839, '2095', '7774', 3456985220123650,46263490), -(621188840, '2096', '7304', 3456985220123658,8212044), -(621188841, '2097', '5569', 3456985220123652,81597658), -(621188842, '2098', '4944', 3456985220123653,24961501), -(621188843, '2099', '5142', 3456985220123654,17035634), -(621188844, '2111', '7245', 3456985220123655,90231951), -(621188846, '2110', '6590', 3456985220123656,72201537), -(667680207, '2564', '4042', 34569832200759166,48401979), -(667680315, '2565', '7143', 34569832200759372,32143252), -(667680318, '2566', '6342', 34569832200759364,39597112), -(667680413, '2567', '5580', 34569832200759356,32786992), -(667680463, '2568', '0171', 34569832200759349,34240853), -(667688217, '2569', '2500', 34569832200759331,5687589), -(633603945, '2212', '7129', 34569832200759323,51554019), -(622130186, '2213', '4826', 34569832200759307,19623551), -(633973424, '2214', '8535', 34569832200759299,94619307), -(633703828, '2215', '8628', 34569832200759281,22468012), -(622025110, '2216', '2399', 34569832200759273,34602918), -(622924867, '2217', '5665', 34569832200759265,26920216), -(722409630, '2218', '5211', 34569832200759240,93750137), -(623590529, '2219', '0493', 34569832200759208,47077088), -(633243462, '2220', '6902', 34569832200759174,6421962), -(633047286, '2221', '5592', 34569832200759182,32069439), -(744716801, '2112', '9184', 34569832200759190,57049814), -(655995021, '2131', '8896', 34569852202049093,19497356), -(685522718, '2132', '1955', 34569852202049101,28519879), -(674587213, '2994', '2006', 34569332200223743,62360135), -(674587227, '2993', '9271', 34569332200223750,81628192), -(674587229, '2993', '0900', 34569332200223768,91119071), -(674587231, '2992', '5007', 34569332200223776,45826232), -(674587234, '2991', '1378', 34569332200223784,91245744), -(674587240, '2990', '0905', 34569332200223792,13083224), -(674587245, '2989', '9059', 34569332200223800,15291807), -(674587250, '2988', '8188', 34569332200223818,83017918), -(674587254, '2987', '2962', 34569332200223826,92809271), -(674587256, '2986', '0358', 34569332200223834,81067040), -(674592713, '2570', '2537', 34569332200230672,82325850), -(697832478, '2579', '0936', 34568732200494825,49658372), -(697832176, '2571', '5944', 34568732200494742,19039461), -(697832477, '2572', '5138', 34568732200494759,25712504), -(697832178, '2573', '4597', 34568732200494767,66241760), -(697832182, '2574', '9241', 34568732200494775,07342562), -(697832196, '2575', '2995', 34568732200494783,53929026), -(697832214, '2576', '7434', 34568732200494791,49698432), -(697832230, '2577', '7004', 34568732200494809,21578612), -(697832235, '2578', '9674', 34568732200494817,93090700), -(673420375, '2599', '5430', 34562052300117259,35911412), -(673420367, '2598', '8402', 34562052300117242,924654), -(673420361, '2597', '5125', 34562052300117234,12027970), -(673420355, '2596', '5069', 34562052300117226,34978149), -(673420348, '2595', '8911', 34562052300117218,4228121), -(673420346, '2594', '2461', 34562052300117200,67670772), -(673420345, '2593', '2226', 34562052300117192,90586404), -(673420306, '2592', '3355', 34562052300117184,97850017), -(673420257, '2591', '9395', 34562052300117176,50713786), -(673420231, '2590', '1378', 34562052300117168,50151763), -(673420223, '2589', '9580', 34562052300117150,99534550), -(673420216, '2588', '4955', 34562052300117143,317554), -(673420203, '2587', '6742', 34562052300117135,69321531), -(673420201, '2586', '1659', 34562052300117127,54720480), -(673420199, '2585', '7823', 34562052300117119,22923796), -(673420198, '2584', '1787', 34562052300117101,54414630), -(673420168, '2583', '6334', 34562052300117093,50694894), -(673420147, '2582', '8951', 34562052300117085,1402535), -(673420125, '2581', '3068', 34562052300117077,86216200), -(673420124, '2580', '9517', 34562052300117069,42504099), -(600294609, '2715', '7474', 34569832304894588,55923317), -(600084713, '2703', '8342', 34569832304894570,8392636), -(600084732, '2704', '1625', 34569832304894513,75477452), -(600084850, '2705', '9896', 34569832304894653,28589813), -(600084951, '2706', '5520', 34569832304894661,75353012), -(600084978, '2707', '2698', 34569832304894679,9005523), -(600085403, '2708', '0837', 34569832304894646,77051152), -(600085513, '2709', '3106', 34569832304894687,41571002), -(600293916, '2712', '8990', 34569832304894620,95188676), -(600294160, '2714', '6376', 34569832304894703,79879896), -(671919529, '2975', '9184', 34569832304806236,7535392), -(671919942, '2981', '0328', 34569832304806269,31052894), -(671919530, '2976', '0344', 34569832304806251,89860304), -(671919533, '2977', '0668', 34569832304806244,42921771), -(671919535, '2978', '0105', 34569832304806277,31009417), -(671919537, '2979', '0881', 34569832304806285,33479769), -(671919540, '2980', '9874', 34569832304806293,14103929), -(671919525, '2972', '2089', 34569832304806301,45903729), -(671919527, '2973', '8206', 34569832304806368,1586035), -(671919528, '2974', '2532', 34569832304806327,62310124), -(673668717, '2836', '7973', 34562032301044223,15635496), -(673668734, '2837', '4457', 34562032301044231,18313118), -(673668738, '2824', '2911', 34562032301044249,30875583), -(673668745, '2838', '7253', 34562032301044256,62754222), -(673668796, '2839', '0068', 34562032301044264,15556829), -(673668803, '2840', '2386', 34562032301044272,17572287), -(673669591, '2850', '3833', 34562032301044280,34828896), -(673668808, '2841', '3584', 34562032301044298,16234497), -(673670102, '2851', '3554', 34562032301044306,23652625), -(673670131, '2852', '4412', 34562032301044314,88611709), -(673670135, '2827', '6058', 34562032301044322,53918579), -(673670201, '2828', '8066', 34562032301044330,92369343), -(673670225, '2829', '4592', 34562032301044348,24126635), -(673670236, '2830', '2974', 34562032301044355,88608465), -(673671485, '2849', '0349', 34562032301044363,44944874), -(673461977, '2871', '1728', 34562032400157090,46975780), -(673461975, '2870', '4734', 34562032400157082,69628432), -(673461972, '2867', '6276', 34562032400157058,53338365), -(673461979, '2872', '6043', 34562032400157108,36525197), -(673461958, '2859', '3164', 34562032400156977,58947831), -(673461957, '2857', '8685', 34562032400156969,15826386), -(673461944, '2853', '1073', 34562032400156910,20452195), -(673461974, '2869', '7121', 34562032400157074,32044645), -(673461973, '2868', '8022', 34562032400157066,29282044), -(673461971, '2866', '3089', 34562032400157041,66149978), -(673461969, '2865', '7555', 34562032400157033,78391293), -(673461960, '2860', '5203', 34562032400156985,37138232), -(673461952, '2855', '6915', 34562032400156936,62724661), -(673461949, '2854', '8706', 34562032400156928,5594345), -(673461966, '2863', '2496', 34562032400157017,93450666), -(673461968, '2864', '3703', 34562032400157025,23208841), -(673461963, '2862', '9364', 34562032400157009,29712130), -(673462719, '2873', '9387', 34562032400156951,50434348), -(673461962, '2861', '8441', 34562032400156993,39686909), -(673461956, '2826', '5392', 34562032400156944,5496107), -(673465284, '2694', '1523', 34562032400171349,14554994), -(673465282, '2692', '4645', 34562032400171323,24871187), -(673465283, '2693', '5253', 34562032400171331,28303238), -(673465841, '2696', '0849', 34562032400171257,21673222), -(673465258, '2679', '4140', 34562032400171174,39793881), -(673465263, '2680', '6922', 34562032400171182,12253261), -(673465265, '2681', '9112', 34562032400171190,93894366), -(673465267, '2682', '3259', 34562032400171208,2342189), -(673465268, '2683', '8540', 34562032400171216,63886925), -(673465285, '2695', '4167', 34562032400171356,79227618), -(673465270, '2684', '4292', 34562032400171224,19216349), -(673465272, '2685', '4007', 34562032400171232,14396903), -(673465273, '2686', '6894', 34562032400171240,13569394), -(673465274, '2687', '5268', 34562032400171265,59453667), -(673465275, '2688', '0232', 34562032400171273,62324713), -(673465276, '2689', '2720', 34562032400171281,65977200), -(673465843, '2698', '4773', 34562032400171364,78387158), -(673465842, '2697', '3729', 34562032400171315,94201789), -(673465280, '2691', '0503', 34562032400171307,12298533), -(673465279, '2690', '8239', 34562032400171299,76183877); +INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `id`, `puk`) VALUES + ('621188151', 2209, 1486, 3456985220092508,14213470), + ('621188152', 2210, 8765, 3456985220092509,99473093), + ('621188153', 2211, 3064, 3456985220092510,52967210), + ('621188759', 2081, 3700, 3456985220123637,56600999), + ('621188760', 2082, 3259, 345698522023638,87492404), + ('621188761', 2083, 2790, 3456985220123639,94009456), + ('621188762', 2084, 2480, 3456985220123644,1484999), + ('621188763', 2085, 6876, 3456985220123641,36577064), + ('621188766', 2086, 7775, 3456985220123642,80761698), + ('621188769', 2088, 4027, 3456985220123643,37921712), + ('621188771', 2089, 8797, 3456985220123640,63092540), + ('621188772', 2090, 8404, 3456985220123645,21014997), + ('621188773', 2091, 5481, 3456985220123646,16317277), + ('621188774', 2092, 9632, 3456985220123647,22235994), + ('621188775', 2093, 4654, 3456985220123648,28506486), + ('621188838', 2094, 1392, 3456985220123649,29498627), + ('621188839', 2095, 7774, 3456985220123650,46263490), + ('621188840', 2096, 7304, 3456985220123658,8212044), + ('621188841', 2097, 5569, 3456985220123652,81597658), + ('621188842', 2098, 4944, 3456985220123653,24961501), + ('621188843', 2099, 5142, 3456985220123654,17035634), + ('621188844', 2111, 7245, 3456985220123655,90231951), + ('621188846', 2110, 6590, 3456985220123656,72201537), + ('667680207', 2564, 4042, 34569832200759166,48401979), + ('667680315', 2565, 7143, 34569832200759372,32143252), + ('667680318', 2566, 6342, 34569832200759364,39597112), + ('667680413', 2567, 5580, 34569832200759356,32786992), + ('667680463', 2568, 0171, 34569832200759349,34240853), + ('667688217', 2569, 2500, 34569832200759331,5687589), + ('633603945', 2212, 7129, 34569832200759323,51554019), + ('622130186', 2213, 4826, 34569832200759307,19623551), + ('633973424', 2214, 8535, 34569832200759299,94619307), + ('633703828', 2215, 8628, 34569832200759281,22468012), + ('622025110', 2216, 2399, 34569832200759273,34602918), + ('622924867', 2217, 5665, 34569832200759265,26920216), + ('722409630', 2218, 5211, 34569832200759240,93750137), + ('623590529', 2219, 0493, 34569832200759208,47077088), + ('633243462', 2220, 6902, 34569832200759174,6421962), + ('633047286', 2221, 5592, 34569832200759182,32069439), + ('744716801', 2112, 9184, 34569832200759190,57049814), + ('655995021', 2131, 8896, 34569852202049093,19497356), + ('685522718', 2132, 1955, 34569852202049101,28519879), + ('674587213', 2994, 2006, 34569332200223743,62360135), + ('674587227', 2993, 9271, 34569332200223750,81628192), + ('674587229', 2993, 0900, 34569332200223768,91119071), + ('674587231', 2992, 5007, 34569332200223776,45826232), + ('674587234', 2991, 1378, 34569332200223784,91245744), + ('674587240', 2990, 0905, 34569332200223792,13083224), + ('674587245', 2989, 9059, 34569332200223800,15291807), + ('674587250', 2988, 8188, 34569332200223818,83017918), + ('674587254', 2987, 2962, 34569332200223826,92809271), + ('674587256', 2986, 0358, 34569332200223834,81067040), + ('674592713', 2570, 2537, 34569332200230672,82325850), + ('697832478', 2579, 0936, 34568732200494825,49658372), + ('697832176', 2571, 5944, 34568732200494742,19039461), + ('697832477', 2572, 5138, 34568732200494759,25712504), + ('697832178', 2573, 4597, 34568732200494767,66241760), + ('697832182', 2574, 9241, 34568732200494775,07342562), + ('697832196', 2575, 2995, 34568732200494783,53929026), + ('697832214', 2576, 7434, 34568732200494791,49698432), + ('697832230', 2577, 7004, 34568732200494809,21578612), + ('697832235', 2578, 9674, 34568732200494817,93090700), + ('673420375', 2599, 5430, 34562052300117259,35911412), + ('673420367', 2598, 8402, 34562052300117242,924654), + ('673420361', 2597, 5125, 34562052300117234,12027970), + ('673420355', 2596, 5069, 34562052300117226,34978149), + ('673420348', 2595, 8911, 34562052300117218,4228121), + ('673420346', 2594, 2461, 34562052300117200,67670772), + ('673420345', 2593, 2226, 34562052300117192,90586404), + ('673420306', 2592, 3355, 34562052300117184,97850017), + ('673420257', 2591, 9395, 34562052300117176,50713786), + ('673420231', 2590, 1378, 34562052300117168,50151763), + ('673420223', 2589, 9580, 34562052300117150,99534550), + ('673420216', 2588, 4955, 34562052300117143,317554), + ('673420203', 2587, 6742, 34562052300117135,69321531), + ('673420201', 2586, 1659, 34562052300117127,54720480), + ('673420199', 2585, 7823, 34562052300117119,22923796), + ('673420198', 2584, 1787, 34562052300117101,54414630), + ('673420168', 2583, 6334, 34562052300117093,50694894), + ('673420147', 2582, 8951, 34562052300117085,1402535), + ('673420125', 2581, 3068, 34562052300117077,86216200), + ('673420124', 2580, 9517, 34562052300117069,42504099), + ('600294609', 2715, 7474, 34569832304894588,55923317), + ('600084713', 2703, 8342, 34569832304894570,8392636), + ('600084732', 2704, 1625, 34569832304894513,75477452), + ('600084850', 2705, 9896, 34569832304894653,28589813), + ('600084951', 2706, 5520, 34569832304894661,75353012), + ('600084978', 2707, 2698, 34569832304894679,9005523), + ('600085403', 2708, 0837, 34569832304894646,77051152), + ('600085513', 2709, 3106, 34569832304894687,41571002), + ('600293916', 2712, 8990, 34569832304894620,95188676), + ('600294160', 2714, 6376, 34569832304894703,79879896), + ('671919529', 2975, 9184, 34569832304806236,7535392), + ('671919942', 2981, 0328, 34569832304806269,31052894), + ('671919530', 2976, 0344, 34569832304806251,89860304), + ('671919533', 2977, 0668, 34569832304806244,42921771), + ('671919535', 2978, 0105, 34569832304806277,31009417), + ('671919537', 2979, 0881, 34569832304806285,33479769), + ('671919540', 2980, 9874, 34569832304806293,14103929), + ('671919525', 2972, 2089, 34569832304806301,45903729), + ('671919527', 2973, 8206, 34569832304806368,1586035), + ('671919528', 2974, 2532, 34569832304806327,62310124), + ('673668717', 2836, 7973, 34562032301044223,15635496), + ('673668734', 2837, 4457, 34562032301044231,18313118), + ('673668738', 2824, 2911, 34562032301044249,30875583), + ('673668745', 2838, 7253, 34562032301044256,62754222), + ('673668796', 2839, 0068, 34562032301044264,15556829), + ('673668803', 2840, 2386, 34562032301044272,17572287), + ('673669591', 2850, 3833, 34562032301044280,34828896), + ('673668808', 2841, 3584, 34562032301044298,16234497), + ('673670102', 2851, 3554, 34562032301044306,23652625), + ('673670131', 2852, 4412, 34562032301044314,88611709), + ('673670135', 2827, 6058, 34562032301044322,53918579), + ('673670201', 2828, 8066, 34562032301044330,92369343), + ('673670225', 2829, 4592, 34562032301044348,24126635), + ('673670236', 2830, 2974, 34562032301044355,88608465), + ('673671485', 2849, 0349, 34562032301044363,44944874), + ('673461977', 2871, 1728, 34562032400157090,46975780), + ('673461975', 2870, 4734, 34562032400157082,69628432), + ('673461972', 2867, 6276, 34562032400157058,53338365), + ('673461979', 2872, 6043, 34562032400157108,36525197), + ('673461958', 2859, 3164, 34562032400156977,58947831), + ('673461957', 2857, 8685, 34562032400156969,15826386), + ('673461944', 2853, 1073, 34562032400156910,20452195), + ('673461974', 2869, 7121, 34562032400157074,32044645), + ('673461973', 2868, 8022, 34562032400157066,29282044), + ('673461971', 2866, 3089, 34562032400157041,66149978), + ('673461969', 2865, 7555, 34562032400157033,78391293), + ('673461960', 2860, 5203, 34562032400156985,37138232), + ('673461952', 2855, 6915, 34562032400156936,62724661), + ('673461949', 2854, 8706, 34562032400156928,5594345), + ('673461966', 2863, 2496, 34562032400157017,93450666), + ('673461968', 2864, 3703, 34562032400157025,23208841), + ('673461963', 2862, 9364, 34562032400157009,29712130), + ('673462719', 2873, 9387, 34562032400156951,50434348), + ('673461962', 2861, 8441, 34562032400156993,39686909), + ('673461956', 2826, 5392, 34562032400156944,5496107), + ('673465284', 2694, 1523, 34562032400171349,14554994), + ('673465282', 2692, 4645, 34562032400171323,24871187), + ('673465283', 2693, 5253, 34562032400171331,28303238), + ('673465841', 2696, 0849, 34562032400171257,21673222), + ('673465258', 2679, 4140, 34562032400171174,39793881), + ('673465263', 2680, 6922, 34562032400171182,12253261), + ('673465265', 2681, 9112, 34562032400171190,93894366), + ('673465267', 2682, 3259, 34562032400171208,2342189), + ('673465268', 2683, 8540, 34562032400171216,63886925), + ('673465285', 2695, 4167, 34562032400171356,79227618), + ('673465270', 2684, 4292, 34562032400171224,19216349), + ('673465272', 2685, 4007, 34562032400171232,14396903), + ('673465273', 2686, 6894, 34562032400171240,13569394), + ('673465274', 2687, 5268, 34562032400171265,59453667), + ('673465275', 2688, 0232, 34562032400171273,62324713), + ('673465276', 2689, 2720, 34562032400171281,65977200), + ('673465843', 2698, 4773, 34562032400171364,78387158), + ('673465842', 2697, 3729, 34562032400171315,94201789), + ('673465280', 2691, 0503, 34562032400171307,12298533), + ('673465279', 2690, 8239, 34562032400171299,76183877); -ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK - FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file +UPDATE vn.deviceProductionUser + SET simFk = NULL + WHERE id IN ( + SELECT dpu.id + FROM vn.deviceProductionUser dpu + LEFT JOIN vn.sim s ON s.id = dpu.simFk + WHERE s.id IS NULL + AND dpu.simFk IS NOT NULL + ); + +ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_sim_FK + FOREIGN KEY (simFk) REFERENCES vn.sim(id) ON DELETE RESTRICT ON UPDATE CASCADE; From d42ff075472a29c6c65f1c2462a3d1ecddae5e30 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 09:20:27 +0100 Subject: [PATCH 079/108] feat: refs #8174 Changed datatype incompatibility access --- .../11327-maroonOak/00-firstScript.sql | 332 +++++++++--------- 1 file changed, 167 insertions(+), 165 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 7c9d8e6e8..570f393cf 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -1,183 +1,185 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( - `id` BIGINT UNSIGNED, + `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, `pin` INT(4) NOT NULL, `puk` INT(15) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk BIGINT unsigned DEFAULT NULL NULL; -ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk BIGINT unsigned DEFAULT NULL NULL; +ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk VARCHAR(25) DEFAULT NULL NULL; +ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk VARCHAR(25) DEFAULT NULL NULL; -INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `id`, `puk`) VALUES - ('621188151', 2209, 1486, 3456985220092508,14213470), - ('621188152', 2210, 8765, 3456985220092509,99473093), - ('621188153', 2211, 3064, 3456985220092510,52967210), - ('621188759', 2081, 3700, 3456985220123637,56600999), - ('621188760', 2082, 3259, 345698522023638,87492404), - ('621188761', 2083, 2790, 3456985220123639,94009456), - ('621188762', 2084, 2480, 3456985220123644,1484999), - ('621188763', 2085, 6876, 3456985220123641,36577064), - ('621188766', 2086, 7775, 3456985220123642,80761698), - ('621188769', 2088, 4027, 3456985220123643,37921712), - ('621188771', 2089, 8797, 3456985220123640,63092540), - ('621188772', 2090, 8404, 3456985220123645,21014997), - ('621188773', 2091, 5481, 3456985220123646,16317277), - ('621188774', 2092, 9632, 3456985220123647,22235994), - ('621188775', 2093, 4654, 3456985220123648,28506486), - ('621188838', 2094, 1392, 3456985220123649,29498627), - ('621188839', 2095, 7774, 3456985220123650,46263490), - ('621188840', 2096, 7304, 3456985220123658,8212044), - ('621188841', 2097, 5569, 3456985220123652,81597658), - ('621188842', 2098, 4944, 3456985220123653,24961501), - ('621188843', 2099, 5142, 3456985220123654,17035634), - ('621188844', 2111, 7245, 3456985220123655,90231951), - ('621188846', 2110, 6590, 3456985220123656,72201537), - ('667680207', 2564, 4042, 34569832200759166,48401979), - ('667680315', 2565, 7143, 34569832200759372,32143252), - ('667680318', 2566, 6342, 34569832200759364,39597112), - ('667680413', 2567, 5580, 34569832200759356,32786992), - ('667680463', 2568, 0171, 34569832200759349,34240853), - ('667688217', 2569, 2500, 34569832200759331,5687589), - ('633603945', 2212, 7129, 34569832200759323,51554019), - ('622130186', 2213, 4826, 34569832200759307,19623551), - ('633973424', 2214, 8535, 34569832200759299,94619307), - ('633703828', 2215, 8628, 34569832200759281,22468012), - ('622025110', 2216, 2399, 34569832200759273,34602918), - ('622924867', 2217, 5665, 34569832200759265,26920216), - ('722409630', 2218, 5211, 34569832200759240,93750137), - ('623590529', 2219, 0493, 34569832200759208,47077088), - ('633243462', 2220, 6902, 34569832200759174,6421962), - ('633047286', 2221, 5592, 34569832200759182,32069439), - ('744716801', 2112, 9184, 34569832200759190,57049814), - ('655995021', 2131, 8896, 34569852202049093,19497356), - ('685522718', 2132, 1955, 34569852202049101,28519879), - ('674587213', 2994, 2006, 34569332200223743,62360135), - ('674587227', 2993, 9271, 34569332200223750,81628192), - ('674587229', 2993, 0900, 34569332200223768,91119071), - ('674587231', 2992, 5007, 34569332200223776,45826232), - ('674587234', 2991, 1378, 34569332200223784,91245744), - ('674587240', 2990, 0905, 34569332200223792,13083224), - ('674587245', 2989, 9059, 34569332200223800,15291807), - ('674587250', 2988, 8188, 34569332200223818,83017918), - ('674587254', 2987, 2962, 34569332200223826,92809271), - ('674587256', 2986, 0358, 34569332200223834,81067040), - ('674592713', 2570, 2537, 34569332200230672,82325850), - ('697832478', 2579, 0936, 34568732200494825,49658372), - ('697832176', 2571, 5944, 34568732200494742,19039461), - ('697832477', 2572, 5138, 34568732200494759,25712504), - ('697832178', 2573, 4597, 34568732200494767,66241760), - ('697832182', 2574, 9241, 34568732200494775,07342562), - ('697832196', 2575, 2995, 34568732200494783,53929026), - ('697832214', 2576, 7434, 34568732200494791,49698432), - ('697832230', 2577, 7004, 34568732200494809,21578612), - ('697832235', 2578, 9674, 34568732200494817,93090700), - ('673420375', 2599, 5430, 34562052300117259,35911412), - ('673420367', 2598, 8402, 34562052300117242,924654), - ('673420361', 2597, 5125, 34562052300117234,12027970), - ('673420355', 2596, 5069, 34562052300117226,34978149), - ('673420348', 2595, 8911, 34562052300117218,4228121), - ('673420346', 2594, 2461, 34562052300117200,67670772), - ('673420345', 2593, 2226, 34562052300117192,90586404), - ('673420306', 2592, 3355, 34562052300117184,97850017), - ('673420257', 2591, 9395, 34562052300117176,50713786), - ('673420231', 2590, 1378, 34562052300117168,50151763), - ('673420223', 2589, 9580, 34562052300117150,99534550), - ('673420216', 2588, 4955, 34562052300117143,317554), - ('673420203', 2587, 6742, 34562052300117135,69321531), - ('673420201', 2586, 1659, 34562052300117127,54720480), - ('673420199', 2585, 7823, 34562052300117119,22923796), - ('673420198', 2584, 1787, 34562052300117101,54414630), - ('673420168', 2583, 6334, 34562052300117093,50694894), - ('673420147', 2582, 8951, 34562052300117085,1402535), - ('673420125', 2581, 3068, 34562052300117077,86216200), - ('673420124', 2580, 9517, 34562052300117069,42504099), - ('600294609', 2715, 7474, 34569832304894588,55923317), - ('600084713', 2703, 8342, 34569832304894570,8392636), - ('600084732', 2704, 1625, 34569832304894513,75477452), - ('600084850', 2705, 9896, 34569832304894653,28589813), - ('600084951', 2706, 5520, 34569832304894661,75353012), - ('600084978', 2707, 2698, 34569832304894679,9005523), - ('600085403', 2708, 0837, 34569832304894646,77051152), - ('600085513', 2709, 3106, 34569832304894687,41571002), - ('600293916', 2712, 8990, 34569832304894620,95188676), - ('600294160', 2714, 6376, 34569832304894703,79879896), - ('671919529', 2975, 9184, 34569832304806236,7535392), - ('671919942', 2981, 0328, 34569832304806269,31052894), - ('671919530', 2976, 0344, 34569832304806251,89860304), - ('671919533', 2977, 0668, 34569832304806244,42921771), - ('671919535', 2978, 0105, 34569832304806277,31009417), - ('671919537', 2979, 0881, 34569832304806285,33479769), - ('671919540', 2980, 9874, 34569832304806293,14103929), - ('671919525', 2972, 2089, 34569832304806301,45903729), - ('671919527', 2973, 8206, 34569832304806368,1586035), - ('671919528', 2974, 2532, 34569832304806327,62310124), - ('673668717', 2836, 7973, 34562032301044223,15635496), - ('673668734', 2837, 4457, 34562032301044231,18313118), - ('673668738', 2824, 2911, 34562032301044249,30875583), - ('673668745', 2838, 7253, 34562032301044256,62754222), - ('673668796', 2839, 0068, 34562032301044264,15556829), - ('673668803', 2840, 2386, 34562032301044272,17572287), - ('673669591', 2850, 3833, 34562032301044280,34828896), - ('673668808', 2841, 3584, 34562032301044298,16234497), - ('673670102', 2851, 3554, 34562032301044306,23652625), - ('673670131', 2852, 4412, 34562032301044314,88611709), - ('673670135', 2827, 6058, 34562032301044322,53918579), - ('673670201', 2828, 8066, 34562032301044330,92369343), - ('673670225', 2829, 4592, 34562032301044348,24126635), - ('673670236', 2830, 2974, 34562032301044355,88608465), - ('673671485', 2849, 0349, 34562032301044363,44944874), - ('673461977', 2871, 1728, 34562032400157090,46975780), - ('673461975', 2870, 4734, 34562032400157082,69628432), - ('673461972', 2867, 6276, 34562032400157058,53338365), - ('673461979', 2872, 6043, 34562032400157108,36525197), - ('673461958', 2859, 3164, 34562032400156977,58947831), - ('673461957', 2857, 8685, 34562032400156969,15826386), - ('673461944', 2853, 1073, 34562032400156910,20452195), - ('673461974', 2869, 7121, 34562032400157074,32044645), - ('673461973', 2868, 8022, 34562032400157066,29282044), - ('673461971', 2866, 3089, 34562032400157041,66149978), - ('673461969', 2865, 7555, 34562032400157033,78391293), - ('673461960', 2860, 5203, 34562032400156985,37138232), - ('673461952', 2855, 6915, 34562032400156936,62724661), - ('673461949', 2854, 8706, 34562032400156928,5594345), - ('673461966', 2863, 2496, 34562032400157017,93450666), - ('673461968', 2864, 3703, 34562032400157025,23208841), - ('673461963', 2862, 9364, 34562032400157009,29712130), - ('673462719', 2873, 9387, 34562032400156951,50434348), - ('673461962', 2861, 8441, 34562032400156993,39686909), - ('673461956', 2826, 5392, 34562032400156944,5496107), - ('673465284', 2694, 1523, 34562032400171349,14554994), - ('673465282', 2692, 4645, 34562032400171323,24871187), - ('673465283', 2693, 5253, 34562032400171331,28303238), - ('673465841', 2696, 0849, 34562032400171257,21673222), - ('673465258', 2679, 4140, 34562032400171174,39793881), - ('673465263', 2680, 6922, 34562032400171182,12253261), - ('673465265', 2681, 9112, 34562032400171190,93894366), - ('673465267', 2682, 3259, 34562032400171208,2342189), - ('673465268', 2683, 8540, 34562032400171216,63886925), - ('673465285', 2695, 4167, 34562032400171356,79227618), - ('673465270', 2684, 4292, 34562032400171224,19216349), - ('673465272', 2685, 4007, 34562032400171232,14396903), - ('673465273', 2686, 6894, 34562032400171240,13569394), - ('673465274', 2687, 5268, 34562032400171265,59453667), - ('673465275', 2688, 0232, 34562032400171273,62324713), - ('673465276', 2689, 2720, 34562032400171281,65977200), - ('673465843', 2698, 4773, 34562032400171364,78387158), - ('673465842', 2697, 3729, 34562032400171315,94201789), - ('673465280', 2691, 0503, 34562032400171307,12298533), - ('673465279', 2690, 8239, 34562032400171299,76183877); +INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `code`, `puk`) VALUES + ('621188151', 2209, 1486, '3456985220092508',14213470), + ('621188152', 2210, 8765, '3456985220092509',99473093), + ('621188153', 2211, 3064, '3456985220092510',52967210), + ('621188759', 2081, 3700, '3456985220123637',56600999), + ('621188760', 2082, 3259, '345698522023638',87492404), + ('621188761', 2083, 2790, '3456985220123639',94009456), + ('621188762', 2084, 2480, '3456985220123644',1484999), + ('621188763', 2085, 6876, '3456985220123641',36577064), + ('621188766', 2086, 7775, '3456985220123642',80761698), + ('621188769', 2088, 4027, '3456985220123643',37921712), + ('621188771', 2089, 8797, '3456985220123640',63092540), + ('621188772', 2090, 8404, '3456985220123645',21014997), + ('621188773', 2091, 5481, '3456985220123646',16317277), + ('621188774', 2092, 9632, '3456985220123647',22235994), + ('621188775', 2093, 4654, '3456985220123648',28506486), + ('621188838', 2094, 1392, '3456985220123649',29498627), + ('621188839', 2095, 7774, '3456985220123650',46263490), + ('621188840', 2096, 7304, '3456985220123658',8212044), + ('621188841', 2097, 5569, '3456985220123652',81597658), + ('621188842', 2098, 4944, '3456985220123653',24961501), + ('621188843', 2099, 5142, '3456985220123654',17035634), + ('621188844', 2111, 7245, '3456985220123655',90231951), + ('621188846', 2110, 6590, '3456985220123656',72201537), + ('667680207', 2564, 4042, '34569832200759166',48401979), + ('667680315', 2565, 7143, '34569832200759372',32143252), + ('667680318', 2566, 6342, '34569832200759364',39597112), + ('667680413', 2567, 5580, '34569832200759356',32786992), + ('667680463', 2568, 0171, '34569832200759349',34240853), + ('667688217', 2569, 2500, '34569832200759331',5687589), + ('633603945', 2212, 7129, '34569832200759323',51554019), + ('622130186', 2213, 4826, '34569832200759307',19623551), + ('633973424', 2214, 8535, '34569832200759299',94619307), + ('633703828', 2215, 8628, '34569832200759281',22468012), + ('622025110', 2216, 2399, '34569832200759273',34602918), + ('622924867', 2217, 5665, '34569832200759265',26920216), + ('722409630', 2218, 5211, '34569832200759240',93750137), + ('623590529', 2219, 0493, '34569832200759208',47077088), + ('633243462', 2220, 6902, '34569832200759174',6421962), + ('633047286', 2221, 5592, '34569832200759182',32069439), + ('744716801', 2112, 9184, '34569832200759190',57049814), + ('655995021', 2131, 8896, '34569852202049093',19497356), + ('685522718', 2132, 1955, '34569852202049101',28519879), + ('674587213', 2994, 2006, '34569332200223743',62360135), + ('674587227', 2993, 9271, '34569332200223750',81628192), + ('674587229', 2993, 0900, '34569332200223768',91119071), + ('674587231', 2992, 5007, '34569332200223776',45826232), + ('674587234', 2991, 1378, '34569332200223784',91245744), + ('674587240', 2990, 0905, '34569332200223792',13083224), + ('674587245', 2989, 9059, '34569332200223800',15291807), + ('674587250', 2988, 8188, '34569332200223818',83017918), + ('674587254', 2987, 2962, '34569332200223826',92809271), + ('674587256', 2986, 0358, '34569332200223834',81067040), + ('674592713', 2570, 2537, '34569332200230672',82325850), + ('697832478', 2579, 0936, '34568732200494825',49658372), + ('697832176', 2571, 5944, '34568732200494742',19039461), + ('697832477', 2572, 5138, '34568732200494759',25712504), + ('697832178', 2573, 4597, '34568732200494767',66241760), + ('697832182', 2574, 9241, '34568732200494775',07342562), + ('697832196', 2575, 2995, '34568732200494783',53929026), + ('697832214', 2576, 7434, '34568732200494791',49698432), + ('697832230', 2577, 7004, '34568732200494809',21578612), + ('697832235', 2578, 9674, '34568732200494817',93090700), + ('673420375', 2599, 5430, '34562052300117259',35911412), + ('673420367', 2598, 8402, '34562052300117242',924654), + ('673420361', 2597, 5125, '34562052300117234',12027970), + ('673420355', 2596, 5069, '34562052300117226',34978149), + ('673420348', 2595, 8911, '34562052300117218',4228121), + ('673420346', 2594, 2461, '34562052300117200',67670772), + ('673420345', 2593, 2226, '34562052300117192',90586404), + ('673420306', 2592, 3355, '34562052300117184',97850017), + ('673420257', 2591, 9395, '34562052300117176',50713786), + ('673420231', 2590, 1378, '34562052300117168',50151763), + ('673420223', 2589, 9580, '34562052300117150',99534550), + ('673420216', 2588, 4955, '34562052300117143',317554), + ('673420203', 2587, 6742, '34562052300117135',69321531), + ('673420201', 2586, 1659, '34562052300117127',54720480), + ('673420199', 2585, 7823, '34562052300117119',22923796), + ('673420198', 2584, 1787, '34562052300117101',54414630), + ('673420168', 2583, 6334, '34562052300117093',50694894), + ('673420147', 2582, 8951, '34562052300117085',1402535), + ('673420125', 2581, 3068, '34562052300117077',86216200), + ('673420124', 2580, 9517, '34562052300117069',42504099), + ('600294609', 2715, 7474, '34569832304894588',55923317), + ('600084713', 2703, 8342, '34569832304894570',8392636), + ('600084732', 2704, 1625, '34569832304894513',75477452), + ('600084850', 2705, 9896, '34569832304894653',28589813), + ('600084951', 2706, 5520, '34569832304894661',75353012), + ('600084978', 2707, 2698, '34569832304894679',9005523), + ('600085403', 2708, 0837, '34569832304894646',77051152), + ('600085513', 2709, 3106, '34569832304894687',41571002), + ('600293916', 2712, 8990, '34569832304894620',95188676), + ('600294160', 2714, 6376, '34569832304894703',79879896), + ('671919529', 2975, 9184, '34569832304806236',7535392), + ('671919942', 2981, 0328, '34569832304806269',31052894), + ('671919530', 2976, 0344, '34569832304806251',89860304), + ('671919533', 2977, 0668, '34569832304806244',42921771), + ('671919535', 2978, 0105, '34569832304806277',31009417), + ('671919537', 2979, 0881, '34569832304806285',33479769), + ('671919540', 2980, 9874, '34569832304806293',14103929), + ('671919525', 2972, 2089, '34569832304806301',45903729), + ('671919527', 2973, 8206, '34569832304806368',1586035), + ('671919528', 2974, 2532, '34569832304806327',62310124), + ('673668717', 2836, 7973, '34562032301044223',15635496), + ('673668734', 2837, 4457, '34562032301044231',18313118), + ('673668738', 2824, 2911, '34562032301044249',30875583), + ('673668745', 2838, 7253, '34562032301044256',62754222), + ('673668796', 2839, 0068, '34562032301044264',15556829), + ('673668803', 2840, 2386, '34562032301044272',17572287), + ('673669591', 2850, 3833, '34562032301044280',34828896), + ('673668808', 2841, 3584, '34562032301044298',16234497), + ('673670102', 2851, 3554, '34562032301044306',23652625), + ('673670131', 2852, 4412, '34562032301044314',88611709), + ('673670135', 2827, 6058, '34562032301044322',53918579), + ('673670201', 2828, 8066, '34562032301044330',92369343), + ('673670225', 2829, 4592, '34562032301044348',24126635), + ('673670236', 2830, 2974, '34562032301044355',88608465), + ('673671485', 2849, 0349, '34562032301044363',44944874), + ('673461977', 2871, 1728, '34562032400157090',46975780), + ('673461975', 2870, 4734, '34562032400157082',69628432), + ('673461972', 2867, 6276, '34562032400157058',53338365), + ('673461979', 2872, 6043, '34562032400157108',36525197), + ('673461958', 2859, 3164, '34562032400156977',58947831), + ('673461957', 2857, 8685, '34562032400156969',15826386), + ('673461944', 2853, 1073, '34562032400156910',20452195), + ('673461974', 2869, 7121, '34562032400157074',32044645), + ('673461973', 2868, 8022, '34562032400157066',29282044), + ('673461971', 2866, 3089, '34562032400157041',66149978), + ('673461969', 2865, 7555, '34562032400157033',78391293), + ('673461960', 2860, 5203, '34562032400156985',37138232), + ('673461952', 2855, 6915, '34562032400156936',62724661), + ('673461949', 2854, 8706, '34562032400156928',5594345), + ('673461966', 2863, 2496, '34562032400157017',93450666), + ('673461968', 2864, 3703, '34562032400157025',23208841), + ('673461963', 2862, 9364, '34562032400157009',29712130), + ('673462719', 2873, 9387, '34562032400156951',50434348), + ('673461962', 2861, 8441, '34562032400156993',39686909), + ('673461956', 2826, 5392, '34562032400156944',5496107), + ('673465284', 2694, 1523, '34562032400171349',14554994), + ('673465282', 2692, 4645, '34562032400171323',24871187), + ('673465283', 2693, 5253, '34562032400171331',28303238), + ('673465841', 2696, 0849, '34562032400171257',21673222), + ('673465258', 2679, 4140, '34562032400171174',39793881), + ('673465263', 2680, 6922, '34562032400171182',12253261), + ('673465265', 2681, 9112, '34562032400171190',93894366), + ('673465267', 2682, 3259, '34562032400171208',2342189), + ('673465268', 2683, 8540, '34562032400171216',63886925), + ('673465285', 2695, 4167, '34562032400171356',79227618), + ('673465270', 2684, 4292, '34562032400171224',19216349), + ('673465272', 2685, 4007, '34562032400171232',14396903), + ('673465273', 2686, 6894, '34562032400171240',13569394), + ('673465274', 2687, 5268, '34562032400171265',59453667), + ('673465275', 2688, 0232, '34562032400171273',62324713), + ('673465276', 2689, 2720, '34562032400171281',65977200), + ('673465843', 2698, 4773, '34562032400171364',78387158), + ('673465842', 2697, 3729, '34562032400171315',94201789), + ('673465280', 2691, 0503, '34562032400171307',12298533), + ('673465279', 2690, 8239, '34562032400171299',76183877); UPDATE vn.deviceProductionUser SET simFk = NULL WHERE id IN ( SELECT dpu.id FROM vn.deviceProductionUser dpu - LEFT JOIN vn.sim s ON s.id = dpu.simFk - WHERE s.id IS NULL + LEFT JOIN vn.sim s ON s.code = dpu.simFk + WHERE s.code IS NULL AND dpu.simFk IS NOT NULL ); ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_sim_FK - FOREIGN KEY (simFk) REFERENCES vn.sim(id) ON DELETE RESTRICT ON UPDATE CASCADE; + FOREIGN KEY (simFk) REFERENCES vn.sim(code) ON DELETE RESTRICT ON UPDATE CASCADE; + +GRANT SELECT, INSERT, DELETE, UPDATE ON TABLE vn.sim TO hr; From d9a6e8a1c98744b9e69d00da5caa612962c079b1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 09:34:45 +0100 Subject: [PATCH 080/108] refactor: refs #7882 Added ACL's --- db/dump/fixtures.before.sql | 2 +- db/versions/11379-yellowCordyline/01-secScript.sql | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 db/versions/11379-yellowCordyline/01-secScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c108bc0f6..57a9f9ca8 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4038,7 +4038,7 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate) VALUES (1106,'26493101E','2019-09-20'); -INSERT INTO vn.osrmConfig (id,url,tolerance) +INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance) VALUES (1,'https://router.project-osrm.org', 0.002); INSERT IGNORE INTO vn.inventoryConfig diff --git a/db/versions/11379-yellowCordyline/01-secScript.sql b/db/versions/11379-yellowCordyline/01-secScript.sql new file mode 100644 index 000000000..bfeb04477 --- /dev/null +++ b/db/versions/11379-yellowCordyline/01-secScript.sql @@ -0,0 +1,5 @@ +INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('OsrmConfig','optimize','READ','ALLOW','ROLE','employee'), + ('Route',' optimizePriority','*','ALLOW','ROLE','employee'); +INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance) + VALUES (1,'https://router.project-osrm.org', 0.002); From d9eab361600ab1eddcd1f02576bebef0932146b3 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 16 Dec 2024 09:35:41 +0100 Subject: [PATCH 081/108] fix: refs #7936 conflicts --- db/routines/sage/procedures/invoiceIn_add.sql | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index eeeb28143..8fdbb9ce3 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -25,7 +25,7 @@ BEGIN DECLARE vIsInformativeExportation BOOL DEFAULT FALSE; DECLARE vCursor CURSOR FOR - SELECT it.taxableBase, + SELECT SUM(it.taxableBase), CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)), t.PorcentajeIva, it.transactionTypeSageFk, @@ -204,25 +204,25 @@ BEGIN FROM vn.invoiceInCorrection WHERE correctingFk = vInvoiceInFk; - IF vInvoiceInOriginalFk THEN + IF vInvoiceInOriginalFk THEN UPDATE movContaIVA mci JOIN vn.invoiceInCorrection iic ON iic.correctingFk = vInvoiceInFk JOIN vn.siiTypeInvoiceIn st ON st.id = iic.siiTypeInvoiceInFk JOIN (SELECT issued, - SUM(sub.taxableBase) taxableBase, + SUM(sub.taxableBase) taxableBase, SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat FROM(SELECT issued, - SUM(iit.taxableBase) taxableBase, + SUM(iit.taxableBase) taxableBase, ti.PorcentajeIva - FROM vn.invoiceIn i + FROM vn.invoiceIn i JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id JOIN TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk WHERE i.id = vInvoiceInOriginalFk GROUP BY ti.CodigoIva)sub )invoiceInOriginal JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' - SET mci.TipoRectificativa = iic.cplusRectificationTypeFk, - mci.ClaseAbonoRectificativas = REGEXP_REPLACE(st.`code`, '[^0-9]', ''), + SET mci.TipoRectificativa = iir.refundCategoryFk, + mci.ClaseAbonoRectificativas = iir.refundType, mci.FechaFacturaOriginal = invoiceInOriginal.issued, mci.FechaOperacion = invoiceInOriginal.issued, mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, @@ -231,5 +231,4 @@ BEGIN WHERE mci.id = vXDiarioFk; END IF; END$$ -$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; From 71fb3996cdc5fe4675c17a6ea3c092fcf8819861 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 09:40:55 +0100 Subject: [PATCH 082/108] refactor: refs #7882 Added ACL's --- db/versions/11379-yellowCordyline/01-secScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11379-yellowCordyline/01-secScript.sql b/db/versions/11379-yellowCordyline/01-secScript.sql index bfeb04477..30479229e 100644 --- a/db/versions/11379-yellowCordyline/01-secScript.sql +++ b/db/versions/11379-yellowCordyline/01-secScript.sql @@ -1,5 +1,5 @@ INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('OsrmConfig','optimize','READ','ALLOW','ROLE','employee'), - ('Route',' optimizePriority','*','ALLOW','ROLE','employee'); + ('Route', 'optimizePriority','*','ALLOW','ROLE','employee'); INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance) VALUES (1,'https://router.project-osrm.org', 0.002); From 32d9a3ace1a2b5a96ec5c74ecdce576a583bd8e3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 16 Dec 2024 09:57:48 +0100 Subject: [PATCH 083/108] fix: refs #7028 remove ifs --- loopback/locale/es.json | 5 +---- modules/ticket/back/methods/ticket-request/deny.js | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 73efce216..a47195d07 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -398,8 +398,5 @@ "An item type with the same code already exists": "Un tipo con el mismo código ya existe", "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", "All tickets have a route order": "Todos los tickets tienen orden de ruta", - "Price cannot be blank": "Price cannot be blank", - "Worker not found": "Trabajador no encontrado", - "Invalid request or related ticket/client data": "Solicitud no válida o datos de ticket/cliente relacionados" - + "Price cannot be blank": "Price cannot be blank" } diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index c6a1d35af..b96d8a244 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -44,7 +44,6 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; const worker = await models.Worker.findById(userId, myOptions); - if (!worker) throw new UserError('Worker not found'); const params = { isOk: false, @@ -66,9 +65,6 @@ module.exports = Self => { } }, myOptions); - if (!request || !request.ticket() || !request.ticket().client()) - throw new UserError('Invalid request or related ticket/client data'); - const url = await models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk; const message = $t('Deny buy request', { From 1e471ac20f146e76405309017f609717c8cca44a Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 16 Dec 2024 10:25:33 +0100 Subject: [PATCH 084/108] fix: refs #7028 requesterId fix --- .../back/methods/ticket-request/confirm.js | 23 ++++++++++--------- .../back/methods/ticket-request/deny.js | 18 ++++++++------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index 56ee14a73..ab4d39d51 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -97,18 +97,19 @@ module.exports = Self => { const query = `CALL vn.sale_calculateComponent(?, NULL)`; await Self.rawSql(query, [sale.id], myOptions); - const url = await Self.app.models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk; - const message = $t('Bought units from buy request', { - quantity: sale.quantity, - concept: sale.concept, - itemId: sale.itemFk, - ticketId: sale.ticketFk, - url: `${url}ticket/${sale.ticketFk}/summary`, - urlItem: `${url}item/${sale.itemFk}/summary` - }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); - + if (requesterId) { + const url = await Self.app.models.Url.getUrl(); + const message = $t('Bought units from buy request', { + quantity: sale.quantity, + concept: sale.concept, + itemId: sale.itemFk, + ticketId: sale.ticketFk, + url: `${url}ticket/${sale.ticketFk}/summary`, + urlItem: `${url}item/${sale.itemFk}/summary` + }); + await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + } if (tx) await tx.commit(); return sale; diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index b96d8a244..5c9f87dde 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -65,16 +65,18 @@ module.exports = Self => { } }, myOptions); - const url = await models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk; - const message = $t('Deny buy request', { - ticketId: request.ticketFk, - url: `${url}ticket/${request.ticketFk}/request/index`, - observation: params.response - }); + if (requesterId) { + const url = await models.Url.getUrl(); + const message = $t('Deny buy request', { + ticketId: request.ticketFk, + url: `${url}ticket/${request.ticketFk}/request/index`, + observation: params.response + }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); - await request.updateAttributes(params, myOptions); + await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + await request.updateAttributes(params, myOptions); + } if (tx) await tx.commit(); From 36705a028edda6324e318fec95ccee74eec00553 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 11:33:18 +0100 Subject: [PATCH 085/108] fix: refs #8174 Version --- modules/worker/back/models/device-production-user.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/device-production-user.json b/modules/worker/back/models/device-production-user.json index a024cc94c..31aaf92d4 100644 --- a/modules/worker/back/models/device-production-user.json +++ b/modules/worker/back/models/device-production-user.json @@ -25,7 +25,7 @@ "userFk": { "type": "number" }, - "simSerialNumber": { + "simFk": { "type": "string" }, "created": { From 5346dd845e39e239b78efe38e76c5cea1258489a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 11:40:57 +0100 Subject: [PATCH 086/108] feat: refs #8218 Added time and code in mistakeType --- db/versions/11384-grayAnthurium/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11384-grayAnthurium/00-firstScript.sql diff --git a/db/versions/11384-grayAnthurium/00-firstScript.sql b/db/versions/11384-grayAnthurium/00-firstScript.sql new file mode 100644 index 000000000..b3a7f3da2 --- /dev/null +++ b/db/versions/11384-grayAnthurium/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.mistakeType + ADD `time` int(10) NULL COMMENT 'Segundos que se suelen tardar en arreglar el fallo', + ADD code varchar(50) DEFAULT NULL NULL AFTER id; From 576641d09d05ef4a9848db4c3137690930b44150 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 16 Dec 2024 11:55:01 +0100 Subject: [PATCH 087/108] fix: refs #7028 requesterId fix --- modules/ticket/back/methods/ticket-request/deny.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index 5c9f87dde..686b9d1de 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -43,7 +43,7 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; - const worker = await models.Worker.findById(userId, myOptions); + const worker = await models.Worker.findById(userId, {fields: ['id']}, myOptions); const params = { isOk: false, From 5f43c0440c0e0710497624993915b0ce63dec196 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 16 Dec 2024 11:58:21 +0100 Subject: [PATCH 088/108] fix: refs #7028 requesterId fix salesPerson --- modules/ticket/back/methods/ticket-request/confirm.js | 6 +++--- modules/ticket/back/methods/ticket-request/deny.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index ab4d39d51..45ee287de 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -97,8 +97,8 @@ module.exports = Self => { const query = `CALL vn.sale_calculateComponent(?, NULL)`; await Self.rawSql(query, [sale.id], myOptions); - const requesterId = request.ticket().client().salesPersonFk; - if (requesterId) { + const salesPerson = request.ticket().client().salesPersonFk; + if (salesPerson) { const url = await Self.app.models.Url.getUrl(); const message = $t('Bought units from buy request', { quantity: sale.quantity, @@ -108,7 +108,7 @@ module.exports = Self => { url: `${url}ticket/${sale.ticketFk}/summary`, urlItem: `${url}item/${sale.itemFk}/summary` }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + await models.Chat.sendCheckingPresence(ctx, salesPerson, message, myOptions); } if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index 686b9d1de..26e6f63ff 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -65,8 +65,8 @@ module.exports = Self => { } }, myOptions); - const requesterId = request.ticket().client().salesPersonFk; - if (requesterId) { + const salesPerson = request.ticket().client().salesPersonFk; + if (salesPerson) { const url = await models.Url.getUrl(); const message = $t('Deny buy request', { ticketId: request.ticketFk, @@ -74,7 +74,7 @@ module.exports = Self => { observation: params.response }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + await models.Chat.sendCheckingPresence(ctx, salesPerson, message, myOptions); await request.updateAttributes(params, myOptions); } From fda2c5725a6f4fc6e9dcda5760272d0bfc17ceb4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 12:23:02 +0100 Subject: [PATCH 089/108] refactor: refs #8262 Deprecated inventoryFailure --- .../vn/procedures/inventoryFailureAdd.sql | 48 ------------------- .../vn/procedures/item_cleanFloramondo.sql | 4 -- .../11385-yellowOrchid/00-firstScript.sql | 5 ++ 3 files changed, 5 insertions(+), 52 deletions(-) delete mode 100644 db/routines/vn/procedures/inventoryFailureAdd.sql create mode 100644 db/versions/11385-yellowOrchid/00-firstScript.sql diff --git a/db/routines/vn/procedures/inventoryFailureAdd.sql b/db/routines/vn/procedures/inventoryFailureAdd.sql deleted file mode 100644 index e2b5fa4a0..000000000 --- a/db/routines/vn/procedures/inventoryFailureAdd.sql +++ /dev/null @@ -1,48 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`inventoryFailureAdd`() -BEGIN - -DECLARE done BOOL DEFAULT FALSE; -DECLARE vTicketFk INT; - -DECLARE rs CURSOR FOR - SELECT id FROM vn.ticket - WHERE shipped = util.yesterday() - AND clientFk = 400 - AND warehouseFk IN (1,44); - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - -OPEN rs; - -FETCH rs INTO vTicketFk; - -WHILE NOT done DO - - INSERT INTO vn.inventoryFailure(dated, itemFk, quantity, value, warehouseFk, throwerFk) - SELECT t.shipped, - s.itemFk, - s.quantity, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue, - t.warehouseFk, - w.id - FROM vn.ticket t - JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN cache.last_buy lb ON lb.warehouse_id = t.warehouseFk AND item_id = s.itemFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.worker w ON w.code = LEFT(s.concept, 3) - WHERE t.id = vTicketFk - AND s.quantity > 0; - - FETCH rs INTO vTicketFk; - -END WHILE; - - -CLOSE rs; - - - - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/item_cleanFloramondo.sql b/db/routines/vn/procedures/item_cleanFloramondo.sql index 849cfe93d..21d8ebe3c 100644 --- a/db/routines/vn/procedures/item_cleanFloramondo.sql +++ b/db/routines/vn/procedures/item_cleanFloramondo.sql @@ -164,10 +164,6 @@ BEGIN SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE inventoryFailure - SET itemFk = vItemNew - WHERE itemFk = vItemOld; - UPDATE genericAllocation SET itemFk = vItemNew WHERE itemFk = vItemOld; diff --git a/db/versions/11385-yellowOrchid/00-firstScript.sql b/db/versions/11385-yellowOrchid/00-firstScript.sql new file mode 100644 index 000000000..287e9fcab --- /dev/null +++ b/db/versions/11385-yellowOrchid/00-firstScript.sql @@ -0,0 +1,5 @@ +RENAME TABLE vn.inventoryFailure TO vn.inventoryFailure__; +ALTER TABLE vn.inventoryFailure__ COMMENT='@deprecated 2024-12-16'; + +RENAME TABLE vn.inventoryFailureCause TO vn.inventoryFailureCause__; +ALTER TABLE vn.inventoryFailureCause__ COMMENT='@deprecated 2024-12-16'; From d03a2ced04e151daba34e59338098a7c63b9a7d2 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 12:30:35 +0100 Subject: [PATCH 090/108] fix: refs8174 pasar a char el PIN --- db/versions/11386-turquoiseTulip/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11386-turquoiseTulip/00-firstScript.sql diff --git a/db/versions/11386-turquoiseTulip/00-firstScript.sql b/db/versions/11386-turquoiseTulip/00-firstScript.sql new file mode 100644 index 000000000..0dc1c8e82 --- /dev/null +++ b/db/versions/11386-turquoiseTulip/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.sim MODIFY COLUMN pin char(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'); From 7232bfb7a6ce26edd33fbaee8f3f67f44967ecca Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 12:42:08 +0100 Subject: [PATCH 091/108] fix: 8174 pasar PIN a CHAR --- db/versions/11327-maroonOak/00-firstScript.sql | 2 +- db/versions/11386-turquoiseTulip/00-firstScript.sql | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 db/versions/11386-turquoiseTulip/00-firstScript.sql diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 570f393cf..a68cf7e6a 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, - `pin` INT(4) NOT NULL, + `pin` INT(4) NOT NULL (`pin` REGEXP '^[0-9]+$') `puk` INT(15) NOT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; diff --git a/db/versions/11386-turquoiseTulip/00-firstScript.sql b/db/versions/11386-turquoiseTulip/00-firstScript.sql deleted file mode 100644 index 0dc1c8e82..000000000 --- a/db/versions/11386-turquoiseTulip/00-firstScript.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE vn.sim MODIFY COLUMN pin char(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'); From deb1b68c49319257fbb4ff928a35d11421240c3c Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 12:47:47 +0100 Subject: [PATCH 092/108] fix: refs#8174 fix --- db/versions/11327-maroonOak/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index a68cf7e6a..b17d12dfc 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, - `pin` INT(4) NOT NULL (`pin` REGEXP '^[0-9]+$') + `pin` INT(4) NOT NULL (`pin` REGEXP '^[0-9]+$'), `puk` INT(15) NOT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; From 11db90c67c3d099de6f6c0e90ae0578e3e19a7fe Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 12:48:43 +0100 Subject: [PATCH 093/108] fix: refs#8174 fix --- db/versions/11327-maroonOak/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index b17d12dfc..68ab19e05 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, - `pin` INT(4) NOT NULL (`pin` REGEXP '^[0-9]+$'), + `pin` INT(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), `puk` INT(15) NOT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; From de69a8db1d52b55abb12e1d8fd6240a92602e0f7 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 13:01:00 +0100 Subject: [PATCH 094/108] fix: refs#8174 fix --- .../11327-maroonOak/00-firstScript.sql | 316 +++++++++--------- 1 file changed, 158 insertions(+), 158 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 68ab19e05..81a36ee26 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, - `pin` INT(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), + `pin` CHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), `puk` INT(15) NOT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -11,163 +11,163 @@ ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk VARCHAR(25) DEF ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk VARCHAR(25) DEFAULT NULL NULL; INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `code`, `puk`) VALUES - ('621188151', 2209, 1486, '3456985220092508',14213470), - ('621188152', 2210, 8765, '3456985220092509',99473093), - ('621188153', 2211, 3064, '3456985220092510',52967210), - ('621188759', 2081, 3700, '3456985220123637',56600999), - ('621188760', 2082, 3259, '345698522023638',87492404), - ('621188761', 2083, 2790, '3456985220123639',94009456), - ('621188762', 2084, 2480, '3456985220123644',1484999), - ('621188763', 2085, 6876, '3456985220123641',36577064), - ('621188766', 2086, 7775, '3456985220123642',80761698), - ('621188769', 2088, 4027, '3456985220123643',37921712), - ('621188771', 2089, 8797, '3456985220123640',63092540), - ('621188772', 2090, 8404, '3456985220123645',21014997), - ('621188773', 2091, 5481, '3456985220123646',16317277), - ('621188774', 2092, 9632, '3456985220123647',22235994), - ('621188775', 2093, 4654, '3456985220123648',28506486), - ('621188838', 2094, 1392, '3456985220123649',29498627), - ('621188839', 2095, 7774, '3456985220123650',46263490), - ('621188840', 2096, 7304, '3456985220123658',8212044), - ('621188841', 2097, 5569, '3456985220123652',81597658), - ('621188842', 2098, 4944, '3456985220123653',24961501), - ('621188843', 2099, 5142, '3456985220123654',17035634), - ('621188844', 2111, 7245, '3456985220123655',90231951), - ('621188846', 2110, 6590, '3456985220123656',72201537), - ('667680207', 2564, 4042, '34569832200759166',48401979), - ('667680315', 2565, 7143, '34569832200759372',32143252), - ('667680318', 2566, 6342, '34569832200759364',39597112), - ('667680413', 2567, 5580, '34569832200759356',32786992), - ('667680463', 2568, 0171, '34569832200759349',34240853), - ('667688217', 2569, 2500, '34569832200759331',5687589), - ('633603945', 2212, 7129, '34569832200759323',51554019), - ('622130186', 2213, 4826, '34569832200759307',19623551), - ('633973424', 2214, 8535, '34569832200759299',94619307), - ('633703828', 2215, 8628, '34569832200759281',22468012), - ('622025110', 2216, 2399, '34569832200759273',34602918), - ('622924867', 2217, 5665, '34569832200759265',26920216), - ('722409630', 2218, 5211, '34569832200759240',93750137), - ('623590529', 2219, 0493, '34569832200759208',47077088), - ('633243462', 2220, 6902, '34569832200759174',6421962), - ('633047286', 2221, 5592, '34569832200759182',32069439), - ('744716801', 2112, 9184, '34569832200759190',57049814), - ('655995021', 2131, 8896, '34569852202049093',19497356), - ('685522718', 2132, 1955, '34569852202049101',28519879), - ('674587213', 2994, 2006, '34569332200223743',62360135), - ('674587227', 2993, 9271, '34569332200223750',81628192), - ('674587229', 2993, 0900, '34569332200223768',91119071), - ('674587231', 2992, 5007, '34569332200223776',45826232), - ('674587234', 2991, 1378, '34569332200223784',91245744), - ('674587240', 2990, 0905, '34569332200223792',13083224), - ('674587245', 2989, 9059, '34569332200223800',15291807), - ('674587250', 2988, 8188, '34569332200223818',83017918), - ('674587254', 2987, 2962, '34569332200223826',92809271), - ('674587256', 2986, 0358, '34569332200223834',81067040), - ('674592713', 2570, 2537, '34569332200230672',82325850), - ('697832478', 2579, 0936, '34568732200494825',49658372), - ('697832176', 2571, 5944, '34568732200494742',19039461), - ('697832477', 2572, 5138, '34568732200494759',25712504), - ('697832178', 2573, 4597, '34568732200494767',66241760), - ('697832182', 2574, 9241, '34568732200494775',07342562), - ('697832196', 2575, 2995, '34568732200494783',53929026), - ('697832214', 2576, 7434, '34568732200494791',49698432), - ('697832230', 2577, 7004, '34568732200494809',21578612), - ('697832235', 2578, 9674, '34568732200494817',93090700), - ('673420375', 2599, 5430, '34562052300117259',35911412), - ('673420367', 2598, 8402, '34562052300117242',924654), - ('673420361', 2597, 5125, '34562052300117234',12027970), - ('673420355', 2596, 5069, '34562052300117226',34978149), - ('673420348', 2595, 8911, '34562052300117218',4228121), - ('673420346', 2594, 2461, '34562052300117200',67670772), - ('673420345', 2593, 2226, '34562052300117192',90586404), - ('673420306', 2592, 3355, '34562052300117184',97850017), - ('673420257', 2591, 9395, '34562052300117176',50713786), - ('673420231', 2590, 1378, '34562052300117168',50151763), - ('673420223', 2589, 9580, '34562052300117150',99534550), - ('673420216', 2588, 4955, '34562052300117143',317554), - ('673420203', 2587, 6742, '34562052300117135',69321531), - ('673420201', 2586, 1659, '34562052300117127',54720480), - ('673420199', 2585, 7823, '34562052300117119',22923796), - ('673420198', 2584, 1787, '34562052300117101',54414630), - ('673420168', 2583, 6334, '34562052300117093',50694894), - ('673420147', 2582, 8951, '34562052300117085',1402535), - ('673420125', 2581, 3068, '34562052300117077',86216200), - ('673420124', 2580, 9517, '34562052300117069',42504099), - ('600294609', 2715, 7474, '34569832304894588',55923317), - ('600084713', 2703, 8342, '34569832304894570',8392636), - ('600084732', 2704, 1625, '34569832304894513',75477452), - ('600084850', 2705, 9896, '34569832304894653',28589813), - ('600084951', 2706, 5520, '34569832304894661',75353012), - ('600084978', 2707, 2698, '34569832304894679',9005523), - ('600085403', 2708, 0837, '34569832304894646',77051152), - ('600085513', 2709, 3106, '34569832304894687',41571002), - ('600293916', 2712, 8990, '34569832304894620',95188676), - ('600294160', 2714, 6376, '34569832304894703',79879896), - ('671919529', 2975, 9184, '34569832304806236',7535392), - ('671919942', 2981, 0328, '34569832304806269',31052894), - ('671919530', 2976, 0344, '34569832304806251',89860304), - ('671919533', 2977, 0668, '34569832304806244',42921771), - ('671919535', 2978, 0105, '34569832304806277',31009417), - ('671919537', 2979, 0881, '34569832304806285',33479769), - ('671919540', 2980, 9874, '34569832304806293',14103929), - ('671919525', 2972, 2089, '34569832304806301',45903729), - ('671919527', 2973, 8206, '34569832304806368',1586035), - ('671919528', 2974, 2532, '34569832304806327',62310124), - ('673668717', 2836, 7973, '34562032301044223',15635496), - ('673668734', 2837, 4457, '34562032301044231',18313118), - ('673668738', 2824, 2911, '34562032301044249',30875583), - ('673668745', 2838, 7253, '34562032301044256',62754222), - ('673668796', 2839, 0068, '34562032301044264',15556829), - ('673668803', 2840, 2386, '34562032301044272',17572287), - ('673669591', 2850, 3833, '34562032301044280',34828896), - ('673668808', 2841, 3584, '34562032301044298',16234497), - ('673670102', 2851, 3554, '34562032301044306',23652625), - ('673670131', 2852, 4412, '34562032301044314',88611709), - ('673670135', 2827, 6058, '34562032301044322',53918579), - ('673670201', 2828, 8066, '34562032301044330',92369343), - ('673670225', 2829, 4592, '34562032301044348',24126635), - ('673670236', 2830, 2974, '34562032301044355',88608465), - ('673671485', 2849, 0349, '34562032301044363',44944874), - ('673461977', 2871, 1728, '34562032400157090',46975780), - ('673461975', 2870, 4734, '34562032400157082',69628432), - ('673461972', 2867, 6276, '34562032400157058',53338365), - ('673461979', 2872, 6043, '34562032400157108',36525197), - ('673461958', 2859, 3164, '34562032400156977',58947831), - ('673461957', 2857, 8685, '34562032400156969',15826386), - ('673461944', 2853, 1073, '34562032400156910',20452195), - ('673461974', 2869, 7121, '34562032400157074',32044645), - ('673461973', 2868, 8022, '34562032400157066',29282044), - ('673461971', 2866, 3089, '34562032400157041',66149978), - ('673461969', 2865, 7555, '34562032400157033',78391293), - ('673461960', 2860, 5203, '34562032400156985',37138232), - ('673461952', 2855, 6915, '34562032400156936',62724661), - ('673461949', 2854, 8706, '34562032400156928',5594345), - ('673461966', 2863, 2496, '34562032400157017',93450666), - ('673461968', 2864, 3703, '34562032400157025',23208841), - ('673461963', 2862, 9364, '34562032400157009',29712130), - ('673462719', 2873, 9387, '34562032400156951',50434348), - ('673461962', 2861, 8441, '34562032400156993',39686909), - ('673461956', 2826, 5392, '34562032400156944',5496107), - ('673465284', 2694, 1523, '34562032400171349',14554994), - ('673465282', 2692, 4645, '34562032400171323',24871187), - ('673465283', 2693, 5253, '34562032400171331',28303238), - ('673465841', 2696, 0849, '34562032400171257',21673222), - ('673465258', 2679, 4140, '34562032400171174',39793881), - ('673465263', 2680, 6922, '34562032400171182',12253261), - ('673465265', 2681, 9112, '34562032400171190',93894366), - ('673465267', 2682, 3259, '34562032400171208',2342189), - ('673465268', 2683, 8540, '34562032400171216',63886925), - ('673465285', 2695, 4167, '34562032400171356',79227618), - ('673465270', 2684, 4292, '34562032400171224',19216349), - ('673465272', 2685, 4007, '34562032400171232',14396903), - ('673465273', 2686, 6894, '34562032400171240',13569394), - ('673465274', 2687, 5268, '34562032400171265',59453667), - ('673465275', 2688, 0232, '34562032400171273',62324713), - ('673465276', 2689, 2720, '34562032400171281',65977200), - ('673465843', 2698, 4773, '34562032400171364',78387158), - ('673465842', 2697, 3729, '34562032400171315',94201789), - ('673465280', 2691, 0503, '34562032400171307',12298533), - ('673465279', 2690, 8239, '34562032400171299',76183877); + ('621188151', 2209, '1486', '3456985220092508',14213470), + ('621188152', 2210, '8765', '3456985220092509',99473093), + ('621188153', 2211, '3064', '3456985220092510',52967210), + ('621188759', 2081, '3700', '3456985220123637',56600999), + ('621188760', 2082, '3259', '345698522023638',87492404), + ('621188761', 2083, '2790', '3456985220123639',94009456), + ('621188762', 2084, '2480', '3456985220123644',1484999), + ('621188763', 2085, '6876', '3456985220123641',36577064), + ('621188766', 2086, '7775', '3456985220123642',80761698), + ('621188769', 2088, '4027', '3456985220123643',37921712), + ('621188771', 2089, '8797', '3456985220123640',63092540), + ('621188772', 2090, '8404', '3456985220123645',21014997), + ('621188773', 2091, '5481', '3456985220123646',16317277), + ('621188774', 2092, '9632', '3456985220123647',22235994), + ('621188775', 2093, '4654', '3456985220123648',28506486), + ('621188838', 2094, '1392', '3456985220123649',29498627), + ('621188839', 2095, '7774', '3456985220123650',46263490), + ('621188840', 2096, '7304', '3456985220123658',8212044), + ('621188841', 2097, '5569', '3456985220123652',81597658), + ('621188842', 2098, '4944', '3456985220123653',24961501), + ('621188843', 2099, '5142', '3456985220123654',17035634), + ('621188844', 2111, '7245', '3456985220123655',90231951), + ('621188846', 2110, '6590', '3456985220123656',72201537), + ('667680207', 2564, '4042', '34569832200759166',48401979), + ('667680315', 2565, '7143', '34569832200759372',32143252), + ('667680318', 2566, '6342', '34569832200759364',39597112), + ('667680413', 2567, '5580', '34569832200759356',32786992), + ('667680463', 2568, '0171', '34569832200759349',34240853), + ('667688217', 2569, '2500', '34569832200759331',5687589), + ('633603945', 2212, '7129', '34569832200759323',51554019), + ('622130186', 2213, '4826', '34569832200759307',19623551), + ('633973424', 2214, '8535', '34569832200759299',94619307), + ('633703828', 2215, '8628', '34569832200759281',22468012), + ('622025110', 2216, '2399', '34569832200759273',34602918), + ('622924867', 2217, '5665', '34569832200759265',26920216), + ('722409630', 2218, '5211', '34569832200759240',93750137), + ('623590529', 2219, '0493', '34569832200759208',47077088), + ('633243462', 2220, '6902', '34569832200759174',6421962), + ('633047286', 2221, '5592', '34569832200759182',32069439), + ('744716801', 2112, '9184', '34569832200759190',57049814), + ('655995021', 2131, '8896', '34569852202049093',19497356), + ('685522718', 2132, '1955', '34569852202049101',28519879), + ('674587213', 2994, '2006', '34569332200223743',62360135), + ('674587227', 2993, '9271', '34569332200223750',81628192), + ('674587229', 2993, '0900', '34569332200223768',91119071), + ('674587231', 2992, '5007', '34569332200223776',45826232), + ('674587234', 2991, '1378', '34569332200223784',91245744), + ('674587240', 2990, '0905', '34569332200223792',13083224), + ('674587245', 2989, '9059', '34569332200223800',15291807), + ('674587250', 2988, '8188', '34569332200223818',83017918), + ('674587254', 2987, '2962', '34569332200223826',92809271), + ('674587256', 2986, '0358', '34569332200223834',81067040), + ('674592713', 2570, '2537', '34569332200230672',82325850), + ('697832478', 2579, '0936', '34568732200494825',49658372), + ('697832176', 2571, '5944', '34568732200494742',19039461), + ('697832477', 2572, '5138', '34568732200494759',25712504), + ('697832178', 2573, '4597', '34568732200494767',66241760), + ('697832182', 2574, '9241', '34568732200494775',07342562), + ('697832196', 2575, '2995', '34568732200494783',53929026), + ('697832214', 2576, '7434', '34568732200494791',49698432), + ('697832230', 2577, '7004', '34568732200494809',21578612), + ('697832235', 2578, '9674', '34568732200494817',93090700), + ('673420375', 2599, '5430', '34562052300117259',35911412), + ('673420367', 2598, '8402', '34562052300117242',924654), + ('673420361', 2597, '5125', '34562052300117234',12027970), + ('673420355', 2596, '5069', '34562052300117226',34978149), + ('673420348', 2595, '8911', '34562052300117218',4228121), + ('673420346', 2594, '2461', '34562052300117200',67670772), + ('673420345', 2593, '2226', '34562052300117192',90586404), + ('673420306', 2592, '3355', '34562052300117184',97850017), + ('673420257', 2591, '9395', '34562052300117176',50713786), + ('673420231', 2590, '1378', '34562052300117168',50151763), + ('673420223', 2589, '9580', '34562052300117150',99534550), + ('673420216', 2588, '4955', '34562052300117143',317554), + ('673420203', 2587, '6742', '34562052300117135',69321531), + ('673420201', 2586, '1659', '34562052300117127',54720480), + ('673420199', 2585, '7823', '34562052300117119',22923796), + ('673420198', 2584, '1787', '34562052300117101',54414630), + ('673420168', 2583, '6334', '34562052300117093',50694894), + ('673420147', 2582, '8951', '34562052300117085',1402535), + ('673420125', 2581, '3068', '34562052300117077',86216200), + ('673420124', 2580, '9517', '34562052300117069',42504099), + ('600294609', 2715, '7474', '34569832304894588',55923317), + ('600084713', 2703, '8342', '34569832304894570',8392636), + ('600084732', 2704, '1625', '34569832304894513',75477452), + ('600084850', 2705, '9896', '34569832304894653',28589813), + ('600084951', 2706, '5520', '34569832304894661',75353012), + ('600084978', 2707, '2698', '34569832304894679',9005523), + ('600085403', 2708, '0837', '34569832304894646',77051152), + ('600085513', 2709, '3106', '34569832304894687',41571002), + ('600293916', 2712, '8990', '34569832304894620',95188676), + ('600294160', 2714, '6376', '34569832304894703',79879896), + ('671919529', 2975, '9184', '34569832304806236',7535392), + ('671919942', 2981, '0328', '34569832304806269',31052894), + ('671919530', 2976, '0344', '34569832304806251',89860304), + ('671919533', 2977, '0668', '34569832304806244',42921771), + ('671919535', 2978, '0105', '34569832304806277',31009417), + ('671919537', 2979, '0881', '34569832304806285',33479769), + ('671919540', 2980, '9874', '34569832304806293',14103929), + ('671919525', 2972, '2089', '34569832304806301',45903729), + ('671919527', 2973, '8206', '34569832304806368',1586035), + ('671919528', 2974, '2532', '34569832304806327',62310124), + ('673668717', 2836, '7973', '34562032301044223',15635496), + ('673668734', 2837, '4457', '34562032301044231',18313118), + ('673668738', 2824, '2911', '34562032301044249',30875583), + ('673668745', 2838, '7253', '34562032301044256',62754222), + ('673668796', 2839, '0068', '34562032301044264',15556829), + ('673668803', 2840, '2386', '34562032301044272',17572287), + ('673669591', 2850, '3833', '34562032301044280',34828896), + ('673668808', 2841, '3584', '34562032301044298',16234497), + ('673670102', 2851, '3554', '34562032301044306',23652625), + ('673670131', 2852, '4412', '34562032301044314',88611709), + ('673670135', 2827, '6058', '34562032301044322',53918579), + ('673670201', 2828, '8066', '34562032301044330',92369343), + ('673670225', 2829, '4592', '34562032301044348',24126635), + ('673670236', 2830, '2974', '34562032301044355',88608465), + ('673671485', 2849, '0349', '34562032301044363',44944874), + ('673461977', 2871, '1728', '34562032400157090',46975780), + ('673461975', 2870, '4734', '34562032400157082',69628432), + ('673461972', 2867, '6276', '34562032400157058',53338365), + ('673461979', 2872, '6043', '34562032400157108',36525197), + ('673461958', 2859, '3164', '34562032400156977',58947831), + ('673461957', 2857, '8685', '34562032400156969',15826386), + ('673461944', 2853, '1073', '34562032400156910',20452195), + ('673461974', 2869, '7121', '34562032400157074',32044645), + ('673461973', 2868, '8022', '34562032400157066',29282044), + ('673461971', 2866, '3089', '34562032400157041',66149978), + ('673461969', 2865, '7555', '34562032400157033',78391293), + ('673461960', 2860, '5203', '34562032400156985',37138232), + ('673461952', 2855, '6915', '34562032400156936',62724661), + ('673461949', 2854, '8706', '34562032400156928',5594345), + ('673461966', 2863, '2496', '34562032400157017',93450666), + ('673461968', 2864, '3703', '34562032400157025',23208841), + ('673461963', 2862, '9364', '34562032400157009',29712130), + ('673462719', 2873, '9387', '34562032400156951',50434348), + ('673461962', 2861, '8441', '34562032400156993',39686909), + ('673461956', 2826, '5392', '34562032400156944',5496107), + ('673465284', 2694, '1523', '34562032400171349',14554994), + ('673465282', 2692, '4645', '34562032400171323',24871187), + ('673465283', 2693, '5253', '34562032400171331',28303238), + ('673465841', 2696, '0849', '34562032400171257',21673222), + ('673465258', 2679, '4140', '34562032400171174',39793881), + ('673465263', 2680, '6922', '34562032400171182',12253261), + ('673465265', 2681, '9112', '34562032400171190',93894366), + ('673465267', 2682, '3259', '34562032400171208',2342189), + ('673465268', 2683, '8540', '34562032400171216',63886925), + ('673465285', 2695, '4167', '34562032400171356',79227618), + ('673465270', 2684, '4292', '34562032400171224',19216349), + ('673465272', 2685, '4007', '34562032400171232',14396903), + ('673465273', 2686, '6894', '34562032400171240',13569394), + ('673465274', 2687, '5268', '34562032400171265',59453667), + ('673465275', 2688, '0232', '34562032400171273',62324713), + ('673465276', 2689, '2720', '34562032400171281',65977200), + ('673465843', 2698, '4773', '34562032400171364',78387158), + ('673465842', 2697, '3729', '34562032400171315',94201789), + ('673465280', 2691, '0503', '34562032400171307',12298533), + ('673465279', 2690, '8239', '34562032400171299',76183877); UPDATE vn.deviceProductionUser SET simFk = NULL From 48064d639377f3dd54cafc80068604ddaf7b188a Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 13:35:50 +0100 Subject: [PATCH 095/108] fix: refs #8174 fix --- db/versions/11327-maroonOak/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 81a36ee26..f59cdfe7e 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, - `pin` CHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), + `pin` VARCHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), `puk` INT(15) NOT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; From 5a7ac8dcb36a249f67fef45285485df1f3866b5c Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 13:44:58 +0100 Subject: [PATCH 096/108] fix: refs #8174 fix --- .../11327-maroonOak/00-firstScript.sql | 318 +++++++++--------- 1 file changed, 159 insertions(+), 159 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index f59cdfe7e..b1c87bf32 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -1,9 +1,9 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), - `ext` INT(4) NOT NULL, + `ext` VARCHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), `pin` VARCHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), - `puk` INT(15) NOT NULL, + `puk` VARCHAR(15) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -11,163 +11,163 @@ ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk VARCHAR(25) DEF ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk VARCHAR(25) DEFAULT NULL NULL; INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `code`, `puk`) VALUES - ('621188151', 2209, '1486', '3456985220092508',14213470), - ('621188152', 2210, '8765', '3456985220092509',99473093), - ('621188153', 2211, '3064', '3456985220092510',52967210), - ('621188759', 2081, '3700', '3456985220123637',56600999), - ('621188760', 2082, '3259', '345698522023638',87492404), - ('621188761', 2083, '2790', '3456985220123639',94009456), - ('621188762', 2084, '2480', '3456985220123644',1484999), - ('621188763', 2085, '6876', '3456985220123641',36577064), - ('621188766', 2086, '7775', '3456985220123642',80761698), - ('621188769', 2088, '4027', '3456985220123643',37921712), - ('621188771', 2089, '8797', '3456985220123640',63092540), - ('621188772', 2090, '8404', '3456985220123645',21014997), - ('621188773', 2091, '5481', '3456985220123646',16317277), - ('621188774', 2092, '9632', '3456985220123647',22235994), - ('621188775', 2093, '4654', '3456985220123648',28506486), - ('621188838', 2094, '1392', '3456985220123649',29498627), - ('621188839', 2095, '7774', '3456985220123650',46263490), - ('621188840', 2096, '7304', '3456985220123658',8212044), - ('621188841', 2097, '5569', '3456985220123652',81597658), - ('621188842', 2098, '4944', '3456985220123653',24961501), - ('621188843', 2099, '5142', '3456985220123654',17035634), - ('621188844', 2111, '7245', '3456985220123655',90231951), - ('621188846', 2110, '6590', '3456985220123656',72201537), - ('667680207', 2564, '4042', '34569832200759166',48401979), - ('667680315', 2565, '7143', '34569832200759372',32143252), - ('667680318', 2566, '6342', '34569832200759364',39597112), - ('667680413', 2567, '5580', '34569832200759356',32786992), - ('667680463', 2568, '0171', '34569832200759349',34240853), - ('667688217', 2569, '2500', '34569832200759331',5687589), - ('633603945', 2212, '7129', '34569832200759323',51554019), - ('622130186', 2213, '4826', '34569832200759307',19623551), - ('633973424', 2214, '8535', '34569832200759299',94619307), - ('633703828', 2215, '8628', '34569832200759281',22468012), - ('622025110', 2216, '2399', '34569832200759273',34602918), - ('622924867', 2217, '5665', '34569832200759265',26920216), - ('722409630', 2218, '5211', '34569832200759240',93750137), - ('623590529', 2219, '0493', '34569832200759208',47077088), - ('633243462', 2220, '6902', '34569832200759174',6421962), - ('633047286', 2221, '5592', '34569832200759182',32069439), - ('744716801', 2112, '9184', '34569832200759190',57049814), - ('655995021', 2131, '8896', '34569852202049093',19497356), - ('685522718', 2132, '1955', '34569852202049101',28519879), - ('674587213', 2994, '2006', '34569332200223743',62360135), - ('674587227', 2993, '9271', '34569332200223750',81628192), - ('674587229', 2993, '0900', '34569332200223768',91119071), - ('674587231', 2992, '5007', '34569332200223776',45826232), - ('674587234', 2991, '1378', '34569332200223784',91245744), - ('674587240', 2990, '0905', '34569332200223792',13083224), - ('674587245', 2989, '9059', '34569332200223800',15291807), - ('674587250', 2988, '8188', '34569332200223818',83017918), - ('674587254', 2987, '2962', '34569332200223826',92809271), - ('674587256', 2986, '0358', '34569332200223834',81067040), - ('674592713', 2570, '2537', '34569332200230672',82325850), - ('697832478', 2579, '0936', '34568732200494825',49658372), - ('697832176', 2571, '5944', '34568732200494742',19039461), - ('697832477', 2572, '5138', '34568732200494759',25712504), - ('697832178', 2573, '4597', '34568732200494767',66241760), - ('697832182', 2574, '9241', '34568732200494775',07342562), - ('697832196', 2575, '2995', '34568732200494783',53929026), - ('697832214', 2576, '7434', '34568732200494791',49698432), - ('697832230', 2577, '7004', '34568732200494809',21578612), - ('697832235', 2578, '9674', '34568732200494817',93090700), - ('673420375', 2599, '5430', '34562052300117259',35911412), - ('673420367', 2598, '8402', '34562052300117242',924654), - ('673420361', 2597, '5125', '34562052300117234',12027970), - ('673420355', 2596, '5069', '34562052300117226',34978149), - ('673420348', 2595, '8911', '34562052300117218',4228121), - ('673420346', 2594, '2461', '34562052300117200',67670772), - ('673420345', 2593, '2226', '34562052300117192',90586404), - ('673420306', 2592, '3355', '34562052300117184',97850017), - ('673420257', 2591, '9395', '34562052300117176',50713786), - ('673420231', 2590, '1378', '34562052300117168',50151763), - ('673420223', 2589, '9580', '34562052300117150',99534550), - ('673420216', 2588, '4955', '34562052300117143',317554), - ('673420203', 2587, '6742', '34562052300117135',69321531), - ('673420201', 2586, '1659', '34562052300117127',54720480), - ('673420199', 2585, '7823', '34562052300117119',22923796), - ('673420198', 2584, '1787', '34562052300117101',54414630), - ('673420168', 2583, '6334', '34562052300117093',50694894), - ('673420147', 2582, '8951', '34562052300117085',1402535), - ('673420125', 2581, '3068', '34562052300117077',86216200), - ('673420124', 2580, '9517', '34562052300117069',42504099), - ('600294609', 2715, '7474', '34569832304894588',55923317), - ('600084713', 2703, '8342', '34569832304894570',8392636), - ('600084732', 2704, '1625', '34569832304894513',75477452), - ('600084850', 2705, '9896', '34569832304894653',28589813), - ('600084951', 2706, '5520', '34569832304894661',75353012), - ('600084978', 2707, '2698', '34569832304894679',9005523), - ('600085403', 2708, '0837', '34569832304894646',77051152), - ('600085513', 2709, '3106', '34569832304894687',41571002), - ('600293916', 2712, '8990', '34569832304894620',95188676), - ('600294160', 2714, '6376', '34569832304894703',79879896), - ('671919529', 2975, '9184', '34569832304806236',7535392), - ('671919942', 2981, '0328', '34569832304806269',31052894), - ('671919530', 2976, '0344', '34569832304806251',89860304), - ('671919533', 2977, '0668', '34569832304806244',42921771), - ('671919535', 2978, '0105', '34569832304806277',31009417), - ('671919537', 2979, '0881', '34569832304806285',33479769), - ('671919540', 2980, '9874', '34569832304806293',14103929), - ('671919525', 2972, '2089', '34569832304806301',45903729), - ('671919527', 2973, '8206', '34569832304806368',1586035), - ('671919528', 2974, '2532', '34569832304806327',62310124), - ('673668717', 2836, '7973', '34562032301044223',15635496), - ('673668734', 2837, '4457', '34562032301044231',18313118), - ('673668738', 2824, '2911', '34562032301044249',30875583), - ('673668745', 2838, '7253', '34562032301044256',62754222), - ('673668796', 2839, '0068', '34562032301044264',15556829), - ('673668803', 2840, '2386', '34562032301044272',17572287), - ('673669591', 2850, '3833', '34562032301044280',34828896), - ('673668808', 2841, '3584', '34562032301044298',16234497), - ('673670102', 2851, '3554', '34562032301044306',23652625), - ('673670131', 2852, '4412', '34562032301044314',88611709), - ('673670135', 2827, '6058', '34562032301044322',53918579), - ('673670201', 2828, '8066', '34562032301044330',92369343), - ('673670225', 2829, '4592', '34562032301044348',24126635), - ('673670236', 2830, '2974', '34562032301044355',88608465), - ('673671485', 2849, '0349', '34562032301044363',44944874), - ('673461977', 2871, '1728', '34562032400157090',46975780), - ('673461975', 2870, '4734', '34562032400157082',69628432), - ('673461972', 2867, '6276', '34562032400157058',53338365), - ('673461979', 2872, '6043', '34562032400157108',36525197), - ('673461958', 2859, '3164', '34562032400156977',58947831), - ('673461957', 2857, '8685', '34562032400156969',15826386), - ('673461944', 2853, '1073', '34562032400156910',20452195), - ('673461974', 2869, '7121', '34562032400157074',32044645), - ('673461973', 2868, '8022', '34562032400157066',29282044), - ('673461971', 2866, '3089', '34562032400157041',66149978), - ('673461969', 2865, '7555', '34562032400157033',78391293), - ('673461960', 2860, '5203', '34562032400156985',37138232), - ('673461952', 2855, '6915', '34562032400156936',62724661), - ('673461949', 2854, '8706', '34562032400156928',5594345), - ('673461966', 2863, '2496', '34562032400157017',93450666), - ('673461968', 2864, '3703', '34562032400157025',23208841), - ('673461963', 2862, '9364', '34562032400157009',29712130), - ('673462719', 2873, '9387', '34562032400156951',50434348), - ('673461962', 2861, '8441', '34562032400156993',39686909), - ('673461956', 2826, '5392', '34562032400156944',5496107), - ('673465284', 2694, '1523', '34562032400171349',14554994), - ('673465282', 2692, '4645', '34562032400171323',24871187), - ('673465283', 2693, '5253', '34562032400171331',28303238), - ('673465841', 2696, '0849', '34562032400171257',21673222), - ('673465258', 2679, '4140', '34562032400171174',39793881), - ('673465263', 2680, '6922', '34562032400171182',12253261), - ('673465265', 2681, '9112', '34562032400171190',93894366), - ('673465267', 2682, '3259', '34562032400171208',2342189), - ('673465268', 2683, '8540', '34562032400171216',63886925), - ('673465285', 2695, '4167', '34562032400171356',79227618), - ('673465270', 2684, '4292', '34562032400171224',19216349), - ('673465272', 2685, '4007', '34562032400171232',14396903), - ('673465273', 2686, '6894', '34562032400171240',13569394), - ('673465274', 2687, '5268', '34562032400171265',59453667), - ('673465275', 2688, '0232', '34562032400171273',62324713), - ('673465276', 2689, '2720', '34562032400171281',65977200), - ('673465843', 2698, '4773', '34562032400171364',78387158), - ('673465842', 2697, '3729', '34562032400171315',94201789), - ('673465280', 2691, '0503', '34562032400171307',12298533), - ('673465279', 2690, '8239', '34562032400171299',76183877); + ('621188151', '2209', '1486', '3456985220092508','14213470'), + ('621188152', '2210', '8765', '3456985220092509','99473093'), + ('621188153', '2211', '3064', '3456985220092510','52967210'), + ('621188759', '2081', '3700', '3456985220123637','56600999'), + ('621188760', '2082', '3259', '345698522023638','87492404'), + ('621188761', '2083', '2790', '3456985220123639','94009456'), + ('621188762', '2084', '2480', '3456985220123644','1484999'), + ('621188763', '2085', '6876', '3456985220123641','36577064'), + ('621188766', '2086', '7775', '3456985220123642','80761698'), + ('621188769', '2088', '4027', '3456985220123643','37921712'), + ('621188771', '2089', '8797', '3456985220123640','63092540'), + ('621188772', '2090', '8404', '3456985220123645','21014997'), + ('621188773', '2091', '5481', '3456985220123646','16317277'), + ('621188774', '2092', '9632', '3456985220123647','22235994'), + ('621188775', '2093', '4654', '3456985220123648','28506486'), + ('621188838', '2094', '1392', '3456985220123649','29498627'), + ('621188839', '2095', '7774', '3456985220123650','46263490'), + ('621188840', '2096', '7304', '3456985220123658','8212044'), + ('621188841', '2097', '5569', '3456985220123652','81597658'), + ('621188842', '2098', '4944', '3456985220123653','24961501'), + ('621188843', '2099', '5142', '3456985220123654','17035634'), + ('621188844', '2111', '7245', '3456985220123655','90231951'), + ('621188846', '2110', '6590', '3456985220123656','72201537'), + ('667680207', '2564', '4042', '34569832200759166','48401979'), + ('667680315', '2565', '7143', '34569832200759372','32143252'), + ('667680318', '2566', '6342', '34569832200759364','39597112'), + ('667680413', '2567', '5580', '34569832200759356','32786992'), + ('667680463', '2568', '0171', '34569832200759349','34240853'), + ('667688217', '2569', '2500', '34569832200759331','5687589'), + ('633603945', '2212', '7129', '34569832200759323','51554019'), + ('622130186', '2213', '4826', '34569832200759307','19623551'), + ('633973424', '2214', '8535', '34569832200759299','94619307'), + ('633703828', '2215', '8628', '34569832200759281','22468012'), + ('622025110', '2216', '2399', '34569832200759273','34602918'), + ('622924867', '2217', '5665', '34569832200759265','26920216'), + ('722409630', '2218', '5211', '34569832200759240','93750137'), + ('623590529', '2219', '0493', '34569832200759208','47077088'), + ('633243462', '2220', '6902', '34569832200759174','6421962'), + ('633047286', '2221', '5592', '34569832200759182','32069439'), + ('744716801', '2112', '9184', '34569832200759190','57049814'), + ('655995021', '2131', '8896', '34569852202049093','19497356'), + ('685522718', '2132', '1955', '34569852202049101','28519879'), + ('674587213', '2994', '2006', '34569332200223743','62360135'), + ('674587227', '2993', '9271', '34569332200223750','81628192'), + ('674587229', '2993', '0900', '34569332200223768','91119071'), + ('674587231', '2992', '5007', '34569332200223776','45826232'), + ('674587234', '2991', '1378', '34569332200223784','91245744'), + ('674587240', '2990', '0905', '34569332200223792','13083224'), + ('674587245', '2989', '9059', '34569332200223800','15291807'), + ('674587250', '2988', '8188', '34569332200223818','83017918'), + ('674587254', '2987', '2962', '34569332200223826','92809271'), + ('674587256', '2986', '0358', '34569332200223834','81067040'), + ('674592713', '2570', '2537', '34569332200230672','82325850'), + ('697832478', '2579', '0936', '34568732200494825','49658372'), + ('697832176', '2571', '5944', '34568732200494742','19039461'), + ('697832477', '2572', '5138', '34568732200494759','25712504'), + ('697832178', '2573', '4597', '34568732200494767','66241760'), + ('697832182', '2574', '9241', '34568732200494775','07342562'), + ('697832196', '2575', '2995', '34568732200494783','53929026'), + ('697832214', '2576', '7434', '34568732200494791','49698432'), + ('697832230', '2577', '7004', '34568732200494809','21578612'), + ('697832235', '2578', '9674', '34568732200494817','93090700'), + ('673420375', '2599', '5430', '34562052300117259','35911412'), + ('673420367', '2598', '8402', '34562052300117242','924654'), + ('673420361', '2597', '5125', '34562052300117234','12027970'), + ('673420355', '2596', '5069', '34562052300117226','34978149'), + ('673420348', '2595', '8911', '34562052300117218','4228121'), + ('673420346', '2594', '2461', '34562052300117200','67670772'), + ('673420345', '2593', '2226', '34562052300117192','90586404'), + ('673420306', '2592', '3355', '34562052300117184','97850017'), + ('673420257', '2591', '9395', '34562052300117176','50713786'), + ('673420231', '2590', '1378', '34562052300117168','50151763'), + ('673420223', '2589', '9580', '34562052300117150','99534550'), + ('673420216', '2588', '4955', '34562052300117143','317554'), + ('673420203', '2587', '6742', '34562052300117135','69321531'), + ('673420201', '2586', '1659', '34562052300117127','54720480'), + ('673420199', '2585', '7823', '34562052300117119','22923796'), + ('673420198', '2584', '1787', '34562052300117101','54414630'), + ('673420168', '2583', '6334', '34562052300117093','50694894'), + ('673420147', '2582', '8951', '34562052300117085','1402535'), + ('673420125', '2581', '3068', '34562052300117077','86216200'), + ('673420124', '2580', '9517', '34562052300117069','42504099'), + ('600294609', '2715', '7474', '34569832304894588','55923317'), + ('600084713', '2703', '8342', '34569832304894570','8392636'), + ('600084732', '2704', '1625', '34569832304894513','75477452'), + ('600084850', '2705', '9896', '34569832304894653','28589813'), + ('600084951', '2706', '5520', '34569832304894661','75353012'), + ('600084978', '2707', '2698', '34569832304894679','9005523'), + ('600085403', '2708', '0837', '34569832304894646','77051152'), + ('600085513', '2709', '3106', '34569832304894687','41571002'), + ('600293916', '2712', '8990', '34569832304894620','95188676'), + ('600294160', '2714', '6376', '34569832304894703','79879896'), + ('671919529', '2975', '9184', '34569832304806236','7535392'), + ('671919942', '2981', '0328', '34569832304806269','31052894'), + ('671919530', '2976', '0344', '34569832304806251','89860304'), + ('671919533', '2977', '0668', '34569832304806244','42921771'), + ('671919535', '2978', '0105', '34569832304806277','31009417'), + ('671919537', '2979', '0881', '34569832304806285','33479769'), + ('671919540', '2980', '9874', '34569832304806293','14103929'), + ('671919525', '2972', '2089', '34569832304806301','45903729'), + ('671919527', '2973', '8206', '34569832304806368','1586035'), + ('671919528', '2974', '2532', '34569832304806327','62310124'), + ('673668717', '2836', '7973', '34562032301044223','15635496'), + ('673668734', '2837', '4457', '34562032301044231','18313118'), + ('673668738', '2824', '2911', '34562032301044249','30875583'), + ('673668745', '2838', '7253', '34562032301044256','62754222'), + ('673668796', '2839', '0068', '34562032301044264','15556829'), + ('673668803', '2840', '2386', '34562032301044272','17572287'), + ('673669591', '2850', '3833', '34562032301044280','34828896'), + ('673668808', '2841', '3584', '34562032301044298','16234497'), + ('673670102', '2851', '3554', '34562032301044306','23652625'), + ('673670131', '2852', '4412', '34562032301044314','88611709'), + ('673670135', '2827', '6058', '34562032301044322','53918579'), + ('673670201', '2828', '8066', '34562032301044330','92369343'), + ('673670225', '2829', '4592', '34562032301044348','24126635'), + ('673670236', '2830', '2974', '34562032301044355','88608465'), + ('673671485', '2849', '0349', '34562032301044363','44944874'), + ('673461977', '2871', '1728', '34562032400157090','46975780'), + ('673461975', '2870', '4734', '34562032400157082','69628432'), + ('673461972', '2867', '6276', '34562032400157058','53338365'), + ('673461979', '2872', '6043', '34562032400157108','36525197'), + ('673461958', '2859', '3164', '34562032400156977','58947831'), + ('673461957', '2857', '8685', '34562032400156969','15826386'), + ('673461944', '2853', '1073', '34562032400156910','20452195'), + ('673461974', '2869', '7121', '34562032400157074','32044645'), + ('673461973', '2868', '8022', '34562032400157066','29282044'), + ('673461971', '2866', '3089', '34562032400157041','66149978'), + ('673461969', '2865', '7555', '34562032400157033','78391293'), + ('673461960', '2860', '5203', '34562032400156985','37138232'), + ('673461952', '2855', '6915', '34562032400156936','62724661'), + ('673461949', '2854', '8706', '34562032400156928','5594345'), + ('673461966', '2863', '2496', '34562032400157017','93450666'), + ('673461968', '2864', '3703', '34562032400157025','23208841'), + ('673461963', '2862', '9364', '34562032400157009','29712130'), + ('673462719', '2873', '9387', '34562032400156951','50434348'), + ('673461962', '2861', '8441', '34562032400156993','39686909'), + ('673461956', '2826', '5392', '34562032400156944','5496107'), + ('673465284', '2694', '1523', '34562032400171349','14554994'), + ('673465282', '2692', '4645', '34562032400171323','24871187'), + ('673465283', '2693', '5253', '34562032400171331','28303238'), + ('673465841', '2696', '0849', '34562032400171257','21673222'), + ('673465258', '2679', '4140', '34562032400171174','39793881'), + ('673465263', '2680', '6922', '34562032400171182','12253261'), + ('673465265', '2681', '9112', '34562032400171190','93894366'), + ('673465267', '2682', '3259', '34562032400171208','2342189'), + ('673465268', '2683', '8540', '34562032400171216','63886925'), + ('673465285', '2695', '4167', '34562032400171356','79227618'), + ('673465270', '2684', '4292', '34562032400171224','19216349'), + ('673465272', '2685', '4007', '34562032400171232','14396903'), + ('673465273', '2686', '6894', '34562032400171240','13569394'), + ('673465274', '2687', '5268', '34562032400171265','59453667'), + ('673465275', '2688', '0232', '34562032400171273','62324713'), + ('673465276', '2689', '2720', '34562032400171281','65977200'), + ('673465843', '2698', '4773', '34562032400171364','78387158'), + ('673465842', '2697', '3729', '34562032400171315','94201789'), + ('673465280', '2691', '0503', '34562032400171307','12298533'), + ('673465279', '2690', '8239', '34562032400171299','76183877'); UPDATE vn.deviceProductionUser SET simFk = NULL From 6a3cbed3ddc2ef57592608ac2401858e09305992 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 13:47:36 +0100 Subject: [PATCH 097/108] fix: refs #8174 fix --- .../11327-maroonOak/00-firstScript.sql | 316 +++++++++--------- 1 file changed, 158 insertions(+), 158 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index b1c87bf32..a51ee3fff 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -1,7 +1,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), - `ext` VARCHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), + `ext` INT(4) NOT NULL, `pin` VARCHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), `puk` VARCHAR(15) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), PRIMARY KEY (`code`) @@ -11,163 +11,163 @@ ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk VARCHAR(25) DEF ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk VARCHAR(25) DEFAULT NULL NULL; INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `code`, `puk`) VALUES - ('621188151', '2209', '1486', '3456985220092508','14213470'), - ('621188152', '2210', '8765', '3456985220092509','99473093'), - ('621188153', '2211', '3064', '3456985220092510','52967210'), - ('621188759', '2081', '3700', '3456985220123637','56600999'), - ('621188760', '2082', '3259', '345698522023638','87492404'), - ('621188761', '2083', '2790', '3456985220123639','94009456'), - ('621188762', '2084', '2480', '3456985220123644','1484999'), - ('621188763', '2085', '6876', '3456985220123641','36577064'), - ('621188766', '2086', '7775', '3456985220123642','80761698'), - ('621188769', '2088', '4027', '3456985220123643','37921712'), - ('621188771', '2089', '8797', '3456985220123640','63092540'), - ('621188772', '2090', '8404', '3456985220123645','21014997'), - ('621188773', '2091', '5481', '3456985220123646','16317277'), - ('621188774', '2092', '9632', '3456985220123647','22235994'), - ('621188775', '2093', '4654', '3456985220123648','28506486'), - ('621188838', '2094', '1392', '3456985220123649','29498627'), - ('621188839', '2095', '7774', '3456985220123650','46263490'), - ('621188840', '2096', '7304', '3456985220123658','8212044'), - ('621188841', '2097', '5569', '3456985220123652','81597658'), - ('621188842', '2098', '4944', '3456985220123653','24961501'), - ('621188843', '2099', '5142', '3456985220123654','17035634'), - ('621188844', '2111', '7245', '3456985220123655','90231951'), - ('621188846', '2110', '6590', '3456985220123656','72201537'), - ('667680207', '2564', '4042', '34569832200759166','48401979'), - ('667680315', '2565', '7143', '34569832200759372','32143252'), - ('667680318', '2566', '6342', '34569832200759364','39597112'), - ('667680413', '2567', '5580', '34569832200759356','32786992'), - ('667680463', '2568', '0171', '34569832200759349','34240853'), - ('667688217', '2569', '2500', '34569832200759331','5687589'), - ('633603945', '2212', '7129', '34569832200759323','51554019'), - ('622130186', '2213', '4826', '34569832200759307','19623551'), - ('633973424', '2214', '8535', '34569832200759299','94619307'), - ('633703828', '2215', '8628', '34569832200759281','22468012'), - ('622025110', '2216', '2399', '34569832200759273','34602918'), - ('622924867', '2217', '5665', '34569832200759265','26920216'), - ('722409630', '2218', '5211', '34569832200759240','93750137'), - ('623590529', '2219', '0493', '34569832200759208','47077088'), - ('633243462', '2220', '6902', '34569832200759174','6421962'), - ('633047286', '2221', '5592', '34569832200759182','32069439'), - ('744716801', '2112', '9184', '34569832200759190','57049814'), - ('655995021', '2131', '8896', '34569852202049093','19497356'), - ('685522718', '2132', '1955', '34569852202049101','28519879'), - ('674587213', '2994', '2006', '34569332200223743','62360135'), - ('674587227', '2993', '9271', '34569332200223750','81628192'), - ('674587229', '2993', '0900', '34569332200223768','91119071'), - ('674587231', '2992', '5007', '34569332200223776','45826232'), - ('674587234', '2991', '1378', '34569332200223784','91245744'), - ('674587240', '2990', '0905', '34569332200223792','13083224'), - ('674587245', '2989', '9059', '34569332200223800','15291807'), - ('674587250', '2988', '8188', '34569332200223818','83017918'), - ('674587254', '2987', '2962', '34569332200223826','92809271'), - ('674587256', '2986', '0358', '34569332200223834','81067040'), - ('674592713', '2570', '2537', '34569332200230672','82325850'), - ('697832478', '2579', '0936', '34568732200494825','49658372'), - ('697832176', '2571', '5944', '34568732200494742','19039461'), - ('697832477', '2572', '5138', '34568732200494759','25712504'), - ('697832178', '2573', '4597', '34568732200494767','66241760'), - ('697832182', '2574', '9241', '34568732200494775','07342562'), - ('697832196', '2575', '2995', '34568732200494783','53929026'), - ('697832214', '2576', '7434', '34568732200494791','49698432'), - ('697832230', '2577', '7004', '34568732200494809','21578612'), - ('697832235', '2578', '9674', '34568732200494817','93090700'), - ('673420375', '2599', '5430', '34562052300117259','35911412'), - ('673420367', '2598', '8402', '34562052300117242','924654'), - ('673420361', '2597', '5125', '34562052300117234','12027970'), - ('673420355', '2596', '5069', '34562052300117226','34978149'), - ('673420348', '2595', '8911', '34562052300117218','4228121'), - ('673420346', '2594', '2461', '34562052300117200','67670772'), - ('673420345', '2593', '2226', '34562052300117192','90586404'), - ('673420306', '2592', '3355', '34562052300117184','97850017'), - ('673420257', '2591', '9395', '34562052300117176','50713786'), - ('673420231', '2590', '1378', '34562052300117168','50151763'), - ('673420223', '2589', '9580', '34562052300117150','99534550'), - ('673420216', '2588', '4955', '34562052300117143','317554'), - ('673420203', '2587', '6742', '34562052300117135','69321531'), - ('673420201', '2586', '1659', '34562052300117127','54720480'), - ('673420199', '2585', '7823', '34562052300117119','22923796'), - ('673420198', '2584', '1787', '34562052300117101','54414630'), - ('673420168', '2583', '6334', '34562052300117093','50694894'), - ('673420147', '2582', '8951', '34562052300117085','1402535'), - ('673420125', '2581', '3068', '34562052300117077','86216200'), - ('673420124', '2580', '9517', '34562052300117069','42504099'), - ('600294609', '2715', '7474', '34569832304894588','55923317'), - ('600084713', '2703', '8342', '34569832304894570','8392636'), - ('600084732', '2704', '1625', '34569832304894513','75477452'), - ('600084850', '2705', '9896', '34569832304894653','28589813'), - ('600084951', '2706', '5520', '34569832304894661','75353012'), - ('600084978', '2707', '2698', '34569832304894679','9005523'), - ('600085403', '2708', '0837', '34569832304894646','77051152'), - ('600085513', '2709', '3106', '34569832304894687','41571002'), - ('600293916', '2712', '8990', '34569832304894620','95188676'), - ('600294160', '2714', '6376', '34569832304894703','79879896'), - ('671919529', '2975', '9184', '34569832304806236','7535392'), - ('671919942', '2981', '0328', '34569832304806269','31052894'), - ('671919530', '2976', '0344', '34569832304806251','89860304'), - ('671919533', '2977', '0668', '34569832304806244','42921771'), - ('671919535', '2978', '0105', '34569832304806277','31009417'), - ('671919537', '2979', '0881', '34569832304806285','33479769'), - ('671919540', '2980', '9874', '34569832304806293','14103929'), - ('671919525', '2972', '2089', '34569832304806301','45903729'), - ('671919527', '2973', '8206', '34569832304806368','1586035'), - ('671919528', '2974', '2532', '34569832304806327','62310124'), - ('673668717', '2836', '7973', '34562032301044223','15635496'), - ('673668734', '2837', '4457', '34562032301044231','18313118'), - ('673668738', '2824', '2911', '34562032301044249','30875583'), - ('673668745', '2838', '7253', '34562032301044256','62754222'), - ('673668796', '2839', '0068', '34562032301044264','15556829'), - ('673668803', '2840', '2386', '34562032301044272','17572287'), - ('673669591', '2850', '3833', '34562032301044280','34828896'), - ('673668808', '2841', '3584', '34562032301044298','16234497'), - ('673670102', '2851', '3554', '34562032301044306','23652625'), - ('673670131', '2852', '4412', '34562032301044314','88611709'), - ('673670135', '2827', '6058', '34562032301044322','53918579'), - ('673670201', '2828', '8066', '34562032301044330','92369343'), - ('673670225', '2829', '4592', '34562032301044348','24126635'), - ('673670236', '2830', '2974', '34562032301044355','88608465'), - ('673671485', '2849', '0349', '34562032301044363','44944874'), - ('673461977', '2871', '1728', '34562032400157090','46975780'), - ('673461975', '2870', '4734', '34562032400157082','69628432'), - ('673461972', '2867', '6276', '34562032400157058','53338365'), - ('673461979', '2872', '6043', '34562032400157108','36525197'), - ('673461958', '2859', '3164', '34562032400156977','58947831'), - ('673461957', '2857', '8685', '34562032400156969','15826386'), - ('673461944', '2853', '1073', '34562032400156910','20452195'), - ('673461974', '2869', '7121', '34562032400157074','32044645'), - ('673461973', '2868', '8022', '34562032400157066','29282044'), - ('673461971', '2866', '3089', '34562032400157041','66149978'), - ('673461969', '2865', '7555', '34562032400157033','78391293'), - ('673461960', '2860', '5203', '34562032400156985','37138232'), - ('673461952', '2855', '6915', '34562032400156936','62724661'), - ('673461949', '2854', '8706', '34562032400156928','5594345'), - ('673461966', '2863', '2496', '34562032400157017','93450666'), - ('673461968', '2864', '3703', '34562032400157025','23208841'), - ('673461963', '2862', '9364', '34562032400157009','29712130'), - ('673462719', '2873', '9387', '34562032400156951','50434348'), - ('673461962', '2861', '8441', '34562032400156993','39686909'), - ('673461956', '2826', '5392', '34562032400156944','5496107'), - ('673465284', '2694', '1523', '34562032400171349','14554994'), - ('673465282', '2692', '4645', '34562032400171323','24871187'), - ('673465283', '2693', '5253', '34562032400171331','28303238'), - ('673465841', '2696', '0849', '34562032400171257','21673222'), - ('673465258', '2679', '4140', '34562032400171174','39793881'), - ('673465263', '2680', '6922', '34562032400171182','12253261'), - ('673465265', '2681', '9112', '34562032400171190','93894366'), - ('673465267', '2682', '3259', '34562032400171208','2342189'), - ('673465268', '2683', '8540', '34562032400171216','63886925'), - ('673465285', '2695', '4167', '34562032400171356','79227618'), - ('673465270', '2684', '4292', '34562032400171224','19216349'), - ('673465272', '2685', '4007', '34562032400171232','14396903'), - ('673465273', '2686', '6894', '34562032400171240','13569394'), - ('673465274', '2687', '5268', '34562032400171265','59453667'), - ('673465275', '2688', '0232', '34562032400171273','62324713'), - ('673465276', '2689', '2720', '34562032400171281','65977200'), - ('673465843', '2698', '4773', '34562032400171364','78387158'), - ('673465842', '2697', '3729', '34562032400171315','94201789'), - ('673465280', '2691', '0503', '34562032400171307','12298533'), - ('673465279', '2690', '8239', '34562032400171299','76183877'); + ('621188151', 2209, '1486', '3456985220092508','14213470'), + ('621188152', 2210, '8765', '3456985220092509','99473093'), + ('621188153', 2211, '3064', '3456985220092510','52967210'), + ('621188759', 2081, '3700', '3456985220123637','56600999'), + ('621188760', 2082, '3259', '345698522023638','87492404'), + ('621188761', 2083, '2790', '3456985220123639','94009456'), + ('621188762', 2084, '2480', '3456985220123644','1484999'), + ('621188763', 2085, '6876', '3456985220123641','36577064'), + ('621188766', 2086, '7775', '3456985220123642','80761698'), + ('621188769', 2088, '4027', '3456985220123643','37921712'), + ('621188771', 2089, '8797', '3456985220123640','63092540'), + ('621188772', 2090, '8404', '3456985220123645','21014997'), + ('621188773', 2091, '5481', '3456985220123646','16317277'), + ('621188774', 2092, '9632', '3456985220123647','22235994'), + ('621188775', 2093, '4654', '3456985220123648','28506486'), + ('621188838', 2094, '1392', '3456985220123649','29498627'), + ('621188839', 2095, '7774', '3456985220123650','46263490'), + ('621188840', 2096, '7304', '3456985220123658','8212044'), + ('621188841', 2097, '5569', '3456985220123652','81597658'), + ('621188842', 2098, '4944', '3456985220123653','24961501'), + ('621188843', 2099, '5142', '3456985220123654','17035634'), + ('621188844', 2111, '7245', '3456985220123655','90231951'), + ('621188846', 2110, '6590', '3456985220123656','72201537'), + ('667680207', 2564, '4042', '34569832200759166','48401979'), + ('667680315', 2565, '7143', '34569832200759372','32143252'), + ('667680318', 2566, '6342', '34569832200759364','39597112'), + ('667680413', 2567, '5580', '34569832200759356','32786992'), + ('667680463', 2568, '0171', '34569832200759349','34240853'), + ('667688217', 2569, '2500', '34569832200759331','5687589'), + ('633603945', 2212, '7129', '34569832200759323','51554019'), + ('622130186', 2213, '4826', '34569832200759307','19623551'), + ('633973424', 2214, '8535', '34569832200759299','94619307'), + ('633703828', 2215, '8628', '34569832200759281','22468012'), + ('622025110', 2216, '2399', '34569832200759273','34602918'), + ('622924867', 2217, '5665', '34569832200759265','26920216'), + ('722409630', 2218, '5211', '34569832200759240','93750137'), + ('623590529', 2219, '0493', '34569832200759208','47077088'), + ('633243462', 2220, '6902', '34569832200759174','6421962'), + ('633047286', 2221, '5592', '34569832200759182','32069439'), + ('744716801', 2112, '9184', '34569832200759190','57049814'), + ('655995021', 2131, '8896', '34569852202049093','19497356'), + ('685522718', 2132, '1955', '34569852202049101','28519879'), + ('674587213', 2994, '2006', '34569332200223743','62360135'), + ('674587227', 2993, '9271', '34569332200223750','81628192'), + ('674587229', 2993, '0900', '34569332200223768','91119071'), + ('674587231', 2992, '5007', '34569332200223776','45826232'), + ('674587234', 2991, '1378', '34569332200223784','91245744'), + ('674587240', 2990, '0905', '34569332200223792','13083224'), + ('674587245', 2989, '9059', '34569332200223800','15291807'), + ('674587250', 2988, '8188', '34569332200223818','83017918'), + ('674587254', 2987, '2962', '34569332200223826','92809271'), + ('674587256', 2986, '0358', '34569332200223834','81067040'), + ('674592713', 2570, '2537', '34569332200230672','82325850'), + ('697832478', 2579, '0936', '34568732200494825','49658372'), + ('697832176', 2571, '5944', '34568732200494742','19039461'), + ('697832477', 2572, '5138', '34568732200494759','25712504'), + ('697832178', 2573, '4597', '34568732200494767','66241760'), + ('697832182', 2574, '9241', '34568732200494775','07342562'), + ('697832196', 2575, '2995', '34568732200494783','53929026'), + ('697832214', 2576, '7434', '34568732200494791','49698432'), + ('697832230', 2577, '7004', '34568732200494809','21578612'), + ('697832235', 2578, '9674', '34568732200494817','93090700'), + ('673420375', 2599, '5430', '34562052300117259','35911412'), + ('673420367', 2598, '8402', '34562052300117242','924654'), + ('673420361', 2597, '5125', '34562052300117234','12027970'), + ('673420355', 2596, '5069', '34562052300117226','34978149'), + ('673420348', 2595, '8911', '34562052300117218','4228121'), + ('673420346', 2594, '2461', '34562052300117200','67670772'), + ('673420345', 2593, '2226', '34562052300117192','90586404'), + ('673420306', 2592, '3355', '34562052300117184','97850017'), + ('673420257', 2591, '9395', '34562052300117176','50713786'), + ('673420231', 2590, '1378', '34562052300117168','50151763'), + ('673420223', 2589, '9580', '34562052300117150','99534550'), + ('673420216', 2588, '4955', '34562052300117143','317554'), + ('673420203', 2587, '6742', '34562052300117135','69321531'), + ('673420201', 2586, '1659', '34562052300117127','54720480'), + ('673420199', 2585, '7823', '34562052300117119','22923796'), + ('673420198', 2584, '1787', '34562052300117101','54414630'), + ('673420168', 2583, '6334', '34562052300117093','50694894'), + ('673420147', 2582, '8951', '34562052300117085','1402535'), + ('673420125', 2581, '3068', '34562052300117077','86216200'), + ('673420124', 2580, '9517', '34562052300117069','42504099'), + ('600294609', 2715, '7474', '34569832304894588','55923317'), + ('600084713', 2703, '8342', '34569832304894570','8392636'), + ('600084732', 2704, '1625', '34569832304894513','75477452'), + ('600084850', 2705, '9896', '34569832304894653','28589813'), + ('600084951', 2706, '5520', '34569832304894661','75353012'), + ('600084978', 2707, '2698', '34569832304894679','9005523'), + ('600085403', 2708, '0837', '34569832304894646','77051152'), + ('600085513', 2709, '3106', '34569832304894687','41571002'), + ('600293916', 2712, '8990', '34569832304894620','95188676'), + ('600294160', 2714, '6376', '34569832304894703','79879896'), + ('671919529', 2975, '9184', '34569832304806236','7535392'), + ('671919942', 2981, '0328', '34569832304806269','31052894'), + ('671919530', 2976, '0344', '34569832304806251','89860304'), + ('671919533', 2977, '0668', '34569832304806244','42921771'), + ('671919535', 2978, '0105', '34569832304806277','31009417'), + ('671919537', 2979, '0881', '34569832304806285','33479769'), + ('671919540', 2980, '9874', '34569832304806293','14103929'), + ('671919525', 2972, '2089', '34569832304806301','45903729'), + ('671919527', 2973, '8206', '34569832304806368','1586035'), + ('671919528', 2974, '2532', '34569832304806327','62310124'), + ('673668717', 2836, '7973', '34562032301044223','15635496'), + ('673668734', 2837, '4457', '34562032301044231','18313118'), + ('673668738', 2824, '2911', '34562032301044249','30875583'), + ('673668745', 2838, '7253', '34562032301044256','62754222'), + ('673668796', 2839, '0068', '34562032301044264','15556829'), + ('673668803', 2840, '2386', '34562032301044272','17572287'), + ('673669591', 2850, '3833', '34562032301044280','34828896'), + ('673668808', 2841, '3584', '34562032301044298','16234497'), + ('673670102', 2851, '3554', '34562032301044306','23652625'), + ('673670131', 2852, '4412', '34562032301044314','88611709'), + ('673670135', 2827, '6058', '34562032301044322','53918579'), + ('673670201', 2828, '8066', '34562032301044330','92369343'), + ('673670225', 2829, '4592', '34562032301044348','24126635'), + ('673670236', 2830, '2974', '34562032301044355','88608465'), + ('673671485', 2849, '0349', '34562032301044363','44944874'), + ('673461977', 2871, '1728', '34562032400157090','46975780'), + ('673461975', 2870, '4734', '34562032400157082','69628432'), + ('673461972', 2867, '6276', '34562032400157058','53338365'), + ('673461979', 2872, '6043', '34562032400157108','36525197'), + ('673461958', 2859, '3164', '34562032400156977','58947831'), + ('673461957', 2857, '8685', '34562032400156969','15826386'), + ('673461944', 2853, '1073', '34562032400156910','20452195'), + ('673461974', 2869, '7121', '34562032400157074','32044645'), + ('673461973', 2868, '8022', '34562032400157066','29282044'), + ('673461971', 2866, '3089', '34562032400157041','66149978'), + ('673461969', 2865, '7555', '34562032400157033','78391293'), + ('673461960', 2860, '5203', '34562032400156985','37138232'), + ('673461952', 2855, '6915', '34562032400156936','62724661'), + ('673461949', 2854, '8706', '34562032400156928','5594345'), + ('673461966', 2863, '2496', '34562032400157017','93450666'), + ('673461968', 2864, '3703', '34562032400157025','23208841'), + ('673461963', 2862, '9364', '34562032400157009','29712130'), + ('673462719', 2873, '9387', '34562032400156951','50434348'), + ('673461962', 2861, '8441', '34562032400156993','39686909'), + ('673461956', 2826, '5392', '34562032400156944','5496107'), + ('673465284', 2694, '1523', '34562032400171349','14554994'), + ('673465282', 2692, '4645', '34562032400171323','24871187'), + ('673465283', 2693, '5253', '34562032400171331','28303238'), + ('673465841', 2696, '0849', '34562032400171257','21673222'), + ('673465258', 2679, '4140', '34562032400171174','39793881'), + ('673465263', 2680, '6922', '34562032400171182','12253261'), + ('673465265', 2681, '9112', '34562032400171190','93894366'), + ('673465267', 2682, '3259', '34562032400171208','2342189'), + ('673465268', 2683, '8540', '34562032400171216','63886925'), + ('673465285', 2695, '4167', '34562032400171356','79227618'), + ('673465270', 2684, '4292', '34562032400171224','19216349'), + ('673465272', 2685, '4007', '34562032400171232','14396903'), + ('673465273', 2686, '6894', '34562032400171240','13569394'), + ('673465274', 2687, '5268', '34562032400171265','59453667'), + ('673465275', 2688, '0232', '34562032400171273','62324713'), + ('673465276', 2689, '2720', '34562032400171281','65977200'), + ('673465843', 2698, '4773', '34562032400171364','78387158'), + ('673465842', 2697, '3729', '34562032400171315','94201789'), + ('673465280', 2691, '0503', '34562032400171307','12298533'), + ('673465279', 2690, '8239', '34562032400171299','76183877'); UPDATE vn.deviceProductionUser SET simFk = NULL From acfafa1c7299f6eb203460f679f42d57a6b39fda Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 17 Dec 2024 12:44:55 +0100 Subject: [PATCH 098/108] fix: monitorPayMethodFilter --- .../monitor/back/methods/sales-monitor/salesFilter.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 95713f9fb..ac8a722bd 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -98,6 +98,11 @@ module.exports = Self => { arg: 'countryFk', type: 'number', description: 'The country id filter' + }, + { + arg: 'payMethod', + type: 'string', + description: 'The payment method filter' } ], returns: { @@ -165,6 +170,8 @@ module.exports = Self => { case 'clientFk': param = `t.${param}`; return {[param]: value}; + case 'payMethod': + return {'c.payMethodFk': value}; } }); @@ -205,6 +212,8 @@ module.exports = Self => { u.name userName, c.salesPersonFk, c.credit, + c.payMethodFk payMethodFk, + pm.id payMethodId, pm.name payMethod, z.hour zoneLanding, z.name zoneName, From f965f7aa52d2bd394ecd89d2bd7b1538c84f81e0 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 17 Dec 2024 12:46:48 +0100 Subject: [PATCH 099/108] fix: refs #6583 update onlyWithDestination logic to handle null values correctly --- modules/ticket/back/methods/ticket/getTicketsAdvance.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index 6abac455f..58d46173c 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -109,8 +109,7 @@ module.exports = Self => { case 'departmentFk': return {'f.departmentFk': value}; case 'onlyWithDestination': - if (!value) return; - return {'f.id': {neq: null}}; + return {'f.id': value ? {neq: null} : null}; } }); From b935878dd6ec75820bf1d4159c20d029f4b6b0a1 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 17 Dec 2024 12:58:25 +0100 Subject: [PATCH 100/108] feat: refs #6583 add tests --- .../ticket/specs/getTicketsAdvance.spec.js | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index a941013cd..bb7f230ee 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -167,4 +167,56 @@ describe('TicketFuture getTicketsAdvance()', () => { throw e; } }); + + it('should return the tickets with only destination', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const args = { + dateFuture: today, + dateToAdvance: today.setHours(23, 59, 59, 999), + warehouseFk: 1, + }; + ctx.args = args; + + const allTickets = await models.Ticket.getTicketsAdvance(ctx, options); + ctx.args.onlyWithDestination = true; + const withDestinationTickets = await models.Ticket.getTicketsAdvance(ctx, options); + + expect(allTickets.filter(ticket => ticket.id).length).toBe(withDestinationTickets.length); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + fit('should return the tickets without only destination', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const args = { + dateFuture: today, + dateToAdvance: today.setHours(23, 59, 59, 999), + warehouseFk: 1, + }; + ctx.args = args; + + const allTickets = await models.Ticket.getTicketsAdvance(ctx, options); + ctx.args.onlyWithDestination = false; + const withoutDestinationTickets = await models.Ticket.getTicketsAdvance(ctx, options); + + expect(allTickets.filter(ticket => !ticket.id).length).toBe(withoutDestinationTickets.length); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); From 9ac8e60f0cb31de688f8d385d16afab5f603f525 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 17 Dec 2024 12:58:57 +0100 Subject: [PATCH 101/108] fix: refs #6583 drop focus --- .../ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index bb7f230ee..e71942341 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -194,7 +194,7 @@ describe('TicketFuture getTicketsAdvance()', () => { } }); - fit('should return the tickets without only destination', async() => { + it('should return the tickets without only destination', async() => { const tx = await models.Ticket.beginTransaction({}); try { From 31952725aa23b50171f42f27b914d1656dc130d6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 17 Dec 2024 13:33:29 +0100 Subject: [PATCH 102/108] refactor: refs #6583 use warehouseId var --- .../ticket/specs/getTicketsAdvance.spec.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index e71942341..157cdb1ff 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -8,6 +8,7 @@ describe('TicketFuture getTicketsAdvance()', () => { tomorrow.setDate(today.getDate() + 1); const salesDeptId = 43; const spain1DeptId = 95; + const warehouseId = 1; beforeAll.mockLoopBackContext(); it('should return the tickets passing the required data', async() => { @@ -19,7 +20,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, }; ctx.args = args; @@ -42,7 +43,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, isFullMovable: true }; @@ -67,7 +68,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, isFullMovable: false }; @@ -92,7 +93,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, ipt: 'V' }; @@ -117,7 +118,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, tfIpt: 'V' }; @@ -141,7 +142,7 @@ describe('TicketFuture getTicketsAdvance()', () => { ctx.args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, }; await models.Ticket.updateAll({id: {inq: [12, 31]}}, {clientFk: 1}, options); @@ -177,7 +178,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: today, dateToAdvance: today.setHours(23, 59, 59, 999), - warehouseFk: 1, + warehouseFk: warehouseId, }; ctx.args = args; @@ -203,7 +204,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: today, dateToAdvance: today.setHours(23, 59, 59, 999), - warehouseFk: 1, + warehouseFk: warehouseId, }; ctx.args = args; From 1a8b05c46bb782a2fd46e1b05329be25744fac2b Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 18 Dec 2024 07:08:23 +0100 Subject: [PATCH 103/108] fix: refs #8315 fixture claimDevelopment --- db/dump/fixtures.before.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 57a9f9ca8..c2afbb7b4 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1922,7 +1922,7 @@ INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`) INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`) VALUES - (1, 1, 1, 21, 1, 1, 2, 5), + (1, 1, 1, 21, 7, 1, 2, 5), (2, 1, 2, 21, 7, 2, 2, 5), (3, 2, 7, 21, 9, 3, 2, 5), (4, 3, 7, 21, 15, 8, 2, 5), From c0893f8684e4d6cdbe1f2af731d5c2c81c09076a Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 18 Dec 2024 13:06:01 +0100 Subject: [PATCH 104/108] feat: refs #7936 add locale --- modules/invoiceIn/back/locale/invoiceIn/en.yml | 7 ++++++- modules/invoiceIn/back/locale/invoiceIn/es.yml | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/invoiceIn/back/locale/invoiceIn/en.yml b/modules/invoiceIn/back/locale/invoiceIn/en.yml index 9e94eba0d..6940b6f77 100644 --- a/modules/invoiceIn/back/locale/invoiceIn/en.yml +++ b/modules/invoiceIn/back/locale/invoiceIn/en.yml @@ -17,4 +17,9 @@ columns: isVatDeductible: is VAT deductible withholdingSageFk: withholding expenseFkDeductible: expense deductible - editorFk: editor \ No newline at end of file + editorFk: editor + cplusRectificationTypeFk: cplus rectification type + cplusSubjectOpFk: cplus subject op + cplusTaxBreakFk: cplus tax break + siiTrasCendencyInvoiceInFk: sii tras cendency invoice in + siiTypeInvoiceInFk: sii type invoice in \ No newline at end of file diff --git a/modules/invoiceIn/back/locale/invoiceIn/es.yml b/modules/invoiceIn/back/locale/invoiceIn/es.yml index bd64c4327..9599c0535 100644 --- a/modules/invoiceIn/back/locale/invoiceIn/es.yml +++ b/modules/invoiceIn/back/locale/invoiceIn/es.yml @@ -5,7 +5,7 @@ columns: serial: serie supplierFk: proveedor issued: fecha emisión - supplierRef: referéncia proveedor + supplierRef: referencia proveedor isBooked: facturado currencyFk: moneda created: creado @@ -17,4 +17,9 @@ columns: isVatDeductible: impuesto deducible withholdingSageFk: código de retención expenseFkDeductible: gasto deducible - editorFk: editor \ No newline at end of file + editorFk: editor + cplusRectificationTypeFk: tipo de rectificación cplus + cplusSubjectOpFk: sujeto op cplus + cplusTaxBreakFk: exención fiscal cplus + siiTrasCendencyInvoiceInFk: trascendencia sii factura recibida + siiTypeInvoiceInFk: tipo sii factura recibida \ No newline at end of file From 1f7dae2514a238ec9d49ef8c9e076b109735a649 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 19 Dec 2024 10:34:46 +0100 Subject: [PATCH 105/108] fix: refs #7936 locale --- modules/invoiceIn/back/locale/invoiceIn/en.yml | 7 ++----- modules/invoiceIn/back/locale/invoiceIn/es.yml | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/modules/invoiceIn/back/locale/invoiceIn/en.yml b/modules/invoiceIn/back/locale/invoiceIn/en.yml index 6940b6f77..f590f9656 100644 --- a/modules/invoiceIn/back/locale/invoiceIn/en.yml +++ b/modules/invoiceIn/back/locale/invoiceIn/en.yml @@ -18,8 +18,5 @@ columns: withholdingSageFk: withholding expenseFkDeductible: expense deductible editorFk: editor - cplusRectificationTypeFk: cplus rectification type - cplusSubjectOpFk: cplus subject op - cplusTaxBreakFk: cplus tax break - siiTrasCendencyInvoiceInFk: sii tras cendency invoice in - siiTypeInvoiceInFk: sii type invoice in \ No newline at end of file + siiTrasCendencyInvoiceInFk: SII tax regime + siiTypeInvoiceInFk: SII Type \ No newline at end of file diff --git a/modules/invoiceIn/back/locale/invoiceIn/es.yml b/modules/invoiceIn/back/locale/invoiceIn/es.yml index 9599c0535..494764d07 100644 --- a/modules/invoiceIn/back/locale/invoiceIn/es.yml +++ b/modules/invoiceIn/back/locale/invoiceIn/es.yml @@ -18,8 +18,5 @@ columns: withholdingSageFk: código de retención expenseFkDeductible: gasto deducible editorFk: editor - cplusRectificationTypeFk: tipo de rectificación cplus - cplusSubjectOpFk: sujeto op cplus - cplusTaxBreakFk: exención fiscal cplus - siiTrasCendencyInvoiceInFk: trascendencia sii factura recibida - siiTypeInvoiceInFk: tipo sii factura recibida \ No newline at end of file + siiTrasCendencyInvoiceInFk: Régimen fiscal SII + siiTypeInvoiceInFk: Tipo SII \ No newline at end of file From 6abbf3ec1d5ddcf7b55191a82db99f00c0af82cd Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 19 Dec 2024 13:01:34 +0100 Subject: [PATCH 106/108] fix: refs #7936 update Spanish locale for SII terms --- modules/invoiceIn/back/locale/invoiceIn/es.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/invoiceIn/back/locale/invoiceIn/es.yml b/modules/invoiceIn/back/locale/invoiceIn/es.yml index 494764d07..64ded6aca 100644 --- a/modules/invoiceIn/back/locale/invoiceIn/es.yml +++ b/modules/invoiceIn/back/locale/invoiceIn/es.yml @@ -18,5 +18,5 @@ columns: withholdingSageFk: código de retención expenseFkDeductible: gasto deducible editorFk: editor - siiTrasCendencyInvoiceInFk: Régimen fiscal SII - siiTypeInvoiceInFk: Tipo SII \ No newline at end of file + siiTrasCendencyInvoiceInFk: régimen fiscal SII + siiTypeInvoiceInFk: tipo SII \ No newline at end of file From 67c484cd876ab4472e3c1b6e7754d6292a4d51f7 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 3 Jan 2025 09:39:49 +0100 Subject: [PATCH 107/108] feat: refs #7301 update SQL fixtures and enhance lastEntriesFilter logic --- db/dump/fixtures.before.sql | 11 ++-- .../back/methods/item/lastEntriesFilter.js | 30 ++++++---- .../item/specs/lastEntriesFilter.spec.js | 57 +++++++++++++------ 3 files changed, 68 insertions(+), 30 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 97ed0ae47..ff24fa2a6 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1516,7 +1516,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, FALSE, NULL), (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2), (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), - (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL); + (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), + (13, util.VN_CURDATE() - INTERVAL 1 MONTH - INTERVAL 1 DAY, util.VN_CURDATE() - INTERVAL 1 MONTH, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`) VALUES @@ -1529,8 +1530,9 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven', 'product'), (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, '', 'product'), (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, '', 'product'), - (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10',1, '', 'product'), - (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 11',0, '', 'product'), + (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2010', 'Movement 10',1, '', 'product'), + (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 1, 442, 'IN2011', 'Movement 11',0, '', 'product'), + (12, 4, util.VN_CURDATE() - INTERVAL 1 MONTH, 13, 1, 442, 'IN2012', 'Movement 12',0, '', 'product'), (99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99',0, '', 'product'); INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) @@ -1572,7 +1574,8 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'), - (17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH); + (17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), + (18, 12, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH); INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) VALUES diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js index 06c60162f..b038bb155 100644 --- a/modules/item/back/methods/item/lastEntriesFilter.js +++ b/modules/item/back/methods/item/lastEntriesFilter.js @@ -29,10 +29,12 @@ module.exports = Self => { Object.assign(myOptions, options); const stmt = new ParameterizedSQL( - `SELECT w.id AS warehouseFk, - w.name AS warehouse, - tr.landed, - b.id AS buyFk, + `SELECT i.id itemFk, + w.id warehouseFk, + w.name warehouse, + CAST(tr.landed AS CHAR) landed, + tr.landed landedDate, + b.id buyFk, b.entryFk, b.isIgnored, b.price2, @@ -47,15 +49,18 @@ module.exports = Self => { b.buyingValue + b.freightValue + b.comissionValue + - b.packageValue AS cost, + b.packageValue cost, b.buyingValue, b.freightValue, b.comissionValue, b.packageValue, b.packagingFk , - s.id AS supplierFk, - s.name AS supplier, - b.printedStickers + s.id supplierFk, + s.name supplier, + b.printedStickers, + c.inventoried, + ic.supplierFk inventorySupplierFk, + s.id = ic.supplierFk isInventorySupplier FROM itemType it RIGHT JOIN (entry e LEFT JOIN supplier s ON s.id = e.supplierFk @@ -66,9 +71,14 @@ module.exports = Self => { LEFT JOIN warehouse w ON w.id = tr.warehouseInFk LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk - LEFT JOIN edi.ekt ek ON b.ektFk = ek.id` + LEFT JOIN edi.ekt ek ON b.ektFk = ek.id + JOIN config c + JOIN inventoryConfig ic` ); - stmt.merge(conn.makeSuffix(filter)); + + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge('AND IF(s.id = ic.supplierFk, tr.landed = DATE(c.inventoried), TRUE)'); + stmt.merge(conn.makePagination(filter)); return conn.executeStmt(stmt, myOptions); }; diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index d4429e158..b2bfdf59c 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,16 +1,22 @@ const {models} = require('vn-loopback/server/server'); +const itemFk = 1; + +const today = Date.vnNew(); +today.setHours(23, 59, 59, 999); + +const twoMonthsAgo = Date.vnNew(); +twoMonthsAgo.setHours(0, 0, 0, 0); +twoMonthsAgo.setMonth(twoMonthsAgo.getMonth() - 2, 1); describe('item lastEntriesFilter()', () => { it('should return two entry for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}}; + const filter = {where: {itemFk, landed: {between: [minDate, today]}}}; const result = await models.Item.lastEntriesFilter(filter, options); expect(result.length).toEqual(2); @@ -23,22 +29,14 @@ describe('item lastEntriesFilter()', () => { }); it('should return six entries for the given item', async() => { - const minDate = Date.vnNew(); - minDate.setHours(0, 0, 0, 0); - minDate.setMonth(minDate.getMonth() - 2, 1); - - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); - const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const itemFk = 1; - const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; + const filter = {where: {itemFk, landed: {between: [twoMonthsAgo, today]}}}; const result = await models.Item.lastEntriesFilter(filter, options); - const minDateUtc = new Date(minDate).getTime(); - const maxDateUtc = new Date(maxDate).getTime(); + const twoMonthsAgoUtc = twoMonthsAgo.getTime(); + const todayUtc = today.getTime(); const resultMatch = ( await Promise.all( @@ -50,8 +48,8 @@ describe('item lastEntriesFilter()', () => { }); const isItemFkValid = itemRecord?.id === itemFk; - const landedDate = new Date(item.landed).getTime(); - const isLandedValid = landedDate >= minDateUtc && landedDate <= maxDateUtc; + const landedDate = Date.vnNew(item.landed).getTime(); + const isLandedValid = landedDate >= twoMonthsAgoUtc && landedDate <= todayUtc; return isItemFkValid && isLandedValid; }) @@ -66,4 +64,31 @@ describe('item lastEntriesFilter()', () => { throw e; } }); + + it('should return just the inventoried inventory', async() => { + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; + + try { + const filter = {where: {itemFk, landed: {between: [twoMonthsAgo, today]}}}; + const result = await models.Item.lastEntriesFilter(filter, options); + + const {supplierFk} = await models.InventoryConfig.findOne(options); + const {inventoried} = await models.Config.findOne(options); + + let hasInventoriedDate = false; + result.forEach(entry => { + if (entry.supplierFk === supplierFk && + entry.landedDate.getTime() === inventoried.getTime() + )hasInventoriedDate = true; + }); + + expect(hasInventoriedDate).toEqual(true); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); From dc52c08c150b5cbb638193af2b018f045c15cec7 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 6 Jan 2025 19:30:06 +0100 Subject: [PATCH 108/108] build: refs #8355 add changelog --- CHANGELOG.md | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73ebecabc..c4eb7d29a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,106 @@ +# Version 24.52 - 2024-01-07 + +### Added 🆕 + +- chore: pullinfo by:alexm +- chore: refs #8002 drop comments by:jorgep +- chore: refs #8002 drop useless code by:jorgep +- feat: added translations and show error in item-type by:Jon +- feat: modified data to be equal as the updated back by:Jon +- feat: refs #4460 invoiceIn refund by:Carlos Andrés +- feat: refs #4466 invoiceIn refund by:Carlos Andrés +- feat: refs #6583 add new opt in where builder by:jorgep +- feat: refs #6583 add tests by:jorgep +- feat: refs #6583 retrieve cloned sale by:jorgep +- feat: refs #6583 rollback by:jorgep +- feat: refs #7301 add inventory-config and acl by:pablone +- feat: refs #7301 update SQL fixtures and enhance lastEntriesFilter logic by:pablone +- feat: refs #7882 Added locationiq service by:guillermo +- feat: refs #7882 Added osrm service by:guillermo +- feat: refs #7882 Added tests by:guillermo +- feat: refs #7882 Fixed problems osrm service by:guillermo +- feat: refs #7882 Osrm service by:guillermo +- feat: refs #7882 Reequested changes by:guillermo +- feat: refs #7882 Requested changes by:guillermo +- feat: refs #7936 add back test for updateInvoiceIn by:jorgep +- feat: refs #7936 add company filter by:jorgep +- feat: refs #7936 add currency check to updateInvoiceIn by:jorgep +- feat: refs #7936 add currency handling in invoiceIn trigger by:jorgep +- feat: refs #7936 add locale by:jorgep +- feat: refs #7936 add minimum due date by:jorgep +- feat: refs #7936 add reference rates for currency in fixtures by:jorgep +- feat: refs #7936 add save validation by:jorgep +- feat: refs #7936 add SiiTypeInvoiceIn model and update invoice correction logic by:jorgep +- feat: refs #7936 add tests for invoiceIn by:jorgep +- feat: refs #7936 add tests for invoiceIn filter by:jorgep +- feat: refs #7936 add validation to InvoiceIn & InvoiceInTax by:jorgep +- feat: refs #7936 return country code & is vies fields by:jorgep +- feat: refs #8002 adjust to lilium by:jorgep +- feat: refs #8002 drop support btn by:jorgep +- feat: refs #8174 Changed datatype incompatibility access by:guillermo +- feat: refs #8174 Created table sim by:guillermo +- feat: refs #8174 create table simsupplier by:Jbreso +- feat: refs #8174 fix by:Jbreso +- feat: refs#8174 simSupplier by:Jbreso +- feat: refs #8190 entry_getCommission by:robert +- feat: refs #8190 entry_getCommission change request by:robert +- feat: refs #8218 Added time and code in mistakeType by:guillermo +- feat: refs #8293 include zone data by:Jtubau +- refactor: refs #6583 entry report table style by:jorgep + +### Changed 📦 + +- refactor: refs #6583 entry report table style by:jorgep +- refactor: refs #6583 use warehouseId var by:jorgep +- refactor: refs #7301 update entry and item filter tests to validate results against specific criteria by:pablone +- refactor: refs #7882 Added ACL's by:guillermo +- refactor: refs #7882 Deleted quadminds files by:guillermo +- refactor: refs #7936 add transaction & tests by:jorgep +- refactor: refs #7936 remove old trigger and add isRaid column to travel table by:jorgep +- refactor: refs #7936 remove schema by:jorgep +- refactor: refs #8002 use loop wip by:jorgep +- refactor: refs #8004 simplify SQL query by removing redundant aliases by:pablone +- refactor: refs #8262 Deprecated inventoryFailure by:guillermo +- refactor: refs #8266 changed expedition item name by:Jtubau +- refactor: refs #8272 delete bi.rotacion by:ivanm + +### Fixed 🛠️ + +- feat: refs #7301 update SQL fixtures and enhance lastEntriesFilter logic by:pablone +- feat: refs #7936 add reference rates for currency in fixtures by:jorgep +- feat: refs #8174 fix by:Jbreso +- fix: 8174 pasar PIN a CHAR by:Jbreso +- fix: monitorPayMethodFilter by:carlossa +- fix: refs #6389 back by:carlossa +- fix: refs #6389 filter by:carlossa +- fix: refs #6389 packing by:carlossa +- fix: refs #6389 saleMonitor filter by:carlossa +- fix: refs #6389 salesFilter by:carlossa +- fix: refs #6583 drop focus by:jorgep +- fix: refs #6583 update onlyWithDestination logic to handle null values correctly by:jorgep +- fix: refs #7028 fix confirm deny by:carlossa +- fix: refs #7028 fix pr by:carlossa +- fix: refs #7028 fix tback findById by:carlossa +- fix: refs #7028 fix userError by:carlossa +- fix: refs #7028 remove ifs by:carlossa +- fix: refs #7028 requesterId fix by:carlossa +- fix: refs #7028 requesterId fix salesPerson by:carlossa +- fix: refs #7031 fix vnPrice by:carlossa +- fix: refs #7031 remove check by:carlossa +- fix: refs #7301 update ACL insertion to use INSERT IGNORE and refine property value by:pablone +- fix: refs #7936 add IF NOT EXISTS to isRaid column in travel table by:jorgep +- fix: refs #7936 change type by:jorgep +- fix: refs #7936 check if insert in hook & change test description by:jorgep +- fix: refs #7936 conflicts by:jorgep +- fix: refs #7936 locale by:jorgep +- fix: refs #7936 update Spanish locale for SII terms by:jorgep +- fix: refs #8174 fix by:Jbreso +- fix: refs#8174 fix by:Jbreso +- fix: refs8174 pasar a char el PIN by:Jbreso +- fix: refs #8174 Version by:guillermo +- fix: refs #8251 add eng template by:carlossa +- fix: refs #8315 fixture claimDevelopment by:alexm + # Version 24.48 - 2024-11-25 ### Added 🆕
{{$t('reference')}} {{$t('boxes')}} {{$t('packing')}}{{$t('concept')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}{{$t('concept')}}{{$t('reference')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
{{buy.comment}} {{buy.stickers}}x{{buy.packing}}{{buy.name}} - {{buy.tag5}} → {{buy.value5}} - {{buy.tag6}} → {{buy.value6}} - {{buy.tag7}} → {{buy.value7}} + x{{buy.packing}}{{buy.name}}{{buy.comment}} + {{buy.tag5}} → {{buy.value5}} + {{buy.tag6}} → {{buy.value6}} + {{buy.tag7}} → {{buy.value7}} {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= + {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= {{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}