From 4d7ac901c6f46fe798b71ba67e7e1008c0636771 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 14 May 2024 07:52:21 +0200 Subject: [PATCH 01/74] feat: refs #3199 Added more scopes ticket_recalcByScope --- .../vn/procedures/ticket_recalcByScope.sql | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index 41105fe23..833ce712d 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -14,10 +14,19 @@ BEGIN DECLARE vTicketFk INT; DECLARE cTickets CURSOR FOR - SELECT id FROM ticket - WHERE refFk IS NULL - AND ((vScope = 'client' AND clientFk = vId) - OR (vScope = 'address' AND addressFk = vId)); + SELECT DISTINCT t.id + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk + WHERE t.refFk IS NULL + DATE(t.shipped) > util.VN_CURDATE() + AND ( + (vScope = 'client' AND t.clientFk = vId) + OR (vScope = 'address' AND t.addressFk = vId) + OR (vScope = 'item' AND itc.itemFk = vId) + OR (vScope = 'country' AND itc.countryFk = vId) + OR (vScope = 'taxClass' AND itc.taxClassFk = vId) + ); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; From 1ba6bf9a9c728c052d0fba75f5ab4505c431d85a Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 14 May 2024 07:54:52 +0200 Subject: [PATCH 02/74] feat: refs #3199 Added more scopes ticket_recalcByScope --- db/routines/vn/procedures/ticket_recalcByScope.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index 833ce712d..e484c2890 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -19,7 +19,7 @@ BEGIN JOIN sale s ON s.ticketFk = t.id JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk WHERE t.refFk IS NULL - DATE(t.shipped) > util.VN_CURDATE() + AND DATE(t.shipped) > util.VN_CURDATE() AND ( (vScope = 'client' AND t.clientFk = vId) OR (vScope = 'address' AND t.addressFk = vId) From 7d47a986bf9797764a12c0cc5e3c16024b04b5e5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 14 May 2024 08:24:11 +0200 Subject: [PATCH 03/74] feat: refs #3199 Created ticket_recalcItemTaxCountryByScope --- .../vn/procedures/ticket_recalcByScope.sql | 17 ++----- .../ticket_recalcItemTaxCountryByScope.sql | 47 +++++++++++++++++++ 2 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 db/routines/vn/procedures/ticket_recalcItemTaxCountryByScope.sql diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index e484c2890..41105fe23 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -14,19 +14,10 @@ BEGIN DECLARE vTicketFk INT; DECLARE cTickets CURSOR FOR - SELECT DISTINCT t.id - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk - WHERE t.refFk IS NULL - AND DATE(t.shipped) > util.VN_CURDATE() - AND ( - (vScope = 'client' AND t.clientFk = vId) - OR (vScope = 'address' AND t.addressFk = vId) - OR (vScope = 'item' AND itc.itemFk = vId) - OR (vScope = 'country' AND itc.countryFk = vId) - OR (vScope = 'taxClass' AND itc.taxClassFk = vId) - ); + SELECT id FROM ticket + WHERE refFk IS NULL + AND ((vScope = 'client' AND clientFk = vId) + OR (vScope = 'address' AND addressFk = vId)); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; diff --git a/db/routines/vn/procedures/ticket_recalcItemTaxCountryByScope.sql b/db/routines/vn/procedures/ticket_recalcItemTaxCountryByScope.sql new file mode 100644 index 000000000..82b2a4a48 --- /dev/null +++ b/db/routines/vn/procedures/ticket_recalcItemTaxCountryByScope.sql @@ -0,0 +1,47 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcItemTaxCountryByScope`( + vScope VARCHAR(255), + vId INT +) +BEGIN +/** + * Recalculates tickets in an scope. + * + * @param vScope The scope name + * @param vId The scope id + */ + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + + DECLARE cTickets CURSOR FOR + SELECT DISTINCT t.id + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk + WHERE t.refFk IS NULL + AND DATE(t.shipped) > util.VN_CURDATE() + AND ( + (vScope = 'item' AND itc.itemFk = vId) + OR (vScope = 'country' AND itc.countryFk = vId) + OR (vScope = 'taxClass' AND itc.taxClassFk = vId) + ); + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cTickets; + + myLoop: LOOP + SET vDone = FALSE; + FETCH cTickets INTO vTicketFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + CALL ticket_recalc(vTicketFk, NULL); + END LOOP; + + CLOSE cTickets; +END$$ +DELIMITER ; From 2cee9c9c01799d53f0a784133735b838b6844b2f Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 14 May 2024 08:58:44 +0200 Subject: [PATCH 04/74] feat: refs #3199 Added one more scope ticket_recalcByScope --- .../vn/procedures/ticket_recalcByScope.sql | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index 41105fe23..c5df8f82d 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -14,10 +14,17 @@ BEGIN DECLARE vTicketFk INT; DECLARE cTickets CURSOR FOR - SELECT id FROM ticket - WHERE refFk IS NULL - AND ((vScope = 'client' AND clientFk = vId) - OR (vScope = 'address' AND addressFk = vId)); + SELECT DISTINCT t.id + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk + WHERE t.refFk IS NULL + AND DATE(t.shipped) > util.VN_CURDATE() + AND ( + (vScope = 'client' AND t.clientFk = vId) + OR (vScope = 'address' AND t.addressFk = vId) + OR (vScope = 'item' AND itc.itemFk = vId) + ); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; From 9b09bc4efb2ffec0312bccba4b6831ddca660c87 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 14 May 2024 08:59:11 +0200 Subject: [PATCH 05/74] feat: refs #3199 Added one more scope ticket_recalcByScope --- .../ticket_recalcItemTaxCountryByScope.sql | 47 ------------------- 1 file changed, 47 deletions(-) delete mode 100644 db/routines/vn/procedures/ticket_recalcItemTaxCountryByScope.sql diff --git a/db/routines/vn/procedures/ticket_recalcItemTaxCountryByScope.sql b/db/routines/vn/procedures/ticket_recalcItemTaxCountryByScope.sql deleted file mode 100644 index 82b2a4a48..000000000 --- a/db/routines/vn/procedures/ticket_recalcItemTaxCountryByScope.sql +++ /dev/null @@ -1,47 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcItemTaxCountryByScope`( - vScope VARCHAR(255), - vId INT -) -BEGIN -/** - * Recalculates tickets in an scope. - * - * @param vScope The scope name - * @param vId The scope id - */ - DECLARE vDone BOOL; - DECLARE vTicketFk INT; - - DECLARE cTickets CURSOR FOR - SELECT DISTINCT t.id - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk - WHERE t.refFk IS NULL - AND DATE(t.shipped) > util.VN_CURDATE() - AND ( - (vScope = 'item' AND itc.itemFk = vId) - OR (vScope = 'country' AND itc.countryFk = vId) - OR (vScope = 'taxClass' AND itc.taxClassFk = vId) - ); - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - OPEN cTickets; - - myLoop: LOOP - SET vDone = FALSE; - FETCH cTickets INTO vTicketFk; - - IF vDone THEN - LEAVE myLoop; - END IF; - - CALL ticket_recalc(vTicketFk, NULL); - END LOOP; - - CLOSE cTickets; -END$$ -DELIMITER ; From 4757ce11a34bfc5064a6a38db41283f7da55986d Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 8 Jul 2024 12:35:29 +0200 Subject: [PATCH 06/74] refactor: refs #7567 Fix and improvement --- db/routines/srt/events/moving_clean.sql | 6 +- db/routines/srt/procedures/moving_clean.sql | 84 ++++++++++--------- .../11141-azureRoebelini/00-firstScript.sql | 1 + 3 files changed, 48 insertions(+), 43 deletions(-) create mode 100644 db/versions/11141-azureRoebelini/00-firstScript.sql diff --git a/db/routines/srt/events/moving_clean.sql b/db/routines/srt/events/moving_clean.sql index a6f7792a2..650c15c62 100644 --- a/db/routines/srt/events/moving_clean.sql +++ b/db/routines/srt/events/moving_clean.sql @@ -5,9 +5,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `srt`.`moving_clean` ON COMPLETION PRESERVE ENABLE COMMENT 'Llama a srt.moving_clean para que elimine y notifique de registr' -DO BEGIN - - CALL srt.moving_clean(); - -END$$ +DO CALL srt.moving_clean()$$ DELIMITER ; diff --git a/db/routines/srt/procedures/moving_clean.sql b/db/routines/srt/procedures/moving_clean.sql index b8fae7ff4..446ad3588 100644 --- a/db/routines/srt/procedures/moving_clean.sql +++ b/db/routines/srt/procedures/moving_clean.sql @@ -3,61 +3,69 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`moving_clean`() BEGIN /** * Elimina movimientos por inactividad - * */ DECLARE vExpeditionFk INT; DECLARE vBufferToFk INT; DECLARE vBufferFromFk INT; - DECLARE done BOOL DEFAULT FALSE; - - DECLARE cur CURSOR FOR + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSorter CURSOR FOR SELECT m.expeditionFk, m.bufferToFk, m.bufferFromFk - FROM srt.moving m - JOIN srt.config c - JOIN (SELECT bufferFk, SUM(isActive) hasBox - FROM srt.photocell - GROUP BY bufferFk) sub ON sub.bufferFk = m.bufferFromFk - WHERE m.created < TIMESTAMPADD(MINUTE, - c.movingMaxLife , util.VN_NOW()) + FROM moving m + JOIN ( + SELECT bufferFk, SUM(isActive) hasBox + FROM photocell + GROUP BY bufferFk + ) sub ON sub.bufferFk = m.bufferFromFk + WHERE m.created < (util.VN_NOW() - INTERVAL (SELECT movingMaxLife FROM config) MINUTE) AND NOT sub.hasBox; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - OPEN cur; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; - bucle: LOOP + OPEN vSorter; + l: LOOP + SET vDone = FALSE; + FETCH vSorter INTO vExpeditionFk, vBufferToFk, vBufferFromFk; - FETCH cur INTO vExpeditionFk, vBufferToFk, vBufferFromFk; - - IF done THEN - LEAVE bucle; + IF vDone THEN + LEAVE l; END IF; - DELETE FROM srt.moving + START TRANSACTION; + + SELECT id + FROM moving + WHERE expeditionFk = vExpeditionFk + FOR UPDATE; + + DELETE FROM moving WHERE expeditionFk = vExpeditionFk; - UPDATE srt.expedition e - JOIN srt.expeditionState es ON es.description = 'OUT' - SET - bufferFk = NULL, + SELECT id + FROM expedition + WHERE id = vExpeditionFk + OR (bufferFk = vBufferFromFk AND `position` > 0) + FOR UPDATE; + + UPDATE expedition + SET bufferFk = NULL, `position` = NULL, - stateFk = es.id - WHERE e.id = vExpeditionFk; + stateFk = (SELECT id FROM expeditionState WHERE `description` = 'OUT') + WHERE id = vExpeditionFk; - UPDATE srt.expedition e - SET e.`position` = e.`position` - 1 - WHERE e.bufferFk = vBufferFromFk - AND e.`position` > 0; + UPDATE expedition + SET `position` = `position` - 1 + WHERE bufferFk = vBufferFromFk + AND `position` > 0; - CALL vn.mail_insert( - 'pako@verdnatura.es, carles@verdnatura.es', - NULL, - CONCAT('Moving_clean. Expedition: ', vExpeditionFk, ' estaba parada'), - CONCAT('Expedition: ', vExpeditionFk,' vBufferToFk: ', vBufferToFk) - ); - - END LOOP bucle; - - CLOSE cur; + COMMIT; + END LOOP l; + CLOSE vSorter; END$$ DELIMITER ; diff --git a/db/versions/11141-azureRoebelini/00-firstScript.sql b/db/versions/11141-azureRoebelini/00-firstScript.sql new file mode 100644 index 000000000..fd6d79cfb --- /dev/null +++ b/db/versions/11141-azureRoebelini/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE srt.moving DROP INDEX moving_fk1_idx; From 618baaf6040b40a45beabaf86a7aada1778b2a78 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 11 Jul 2024 08:37:08 +0200 Subject: [PATCH 07/74] usa campo factura multipe --- db/routines/vn/procedures/invoiceOut_new.sql | 2 +- .../11142-aquaGerbera/00-invoiceOutSerialColumn.sql | 2 ++ .../11142-aquaGerbera/01-invoiceOutSerialUpdate.sql | 3 +++ .../back/methods/invoiceOut/clientsToInvoice.js | 2 +- .../invoiceOut/back/methods/invoiceOut/invoiceClient.js | 8 ++++++-- modules/invoiceOut/back/models/invoice-out-serial.json | 5 ++++- 6 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql create mode 100644 db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql diff --git a/db/routines/vn/procedures/invoiceOut_new.sql b/db/routines/vn/procedures/invoiceOut_new.sql index 42c3f99da..610e05cb4 100644 --- a/db/routines/vn/procedures/invoiceOut_new.sql +++ b/db/routines/vn/procedures/invoiceOut_new.sql @@ -97,7 +97,7 @@ BEGIN AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase()) THEN - -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial + -- el trigger añade el siguiente ref correspondiente a la vSerial INSERT INTO invoiceOut( ref, serial, diff --git a/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql b/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql new file mode 100644 index 000000000..db476c4a5 --- /dev/null +++ b/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceOutSerial + MODIFY COLUMN `type` enum('global','quick','multiple') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; diff --git a/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql b/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql new file mode 100644 index 000000000..581a6f5f3 --- /dev/null +++ b/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql @@ -0,0 +1,3 @@ +UPDATE vn.invoiceOutSerial + SET `type`='multiple' + WHERE `description` LIKE '%multiple%'; diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index 63b00fe38..5526d214a 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -75,7 +75,7 @@ module.exports = Self => { AND c.isTaxDataChecked AND c.isActive AND NOT t.isDeleted - GROUP BY c.id, IF(c.hasToInvoiceByAddress, a.id, TRUE) + GROUP BY IF(c.hasToInvoiceByAddress, a.id, c.id) HAVING SUM(t.totalWithVat) > 0;`; const addresses = await Self.rawSql(query, [ diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js index 530b02353..ef8a26efc 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js @@ -28,6 +28,11 @@ module.exports = Self => { type: 'number', description: 'The company id to invoice', required: true + }, { + arg: 'serialType', + type: 'string', + description: 'Type of serial', + required: true } ], returns: { @@ -74,10 +79,9 @@ module.exports = Self => { ], options); } - const invoiceType = 'G'; const invoiceId = await models.Ticket.makeInvoice( ctx, - invoiceType, + serialType, args.companyFk, args.invoiceDate, null, diff --git a/modules/invoiceOut/back/models/invoice-out-serial.json b/modules/invoiceOut/back/models/invoice-out-serial.json index 912269fd7..30e1f1b39 100644 --- a/modules/invoiceOut/back/models/invoice-out-serial.json +++ b/modules/invoiceOut/back/models/invoice-out-serial.json @@ -20,6 +20,9 @@ }, "isCEE": { "type": "boolean" + }, + "type": { + "type": "string" } }, "relations": { @@ -35,4 +38,4 @@ "principalId": "$everyone", "permission": "ALLOW" }] -} \ No newline at end of file +} From 625b3a5608b03537bc1eec42bcfccfea857abd14 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 18 Jul 2024 14:12:37 +0200 Subject: [PATCH 08/74] refactor: refs #7567 Minor change --- db/routines/srt/procedures/moving_clean.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/routines/srt/procedures/moving_clean.sql b/db/routines/srt/procedures/moving_clean.sql index 446ad3588..ab16aac99 100644 --- a/db/routines/srt/procedures/moving_clean.sql +++ b/db/routines/srt/procedures/moving_clean.sql @@ -7,6 +7,8 @@ BEGIN DECLARE vExpeditionFk INT; DECLARE vBufferToFk INT; DECLARE vBufferFromFk INT; + DECLARE vStateOutFk INT + DEFAULT (SELECT id FROM expeditionState WHERE `description` = 'OUT'); DECLARE vDone BOOL DEFAULT FALSE; DECLARE vSorter CURSOR FOR SELECT m.expeditionFk, m.bufferToFk, m.bufferFromFk @@ -52,10 +54,10 @@ BEGIN OR (bufferFk = vBufferFromFk AND `position` > 0) FOR UPDATE; - UPDATE expedition + UPDATE expedition SET bufferFk = NULL, `position` = NULL, - stateFk = (SELECT id FROM expeditionState WHERE `description` = 'OUT') + stateFk = vStateOutFk WHERE id = vExpeditionFk; UPDATE expedition @@ -64,7 +66,6 @@ BEGIN AND `position` > 0; COMMIT; - END LOOP l; CLOSE vSorter; END$$ From e61210fd17e52951a5f010d73bdb8b043129e2cb Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 09:09:45 +0200 Subject: [PATCH 09/74] feat: #3199 Requested changes --- db/routines/vn/procedures/ticket_recalcByScope.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index c5df8f82d..1541b532e 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -19,7 +19,6 @@ BEGIN JOIN sale s ON s.ticketFk = t.id JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk WHERE t.refFk IS NULL - AND DATE(t.shipped) > util.VN_CURDATE() AND ( (vScope = 'client' AND t.clientFk = vId) OR (vScope = 'address' AND t.addressFk = vId) From 8f623bd51ec47c32239cb2f4152f76169dc8ee8d Mon Sep 17 00:00:00 2001 From: jgallego Date: Mon, 22 Jul 2024 10:26:40 +0200 Subject: [PATCH 10/74] feat: refs #7346 mas intuitivo --- db/routines/vn/functions/invoiceSerial.sql | 22 +++++++----- .../vn/functions/invoiceSerialArea.sql | 34 ------------------- db/routines/vn/procedures/ticket_close.sql | 26 +++++++------- .../ticket/back/methods/ticket/closeAll.js | 22 ++++++------ .../back/methods/ticket/invoiceTickets.js | 2 +- .../methods/ticket/specs/makeInvoice.spec.js | 2 +- 6 files changed, 40 insertions(+), 68 deletions(-) delete mode 100644 db/routines/vn/functions/invoiceSerialArea.sql diff --git a/db/routines/vn/functions/invoiceSerial.sql b/db/routines/vn/functions/invoiceSerial.sql index 66448ac9c..5ce20dc8b 100644 --- a/db/routines/vn/functions/invoiceSerial.sql +++ b/db/routines/vn/functions/invoiceSerial.sql @@ -1,26 +1,32 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(1)) +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(15)) RETURNS char(1) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN /** - * Obtiene la serie de de una factura + * Obtiene la serie de de una factura * dependiendo del area del cliente. - * + * * @param vClientFk Id del cliente * @param vCompanyFk Id de la empresa - * @param vType Tipo de factura ["R", "M", "G"] - * @return Serie de la factura + * @param vType Tipo de factura ['global','multiple','quick'] + * @return vSerie de la factura */ DECLARE vTaxArea VARCHAR(25); - DECLARE vSerie CHAR(1); + DECLARE vSerie CHAR(2); IF (SELECT hasInvoiceSimplified FROM client WHERE id = vClientFk) THEN RETURN 'S'; END IF; - SELECT clientTaxArea(vClientFk, vCompanyFk) INTO vTaxArea; - SELECT invoiceSerialArea(vType,vTaxArea) INTO vSerie; + SELECT addressTaxArea(defaultAddressFk, vCompanyFk) INTO vTaxArea + FROM client + WHERE id = vClientFk; + + SELECT code INTO vSerie + FROM invoiceOutSerial + WHERE `type` = vType AND taxAreaFk = vTaxArea; + RETURN vSerie; END$$ DELIMITER ; diff --git a/db/routines/vn/functions/invoiceSerialArea.sql b/db/routines/vn/functions/invoiceSerialArea.sql deleted file mode 100644 index 02edd83f2..000000000 --- a/db/routines/vn/functions/invoiceSerialArea.sql +++ /dev/null @@ -1,34 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceSerialArea`(vType CHAR(1), vTaxArea VARCHAR(25)) - RETURNS char(1) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci - DETERMINISTIC -BEGIN - DECLARE vSerie CHAR(1); - - IF vType = 'R' THEN - SELECT - CASE vTaxArea - WHEN 'CEE' THEN 'H' - WHEN 'WORLD' THEN 'E' - ELSE 'T' - END INTO vSerie; - -- Factura multiple - ELSEIF vType = 'M' THEN - SELECT - CASE vTaxArea - WHEN 'CEE' THEN 'H' - WHEN 'WORLD' THEN 'E' - ELSE 'M' - END INTO vSerie; - -- Factura global - ELSEIF vType = 'G' THEN - SELECT - CASE vTaxArea - WHEN 'CEE' THEN 'V' - WHEN 'WORLD' THEN 'X' - ELSE 'A' - END INTO vSerie; - END IF; - RETURN vSerie; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_close.sql b/db/routines/vn/procedures/ticket_close.sql index 7f52e81a7..97da5057c 100644 --- a/db/routines/vn/procedures/ticket_close.sql +++ b/db/routines/vn/procedures/ticket_close.sql @@ -2,7 +2,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_close`() BEGIN /** - * Realiza el cierre de todos los + * Realiza el cierre de todos los * tickets de la tabla tmp.ticket_close. * * @table tmp.ticket_close(ticketFk) Identificadores de los tickets a cerrar @@ -20,7 +20,7 @@ BEGIN DECLARE cur CURSOR FOR SELECT ticketFk FROM tmp.ticket_close; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN RESIGNAL; @@ -30,7 +30,7 @@ BEGIN proc: LOOP SET vDone = FALSE; - + FETCH cur INTO vCurTicketFk; IF vDone THEN @@ -47,12 +47,12 @@ BEGIN c.hasToInvoice INTO vClientFk, vIsTaxDataChecked, - vCompanyFk, + vCompanyFk, vShipped, vHasDailyInvoice, vWithPackage, vHasToInvoice - FROM ticket t + FROM ticket t JOIN `client` c ON c.id = t.clientFk JOIN province p ON p.id = c.provinceFk LEFT JOIN autonomy a ON a.id = p.autonomyFk @@ -62,7 +62,7 @@ BEGIN INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) (SELECT vCurTicketFk, p.id, COUNT(*) - FROM expedition e + FROM expedition e JOIN packaging p ON p.id = e.packagingFk JOIN ticket t ON t.id = e.ticketFk LEFT JOIN agencyMode am ON am.id = t.agencyModeFk @@ -73,15 +73,15 @@ BEGIN GROUP BY p.itemFk); -- No retornables o no catalogados - INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed) + INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed) (SELECT e.freightItemFk, vCurTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.freightItemFk, vClientFk), 1 - FROM expedition e + FROM expedition e JOIN item i ON i.id = e.freightItemFk LEFT JOIN packaging p ON p.itemFk = i.id WHERE e.ticketFk = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0 AND getSpecialPrice(e.freightItemFk, vClientFk) > 0 GROUP BY e.freightItemFk); - + IF(vHasDailyInvoice) AND vHasToInvoice THEN -- Facturacion rapida @@ -89,10 +89,10 @@ BEGIN -- Facturar si está contabilizado IF vIsTaxDataChecked THEN CALL invoiceOut_newFromClient( - vClientFk, - (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), - vShipped, - vCompanyFk, + vClientFk, + (SELECT invoiceSerial(vClientFk, vCompanyFk, 'multiple')), + vShipped, + vCompanyFk, NULL, NULL, vNewInvoiceId); diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 35b9b1e37..ef38d4255 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -91,8 +91,8 @@ module.exports = Self => { SUM(t.isDeleted) hasErrorDeleted, SUM(itc.id IS NULL) hasErrorItemTaxCountry, SUM(a.id IS NULL) hasErrorAddress, - SUM(ios.code IS NOT NULL - AND(ad.customsAgentFk IS NULL + SUM(ios.code IS NOT NULL + AND(ad.customsAgentFk IS NULL OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld FROM ticket t LEFT JOIN address ad ON ad.id = t.addressFk @@ -110,24 +110,24 @@ module.exports = Self => { LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk - LEFT JOIN vn.invoiceOutSerial ios ON ios.taxAreaFk = 'WORLD' - AND ios.code = invoiceSerial(t.clientFk, t.companyFk, 'M') + LEFT JOIN vn.invoiceOutSerial ios ON ios.taxAreaFk = 'WORLD' + AND ios.code = invoiceSerial(t.clientFk, t.companyFk, 'multiple') WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered')) AND DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?) AND t.refFk IS NULL AND IFNULL(a.hasDailyInvoice, co.hasDailyInvoice) - GROUP BY ticketFk - HAVING hasErrorToInvoice - OR hasErrorTaxDataChecked - OR hasErrorDeleted - OR hasErrorItemTaxCountry - OR hasErrorAddress + GROUP BY ticketFk + HAVING hasErrorToInvoice + OR hasErrorTaxDataChecked + OR hasErrorDeleted + OR hasErrorItemTaxCountry + OR hasErrorAddress OR hasErrorInfoTaxAreaWorld )sub )sub2 ) SELECT IF(errors = '{"tickets": null}', 'No errors', - util.notification_send('invoice-ticket-closure', errors, NULL)) + util.notification_send('invoice-ticket-closure', errors, NULL)) FROM ticketNotInvoiceable`, [toDate, toDate]); await closure(ctx, Self, tickets); diff --git a/modules/ticket/back/methods/ticket/invoiceTickets.js b/modules/ticket/back/methods/ticket/invoiceTickets.js index 53400e724..3c725c4a7 100644 --- a/modules/ticket/back/methods/ticket/invoiceTickets.js +++ b/modules/ticket/back/methods/ticket/invoiceTickets.js @@ -95,7 +95,7 @@ module.exports = function(Self) { FROM vn.ticket WHERE id IN (?) `, [ticketsIds], myOptions); - return models.Ticket.makeInvoice(ctx, 'R', companyId, Date.vnNew(), invoiceCorrection, myOptions); + return models.Ticket.makeInvoice(ctx, 'quick', companyId, Date.vnNew(), invoiceCorrection, myOptions); } }; diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index fea8b2096..88812dc92 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -3,7 +3,7 @@ const LoopBackContext = require('loopback-context'); describe('ticket makeInvoice()', () => { const userId = 19; - const invoiceType = 'R'; + const invoiceType = 'quick'; const companyFk = 442; const invoiceDate = Date.vnNew(); const activeCtx = { From baa1498923c7434a9f780e91876544b121526ed8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 13:29:26 +0200 Subject: [PATCH 11/74] feat: refs #7712 sizeLimit --- db/routines/vn/procedures/collection_new.sql | 19 +++++++++++++++---- .../11171-maroonMoss/00-firstScript.sql | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 db/versions/11171-maroonMoss/00-firstScript.sql diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 0bd6e1b25..f7f342ea7 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -9,10 +9,11 @@ BEGIN DECLARE vWarehouseFk INT; DECLARE vWagons INT; DECLARE vTrainFk INT; - DECLARE vLinesLimit INT DEFAULT NULL; + DECLARE vLinesLimit INT; DECLARE vTicketLines INT; - DECLARE vVolumeLimit DECIMAL DEFAULT NULL; + DECLARE vVolumeLimit DECIMAL; DECLARE vTicketVolume DECIMAL; + DECLARE vSizeLimit INT; DECLARE vMaxTickets INT; DECLARE vStateFk VARCHAR(45); DECLARE vFirstTicketFk INT; @@ -77,6 +78,7 @@ BEGIN o.trainFk, o.linesLimit, o.volumeLimit, + o.sizeLimit, pc.collection_new_lockname INTO vMaxTickets, vHasUniqueCollectionTime, @@ -88,6 +90,7 @@ BEGIN vTrainFk, vLinesLimit, vVolumeLimit, + vSizeLimit, vLockName FROM productionConfig pc JOIN worker w ON w.id = vUserFk @@ -172,6 +175,13 @@ BEGIN JOIN state s ON s.id = pb.state JOIN agencyMode am ON am.id = pb.agencyModeFk JOIN agency a ON a.id = am.agencyFk + LEFT JOIN ( + SELECT pb.ticketFk, MAX(i.`size`) maxSize + FROM tmp.productionBuffer pb + JOIN ticket t ON t.id = pb.ticketfk + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + ) sub ON sub.ticketFk = pb.ticketFk JOIN productionConfig pc WHERE pb.shipped <> util.VN_CURDATE() OR (pb.ubicacion IS NULL AND a.isOwn) @@ -183,8 +193,9 @@ BEGIN OR (NOT pb.V AND vItemPackingTypeFk = 'V') OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) OR LENGTH(pb.problem) > 0 - OR (pb.lines >= vLinesLimit AND vLinesLimit IS NOT NULL) - OR (pb.m3 >= vVolumeLimit AND vVolumeLimit IS NOT NULL); + OR (pb.lines > vLinesLimit AND vLinesLimit IS NOT NULL) + OR (pb.m3 > vVolumeLimit AND vVolumeLimit IS NOT NULL) + OR ((sub.maxSize > vSizeLimit OR sub.maxSize IS NOT NULL) AND vSizeLimit IS NOT NULL); END IF; -- Es importante que el primer ticket se coja en todos los casos diff --git a/db/versions/11171-maroonMoss/00-firstScript.sql b/db/versions/11171-maroonMoss/00-firstScript.sql new file mode 100644 index 000000000..1bf0d646b --- /dev/null +++ b/db/versions/11171-maroonMoss/00-firstScript.sql @@ -0,0 +1,8 @@ +ALTER TABLE vn.operator + ADD sizeLimit int(10) unsigned DEFAULT 90 NULL + COMMENT 'Límite de altura en una colección para la asignación de pedidos' + AFTER volumeLimit; + +ALTER TABLE vn.operator + MODIFY COLUMN linesLimit int(10) unsigned DEFAULT 20 NULL + COMMENT 'Límite de lineas en una colección para la asignación de pedidos'; From a01ae9b7b8d35ea976c8510e25c47164274d0125 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 14:09:55 +0200 Subject: [PATCH 12/74] fix: refs #7756 Foreign keys invoiceOut --- db/versions/11172-blueFern/00-firstScript.sql | 1 + db/versions/11172-blueFern/01-firstScript.sql | 1 + db/versions/11172-blueFern/02-firstScript.sql | 1 + db/versions/11172-blueFern/03-firstScript.sql | 1 + db/versions/11172-blueFern/04-firstScript.sql | 1 + db/versions/11172-blueFern/05-firstScript.sql | 1 + db/versions/11172-blueFern/06-firstScript.sql | 1 + db/versions/11172-blueFern/07-firstScript.sql | 1 + db/versions/11172-blueFern/08-firstScript.sql | 1 + db/versions/11172-blueFern/09-firstScript.sql | 1 + db/versions/11172-blueFern/10-firstScript.sql | 2 ++ db/versions/11172-blueFern/11-firstScript.sql | 2 ++ db/versions/11172-blueFern/12-firstScript.sql | 2 ++ db/versions/11172-blueFern/13-firstScript.sql | 2 ++ db/versions/11172-blueFern/14-firstScript.sql | 2 ++ 15 files changed, 20 insertions(+) create mode 100644 db/versions/11172-blueFern/00-firstScript.sql create mode 100644 db/versions/11172-blueFern/01-firstScript.sql create mode 100644 db/versions/11172-blueFern/02-firstScript.sql create mode 100644 db/versions/11172-blueFern/03-firstScript.sql create mode 100644 db/versions/11172-blueFern/04-firstScript.sql create mode 100644 db/versions/11172-blueFern/05-firstScript.sql create mode 100644 db/versions/11172-blueFern/06-firstScript.sql create mode 100644 db/versions/11172-blueFern/07-firstScript.sql create mode 100644 db/versions/11172-blueFern/08-firstScript.sql create mode 100644 db/versions/11172-blueFern/09-firstScript.sql create mode 100644 db/versions/11172-blueFern/10-firstScript.sql create mode 100644 db/versions/11172-blueFern/11-firstScript.sql create mode 100644 db/versions/11172-blueFern/12-firstScript.sql create mode 100644 db/versions/11172-blueFern/13-firstScript.sql create mode 100644 db/versions/11172-blueFern/14-firstScript.sql diff --git a/db/versions/11172-blueFern/00-firstScript.sql b/db/versions/11172-blueFern/00-firstScript.sql new file mode 100644 index 000000000..04e0813d5 --- /dev/null +++ b/db/versions/11172-blueFern/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.ticket DROP FOREIGN KEY ticket_FK; \ No newline at end of file diff --git a/db/versions/11172-blueFern/01-firstScript.sql b/db/versions/11172-blueFern/01-firstScript.sql new file mode 100644 index 000000000..64255f9de --- /dev/null +++ b/db/versions/11172-blueFern/01-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut DROP KEY Id_Factura; diff --git a/db/versions/11172-blueFern/02-firstScript.sql b/db/versions/11172-blueFern/02-firstScript.sql new file mode 100644 index 000000000..e76b7f7d6 --- /dev/null +++ b/db/versions/11172-blueFern/02-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned NOT NULL; \ No newline at end of file diff --git a/db/versions/11172-blueFern/03-firstScript.sql b/db/versions/11172-blueFern/03-firstScript.sql new file mode 100644 index 000000000..e6def98a4 --- /dev/null +++ b/db/versions/11172-blueFern/03-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceCorrection DROP FOREIGN KEY corrected_fk; diff --git a/db/versions/11172-blueFern/04-firstScript.sql b/db/versions/11172-blueFern/04-firstScript.sql new file mode 100644 index 000000000..a19bc336e --- /dev/null +++ b/db/versions/11172-blueFern/04-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceCorrection DROP FOREIGN KEY correcting_fk; diff --git a/db/versions/11172-blueFern/05-firstScript.sql b/db/versions/11172-blueFern/05-firstScript.sql new file mode 100644 index 000000000..9f5ec2871 --- /dev/null +++ b/db/versions/11172-blueFern/05-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOutExpense DROP FOREIGN KEY invoiceOutExpence_FK_1; diff --git a/db/versions/11172-blueFern/06-firstScript.sql b/db/versions/11172-blueFern/06-firstScript.sql new file mode 100644 index 000000000..2c16e9b77 --- /dev/null +++ b/db/versions/11172-blueFern/06-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOutTax DROP FOREIGN KEY invoiceOutFk; diff --git a/db/versions/11172-blueFern/07-firstScript.sql b/db/versions/11172-blueFern/07-firstScript.sql new file mode 100644 index 000000000..bec72a131 --- /dev/null +++ b/db/versions/11172-blueFern/07-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut DROP PRIMARY KEY; diff --git a/db/versions/11172-blueFern/08-firstScript.sql b/db/versions/11172-blueFern/08-firstScript.sql new file mode 100644 index 000000000..316db2e32 --- /dev/null +++ b/db/versions/11172-blueFern/08-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_pk PRIMARY KEY (id); diff --git a/db/versions/11172-blueFern/09-firstScript.sql b/db/versions/11172-blueFern/09-firstScript.sql new file mode 100644 index 000000000..553d7857e --- /dev/null +++ b/db/versions/11172-blueFern/09-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_unique UNIQUE KEY (`ref`); diff --git a/db/versions/11172-blueFern/10-firstScript.sql b/db/versions/11172-blueFern/10-firstScript.sql new file mode 100644 index 000000000..e1847a877 --- /dev/null +++ b/db/versions/11172-blueFern/10-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.ticket ADD CONSTRAINT ticket_invoiceOut_FK + FOREIGN KEY (refFk) REFERENCES vn.invoiceOut(`ref`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/11-firstScript.sql b/db/versions/11172-blueFern/11-firstScript.sql new file mode 100644 index 000000000..720b7962e --- /dev/null +++ b/db/versions/11172-blueFern/11-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK + FOREIGN KEY (correctingFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/12-firstScript.sql b/db/versions/11172-blueFern/12-firstScript.sql new file mode 100644 index 000000000..35099bd5d --- /dev/null +++ b/db/versions/11172-blueFern/12-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK_1 + FOREIGN KEY (correctedFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/versions/11172-blueFern/13-firstScript.sql b/db/versions/11172-blueFern/13-firstScript.sql new file mode 100644 index 000000000..f1aa0a216 --- /dev/null +++ b/db/versions/11172-blueFern/13-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceOutExpense ADD CONSTRAINT invoiceOutExpense_invoiceOut_FK + FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/14-firstScript.sql b/db/versions/11172-blueFern/14-firstScript.sql new file mode 100644 index 000000000..ba570e20c --- /dev/null +++ b/db/versions/11172-blueFern/14-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceOutTax ADD CONSTRAINT invoiceOutTax_invoiceOut_FK + FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; From 766da06c2fe150638a9d58b12888edb0ac9eb65c Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 30 Jul 2024 09:40:34 +0200 Subject: [PATCH 13/74] feat: refs #7524 add mock limit on find query --- back/model-config.json | 3 +++ back/models/ormConfig.json | 26 +++++++++++++++++++ .../11175-pinkChico/00-firstScript.sql | 8 ++++++ loopback/common/models/vn-model.js | 24 ++++++++++++++++- loopback/locale/es.json | 3 ++- 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 back/models/ormConfig.json create mode 100644 db/versions/11175-pinkChico/00-firstScript.sql diff --git a/back/model-config.json b/back/model-config.json index a16fe4e8a..9884eadfb 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -115,6 +115,9 @@ "NotificationSubscription": { "dataSource": "vn" }, + "OrmConfig": { + "dataSource": "vn" + }, "Province": { "dataSource": "vn" }, diff --git a/back/models/ormConfig.json b/back/models/ormConfig.json new file mode 100644 index 000000000..ef4c2b181 --- /dev/null +++ b/back/models/ormConfig.json @@ -0,0 +1,26 @@ +{ + "name": "OrmConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "ormConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "selectLimit": { + "type": "number" + } + }, + "acls": [ + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/db/versions/11175-pinkChico/00-firstScript.sql b/db/versions/11175-pinkChico/00-firstScript.sql new file mode 100644 index 000000000..349f4c7f7 --- /dev/null +++ b/db/versions/11175-pinkChico/00-firstScript.sql @@ -0,0 +1,8 @@ +USE vn; + +CREATE TABLE IF NOT EXISTS ormConfig ( + id int(5) NOT NULL AUTO_INCREMENT primary key, + selectLimit int(5) NOT NULL +); + +INSERT IGNORE INTO ormConfig SET selectLimit = 1000; \ No newline at end of file diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 22b535f62..30a2da6be 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -5,6 +5,7 @@ const utils = require('loopback/lib/utils'); module.exports = function(Self) { Self.ParameterizedSQL = ParameterizedSQL; + let isSelect; require('../methods/vn-model/getSetValues')(Self); require('../methods/vn-model/getEnumValues')(Self); @@ -13,7 +14,6 @@ module.exports = function(Self) { Object.assign(Self, { setup() { Self.super_.setup.call(this); - /** * Setting a global transaction timeout to find out if the service * is blocked because the connection pool is empty. @@ -28,6 +28,28 @@ module.exports = function(Self) { }; }); + /* + * Intercept GET request for find + */ + this.beforeRemote('find', async function(ctx) { + isSelect = true; + const filter = ctx.args.filter || {}; + // const models = this.app.models; + if (filter.limit === undefined) { + // WIP + // const {limit} = await models.OrmConfig.findOne(); Not working + // const [{selectLimit: limit}] = await this.rawSql('SELECT selectLimit FROM ormConfig', null); + filter.limit = 1/* limit */; + ctx.args.filter = filter; + } + }); + + this.observe('loaded', async function({data}) { + if (!isSelect) return; + const length = Array.isArray(data) ? data.length : data ? 1 : 0; + if (length >= 1) throw new UserError('Too many records'); + }); + // Register field ACL validation /* this.beforeRemote('prototype.patchAttributes', ctx => this.checkUpdateAcls(ctx)); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index acc3d69f6..c2973bf62 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -368,5 +368,6 @@ "Payment method is required": "El método de pago es obligatorio", "Cannot send mail": "Não é possível enviar o email", "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", - "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo" + "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", + "Too many records": "Demasiados registros" } \ No newline at end of file From 82c28e03991565d494e12fb678ed0e80cc3019eb Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 30 Jul 2024 10:01:05 +0200 Subject: [PATCH 14/74] chore: refs #7524 WIP limit call --- loopback/common/models/vn-model.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 30a2da6be..0b16c6532 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -34,11 +34,8 @@ module.exports = function(Self) { this.beforeRemote('find', async function(ctx) { isSelect = true; const filter = ctx.args.filter || {}; - // const models = this.app.models; + // console.log(this.dataSource, Self.dataSource); undefined/null if (filter.limit === undefined) { - // WIP - // const {limit} = await models.OrmConfig.findOne(); Not working - // const [{selectLimit: limit}] = await this.rawSql('SELECT selectLimit FROM ormConfig', null); filter.limit = 1/* limit */; ctx.args.filter = filter; } From b3b7e9c2135c114fe842359abe48029f7d6cd353 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 6 Aug 2024 17:08:27 +0200 Subject: [PATCH 15/74] fix: refs #7524 default limit select --- loopback/common/models/vn-model.js | 9 ++++----- loopback/server/boot/orm.js | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 loopback/server/boot/orm.js diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 0b16c6532..20c75ca8c 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -31,20 +31,19 @@ module.exports = function(Self) { /* * Intercept GET request for find */ - this.beforeRemote('find', async function(ctx) { + this.beforeRemote('find', async ctx => { isSelect = true; const filter = ctx.args.filter || {}; - // console.log(this.dataSource, Self.dataSource); undefined/null if (filter.limit === undefined) { - filter.limit = 1/* limit */; + filter.limit = this.app.orm.selectLimit; ctx.args.filter = filter; } }); - this.observe('loaded', async function({data}) { + this.observe('loaded', async({data}) => { if (!isSelect) return; const length = Array.isArray(data) ? data.length : data ? 1 : 0; - if (length >= 1) throw new UserError('Too many records'); + if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); }); // Register field ACL validation diff --git a/loopback/server/boot/orm.js b/loopback/server/boot/orm.js new file mode 100644 index 000000000..8bbd969e1 --- /dev/null +++ b/loopback/server/boot/orm.js @@ -0,0 +1,6 @@ +module.exports = async function(app) { + if (!app.orm) { + const ormConfig = await app.models.OrmConfig.findOne(); + app.orm = ormConfig; + } +}; From b64b91e50fe9bbc3c1fb2f368d8a10a3f2f4a731 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 7 Aug 2024 10:12:54 +0200 Subject: [PATCH 16/74] feat: refs #7524 wip remote hooks --- loopback/common/models/vn-model.js | 32 ++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 20c75ca8c..56a4f4dd0 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -28,21 +28,33 @@ module.exports = function(Self) { }; }); - /* - * Intercept GET request for find - */ this.beforeRemote('find', async ctx => { - isSelect = true; - const filter = ctx.args.filter || {}; - if (filter.limit === undefined) { - filter.limit = this.app.orm.selectLimit; + const defaultLimit = this.app.orm.selectLimit; + const filter = ctx.args.filter || {limit: defaultLimit}; + + if (filter.limit > defaultLimit) { + filter.limit = defaultLimit; ctx.args.filter = filter; } }); - this.observe('loaded', async({data}) => { - if (!isSelect) return; - const length = Array.isArray(data) ? data.length : data ? 1 : 0; + this.afterRemote('find', async({result}) => { + const length = Array.isArray(result) ? result.length : result ? 1 : 0; + if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); + }); + + this.beforeRemote('filter', async ctx => { + const defaultLimit = this.app.orm.selectLimit; + const filter = ctx.args.filter || {limit: defaultLimit}; + + if (filter.limit > defaultLimit) { + filter.limit = defaultLimit; + ctx.args.filter = filter; + } + }); + + this.afterRemote('filter', async({result}) => { + const length = Array.isArray(result) ? result.length : result ? 1 : 0; if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); }); From ea754469824eb0610f1e59243172dd1127b6ed56 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 7 Aug 2024 10:32:47 +0200 Subject: [PATCH 17/74] refs #7844 Change in problems calc --- .../vn/procedures/productionControl.sql | 6 - .../vn/procedures/sale_getProblems.sql | 285 +++++++----------- .../procedures/sale_getProblemsByTicket.sql | 3 +- .../vn/procedures/ticket_getProblems.sql | 4 +- 4 files changed, 107 insertions(+), 191 deletions(-) diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index af6d929d7..84717a19a 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -15,11 +15,6 @@ proc: BEGIN DECLARE vEndingDate DATETIME; DECLARE vIsTodayRelative BOOLEAN; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - RESIGNAL; - END; - SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY INTO vEndingDate FROM productionConfig; @@ -273,7 +268,6 @@ proc: BEGIN DROP TEMPORARY TABLE tmp.productionTicket, tmp.ticket, - tmp.risk, tmp.ticket_problems, tmp.ticketWithPrevia, tItemShelvingStock, diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index c881bcf92..20e9f4c3a 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -1,152 +1,87 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getProblems`(IN vIsTodayRelative tinyint(1)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getProblems`( + vIsTodayRelative tinyint(1) +) BEGIN /** * Calcula los problemas de cada venta para un conjunto de tickets. * * @param vIsTodayRelative Indica si se calcula el disponible como si todo saliera hoy - * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular + * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Tickets a calcular * @return tmp.sale_problems */ - DECLARE vWarehouseFk INT; + DECLARE vWarehouseFk INT; DECLARE vDate DATE; - DECLARE vAvailableCache INT; + DECLARE vAvailableCache INT; DECLARE vVisibleCache INT; DECLARE vDone BOOL; - DECLARE vRequiredComponent INT; - - DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(tt.shipped)) - FROM tmp.sale_getProblems tt - WHERE DATE(tt.shipped) BETWEEN util.VN_CURDATE() - AND util.VN_CURDATE() + INTERVAL IF(vIsTodayRelative, 9.9, 1.9) DAY; + DECLARE vCursor CURSOR FOR + SELECT DISTINCT warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(shipped)) + FROM tmp.sale_getProblems + WHERE shipped BETWEEN util.VN_CURDATE() + AND util.dayEnd(util.VN_CURDATE() + INTERVAL IF(vIsTodayRelative, 9.9, 1.9) DAY); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DELETE tt.* FROM tmp.sale_getProblems tt JOIN ticketObservation tto ON tto.ticketFk = tt.ticketFk - JOIN observationType ot ON ot.id = tto.observationTypeFk - WHERE ot.code = 'administrative' + JOIN observationType ot ON ot.id = tto.observationTypeFk + WHERE ot.code = 'administrative' AND tto.description = 'Miriam'; - CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems ( - ticketFk INT(11), - saleFk INT(11), - isFreezed INTEGER(1) DEFAULT 0, - risk DECIMAL(10,1) DEFAULT 0, - hasHighRisk TINYINT(1) DEFAULT 0, - hasTicketRequest INTEGER(1) DEFAULT 0, - itemShortage VARCHAR(255), - isTaxDataChecked INTEGER(1) DEFAULT 1, - itemDelay VARCHAR(255), - itemLost VARCHAR(255), - hasComponentLack INTEGER(1), - hasRounding VARCHAR(255), - isTooLittle BOOL DEFAULT FALSE, - isVip BOOL DEFAULT FALSE, - PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems ( + ticketFk INT(11), + saleFk INT(11), + isFreezed INTEGER(1) DEFAULT 0, + risk DECIMAL(10,1) DEFAULT 0, + hasHighRisk TINYINT(1) DEFAULT 0, + hasTicketRequest INTEGER(1) DEFAULT 0, + itemShortage VARCHAR(255), + isTaxDataChecked INTEGER(1) DEFAULT 1, + itemDelay VARCHAR(255), + itemLost VARCHAR(255), + hasComponentLack INTEGER(1), + hasRounding VARCHAR(255), + isTooLittle BOOL DEFAULT FALSE, + isVip BOOL DEFAULT FALSE, + PRIMARY KEY (ticketFk, saleFk) + ) ENGINE = MEMORY; - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (ticketFk)) - ENGINE = MEMORY - SELECT ticketFk, clientFk - FROM tmp.sale_getProblems; - - SELECT COUNT(*) INTO vRequiredComponent - FROM component - WHERE isRequired; - - -- Too Little - INSERT INTO tmp.sale_problems(ticketFk, isTooLittle) - SELECT tp.ticketFk, TRUE - FROM tmp.sale_getProblems tp - JOIN ticket t ON t.id = tp.ticketFk - JOIN ( - SELECT t.addressFk, - SUM(ROUND(`ic`.`cm3delivery` * `s`.`quantity` / 1000, 0)) litros, - t.totalWithoutVat - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk - JOIN sale s ON s.ticketFk = t.id - AND s.quantity > 0 - JOIN itemCost ic ON ic.itemFk = s.itemFk - AND ic.warehouseFk = t.warehouseFk - JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk - AND zc.dated = util.VN_CURDATE() - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE util.VN_NOW() < (util.VN_CURDATE() + INTERVAL HOUR(zc.`hour`) HOUR) + INTERVAL MINUTE(zc.`hour`) MINUTE - AND dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight() - GROUP BY t.addressFk - ) sub ON sub.addressFk = t.addressFk - JOIN volumeConfig vc - WHERE sub.litros < vc.minTicketVolume - AND sub.totalWithoutVat < vc.minTicketValue; - - -- VIP - INSERT INTO tmp.sale_problems(ticketFk, isVip) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk - WHERE c.businessTypeFk = 'VIP' - ON DUPLICATE KEY UPDATE isVip = TRUE; - - -- Faltan componentes - INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT t.id, COUNT(c.id) < vRequiredComponent hasComponentLack, s.id - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk - JOIN sale s ON s.ticketFk = t.id - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - LEFT JOIN component c ON c.id = sc.componentFk - AND c.isRequired - WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND s.quantity > 0 - GROUP BY s.id - HAVING hasComponentLack; - - -- Cliente congelado - INSERT INTO tmp.sale_problems(ticketFk, isFreezed) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk - WHERE c.isFreezed - ON DUPLICATE KEY UPDATE isFreezed = c.isFreezed; - - -- Credit exceeded - CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT DISTINCT clientFk - FROM tmp.ticket_list; - - CALL client_getDebt(util.VN_CURDATE()); - - INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk) - SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10) - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk - JOIN agencyMode a ON t.agencyModeFk = a.id - JOIN tmp.risk r ON r.clientFk = t.clientFk - JOIN client c ON c.id = t.clientFk - JOIN clientConfig cc - WHERE r.risk > c.credit + 10 - AND NOT a.isRiskFree - ON DUPLICATE KEY UPDATE - risk = r.risk, hasHighRisk = ((r.risk - cc.riskTolerance) > c.credit + 10); - - -- Antiguo COD 100, son peticiones de compra sin terminar - INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN ticketRequest tr ON tr.ticketFk = tl.ticketFk - WHERE tr.isOK IS NULL - ON DUPLICATE KEY UPDATE hasTicketRequest = TRUE; + INSERT INTO tmp.sale_problems (ticketFk, + saleFk, + isFreezed, + hasHighRisk, + hasTicketRequest, + isTaxDataChecked, + hasComponentLack, + hasRounding, + isTooLittle, + isVip) + SELECT sgp.ticketFk, + s.id, + IF(FIND_IN_SET('isFreezed', s.problem), TRUE, FALSE) isFreezed, + IF(FIND_IN_SET('hasHighRisk', s.problem), TRUE, FALSE) hasHighRisk, + IF(FIND_IN_SET('hasTicketRequest', s.problem), TRUE, FALSE) hasTicketRequest, + IF(FIND_IN_SET('isTaxDataChecked', s.problem), FALSE, TRUE) isTaxDataChecked, + IF(FIND_IN_SET('hasComponentLack', s.problem), TRUE, FALSE) hasComponentLack, + IF(FIND_IN_SET('hasRounding', s.problem), + LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250), + NULL + ) hasRounding, + IF(FIND_IN_SET('isTooLittle', s.problem), TRUE, FALSE) isTooLittle, + IF(FIND_IN_SET('isVip', s.problem), TRUE, FALSE) isVip + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE s.problem <> '' + GROUP BY s.id; + + INSERT INTO tmp.sale_problems (ticketFk, risk) + SELECT t.id, t.risk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk; CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock_byWarehouse (INDEX (itemFk, warehouseFk)) @@ -158,10 +93,9 @@ BEGIN JOIN shelving sh ON sh.code = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk - GROUP BY ish.itemFk, - s.warehouseFk; + GROUP BY ish.itemFk, s.warehouseFk; - -- Disponible, Faltas, Inventario y Retrasos + -- Disponible, faltas, inventario y retrasos OPEN vCursor; l: LOOP SET vDone = FALSE; @@ -180,14 +114,14 @@ BEGIN INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, - LEFT(CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')),250) problem, - s.id AS saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + SELECT sgp.ticketFk, + LEFT(CONCAT('F: ', GROUP_CONCAT(i.id, ' ', i.longName, ' ')), 250) problem, + s.id saleFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache @@ -195,8 +129,8 @@ BEGIN AND av.calc_id = vAvailableCache LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE IFNULL(v.visible,0) < s.quantity - AND IFNULL(av.available ,0) < s.quantity + WHERE IFNULL(v.visible, 0) < s.quantity + AND IFNULL(av.available, 0) < s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND NOT s.isPicked AND NOT s.reserved @@ -205,27 +139,27 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk) sub + GROUP BY sgp.ticketFk) sub ON DUPLICATE KEY UPDATE itemShortage = sub.problem, saleFk = sub.saleFk; -- Inventario: Visible suficiente, pero ubicado menor a la cantidad vendida INSERT INTO tmp.sale_problems(ticketFk, itemLost, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, + SELECT sgp.ticketFk, LEFT(GROUP_CONCAT('I: ', i.id, ' ', i.longName, ' '), 250) problem, s.id saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE IFNULL(v.visible,0) >= s.quantity + WHERE IFNULL(v.visible, 0) >= s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND s.quantity > 0 AND NOT s.isPicked @@ -235,22 +169,22 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk + GROUP BY sgp.ticketFk ) sub - ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; + ON DUPLICATE KEY UPDATE itemLost = sub.problem, saleFk = sub.saleFk; -- Retraso: Disponible suficiente, pero no visible ni ubicado INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, + SELECT sgp.ticketFk, LEFT(GROUP_CONCAT('R: ', i.id, ' ', i.longName, ' '), 250) problem, s.id saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache @@ -269,42 +203,29 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk + GROUP BY sgp.ticketFk ) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; - - -- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra - CALL buy_getUltimate(NULL, vWarehouseFk, vDate); - INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) - SELECT ticketFk, problem ,saleFk - FROM ( - SELECT tl.ticketFk, - s.id saleFk, - LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk - AND t.warehouseFk = vWarehouseFk - JOIN sale s ON s.ticketFk = tl.ticketFk - JOIN item i ON i.id = s.itemFk - JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - JOIN buy b ON b.id = bu.buyFk - WHERE MOD(s.quantity, b.`grouping`) - GROUP BY tl.ticketFk - )sub - ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; END LOOP; CLOSE vCursor; - - INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked) - SELECT DISTINCT tl.ticketFk, FALSE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk - WHERE NOT c.isTaxDataChecked - ON DUPLICATE KEY UPDATE isTaxDataChecked = FALSE; + + INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) + SELECT ticketFk, problem, saleFk + FROM ( + SELECT sgp.ticketFk, + s.id saleFk, + LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk + JOIN sale s ON s.ticketFk = sgp.ticketFk + JOIN item i ON i.id = s.itemFk + WHERE FIND_IN_SET('hasRounding', s.problem) + GROUP BY sgp.ticketFk + ) sub + ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; DROP TEMPORARY TABLE - tmp.clientGetDebt, - tmp.ticket_list, + tmp.sale_getProblems, tItemShelvingStock_byWarehouse; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/sale_getProblemsByTicket.sql b/db/routines/vn/procedures/sale_getProblemsByTicket.sql index b4aaad7de..f7a066705 100644 --- a/db/routines/vn/procedures/sale_getProblemsByTicket.sql +++ b/db/routines/vn/procedures/sale_getProblemsByTicket.sql @@ -7,8 +7,7 @@ BEGIN * * @return Problems result */ - DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems; - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT t.id ticketFk, t.clientFk, t.warehouseFk, t.shipped diff --git a/db/routines/vn/procedures/ticket_getProblems.sql b/db/routines/vn/procedures/ticket_getProblems.sql index 521e4cf2f..e9becab2a 100644 --- a/db/routines/vn/procedures/ticket_getProblems.sql +++ b/db/routines/vn/procedures/ticket_getProblems.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getProblems`(IN vIsTodayRelative tinyint(1)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getProblems`( + vIsTodayRelative tinyint(1) +) BEGIN /** * Calcula los problemas para un conjunto de tickets. From 4f2e343d0c7e78f766571ccfc683fa6035938673 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 7 Aug 2024 10:40:10 +0200 Subject: [PATCH 18/74] refs #7844 Fix --- db/routines/vn/procedures/sale_getProblems.sql | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 20e9f4c3a..d8b7264c1 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -224,8 +224,6 @@ BEGIN ) sub ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; - DROP TEMPORARY TABLE - tmp.sale_getProblems, - tItemShelvingStock_byWarehouse; + DROP TEMPORARY TABLE tItemShelvingStock_byWarehouse; END$$ DELIMITER ; From 8aa06e12b3374e1476a140e029af4146b3982cbe Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 7 Aug 2024 12:39:18 +0200 Subject: [PATCH 19/74] refs #7844 Fix tests part 1/2 --- db/dump/fixtures.before.sql | 162 +++++++++--------- .../vn/procedures/sale_getProblems.sql | 2 +- modules/ticket/back/methods/ticket/filter.js | 63 ++++--- .../back/methods/ticket/getTicketsFuture.js | 19 +- 4 files changed, 122 insertions(+), 124 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 60c96abb4..4b69d3b6d 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -743,45 +743,45 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3), (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5); -INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`) +INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`, `problem`, `risk`) VALUES - (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1), - (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2), - (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3), - (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL), - (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL), - (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, NULL), - (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL), - (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL), - (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL, NULL), - (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL), - (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL), - (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL), - (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL), - (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL), - (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL), - (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL), - (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL), - (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL); + (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'hasHighRisk', 901.4), + (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'hasHighRisk', 901.4), + (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3, NULL, NULL), + (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL, NULL, NULL), + (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL, NULL, NULL), + (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, NULL, 'hasHighRisk', 901.4), + (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isTooLittle', NULL), + (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7), + (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7), + (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL, 'isFreezed', NULL), + (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isTaxDataChecked', NULL), + (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL), + (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL), + (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL), + (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasTicketRequest, hasHighRisk', 901.4), + (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, 'isTaxDataChecked', NULL); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES @@ -1059,50 +1059,50 @@ INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, (2, 2, 2, 1, util.VN_CURDATE(), NULL), (3, 3, 2, 4, util.VN_CURDATE(), NULL); -INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`) +INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`, `problem`) VALUES - (1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), - (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE()), - (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE()), - (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), - (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()), - (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), - (12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE()), - (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE()), - (14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()), - (15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), - (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE()), - (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), - (18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), - (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), - (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), - (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE()), - (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE()), - (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), - (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()), - (40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE()), - (41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE()), - (42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE()); + (1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 'hasComponentLack'), + (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE(), NULL), + (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE(), NULL), + (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE(), NULL), + (14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), + (18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), + (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 'hasComponentLack'), + (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 'hasComponentLack'), + (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack, isFreezed'), + (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE(), 'hasRounding'), + (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE(), NULL), + (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE(), NULL), + (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), + (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'); INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) VALUES diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index d8b7264c1..258998e68 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -77,7 +77,7 @@ BEGIN JOIN item i ON i.id = s.itemFk WHERE s.problem <> '' GROUP BY s.id; - + INSERT INTO tmp.sale_problems (ticketFk, risk) SELECT t.id, t.risk FROM tmp.sale_getProblems sgp diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 0823b38b8..3e8b732af 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -224,16 +224,14 @@ module.exports = Self => { const stmts = []; let stmt; - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); - stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.filter + stmt = new ParameterizedSQL(` + CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = MEMORY - SELECT - t.id, + SELECT t.id, t.shipped, - CAST(DATE(t.shipped) AS CHAR) AS shippedDate, - HOUR(t.shipped) AS shippedHour, + CAST(DATE(t.shipped) AS CHAR) shippedDate, + HOUR(t.shipped) shippedHour, t.nickname, t.refFk, t.routeFk, @@ -241,26 +239,26 @@ module.exports = Self => { t.clientFk, t.totalWithoutVat, t.totalWithVat, - io.id AS invoiceOutId, + io.id invoiceOutId, a.provinceFk, - p.name AS province, - w.name AS warehouse, - am.name AS agencyMode, - am.id AS agencyModeFk, - st.name AS state, + p.name province, + w.name warehouse, + am.name agencyMode, + am.id agencyModeFk, + st.name state, st.classColor, - wk.lastName AS salesPerson, - ts.stateFk AS stateFk, - ts.alertLevel AS alertLevel, - ts.code AS alertLevelCode, - u.name AS userName, + wk.lastName salesPerson, + ts.stateFk stateFk, + ts.alertLevel alertLevel, + ts.code alertLevelCode, + u.name userName, c.salesPersonFk, - z.hour AS zoneLanding, - HOUR(z.hour) AS zoneHour, - MINUTE(z.hour) AS zoneMinute, - z.name AS zoneName, - z.id AS zoneFk, - CAST(z.hour AS CHAR) AS hour + z.hour zoneLanding, + HOUR(z.hour) zoneHour, + MINUTE(z.hour) zoneMinute, + z.name zoneName, + z.id zoneFk, + CAST(z.hour AS CHAR) hour FROM ticket t LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN zone z ON z.id = t.zoneFk @@ -273,7 +271,8 @@ module.exports = Self => { LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = wk.id - LEFT JOIN route r ON r.id = t.routeFk`); + LEFT JOIN route r ON r.id = t.routeFk + `); if (args.orderFk) { stmt.merge({ @@ -293,25 +292,25 @@ module.exports = Self => { stmt.merge(conn.makeWhere(filter.where)); stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); - stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped FROM tmp.filter f LEFT JOIN alertLevel al ON al.id = f.alertLevel WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) - AND f.shipped >= ?`, [date]); - stmts.push(stmt); + AND f.shipped >= ? + `, [date]); + stmts.push(stmt); stmts.push('CALL ticket_getProblems(FALSE)'); stmt = new ParameterizedSQL(` SELECT f.*, tp.* - FROM tmp.filter f - LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id`); + FROM tmp.filter f + LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id + `); if (args.problems != undefined && (!args.from && !args.to)) throw new UserError('Choose a date range or days forward'); diff --git a/modules/ticket/back/methods/ticket/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js index ab5071be4..b7267995e 100644 --- a/modules/ticket/back/methods/ticket/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket/getTicketsFuture.js @@ -145,18 +145,17 @@ module.exports = Self => { stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); - stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getProblems - (INDEX (ticketFk)) - ENGINE = MEMORY - SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped, f.lines, f.liters - FROM tmp.filter f - LEFT JOIN alertLevel al ON al.id = f.alertLevel - WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)`); - stmts.push(stmt); + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped, f.lines, f.liters + FROM tmp.filter f + LEFT JOIN alertLevel al ON al.id = f.alertLevel + WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) + `); + stmts.push(stmt); stmts.push('CALL ticket_getProblems(FALSE)'); stmt = new ParameterizedSQL(` From 4cbea3bf7bc1dc981e523ff6dd9d99d629b12189 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 7 Aug 2024 13:51:00 +0200 Subject: [PATCH 20/74] refs #7844 Fix tests part 2/2 --- db/dump/fixtures.before.sql | 20 +++++------ .../vn/procedures/sale_getProblems.sql | 36 ++++++++++--------- .../back/methods/ticket/getTicketsFuture.js | 3 +- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 4b69d3b6d..650cf5333 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -755,11 +755,11 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isTooLittle', NULL), - (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasTicketRequest', NULL), (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), - (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isFreezed', NULL), (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7), (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7), (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL, 'isFreezed', NULL), @@ -771,7 +771,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), - (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 901.4), (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), @@ -781,7 +781,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), - (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, 'isTaxDataChecked', NULL); + (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES @@ -1067,8 +1067,8 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 'hasComponentLack'), - (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), - (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE(), NULL), + (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE(), NULL), (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE(), NULL), (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), @@ -1088,15 +1088,15 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), - (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack, isFreezed'), + (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), - (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE(), 'hasRounding'), - (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE(), NULL), + (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE(), NULL), + (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE(), NULL), (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE(), NULL), (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), - (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), NULL), (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 258998e68..6f65a3722 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -48,40 +48,42 @@ BEGIN PRIMARY KEY (ticketFk, saleFk) ) ENGINE = MEMORY; - INSERT INTO tmp.sale_problems (ticketFk, + INSERT INTO tmp.sale_problems(ticketFk, saleFk, isFreezed, + risk, hasHighRisk, hasTicketRequest, isTaxDataChecked, hasComponentLack, hasRounding, - isTooLittle, - isVip) + isTooLittle) SELECT sgp.ticketFk, s.id, - IF(FIND_IN_SET('isFreezed', s.problem), TRUE, FALSE) isFreezed, - IF(FIND_IN_SET('hasHighRisk', s.problem), TRUE, FALSE) hasHighRisk, - IF(FIND_IN_SET('hasTicketRequest', s.problem), TRUE, FALSE) hasTicketRequest, - IF(FIND_IN_SET('isTaxDataChecked', s.problem), FALSE, TRUE) isTaxDataChecked, + IF(FIND_IN_SET('isFreezed', t.problem), TRUE, FALSE) isFreezed, + t.risk, + IF(FIND_IN_SET('hasHighRisk', t.problem), TRUE, FALSE) hasHighRisk, + IF(FIND_IN_SET('hasTicketRequest', t.problem), TRUE, FALSE) hasTicketRequest, + IF(FIND_IN_SET('isTaxDataChecked', t.problem), FALSE, TRUE) isTaxDataChecked, IF(FIND_IN_SET('hasComponentLack', s.problem), TRUE, FALSE) hasComponentLack, IF(FIND_IN_SET('hasRounding', s.problem), LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250), NULL ) hasRounding, - IF(FIND_IN_SET('isTooLittle', s.problem), TRUE, FALSE) isTooLittle, - IF(FIND_IN_SET('isVip', s.problem), TRUE, FALSE) isVip + IF(FIND_IN_SET('isTooLittle', t.problem), TRUE, FALSE) isTooLittle FROM tmp.sale_getProblems sgp JOIN ticket t ON t.id = sgp.ticketFk - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - WHERE s.problem <> '' - GROUP BY s.id; + LEFT JOIN sale s ON s.ticketFk = t.id + LEFT JOIN item i ON i.id = s.itemFk + WHERE s.problem <> '' OR t.problem <> '' OR t.risk + GROUP BY t.id, s.id; - INSERT INTO tmp.sale_problems (ticketFk, risk) - SELECT t.id, t.risk - FROM tmp.sale_getProblems sgp - JOIN ticket t ON t.id = sgp.ticketFk; + INSERT INTO tmp.sale_problems(ticketFk, isVip) + SELECT sgp.ticketFk, TRUE + FROM tmp.sale_getProblems sgp + JOIN client c ON c.id = sgp.clientFk + WHERE c.businessTypeFk = 'VIP' + ON DUPLICATE KEY UPDATE isVIP = TRUE; CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock_byWarehouse (INDEX (itemFk, warehouseFk)) diff --git a/modules/ticket/back/methods/ticket/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js index b7267995e..0fd21ea74 100644 --- a/modules/ticket/back/methods/ticket/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket/getTicketsFuture.js @@ -161,7 +161,8 @@ module.exports = Self => { stmt = new ParameterizedSQL(` SELECT f.*, tp.* FROM tmp.filter f - LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id`); + LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id + `); if (args.problems != undefined && (!args.originDated && !args.futureDated)) throw new UserError('Choose a date range or days forward'); From 09a0459a7b4cbdca8690661f44e2ccf0acd2227c Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 7 Aug 2024 13:52:41 +0200 Subject: [PATCH 21/74] refs #7844 Fix tests part 2/2 --- modules/ticket/back/methods/ticket/specs/filter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 1d050931b..72249fe5d 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -71,7 +71,7 @@ describe('ticket filter()', () => { const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(10); + expect(result.length).toEqual(11); await tx.rollback(); } catch (e) { From 3ee9833a701b8e6c270d554b60d84eae3bec2534 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 12 Aug 2024 14:06:02 +0200 Subject: [PATCH 22/74] fix: refs #7355 remove and tests accounts --- .../01_create_and_basic_data.spec.js | 164 ------------ .../02_alias_create_and_basic_data.spec.js | 66 ----- .../03_role_create_and_basic_data.spec.js | 86 ------- e2e/paths/14-account/04_acl.spec.js | 60 ----- e2e/paths/14-account/05_connections.spec.js | 25 -- e2e/paths/14-account/06_accounts.spec.js | 37 --- e2e/paths/14-account/07_ldap.spec.js | 41 --- e2e/paths/14-account/08_samba.spec.js | 42 --- e2e/paths/14-account/09_privileges.spec.js | 112 -------- modules/account/front/accounts/index.html | 75 ------ modules/account/front/accounts/index.js | 19 -- modules/account/front/accounts/locale/es.yml | 14 - modules/account/front/acl/create/index.html | 70 ----- modules/account/front/acl/create/index.js | 33 --- modules/account/front/acl/index.js | 4 - modules/account/front/acl/index/index.html | 51 ---- modules/account/front/acl/index/index.js | 15 -- modules/account/front/acl/index/locale/es.yml | 4 - modules/account/front/acl/locale/es.yml | 4 - modules/account/front/acl/main/index.html | 20 -- modules/account/front/acl/main/index.js | 18 -- .../account/front/acl/search-panel/index.html | 39 --- .../account/front/acl/search-panel/index.js | 26 -- .../account/front/alias/basic-data/index.html | 43 ---- .../account/front/alias/basic-data/index.js | 12 - modules/account/front/alias/card/index.html | 5 - modules/account/front/alias/card/index.js | 14 - modules/account/front/alias/create/index.html | 38 --- modules/account/front/alias/create/index.js | 15 -- .../account/front/alias/descriptor/index.html | 27 -- .../account/front/alias/descriptor/index.js | 26 -- .../front/alias/descriptor/locale/es.yml | 2 - modules/account/front/alias/index.js | 9 - modules/account/front/alias/index/index.html | 39 --- modules/account/front/alias/index/index.js | 14 - .../account/front/alias/index/locale/es.yml | 2 - modules/account/front/alias/locale/es.yml | 1 - modules/account/front/alias/main/index.html | 17 -- modules/account/front/alias/main/index.js | 18 -- .../account/front/alias/summary/index.html | 16 -- modules/account/front/alias/summary/index.js | 25 -- modules/account/front/alias/users/index.html | 26 -- modules/account/front/alias/users/index.js | 31 --- .../account/front/alias/users/index.spec.js | 42 --- .../account/front/alias/users/locale/es.yml | 2 - modules/account/front/aliases/index.html | 64 ----- modules/account/front/aliases/index.js | 51 ---- modules/account/front/aliases/index.spec.js | 53 ---- modules/account/front/aliases/locale/es.yml | 3 - modules/account/front/basic-data/index.html | 51 ---- modules/account/front/basic-data/index.js | 25 -- .../account/front/basic-data/locale/es.yml | 1 - modules/account/front/card/index.html | 8 - modules/account/front/card/index.js | 32 --- modules/account/front/card/index.spec.js | 27 -- modules/account/front/card/style.scss | 10 - modules/account/front/connections/index.html | 45 ---- modules/account/front/connections/index.js | 29 --- .../account/front/connections/locale/es.yml | 5 - modules/account/front/create/index.html | 57 ---- modules/account/front/create/index.js | 20 -- .../front/descriptor-popover/index.html | 4 - .../account/front/descriptor-popover/index.js | 9 - .../__snapshots__/index.spec.js.snap | 5 - modules/account/front/descriptor/index.html | 192 -------------- modules/account/front/descriptor/index.js | 145 ----------- .../account/front/descriptor/index.spec.js | 97 ------- .../account/front/descriptor/locale/es.yml | 35 --- modules/account/front/index.js | 21 -- modules/account/front/index/index.html | 47 ---- modules/account/front/index/index.js | 14 - modules/account/front/index/locale/es.yml | 2 - modules/account/front/ldap/index.html | 66 ----- modules/account/front/ldap/index.js | 14 - modules/account/front/ldap/locale/es.yml | 8 - .../account/front/mail-forwarding/index.html | 49 ---- .../account/front/mail-forwarding/index.js | 12 - .../front/mail-forwarding/locale/es.yml | 7 - modules/account/front/main/index.html | 19 -- modules/account/front/main/index.js | 28 +- modules/account/front/main/index.spec.js | 28 -- modules/account/front/privileges/index.html | 41 --- modules/account/front/privileges/index.js | 21 -- .../account/front/privileges/locale/es.yml | 2 - modules/account/front/role-log/index.html | 1 - modules/account/front/role-log/index.js | 7 - .../account/front/role/basic-data/index.html | 40 --- .../account/front/role/basic-data/index.js | 12 - modules/account/front/role/card/index.html | 5 - modules/account/front/role/card/index.js | 14 - modules/account/front/role/card/index.spec.js | 25 -- modules/account/front/role/create/index.html | 38 --- modules/account/front/role/create/index.js | 15 -- .../account/front/role/descriptor/index.html | 27 -- .../account/front/role/descriptor/index.js | 26 -- .../front/role/descriptor/index.spec.js | 29 --- .../front/role/descriptor/locale/es.yml | 2 - modules/account/front/role/index.js | 10 - modules/account/front/role/index/index.html | 42 --- modules/account/front/role/index/index.js | 14 - .../account/front/role/index/locale/es.yml | 2 - .../account/front/role/inherited/index.html | 21 -- modules/account/front/role/inherited/index.js | 23 -- .../front/role/inherited/index.spec.js | 23 -- modules/account/front/role/locale/es.yml | 1 - modules/account/front/role/main/index.html | 18 -- modules/account/front/role/main/index.js | 24 -- .../front/role/search-panel/index.html | 21 -- .../account/front/role/search-panel/index.js | 7 - .../account/front/role/subroles/index.html | 57 ---- modules/account/front/role/subroles/index.js | 51 ---- .../account/front/role/subroles/index.spec.js | 53 ---- .../account/front/role/subroles/locale/es.yml | 4 - modules/account/front/role/summary/index.html | 20 -- modules/account/front/role/summary/index.js | 24 -- modules/account/front/roles/index.html | 21 -- modules/account/front/roles/index.js | 26 -- modules/account/front/routes.json | 243 ------------------ modules/account/front/samba/index.html | 71 ----- modules/account/front/samba/index.js | 14 - modules/account/front/samba/locale/es.yml | 9 - modules/account/front/search-panel/index.html | 31 --- modules/account/front/search-panel/index.js | 7 - modules/account/front/summary/index.html | 40 --- modules/account/front/summary/index.js | 40 --- modules/account/front/user-log/index.html | 1 - modules/account/front/user-log/index.js | 7 - 127 files changed, 3 insertions(+), 3959 deletions(-) delete mode 100644 e2e/paths/14-account/01_create_and_basic_data.spec.js delete mode 100644 e2e/paths/14-account/02_alias_create_and_basic_data.spec.js delete mode 100644 e2e/paths/14-account/03_role_create_and_basic_data.spec.js delete mode 100644 e2e/paths/14-account/04_acl.spec.js delete mode 100644 e2e/paths/14-account/05_connections.spec.js delete mode 100644 e2e/paths/14-account/06_accounts.spec.js delete mode 100644 e2e/paths/14-account/07_ldap.spec.js delete mode 100644 e2e/paths/14-account/08_samba.spec.js delete mode 100644 e2e/paths/14-account/09_privileges.spec.js delete mode 100644 modules/account/front/accounts/index.html delete mode 100644 modules/account/front/accounts/index.js delete mode 100644 modules/account/front/accounts/locale/es.yml delete mode 100644 modules/account/front/acl/create/index.html delete mode 100644 modules/account/front/acl/create/index.js delete mode 100644 modules/account/front/acl/index.js delete mode 100644 modules/account/front/acl/index/index.html delete mode 100644 modules/account/front/acl/index/index.js delete mode 100644 modules/account/front/acl/index/locale/es.yml delete mode 100644 modules/account/front/acl/locale/es.yml delete mode 100644 modules/account/front/acl/main/index.html delete mode 100644 modules/account/front/acl/main/index.js delete mode 100644 modules/account/front/acl/search-panel/index.html delete mode 100644 modules/account/front/acl/search-panel/index.js delete mode 100644 modules/account/front/alias/basic-data/index.html delete mode 100644 modules/account/front/alias/basic-data/index.js delete mode 100644 modules/account/front/alias/card/index.html delete mode 100644 modules/account/front/alias/card/index.js delete mode 100644 modules/account/front/alias/create/index.html delete mode 100644 modules/account/front/alias/create/index.js delete mode 100644 modules/account/front/alias/descriptor/index.html delete mode 100644 modules/account/front/alias/descriptor/index.js delete mode 100644 modules/account/front/alias/descriptor/locale/es.yml delete mode 100644 modules/account/front/alias/index.js delete mode 100644 modules/account/front/alias/index/index.html delete mode 100644 modules/account/front/alias/index/index.js delete mode 100644 modules/account/front/alias/index/locale/es.yml delete mode 100644 modules/account/front/alias/locale/es.yml delete mode 100644 modules/account/front/alias/main/index.html delete mode 100644 modules/account/front/alias/main/index.js delete mode 100644 modules/account/front/alias/summary/index.html delete mode 100644 modules/account/front/alias/summary/index.js delete mode 100644 modules/account/front/alias/users/index.html delete mode 100644 modules/account/front/alias/users/index.js delete mode 100644 modules/account/front/alias/users/index.spec.js delete mode 100644 modules/account/front/alias/users/locale/es.yml delete mode 100644 modules/account/front/aliases/index.html delete mode 100644 modules/account/front/aliases/index.js delete mode 100644 modules/account/front/aliases/index.spec.js delete mode 100644 modules/account/front/aliases/locale/es.yml delete mode 100644 modules/account/front/basic-data/index.html delete mode 100644 modules/account/front/basic-data/index.js delete mode 100644 modules/account/front/basic-data/locale/es.yml delete mode 100644 modules/account/front/card/index.html delete mode 100644 modules/account/front/card/index.js delete mode 100644 modules/account/front/card/index.spec.js delete mode 100644 modules/account/front/card/style.scss delete mode 100644 modules/account/front/connections/index.html delete mode 100644 modules/account/front/connections/index.js delete mode 100644 modules/account/front/connections/locale/es.yml delete mode 100644 modules/account/front/create/index.html delete mode 100644 modules/account/front/create/index.js delete mode 100644 modules/account/front/descriptor-popover/index.html delete mode 100644 modules/account/front/descriptor-popover/index.js delete mode 100644 modules/account/front/descriptor/__snapshots__/index.spec.js.snap delete mode 100644 modules/account/front/descriptor/index.html delete mode 100644 modules/account/front/descriptor/index.js delete mode 100644 modules/account/front/descriptor/index.spec.js delete mode 100644 modules/account/front/descriptor/locale/es.yml delete mode 100644 modules/account/front/index/index.html delete mode 100644 modules/account/front/index/index.js delete mode 100644 modules/account/front/index/locale/es.yml delete mode 100644 modules/account/front/ldap/index.html delete mode 100644 modules/account/front/ldap/index.js delete mode 100644 modules/account/front/ldap/locale/es.yml delete mode 100644 modules/account/front/mail-forwarding/index.html delete mode 100644 modules/account/front/mail-forwarding/index.js delete mode 100644 modules/account/front/mail-forwarding/locale/es.yml delete mode 100644 modules/account/front/main/index.spec.js delete mode 100644 modules/account/front/privileges/index.html delete mode 100644 modules/account/front/privileges/index.js delete mode 100644 modules/account/front/privileges/locale/es.yml delete mode 100644 modules/account/front/role-log/index.html delete mode 100644 modules/account/front/role-log/index.js delete mode 100644 modules/account/front/role/basic-data/index.html delete mode 100644 modules/account/front/role/basic-data/index.js delete mode 100644 modules/account/front/role/card/index.html delete mode 100644 modules/account/front/role/card/index.js delete mode 100644 modules/account/front/role/card/index.spec.js delete mode 100644 modules/account/front/role/create/index.html delete mode 100644 modules/account/front/role/create/index.js delete mode 100644 modules/account/front/role/descriptor/index.html delete mode 100644 modules/account/front/role/descriptor/index.js delete mode 100644 modules/account/front/role/descriptor/index.spec.js delete mode 100644 modules/account/front/role/descriptor/locale/es.yml delete mode 100644 modules/account/front/role/index.js delete mode 100644 modules/account/front/role/index/index.html delete mode 100644 modules/account/front/role/index/index.js delete mode 100644 modules/account/front/role/index/locale/es.yml delete mode 100644 modules/account/front/role/inherited/index.html delete mode 100644 modules/account/front/role/inherited/index.js delete mode 100644 modules/account/front/role/inherited/index.spec.js delete mode 100644 modules/account/front/role/locale/es.yml delete mode 100644 modules/account/front/role/main/index.html delete mode 100644 modules/account/front/role/main/index.js delete mode 100644 modules/account/front/role/search-panel/index.html delete mode 100644 modules/account/front/role/search-panel/index.js delete mode 100644 modules/account/front/role/subroles/index.html delete mode 100644 modules/account/front/role/subroles/index.js delete mode 100644 modules/account/front/role/subroles/index.spec.js delete mode 100644 modules/account/front/role/subroles/locale/es.yml delete mode 100644 modules/account/front/role/summary/index.html delete mode 100644 modules/account/front/role/summary/index.js delete mode 100644 modules/account/front/roles/index.html delete mode 100644 modules/account/front/roles/index.js delete mode 100644 modules/account/front/samba/index.html delete mode 100644 modules/account/front/samba/index.js delete mode 100644 modules/account/front/samba/locale/es.yml delete mode 100644 modules/account/front/search-panel/index.html delete mode 100644 modules/account/front/search-panel/index.js delete mode 100644 modules/account/front/summary/index.html delete mode 100644 modules/account/front/summary/index.js delete mode 100644 modules/account/front/user-log/index.html delete mode 100644 modules/account/front/user-log/index.js diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js deleted file mode 100644 index e2c069d80..000000000 --- a/e2e/paths/14-account/01_create_and_basic_data.spec.js +++ /dev/null @@ -1,164 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account create and basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('itManagement', 'account'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the new account form by clicking the add button', async() => { - await page.waitToClick(selectors.accountIndex.addAccount); - await page.waitForState('account.create'); - }); - - it('should fill the form and then save it by clicking the create button', async() => { - await page.write(selectors.accountIndex.newName, 'remy'); - await page.write(selectors.accountIndex.newNickname, 'Gambit'); - await page.write(selectors.accountIndex.newEmail, 'RemyEtienneLeBeau@verdnatura.es'); - await page.autocompleteSearch(selectors.accountIndex.newRole, 'Trainee'); - await page.write(selectors.accountIndex.newPassword, 'cestlavie'); - await page.waitToClick(selectors.accountIndex.createAccountButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should redirect the user to the created account basic data section', async() => { - await page.waitForState('account.card.basicData'); - }); - - it('should check the name is as expected', async() => { - const result = await page.waitToGetProperty(selectors.accountBasicData.name, 'value'); - - expect(result).toEqual('remy'); - }); - - it('should check the nickname is as expected', async() => { - const result = await page.waitToGetProperty(selectors.accountBasicData.nickname, 'value'); - - expect(result).toEqual('Gambit'); - }); - - it('should check the email is as expected', async() => { - const result = await page.waitToGetProperty(selectors.accountBasicData.email, 'value'); - - expect(result).toEqual('RemyEtienneLeBeau@verdnatura.es'); - }); - - it('should navigate to the roles section to check the roles are correct', async() => { - await page.accessToSection('account.card.roles'); - const rolesCount = await page.countElement(selectors.accountRoles.anyResult); - - expect(rolesCount).toEqual(3); - }); - - describe('Descriptor option', () => { - describe('activate account', () => { - it(`should check the active account icon isn't present in the descriptor`, async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeAccountIcon, 0); - }); - - it('should activate the account using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.activateAccount); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Account enabled!'); - }); - - it('should check the active account icon is now present in the descriptor', async() => { - await page.waitForSelector(selectors.accountDescriptor.activeAccountIcon, {visible: false}); - }); - }); - - describe('deactivate user', () => { - it(`should check the inactive user icon isn't present in the descriptor just yet`, async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0); - }); - - it('should deactivate the user using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.deactivateUser); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('User deactivated!'); - }); - - it('should check the inactive user icon is now present', async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 1); - }); - }); - - describe('activate user', () => { - it('should activate the user using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.activateUser); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('User activated!'); - }); - - it('should check the inactive user icon is not present anymore', async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0); - }); - }); - - describe('mail forwarding', () => { - it('should activate the mail forwarding and set the recipent email', async() => { - await page.accessToSection('account.card.mailForwarding'); - await page.waitToClick(selectors.accountMailForwarding.mailForwardingCheckbox); - await page.write(selectors.accountMailForwarding.email, 'someEmail@someDomain.es'); - await page.waitToClick(selectors.accountMailForwarding.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - }); - - describe('Set password', () => { - it('should set the password using the descriptor menu', async() => { - const newPassword = 'quantum.12345'; - - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.setPassword); - await page.write(selectors.accountDescriptor.newPassword, newPassword); - await page.write(selectors.accountDescriptor.repeatPassword, newPassword); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Password changed succesfully!'); - }); - - // cant log into created account for unknown reasons - // it('should login into the created account with the new password', async() => { - // await page.loginAndModule('Remy', 'quantum.crypt0graphy'); - // }); - }); - - describe('delete account', () => { - // it('should navigate to the account basic data section', async() => { - // }); - - it('should delete the account using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.deleteAccount); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('User removed'); - }); - }); - }); -}); diff --git a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js deleted file mode 100644 index 840fb8afe..000000000 --- a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js +++ /dev/null @@ -1,66 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Alias create and basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('itManagement', 'account'); - await page.accessToSection('account.alias'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the new account alias form by clicking the add button', async() => { - await page.waitToClick(selectors.accountAliasIndex.addAlias); - await page.waitForState('account.alias.create'); - }); - - it('should fill the form and then save it by clicking the create alias button', async() => { - await page.write(selectors.accountAliasIndex.newName, 'Boring alias'); - await page.write(selectors.accountAliasIndex.newDescription, 'Boring description'); - await page.waitToClick(selectors.accountAliasIndex.createAliasButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should redirect the user to the created account alias basic data section', async() => { - await page.waitForState('account.alias.card.basicData'); - }); - - it('should edit the alias basic data', async() => { - await page.overwrite(selectors.accountAliasBasicData.name, 'Psykers'); - await page.overwrite(selectors.accountAliasBasicData.description, 'Email group for psykers'); - await page.waitToClick(selectors.accountAliasBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the basicData section and check the name was edited successfully', async() => { - await page.reloadSection('account.alias.card.basicData'); - const result = await page.waitToGetProperty(selectors.accountAliasBasicData.name, 'value'); - - expect(result).toEqual('Psykers'); - }); - - it('should check the alias description was edited successfully', async() => { - const result = await page.waitToGetProperty(selectors.accountAliasBasicData.description, 'value'); - - expect(result).toContain('psykers'); - }); - - it('should search IT alias then access the user section to check the role listed is the expected one', async() => { - await page.accessToSearchResult('IT'); - await page.accessToSection('account.alias.card.users'); - const rolesCount = await page.countElement(selectors.accountAliasUsers.anyResult); - - expect(rolesCount).toEqual(1); - }); -}); diff --git a/e2e/paths/14-account/03_role_create_and_basic_data.spec.js b/e2e/paths/14-account/03_role_create_and_basic_data.spec.js deleted file mode 100644 index 6acf82318..000000000 --- a/e2e/paths/14-account/03_role_create_and_basic_data.spec.js +++ /dev/null @@ -1,86 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Role create and basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('it', 'account'); - await page.accessToSection('account.role'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the new account role form by clicking the add button', async() => { - await page.waitToClick(selectors.accountRoleIndex.addRole); - await page.waitForState('account.role.create'); - }); - - it('should fill the form and then save it by clicking the create role button', async() => { - await page.write(selectors.accountRoleIndex.newName, 'boringRole'); - await page.write(selectors.accountRoleIndex.newDescription, 'Boring description'); - await page.waitToClick(selectors.accountRoleIndex.createRoleButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should redirect the user to the created role basic data section', async() => { - await page.waitForState('account.role.card.basicData'); - }); - - it('should edit the role basic data', async() => { - await page.overwrite(selectors.accountRoleBasicData.name, 'psyker'); - await page.overwrite(selectors.accountRoleBasicData.description, 'A role just for psykers'); - await page.waitToClick(selectors.accountRoleBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the role basicData section and check the name was edited successfully', async() => { - await page.reloadSection('account.role.card.basicData'); - const result = await page.waitToGetProperty(selectors.accountRoleBasicData.name, 'value'); - - expect(result).toEqual('psyker'); - }); - - it('should check the role description was edited successfully', async() => { - const result = await page.waitToGetProperty(selectors.accountRoleBasicData.description, 'value'); - - expect(result).toContain('psykers'); - }); - - it('should navigate to the subroles section', async() => { - await page.accessToSection('account.role.card.subroles'); - }); - - it('should asign a subrole', async() => { - await page.waitToClick(selectors.accountSubroles.addSubrole); - await page.autocompleteSearch(selectors.accountSubroles.role, 'teamManager'); - await page.waitToClick(selectors.accountSubroles.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Role added!'); - }); - - it('should reload the subroles section and check a role was added', async() => { - await page.reloadSection('account.role.card.subroles'); - const subrolesCount = await page.countElement(selectors.accountSubroles.anyResult); - - expect(subrolesCount).toEqual(1); - }); - - it('should access the employee roles inheritance then check the roles listed are the expected ones', async() => { - await page.accessToSearchResult('employee'); - await page.accessToSection('account.role.card.inherited'); - const rolesCount = await page.countElement(selectors.accountRoleInheritance.anyResult); - - expect(rolesCount).toEqual(7); - }); -}); diff --git a/e2e/paths/14-account/04_acl.spec.js b/e2e/paths/14-account/04_acl.spec.js deleted file mode 100644 index ce2a63b14..000000000 --- a/e2e/paths/14-account/04_acl.spec.js +++ /dev/null @@ -1,60 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account ACL path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('developer', 'account'); - await page.accessToSection('account.acl'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should go to create new acl', async() => { - await page.waitToClick(selectors.accountAcl.addAcl); - await page.waitForState('account.acl.create'); - }); - - it('should create new acl', async() => { - await page.autocompleteSearch(selectors.accountAcl.role, 'sysadmin'); - await page.autocompleteSearch(selectors.accountAcl.model, 'Account'); - await page.autocompleteSearch(selectors.accountAcl.accessType, '*'); - await page.autocompleteSearch(selectors.accountAcl.permission, 'ALLOW'); - await page.waitToClick(selectors.accountAcl.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should navigate to edit', async() => { - await page.doSearch(); - await page.waitToClick(selectors.accountAcl.thirdAcl); - await page.waitForState('account.acl.edit'); - }); - - it('should edit the third acl', async() => { - await page.autocompleteSearch(selectors.accountAcl.model, 'Supplier'); - await page.autocompleteSearch(selectors.accountAcl.accessType, 'READ'); - await page.waitToClick(selectors.accountAcl.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should delete the third result', async() => { - const result = await page.waitToGetProperty(selectors.accountAcl.thirdAcl, 'innerText'); - await page.waitToClick(selectors.accountAcl.deleteThirdAcl); - await page.waitToClick(selectors.globalItems.acceptButton); - const message = await page.waitForSnackbar(); - const newResult = await page.waitToGetProperty(selectors.accountAcl.thirdAcl, 'innerText'); - - expect(message.text).toContain('ACL removed'); - expect(result).not.toEqual(newResult); - }); -}); diff --git a/e2e/paths/14-account/05_connections.spec.js b/e2e/paths/14-account/05_connections.spec.js deleted file mode 100644 index 49d5f612d..000000000 --- a/e2e/paths/14-account/05_connections.spec.js +++ /dev/null @@ -1,25 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Connections path', () => { - let browser; - let page; - const account = 'sysadmin'; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule(account, 'account'); - await page.accessToSection('account.connections'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should check this is the last connection', async() => { - const firstResult = await page.waitToGetProperty(selectors.accountConnections.firstConnection, 'innerText'); - - expect(firstResult).toContain(account); - }); -}); diff --git a/e2e/paths/14-account/06_accounts.spec.js b/e2e/paths/14-account/06_accounts.spec.js deleted file mode 100644 index 8bd6ea7d5..000000000 --- a/e2e/paths/14-account/06_accounts.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Accounts path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.accounts'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should sync roles', async() => { - await page.waitToClick(selectors.accountAccounts.syncRoles); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Roles synchronized!'); - }); - - it('should relogin', async() => { - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.accounts'); - }); - - it('should sync all', async() => { - await page.waitToClick(selectors.accountAccounts.syncAll); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Synchronizing in the background'); - }); -}); diff --git a/e2e/paths/14-account/07_ldap.spec.js b/e2e/paths/14-account/07_ldap.spec.js deleted file mode 100644 index eb22f695c..000000000 --- a/e2e/paths/14-account/07_ldap.spec.js +++ /dev/null @@ -1,41 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account LDAP path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.ldap'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should set data and save', async() => { - await page.waitToClick(selectors.accountLdap.checkEnable); - await page.write(selectors.accountLdap.server, '1234'); - await page.write(selectors.accountLdap.rdn, '1234'); - await page.write(selectors.accountLdap.password, 'nightmare'); - await page.write(selectors.accountLdap.userDn, 'sysadmin'); - await page.write(selectors.accountLdap.groupDn, '1234'); - await page.waitToClick(selectors.accountLdap.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reset data', async() => { - await page.waitToClick(selectors.accountLdap.checkEnable); - await page.waitToClick(selectors.accountLdap.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/14-account/08_samba.spec.js b/e2e/paths/14-account/08_samba.spec.js deleted file mode 100644 index a92344acb..000000000 --- a/e2e/paths/14-account/08_samba.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Samba path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.samba'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should set data and save', async() => { - await page.waitToClick(selectors.accountSamba.checkEnable); - await page.write(selectors.accountSamba.adDomain, '1234'); - await page.write(selectors.accountSamba.adController, '1234'); - await page.write(selectors.accountSamba.adUser, 'sysadmin'); - await page.write(selectors.accountSamba.adPassword, 'nightmare'); - await page.write(selectors.accountSamba.userDn, 'testDn'); - await page.waitToClick(selectors.accountSamba.verifyCert); - await page.waitToClick(selectors.accountSamba.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reset data', async() => { - await page.waitToClick(selectors.accountSamba.checkEnable); - await page.waitToClick(selectors.accountSamba.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/14-account/09_privileges.spec.js b/e2e/paths/14-account/09_privileges.spec.js deleted file mode 100644 index e4b8fb24c..000000000 --- a/e2e/paths/14-account/09_privileges.spec.js +++ /dev/null @@ -1,112 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account privileges path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('developer', 'account'); - await page.accessToSearchResult('1101'); - await page.accessToSection('account.card.privileges'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('as developer', () => { - it('should throw error when give privileges', async() => { - await page.waitToClick(selectors.accountPrivileges.checkHasGrant); - await page.waitToClick(selectors.accountPrivileges.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You don't have grant privilege`); - }); - - it('should throw error when change role', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'employee'); - await page.waitToClick(selectors.accountPrivileges.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You don't have grant privilege`); - }); - }); - - describe('as sysadmin', () => { - beforeAll(async() => { - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSearchResult('9'); - await page.accessToSection('account.card.privileges'); - }); - - it('should give privileges', async() => { - await page.waitToClick(selectors.accountPrivileges.checkHasGrant); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('account.card.privileges'); - const result = await page.checkboxState(selectors.accountPrivileges.checkHasGrant); - - expect(message.text).toContain(`Data saved!`); - expect(result).toBe('checked'); - }); - - it('should throw error when change role and not own role', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'itBoss'); - await page.waitToClick(selectors.accountPrivileges.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You don't own the role and you can't assign it to another user`); - }); - - it('should change role to employee', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'employee'); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('account.card.privileges'); - const result = await page.waitToGetProperty(selectors.accountPrivileges.role, 'value'); - - expect(message.text).toContain(`Data saved!`); - expect(result).toContain('employee'); - }); - - it('should return role to developer', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'developer'); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('account.card.privileges'); - const result = await page.waitToGetProperty(selectors.accountPrivileges.role, 'value'); - - expect(message.text).toContain(`Data saved!`); - expect(result).toContain('developer'); - }); - }); - - describe('as developer again', () => { - it('should remove privileges', async() => { - await page.accessToSearchResult('9'); - await page.accessToSection('account.card.privileges'); - - await page.waitToClick(selectors.accountPrivileges.checkHasGrant); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`Data saved!`); - }); - - it('should logIn in developer', async() => { - await page.reloadSection('account.card.privileges'); - const result = await page.checkboxState(selectors.accountPrivileges.checkHasGrant); - - expect(result).toBe('unchecked'); - }); - }); -}); diff --git a/modules/account/front/accounts/index.html b/modules/account/front/accounts/index.html deleted file mode 100644 index 6847e68d1..000000000 --- a/modules/account/front/accounts/index.html +++ /dev/null @@ -1,75 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/accounts/index.js b/modules/account/front/accounts/index.js deleted file mode 100644 index ab19126a1..000000000 --- a/modules/account/front/accounts/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSynchronizeAll() { - this.vnApp.showSuccess(this.$t('Synchronizing in the background')); - this.$http.patch(`Accounts/syncAll`); - } - - onSynchronizeRoles() { - this.$http.patch(`RoleInherits/sync`) - .then(() => this.vnApp.showSuccess(this.$t('Roles synchronized!'))); - } -} - -ngModule.component('vnAccountAccounts', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/accounts/locale/es.yml b/modules/account/front/accounts/locale/es.yml deleted file mode 100644 index 614ade3eb..000000000 --- a/modules/account/front/accounts/locale/es.yml +++ /dev/null @@ -1,14 +0,0 @@ -Accounts: Cuentas -Homedir base: Directorio base para carpetas de usuario -Shell: Intérprete de línea de comandos -User and role base id: Id base usuarios y roles -Synchronize all: Sincronizar todo -Synchronize roles: Sincronizar roles -If password is not specified, just user attributes are synchronized: >- - Si la contraseña no se especifica solo se sincronizarán lo atributos del usuario -Synchronizing in the background: Sincronizando en segundo plano -Users synchronized!: ¡Usuarios sincronizados! -Username: Nombre de usuario -Synchronize: Sincronizar -Please enter the username: Por favor introduce el nombre de usuario -Roles synchronized!: ¡Roles sincronizados! diff --git a/modules/account/front/acl/create/index.html b/modules/account/front/acl/create/index.html deleted file mode 100644 index 14332f737..000000000 --- a/modules/account/front/acl/create/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/acl/create/index.js b/modules/account/front/acl/create/index.js deleted file mode 100644 index fea71991f..000000000 --- a/modules/account/front/acl/create/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor(...args) { - super(...args); - this.accessTypes = [ - {name: '*'}, - {name: 'READ'}, - {name: 'WRITE'} - ]; - this.permissions = [ - {name: 'ALLOW'}, - {name: 'DENY'} - ]; - - this.models = []; - for (let model in window.validations) - this.models.push({name: model}); - - this.acl = { - property: '*', - principalType: 'ROLE', - accessType: 'READ', - permission: 'ALLOW' - }; - } -} - -ngModule.component('vnAclCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/acl/index.js b/modules/account/front/acl/index.js deleted file mode 100644 index 8393859a5..000000000 --- a/modules/account/front/acl/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import './main'; -import './index/'; -import './create'; -import './search-panel'; diff --git a/modules/account/front/acl/index/index.html b/modules/account/front/acl/index/index.html deleted file mode 100644 index af06ec481..000000000 --- a/modules/account/front/acl/index/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - -
{{::row.model}}.{{::row.property}}
- - - - - - -
- - - - -
-
-
-
- - - - - \ No newline at end of file diff --git a/modules/account/front/acl/index/index.js b/modules/account/front/acl/index/index.js deleted file mode 100644 index a2aec534a..000000000 --- a/modules/account/front/acl/index/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onDelete(row) { - return this.$http.delete(`ACLs/${row.id}`) - .then(() => this.$.model.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('ACL removed'))); - } -} - -ngModule.component('vnAclIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/acl/index/locale/es.yml b/modules/account/front/acl/index/locale/es.yml deleted file mode 100644 index 8024f804c..000000000 --- a/modules/account/front/acl/index/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -New ACL: Nuevo ACL -Edit ACL: Editar ACL -ACL will be removed: El ACL será eliminado -ACL removed: ACL eliminado diff --git a/modules/account/front/acl/locale/es.yml b/modules/account/front/acl/locale/es.yml deleted file mode 100644 index ff6a1b41c..000000000 --- a/modules/account/front/acl/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Model: Modelo -Property: Propiedad -Access type: Tipo de acceso -Permission: Permiso \ No newline at end of file diff --git a/modules/account/front/acl/main/index.html b/modules/account/front/acl/main/index.html deleted file mode 100644 index 7767768d9..000000000 --- a/modules/account/front/acl/main/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/modules/account/front/acl/main/index.js b/modules/account/front/acl/main/index.js deleted file mode 100644 index a91a71cb7..000000000 --- a/modules/account/front/acl/main/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class ACL extends ModuleMain { - exprBuilder(param, value) { - switch (param) { - case 'search': - return {model: {like: `%${value}%`}}; - default: - return {[param]: value}; - } - } -} - -ngModule.vnComponent('vnAclComponent', { - controller: ACL, - template: require('./index.html') -}); diff --git a/modules/account/front/acl/search-panel/index.html b/modules/account/front/acl/search-panel/index.html deleted file mode 100644 index a3efab440..000000000 --- a/modules/account/front/acl/search-panel/index.html +++ /dev/null @@ -1,39 +0,0 @@ -
-
- - - - - - - - - - - - - - -
-
diff --git a/modules/account/front/acl/search-panel/index.js b/modules/account/front/acl/search-panel/index.js deleted file mode 100644 index 4f571059e..000000000 --- a/modules/account/front/acl/search-panel/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -export default class Controller extends SearchPanel { - constructor(...args) { - super(...args); - this.accessTypes = [ - {name: '*'}, - {name: 'READ'}, - {name: 'WRITE'} - ]; - this.permissions = [ - {name: 'ALLOW'}, - {name: 'DENY'} - ]; - - this.models = []; - for (let model in window.validations) - this.models.push({name: model}); - } -} - -ngModule.component('vnAclSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/basic-data/index.html b/modules/account/front/alias/basic-data/index.html deleted file mode 100644 index 523c9297a..000000000 --- a/modules/account/front/alias/basic-data/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - -
- - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/account/front/alias/basic-data/index.js b/modules/account/front/alias/basic-data/index.js deleted file mode 100644 index b7c2db089..000000000 --- a/modules/account/front/alias/basic-data/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section {} - -ngModule.component('vnAliasBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - alias: '<' - } -}); diff --git a/modules/account/front/alias/card/index.html b/modules/account/front/alias/card/index.html deleted file mode 100644 index 712147a24..000000000 --- a/modules/account/front/alias/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/account/front/alias/card/index.js b/modules/account/front/alias/card/index.js deleted file mode 100644 index fd1a18f6a..000000000 --- a/modules/account/front/alias/card/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - this.$http.get(`MailAliases/${this.$params.id}`) - .then(res => this.alias = res.data); - } -} - -ngModule.vnComponent('vnAliasCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/create/index.html b/modules/account/front/alias/create/index.html deleted file mode 100644 index 4dad1b870..000000000 --- a/modules/account/front/alias/create/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - -
- - - - - - - - - - - - - - -
diff --git a/modules/account/front/alias/create/index.js b/modules/account/front/alias/create/index.js deleted file mode 100644 index c058c3adf..000000000 --- a/modules/account/front/alias/create/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - return this.$.watcher.submit().then(res => - this.$state.go('account.alias.card.basicData', {id: res.data.id}) - ); - } -} - -ngModule.component('vnAliasCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/descriptor/index.html b/modules/account/front/alias/descriptor/index.html deleted file mode 100644 index 71b98c6a3..000000000 --- a/modules/account/front/alias/descriptor/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - Delete - - - -
- - -
-
-
- - \ No newline at end of file diff --git a/modules/account/front/alias/descriptor/index.js b/modules/account/front/alias/descriptor/index.js deleted file mode 100644 index a21baae5a..000000000 --- a/modules/account/front/alias/descriptor/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get alias() { - return this.entity; - } - - set alias(value) { - this.entity = value; - } - - onDelete() { - return this.$http.delete(`MailAliases/${this.id}`) - .then(() => this.$state.go('account.alias')) - .then(() => this.vnApp.showSuccess(this.$t('Alias removed'))); - } -} - -ngModule.component('vnAliasDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - alias: '<' - } -}); diff --git a/modules/account/front/alias/descriptor/locale/es.yml b/modules/account/front/alias/descriptor/locale/es.yml deleted file mode 100644 index 9c6fa0e73..000000000 --- a/modules/account/front/alias/descriptor/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Alias will be removed: El alias será eliminado -Alias removed: Alias eliminado \ No newline at end of file diff --git a/modules/account/front/alias/index.js b/modules/account/front/alias/index.js deleted file mode 100644 index 8eed3a3d3..000000000 --- a/modules/account/front/alias/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import './main'; -import './index/'; -import './create'; -import './summary'; -import './card'; -import './descriptor'; -import './create'; -import './basic-data'; -import './users'; diff --git a/modules/account/front/alias/index/index.html b/modules/account/front/alias/index/index.html deleted file mode 100644 index 7343cb9bd..000000000 --- a/modules/account/front/alias/index/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - -
{{::alias.alias}}
-
{{::alias.description}}
-
- - - - -
-
-
-
- - - - - - \ No newline at end of file diff --git a/modules/account/front/alias/index/index.js b/modules/account/front/alias/index/index.js deleted file mode 100644 index 44e146fb4..000000000 --- a/modules/account/front/alias/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(alias) { - this.selectedAlias = alias; - this.$.summary.show(); - } -} - -ngModule.component('vnAliasIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/index/locale/es.yml b/modules/account/front/alias/index/locale/es.yml deleted file mode 100644 index 4df41c0be..000000000 --- a/modules/account/front/alias/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New alias: Nuevo alias -View alias: Ver alias \ No newline at end of file diff --git a/modules/account/front/alias/locale/es.yml b/modules/account/front/alias/locale/es.yml deleted file mode 100644 index ecc856fcf..000000000 --- a/modules/account/front/alias/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Public: Público \ No newline at end of file diff --git a/modules/account/front/alias/main/index.html b/modules/account/front/alias/main/index.html deleted file mode 100644 index 43f6e2f51..000000000 --- a/modules/account/front/alias/main/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/modules/account/front/alias/main/index.js b/modules/account/front/alias/main/index.js deleted file mode 100644 index 21eed3d85..000000000 --- a/modules/account/front/alias/main/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class Alias extends ModuleMain { - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {alias: {like: `%${value}%`}}; - } - } -} - -ngModule.vnComponent('vnAlias', { - controller: Alias, - template: require('./index.html') -}); diff --git a/modules/account/front/alias/summary/index.html b/modules/account/front/alias/summary/index.html deleted file mode 100644 index 52ee2813d..000000000 --- a/modules/account/front/alias/summary/index.html +++ /dev/null @@ -1,16 +0,0 @@ - -
{{summary.alias}}
- - -

Basic data

- - - - -
-
-
\ No newline at end of file diff --git a/modules/account/front/alias/summary/index.js b/modules/account/front/alias/summary/index.js deleted file mode 100644 index 21bc8d9ba..000000000 --- a/modules/account/front/alias/summary/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; - -class Controller extends Component { - set alias(value) { - this._alias = value; - this.$.summary = null; - if (!value) return; - - this.$http.get(`MailAliases/${value.id}`) - .then(res => this.$.summary = res.data); - } - - get alias() { - return this._alias; - } -} - -ngModule.component('vnAliasSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - alias: '<' - } -}); diff --git a/modules/account/front/alias/users/index.html b/modules/account/front/alias/users/index.html deleted file mode 100644 index 048a702ea..000000000 --- a/modules/account/front/alias/users/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - {{::row.user.name}} - - - - - - - - - - - diff --git a/modules/account/front/alias/users/index.js b/modules/account/front/alias/users/index.js deleted file mode 100644 index b2446d71b..000000000 --- a/modules/account/front/alias/users/index.js +++ /dev/null @@ -1,31 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - let filter = { - include: { - relation: 'user', - scope: { - fields: ['id', 'name'] - } - } - }; - this.$http.get(`MailAliases/${this.$params.id}/accounts`, {filter}) - .then(res => this.$.data = res.data); - } - - onRemove(row) { - return this.$http.delete(`MailAliases/${this.$params.id}/accounts/${row.id}`) - .then(() => { - let index = this.$.data.indexOf(row); - if (index !== -1) this.$.data.splice(index, 1); - this.vnApp.showSuccess(this.$t('User removed')); - }); - } -} - -ngModule.component('vnAliasUsers', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/users/index.spec.js b/modules/account/front/alias/users/index.spec.js deleted file mode 100644 index d618f1de1..000000000 --- a/modules/account/front/alias/users/index.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import './index'; - -describe('component vnAliasUsers', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnAliasUsers', {$element: null}); - controller.$params.id = 1; - })); - - describe('$onInit()', () => { - it('should delete entity and go to index', () => { - $httpBackend.expectGET('MailAliases/1/accounts').respond('foo'); - controller.$onInit(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); - - describe('onRemove()', () => { - it('should call backend method to change role', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.$.data = [ - {id: 1, alias: 'foo'}, - {id: 2, alias: 'bar'} - ]; - - $httpBackend.expectDELETE('MailAliases/1/accounts/1').respond(); - controller.onRemove(controller.$.data[0]); - $httpBackend.flush(); - - expect(controller.$.data).toEqual([{id: 2, alias: 'bar'}]); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/alias/users/locale/es.yml b/modules/account/front/alias/users/locale/es.yml deleted file mode 100644 index dc24eb318..000000000 --- a/modules/account/front/alias/users/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -User will be removed from alias: El usuario será borrado del alias -User removed: Usuario borrado \ No newline at end of file diff --git a/modules/account/front/aliases/index.html b/modules/account/front/aliases/index.html deleted file mode 100644 index 4a73ec873..000000000 --- a/modules/account/front/aliases/index.html +++ /dev/null @@ -1,64 +0,0 @@ -
- - - - - -
- {{::row.alias.alias}} -
-
- {{::row.alias.description}} -
-
- - - - -
-
- -
-
- - - - - - - - - - - - - - -
-
- Account not enabled -
diff --git a/modules/account/front/aliases/index.js b/modules/account/front/aliases/index.js deleted file mode 100644 index 0fc806a71..000000000 --- a/modules/account/front/aliases/index.js +++ /dev/null @@ -1,51 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - this.refresh(); - } - - refresh() { - let filter = { - where: {account: this.$params.id}, - include: { - relation: 'alias', - scope: { - fields: ['id', 'alias', 'description'] - } - } - }; - return this.$http.get(`MailAliasAccounts`, {filter}) - .then(res => this.$.data = res.data); - } - - onAddClick() { - this.addData = {account: this.$params.id}; - this.$.dialog.show(); - } - - onAddSave() { - return this.$http.post(`MailAliasAccounts`, this.addData) - .then(() => this.refresh()) - .then(() => this.vnApp.showSuccess( - this.$t('Subscribed to alias!')) - ); - } - - onRemove(row) { - return this.$http.delete(`MailAliasAccounts/${row.id}`) - .then(() => { - this.$.data.splice(this.$.data.indexOf(row), 1); - this.vnApp.showSuccess(this.$t('Unsubscribed from alias!')); - }); - } -} - -ngModule.component('vnUserAliases', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnUserCard' - } -}); diff --git a/modules/account/front/aliases/index.spec.js b/modules/account/front/aliases/index.spec.js deleted file mode 100644 index 466f1e1e9..000000000 --- a/modules/account/front/aliases/index.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -import './index'; - -describe('component vnUserAliases', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnUserAliases', {$element: null}); - jest.spyOn(controller.vnApp, 'showSuccess'); - })); - - describe('refresh()', () => { - it('should refresh the controller data', () => { - $httpBackend.expectGET('MailAliasAccounts').respond('foo'); - controller.refresh(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); - - describe('onAddSave()', () => { - it('should add the new row', () => { - controller.addData = {account: 1}; - - $httpBackend.expectPOST('MailAliasAccounts').respond(); - $httpBackend.expectGET('MailAliasAccounts').respond('foo'); - controller.onAddSave(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onRemove()', () => { - it('shoud remove the passed row remote and locally', () => { - controller.$.data = [ - {id: 1, alias: 'foo'}, - {id: 2, alias: 'bar'} - ]; - - $httpBackend.expectDELETE('MailAliasAccounts/1').respond(); - controller.onRemove(controller.$.data[0]); - $httpBackend.flush(); - - expect(controller.$.data).toEqual([{id: 2, alias: 'bar'}]); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/aliases/locale/es.yml b/modules/account/front/aliases/locale/es.yml deleted file mode 100644 index 4d1ad76a7..000000000 --- a/modules/account/front/aliases/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Unsubscribe: Desuscribir -Subscribed to alias!: ¡Suscrito al alias! -Unsubscribed from alias!: ¡Desuscrito del alias! \ No newline at end of file diff --git a/modules/account/front/basic-data/index.html b/modules/account/front/basic-data/index.html deleted file mode 100644 index 9fd3506fe..000000000 --- a/modules/account/front/basic-data/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/basic-data/index.js b/modules/account/front/basic-data/index.js deleted file mode 100644 index f6b266bbc..000000000 --- a/modules/account/front/basic-data/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - if (this.$params.emailConfirmed) - this.vnApp.showSuccess(this.$t('Email verified successfully!')); - } - - onSubmit() { - this.$.watcher.submit() - .then(() => this.card.reload()); - } -} - -ngModule.component('vnUserBasicData', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnUserCard' - }, - bindings: { - user: '<' - } -}); diff --git a/modules/account/front/basic-data/locale/es.yml b/modules/account/front/basic-data/locale/es.yml deleted file mode 100644 index 2ca7bf698..000000000 --- a/modules/account/front/basic-data/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Email verified successfully!: Correo verificado correctamente! diff --git a/modules/account/front/card/index.html b/modules/account/front/card/index.html deleted file mode 100644 index cba6b93c6..000000000 --- a/modules/account/front/card/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/modules/account/front/card/index.js b/modules/account/front/card/index.js deleted file mode 100644 index 2c8cc7637..000000000 --- a/modules/account/front/card/index.js +++ /dev/null @@ -1,32 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; -import './style.scss'; - -class Controller extends ModuleCard { - reload() { - const filter = { - where: {id: this.$params.id}, - include: { - relation: 'role', - scope: { - fields: ['id', 'name'] - } - } - }; - - return Promise.all([ - this.$http.get(`VnUsers/preview`, {filter}) - .then(res => { - const [user] = res.data; - this.user = user; - }), - this.$http.get(`Accounts/${this.$params.id}/exists`) - .then(res => this.hasAccount = res.data.exists) - ]); - } -} - -ngModule.vnComponent('vnUserCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/card/index.spec.js b/modules/account/front/card/index.spec.js deleted file mode 100644 index 712d3c1d8..000000000 --- a/modules/account/front/card/index.spec.js +++ /dev/null @@ -1,27 +0,0 @@ -import './index'; - -describe('component vnUserCard', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnUserCard', {$element: null}); - })); - - describe('reload()', () => { - it('should reload the controller data', () => { - controller.$params.id = 1; - - $httpBackend.expectGET('VnUsers/preview').respond('foo'); - $httpBackend.expectGET('Accounts/1/exists').respond({exists: true}); - controller.reload(); - $httpBackend.flush(); - - expect(controller.user).toBe('f'); - expect(controller.hasAccount).toBeTruthy(); - }); - }); -}); diff --git a/modules/account/front/card/style.scss b/modules/account/front/card/style.scss deleted file mode 100644 index 4d9d108a0..000000000 --- a/modules/account/front/card/style.scss +++ /dev/null @@ -1,10 +0,0 @@ -@import "variables"; - -.bg-title { - display: block; - text-align: center; - padding: 24px; - box-sizing: border-box; - color: $color-font-secondary; - font-size: 1.375rem; -} diff --git a/modules/account/front/connections/index.html b/modules/account/front/connections/index.html deleted file mode 100644 index d634b7a9f..000000000 --- a/modules/account/front/connections/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - -
{{::row.user.username}}
-
{{::row.created | date:'dd/MM HH:mm'}}
-
- - - - -
-
-
-
- - - - \ No newline at end of file diff --git a/modules/account/front/connections/index.js b/modules/account/front/connections/index.js deleted file mode 100644 index c4ddd5615..000000000 --- a/modules/account/front/connections/index.js +++ /dev/null @@ -1,29 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor(...args) { - super(...args); - this.filter = { - fields: ['id', 'created', 'userId'], - include: { - relation: 'user', - scope: { - fields: ['username'] - } - }, - order: 'created DESC' - }; - } - - onDisconnect(row) { - return this.$http.delete(`AccessTokens/${row.id}`) - .then(() => this.$.model.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('Session killed'))); - } -} - -ngModule.component('vnConnections', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/connections/locale/es.yml b/modules/account/front/connections/locale/es.yml deleted file mode 100644 index 41ef18b45..000000000 --- a/modules/account/front/connections/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Go to user: Ir al usuario -Refresh: Actualizar -Session will be killed: Se va a matar la sesión -Kill session: Matar sesión -Session killed: Sesión matada \ No newline at end of file diff --git a/modules/account/front/create/index.html b/modules/account/front/create/index.html deleted file mode 100644 index 70a518885..000000000 --- a/modules/account/front/create/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/create/index.js b/modules/account/front/create/index.js deleted file mode 100644 index 01ba7905b..000000000 --- a/modules/account/front/create/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.user = {active: true}; - } - - onSubmit() { - return this.$.watcher.submit().then(res => { - this.$state.go('account.card.basicData', {id: res.data.id}); - }); - } -} - -ngModule.component('vnUserCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/descriptor-popover/index.html b/modules/account/front/descriptor-popover/index.html deleted file mode 100644 index f3131a84b..000000000 --- a/modules/account/front/descriptor-popover/index.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/modules/account/front/descriptor-popover/index.js b/modules/account/front/descriptor-popover/index.js deleted file mode 100644 index d7b052473..000000000 --- a/modules/account/front/descriptor-popover/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import ngModule from '../module'; -import DescriptorPopover from 'salix/components/descriptor-popover'; - -class Controller extends DescriptorPopover {} - -ngModule.vnComponent('vnAccountDescriptorPopover', { - slotTemplate: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/descriptor/__snapshots__/index.spec.js.snap b/modules/account/front/descriptor/__snapshots__/index.spec.js.snap deleted file mode 100644 index de5f8e8c2..000000000 --- a/modules/account/front/descriptor/__snapshots__/index.spec.js.snap +++ /dev/null @@ -1,5 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`component vnUserDescriptor onPassChange() should throw an error when password is empty 1`] = `"You must enter a new password"`; - -exports[`component vnUserDescriptor onPassChange() should throw an error when repeat password not matches new password 1`] = `"Passwords don't match"`; diff --git a/modules/account/front/descriptor/index.html b/modules/account/front/descriptor/index.html deleted file mode 100644 index 86e78dfce..000000000 --- a/modules/account/front/descriptor/index.html +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - - Delete - - - Change password - - - Set password - - - Enable account - - - Disable account - - - Activate user - - - Deactivate user - - - Synchronize - - - -
- - - - -
-
- - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - Do you want to synchronize user? - - - - - - - - - - - - - - - diff --git a/modules/account/front/descriptor/index.js b/modules/account/front/descriptor/index.js deleted file mode 100644 index de41d619d..000000000 --- a/modules/account/front/descriptor/index.js +++ /dev/null @@ -1,145 +0,0 @@ -import ngModule from '../module'; -import Descriptor from 'salix/components/descriptor'; -import UserError from 'core/lib/user-error'; - -class Controller extends Descriptor { - get user() { - return this.entity; - } - - set user(value) { - this.entity = value; - } - - get entity() { - return super.entity; - } - - set entity(value) { - super.entity = value; - this.hasAccount = null; - if (!value) return; - - this.$http.get(`Accounts/${value.id}/exists`) - .then(res => this.hasAccount = res.data.exists); - } - - loadData() { - const filter = { - where: {id: this.$params.id}, - include: { - relation: 'role', - scope: { - fields: ['id', 'name'] - } - } - }; - - return Promise.all([ - this.$http.get(`VnUsers/preview`, {filter}) - .then(res => { - const [user] = res.data; - this.user = user; - }), - this.$http.get(`Accounts/${this.$params.id}/exists`) - .then(res => this.hasAccount = res.data.exists) - ]); - } - - onDelete() { - return this.$http.delete(`VnUsers/${this.id}`) - .then(() => this.$state.go('account.index')) - .then(() => this.vnApp.showSuccess(this.$t('User removed'))); - } - - onChangePassClick(askOldPass) { - this.$http.get('UserPasswords/findOne') - .then(res => { - this.passRequirements = res.data; - this.askOldPass = askOldPass; - this.$.changePass.show(); - }); - } - - onPassChange() { - if (!this.newPassword) - throw new UserError(`You must enter a new password`); - if (this.newPassword != this.repeatPassword) - throw new UserError(`Passwords don't match`); - - let method; - const params = {newPassword: this.newPassword}; - - if (this.askOldPass) { - method = 'change-password'; - params.oldPassword = this.oldPassword; - } else - method = 'setPassword'; - - return this.$http.patch(`Accounts/${this.id}/${method}`, params) - .then(() => { - this.emit('change'); - this.vnApp.showSuccess(this.$t('Password changed succesfully!')); - }); - } - - onPassClose() { - this.oldPassword = ''; - this.newPassword = ''; - this.repeatPassword = ''; - this.$.$apply(); - } - - onEnableAccount() { - return this.$http.post(`Accounts`, {id: this.id}) - .then(() => this.onSwitchAccount(true)); - } - - onDisableAccount() { - return this.$http.delete(`Accounts/${this.id}`) - .then(() => this.onSwitchAccount(false)); - } - - onSwitchAccount(enable) { - this.hasAccount = enable; - const message = enable - ? 'Account enabled!' - : 'Account disabled!'; - this.emit('change'); - this.vnApp.showSuccess(this.$t(message)); - } - - onSetActive(active) { - return this.$http.patch(`VnUsers/${this.id}`, {active}) - .then(() => { - this.user.active = active; - const message = active - ? 'User activated!' - : 'User deactivated!'; - this.emit('change'); - this.vnApp.showSuccess(this.$t(message)); - }); - } - - onSync() { - const params = {force: true}; - if (this.shouldSyncPassword) - params.password = this.syncPassword; - - return this.$http.patch(`Accounts/${this.user.name}/sync`, params) - .then(() => this.vnApp.showSuccess(this.$t('User synchronized!'))); - } - - onSyncClose() { - this.shouldSyncPassword = false; - this.syncPassword = undefined; - } -} - -ngModule.component('vnUserDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - user: '<' - } -}); diff --git a/modules/account/front/descriptor/index.spec.js b/modules/account/front/descriptor/index.spec.js deleted file mode 100644 index 46c7e376c..000000000 --- a/modules/account/front/descriptor/index.spec.js +++ /dev/null @@ -1,97 +0,0 @@ -import './index'; - -describe('component vnUserDescriptor', () => { - let controller; - let $httpBackend; - - let user = {id: 1, name: 'foo'}; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $httpBackend.whenGET('Accounts/1/exists').respond({exists: true}); - - controller = $componentController('vnUserDescriptor', {$element: null}, {user}); - jest.spyOn(controller, 'emit'); - jest.spyOn(controller.vnApp, 'showSuccess'); - })); - - describe('onDelete()', () => { - it('should delete entity and go to index', () => { - controller.$state.go = jest.fn(); - - $httpBackend.expectDELETE('VnUsers/1').respond(); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('account.index'); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onPassChange()', () => { - it('should throw an error when password is empty', () => { - expect(() => { - controller.onPassChange(); - }).toThrowErrorMatchingSnapshot(); - }); - - it('should throw an error when repeat password not matches new password', () => { - controller.newPassword = 'foo'; - controller.repeatPassword = 'bar'; - - expect(() => { - controller.onPassChange(); - }).toThrowErrorMatchingSnapshot(); - }); - - it('should make a request when password checks passes', () => { - controller.newPassword = 'foo'; - controller.repeatPassword = 'foo'; - - $httpBackend.expectPATCH('Accounts/1/setPassword').respond(); - controller.onPassChange(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); - - describe('onEnableAccount()', () => { - it('should make request to enable account', () => { - $httpBackend.expectPOST('Accounts', {id: 1}).respond(); - controller.onEnableAccount(); - $httpBackend.flush(); - - expect(controller.hasAccount).toBeTruthy(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); - - describe('onDisableAccount()', () => { - it('should make request to disable account', () => { - $httpBackend.expectDELETE('Accounts/1').respond(); - controller.onDisableAccount(); - $httpBackend.flush(); - - expect(controller.hasAccount).toBeFalsy(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); - - describe('onSetActive()', () => { - it('should make request to activate/deactivate the user', () => { - $httpBackend.expectPATCH('VnUsers/1', {active: true}).respond(); - controller.onSetActive(true); - $httpBackend.flush(); - - expect(controller.user.active).toBeTruthy(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); -}); diff --git a/modules/account/front/descriptor/locale/es.yml b/modules/account/front/descriptor/locale/es.yml deleted file mode 100644 index 98ced7694..000000000 --- a/modules/account/front/descriptor/locale/es.yml +++ /dev/null @@ -1,35 +0,0 @@ -User will be removed: El usuario será eliminado -User removed: Usuario eliminado -Are you sure you want to continue?: ¿Seguro que quieres continuar? -Account will be enabled: La cuenta será habilitada -Account will be disabled: La cuenta será deshabilitada -Account enabled!: ¡Cuenta habilitada! -Account disabled!: ¡Cuenta deshabilitada! -User will activated: El usuario será activado -User will be deactivated: El usuario será desactivado -User activated!: ¡Usuario activado! -User deactivated!: ¡Usuario desactivado! -Account enabled: Cuenta habilitada -User deactivated: Usuario desactivado -Change role: Modificar rol -Change password: Cambiar contraseña -Set password: Establecer contraseña -Enable account: Habilitar cuenta -Disable account: Deshabilitar cuenta -Activate user: Activar usuario -Deactivate user: Desactivar usuario -Old password: Contraseña antigua -New password: Nueva contraseña -Repeat password: Repetir contraseña -Password changed succesfully!: ¡Contraseña modificada correctamente! -Synchronize: Sincronizar -Do you want to synchronize user?: ¿Quieres sincronizar el usuario? -Synchronize password: Sincronizar contraseña -User synchronized!: ¡Usuario sincronizado! -Role changed succesfully!: ¡Rol modificado correctamente! -Password requirements: > - La contraseña debe tener al menos {{ length }} caracteres de longitud, - {{nAlpha}} caracteres alfabéticos, {{nUpper}} letras mayúsculas, {{nDigits}} - dígitos y {{nPunct}} símbolos (Ej: $%&.) -You must enter a new password: Debes introducir la nueva contraseña -Passwords don't match: Las contraseñas no coinciden diff --git a/modules/account/front/index.js b/modules/account/front/index.js index 4d6aedcae..a7209a0bd 100644 --- a/modules/account/front/index.js +++ b/modules/account/front/index.js @@ -1,24 +1,3 @@ export * from './module'; import './main'; -import './index/'; -import './role'; -import './alias'; -import './connections'; -import './acl'; -import './summary'; -import './card'; -import './descriptor'; -import './descriptor-popover'; -import './search-panel'; -import './create'; -import './basic-data'; -import './mail-forwarding'; -import './aliases'; -import './roles'; -import './ldap'; -import './samba'; -import './accounts'; -import './privileges'; -import './user-log'; -import './role-log'; diff --git a/modules/account/front/index/index.html b/modules/account/front/index/index.html deleted file mode 100644 index 7502c8b3d..000000000 --- a/modules/account/front/index/index.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - diff --git a/modules/account/front/index/index.js b/modules/account/front/index/index.js deleted file mode 100644 index 9324ca740..000000000 --- a/modules/account/front/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(user) { - this.selectedUser = user; - this.$.summary.show(); - } -} - -ngModule.component('vnUserIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/index/locale/es.yml b/modules/account/front/index/locale/es.yml deleted file mode 100644 index 074fb054e..000000000 --- a/modules/account/front/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New user: Nuevo usuario -View user: Ver usuario \ No newline at end of file diff --git a/modules/account/front/ldap/index.html b/modules/account/front/ldap/index.html deleted file mode 100644 index 23356452a..000000000 --- a/modules/account/front/ldap/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/ldap/index.js b/modules/account/front/ldap/index.js deleted file mode 100644 index 40e1e8db1..000000000 --- a/modules/account/front/ldap/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onTestConection() { - this.$http.get(`LdapConfigs/test`) - .then(() => this.vnApp.showSuccess(this.$t('LDAP connection established!'))); - } -} - -ngModule.component('vnAccountLdap', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/ldap/locale/es.yml b/modules/account/front/ldap/locale/es.yml deleted file mode 100644 index 0353d6b72..000000000 --- a/modules/account/front/ldap/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Enable synchronization: Habilitar sincronización -Server: Servidor -RDN: RDN -User DN: DN usuarios -Filter: Filtro -Group DN: DN grupos -Test connection: Probar conexión -LDAP connection established!: ¡Conexión con LDAP establecida! diff --git a/modules/account/front/mail-forwarding/index.html b/modules/account/front/mail-forwarding/index.html deleted file mode 100644 index df5cd80bf..000000000 --- a/modules/account/front/mail-forwarding/index.html +++ /dev/null @@ -1,49 +0,0 @@ -
- - -
- - - - - - - - - - - - - - -
-
-
- Account not enabled -
diff --git a/modules/account/front/mail-forwarding/index.js b/modules/account/front/mail-forwarding/index.js deleted file mode 100644 index 5118e8eab..000000000 --- a/modules/account/front/mail-forwarding/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section {} - -ngModule.component('vnUserMailForwarding', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnUserCard' - }, -}); diff --git a/modules/account/front/mail-forwarding/locale/es.yml b/modules/account/front/mail-forwarding/locale/es.yml deleted file mode 100644 index 688ace6b5..000000000 --- a/modules/account/front/mail-forwarding/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Mail forwarding: Reenvío de correo -Forward email: Dirección de reenvío -Enable mail forwarding: Habilitar redirección de correo -All emails will be forwarded to the specified address.: > - Todos los correos serán reenviados a la dirección especificada, no se - mantendrá copia de los mismos en el buzón del usuario. -You don't have enough privileges: No tienes suficientes permisos diff --git a/modules/account/front/main/index.html b/modules/account/front/main/index.html index 36b493ec4..e69de29bb 100644 --- a/modules/account/front/main/index.html +++ b/modules/account/front/main/index.html @@ -1,19 +0,0 @@ - - - - - - - - - - diff --git a/modules/account/front/main/index.js b/modules/account/front/main/index.js index a43ffb76b..335d71b42 100644 --- a/modules/account/front/main/index.js +++ b/modules/account/front/main/index.js @@ -4,32 +4,10 @@ import ModuleMain from 'salix/components/module-main'; export default class User extends ModuleMain { constructor($element, $) { super($element, $); - this.filter = { - fields: ['id', 'nickname', 'name', 'role'], - include: { - relation: 'role', - scope: { - fields: ['id', 'name'] - } - } - }; } - - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {or: [ - {name: {like: `%${value}%`}}, - {nickname: {like: `%${value}%`}} - ]}; - case 'name': - case 'nickname': - return {[param]: {like: `%${value}%`}}; - case 'roleFk': - return {[param]: value}; - } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`account/`); } } diff --git a/modules/account/front/main/index.spec.js b/modules/account/front/main/index.spec.js deleted file mode 100644 index c232aa849..000000000 --- a/modules/account/front/main/index.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -import './index'; - -describe('component vnUser', () => { - let controller; - - beforeEach(ngModule('account')); - - beforeEach(inject($componentController => { - controller = $componentController('vnUser', {$element: null}); - })); - - describe('exprBuilder()', () => { - it('should search by id when only digits string is passed', () => { - let expr = controller.exprBuilder('search', '1'); - - expect(expr).toEqual({id: '1'}); - }); - - it('should search by name when non-only digits string is passed', () => { - let expr = controller.exprBuilder('search', '1foo'); - - expect(expr).toEqual({or: [ - {name: {like: '%1foo%'}}, - {nickname: {like: '%1foo%'}} - ]}); - }); - }); -}); diff --git a/modules/account/front/privileges/index.html b/modules/account/front/privileges/index.html deleted file mode 100644 index 343c179e3..000000000 --- a/modules/account/front/privileges/index.html +++ /dev/null @@ -1,41 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/privileges/index.js b/modules/account/front/privileges/index.js deleted file mode 100644 index f69428666..000000000 --- a/modules/account/front/privileges/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - get user() { - return this._user; - } - - set user(value) { - this._user = value; - if (!value) return; - } -} - -ngModule.component('vnUserPrivileges', { - template: require('./index.html'), - controller: Controller, - bindings: { - user: '<' - } -}); diff --git a/modules/account/front/privileges/locale/es.yml b/modules/account/front/privileges/locale/es.yml deleted file mode 100644 index d66a7a6cf..000000000 --- a/modules/account/front/privileges/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Privileges: Privilegios -Has grant: Puede delegar privilegios diff --git a/modules/account/front/role-log/index.html b/modules/account/front/role-log/index.html deleted file mode 100644 index 9e2b151b5..000000000 --- a/modules/account/front/role-log/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modules/account/front/role-log/index.js b/modules/account/front/role-log/index.js deleted file mode 100644 index 02448ccaa..000000000 --- a/modules/account/front/role-log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnRoleLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/account/front/role/basic-data/index.html b/modules/account/front/role/basic-data/index.html deleted file mode 100644 index 846f8b455..000000000 --- a/modules/account/front/role/basic-data/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - -
- - - - - - - - - - - - - - -
diff --git a/modules/account/front/role/basic-data/index.js b/modules/account/front/role/basic-data/index.js deleted file mode 100644 index 4e26906ee..000000000 --- a/modules/account/front/role/basic-data/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section {} - -ngModule.component('vnRoleBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - role: '<' - } -}); diff --git a/modules/account/front/role/card/index.html b/modules/account/front/role/card/index.html deleted file mode 100644 index 2f51f88b5..000000000 --- a/modules/account/front/role/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/account/front/role/card/index.js b/modules/account/front/role/card/index.js deleted file mode 100644 index 3c7c758ef..000000000 --- a/modules/account/front/role/card/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - this.$http.get(`VnRoles/${this.$params.id}`) - .then(res => this.role = res.data); - } -} - -ngModule.vnComponent('vnRoleCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/card/index.spec.js b/modules/account/front/role/card/index.spec.js deleted file mode 100644 index 569fe487d..000000000 --- a/modules/account/front/role/card/index.spec.js +++ /dev/null @@ -1,25 +0,0 @@ -import './index'; - -describe('component vnRoleCard', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleCard', {$element: null}); - })); - - describe('reload()', () => { - it('should reload the controller data', () => { - controller.$params.id = 1; - - $httpBackend.expectGET('VnRoles/1').respond('foo'); - controller.reload(); - $httpBackend.flush(); - - expect(controller.role).toBe('foo'); - }); - }); -}); diff --git a/modules/account/front/role/create/index.html b/modules/account/front/role/create/index.html deleted file mode 100644 index 77d6fc2c1..000000000 --- a/modules/account/front/role/create/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - -
- - - - - - - - - - - - - - -
diff --git a/modules/account/front/role/create/index.js b/modules/account/front/role/create/index.js deleted file mode 100644 index 3f7fcc9cf..000000000 --- a/modules/account/front/role/create/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - return this.$.watcher.submit().then(res => - this.$state.go('account.role.card.basicData', {id: res.data.id}) - ); - } -} - -ngModule.component('vnRoleCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/descriptor/index.html b/modules/account/front/role/descriptor/index.html deleted file mode 100644 index d8bf4857a..000000000 --- a/modules/account/front/role/descriptor/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - Delete - - - -
- - -
-
-
- - diff --git a/modules/account/front/role/descriptor/index.js b/modules/account/front/role/descriptor/index.js deleted file mode 100644 index 17b585cb7..000000000 --- a/modules/account/front/role/descriptor/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get role() { - return this.entity; - } - - set role(value) { - this.entity = value; - } - - onDelete() { - return this.$http.delete(`VnRoles/${this.id}`) - .then(() => this.$state.go('account.role')) - .then(() => this.vnApp.showSuccess(this.$t('Role removed'))); - } -} - -ngModule.component('vnRoleDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - role: '<' - } -}); diff --git a/modules/account/front/role/descriptor/index.spec.js b/modules/account/front/role/descriptor/index.spec.js deleted file mode 100644 index f3b2e4763..000000000 --- a/modules/account/front/role/descriptor/index.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -import './index'; - -describe('component vnRoleDescriptor', () => { - let controller; - let $httpBackend; - - let role = {id: 1, name: 'foo'}; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleDescriptor', {$element: null}, {role}); - })); - - describe('onDelete()', () => { - it('should delete entity and go to index', () => { - controller.$state.go = jest.fn(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expectDELETE('VnRoles/1').respond(); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('account.role'); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/role/descriptor/locale/es.yml b/modules/account/front/role/descriptor/locale/es.yml deleted file mode 100644 index 1ca512e4f..000000000 --- a/modules/account/front/role/descriptor/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Role will be removed: El rol va a ser eliminado -Role removed: Rol eliminado \ No newline at end of file diff --git a/modules/account/front/role/index.js b/modules/account/front/role/index.js deleted file mode 100644 index 97a20d3bc..000000000 --- a/modules/account/front/role/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import './main'; -import './index/'; -import './summary'; -import './card'; -import './descriptor'; -import './search-panel'; -import './create'; -import './basic-data'; -import './subroles'; -import './inherited'; diff --git a/modules/account/front/role/index/index.html b/modules/account/front/role/index/index.html deleted file mode 100644 index 4c4c6b0ad..000000000 --- a/modules/account/front/role/index/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/account/front/role/index/index.js b/modules/account/front/role/index/index.js deleted file mode 100644 index 40773b23b..000000000 --- a/modules/account/front/role/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(role) { - this.selectedRole = role; - this.$.summary.show(); - } -} - -ngModule.component('vnRoleIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/index/locale/es.yml b/modules/account/front/role/index/locale/es.yml deleted file mode 100644 index 70932e983..000000000 --- a/modules/account/front/role/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New role: Nuevo rol -View role: Ver rol \ No newline at end of file diff --git a/modules/account/front/role/inherited/index.html b/modules/account/front/role/inherited/index.html deleted file mode 100644 index 83ecbbff4..000000000 --- a/modules/account/front/role/inherited/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - -
- {{::row.inherits.name}} -
-
- {{::row.inherits.description}} -
-
-
-
-
-
diff --git a/modules/account/front/role/inherited/index.js b/modules/account/front/role/inherited/index.js deleted file mode 100644 index 5927493ee..000000000 --- a/modules/account/front/role/inherited/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - let filter = { - where: {role: this.$params.id}, - include: { - relation: 'inherits', - scope: { - fields: ['id', 'name', 'description'] - } - } - }; - this.$http.get('RoleRoles', {filter}) - .then(res => this.$.data = res.data); - } -} - -ngModule.component('vnRoleInherited', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/inherited/index.spec.js b/modules/account/front/role/inherited/index.spec.js deleted file mode 100644 index 16b0c53b2..000000000 --- a/modules/account/front/role/inherited/index.spec.js +++ /dev/null @@ -1,23 +0,0 @@ -import './index'; - -describe('component vnRoleInherited', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleInherited', {$element: null}); - })); - - describe('$onInit()', () => { - it('should delete entity and go to index', () => { - $httpBackend.expectGET('RoleRoles').respond('foo'); - controller.$onInit(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); -}); diff --git a/modules/account/front/role/locale/es.yml b/modules/account/front/role/locale/es.yml deleted file mode 100644 index 159fc7f16..000000000 --- a/modules/account/front/role/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Subroles: Subroles diff --git a/modules/account/front/role/main/index.html b/modules/account/front/role/main/index.html deleted file mode 100644 index cfef28e57..000000000 --- a/modules/account/front/role/main/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - diff --git a/modules/account/front/role/main/index.js b/modules/account/front/role/main/index.js deleted file mode 100644 index 77d15cf17..000000000 --- a/modules/account/front/role/main/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class Role extends ModuleMain { - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {or: [ - {name: {like: `%${value}%`}}, - {nickname: {like: `%${value}%`}} - ]}; - case 'name': - case 'description': - return {[param]: {like: `%${value}%`}}; - } - } -} - -ngModule.vnComponent('vnRole', { - controller: Role, - template: require('./index.html') -}); diff --git a/modules/account/front/role/search-panel/index.html b/modules/account/front/role/search-panel/index.html deleted file mode 100644 index dfea9f01c..000000000 --- a/modules/account/front/role/search-panel/index.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
- - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/account/front/role/search-panel/index.js b/modules/account/front/role/search-panel/index.js deleted file mode 100644 index 35da591ad..000000000 --- a/modules/account/front/role/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.component('vnRoleSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/account/front/role/subroles/index.html b/modules/account/front/role/subroles/index.html deleted file mode 100644 index eba1002b0..000000000 --- a/modules/account/front/role/subroles/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - -
- {{::row.inherits.name}} -
-
- {{::row.inherits.description}} -
-
- - - - -
-
-
-
- - - - - - - - - - - - - - diff --git a/modules/account/front/role/subroles/index.js b/modules/account/front/role/subroles/index.js deleted file mode 100644 index b7e1caaa4..000000000 --- a/modules/account/front/role/subroles/index.js +++ /dev/null @@ -1,51 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - this.refresh(); - } - - get path() { - return `RoleInherits`; - } - - refresh() { - let filter = { - where: {role: this.$params.id}, - include: { - relation: 'inherits', - scope: { - fields: ['id', 'name', 'description'] - } - } - }; - this.$http.get(this.path, {filter}) - .then(res => this.$.data = res.data); - } - - onAddClick() { - this.addData = {role: this.$params.id}; - this.$.dialog.show(); - } - - onAddSave() { - return this.$http.post(this.path, this.addData) - .then(() => this.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('Role added! Changes will take a while to fully propagate.'))); - } - - onRemove(row) { - return this.$http.delete(`${this.path}/${row.id}`) - .then(() => { - let index = this.$.data.indexOf(row); - if (index !== -1) this.$.data.splice(index, 1); - this.vnApp.showSuccess(this.$t('Role removed. Changes will take a while to fully propagate.')); - }); - } -} - -ngModule.component('vnRoleSubroles', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/subroles/index.spec.js b/modules/account/front/role/subroles/index.spec.js deleted file mode 100644 index e7d9a4d0e..000000000 --- a/modules/account/front/role/subroles/index.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -import './index'; - -describe('component vnRoleSubroles', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleSubroles', {$element: null}); - jest.spyOn(controller.vnApp, 'showSuccess'); - })); - - describe('refresh()', () => { - it('should delete entity and go to index', () => { - $httpBackend.expectGET('RoleInherits').respond('foo'); - controller.refresh(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); - - describe('onAddSave()', () => { - it('should add a subrole', () => { - controller.addData = {role: 'foo'}; - - $httpBackend.expectPOST('RoleInherits', {role: 'foo'}).respond(); - $httpBackend.expectGET('RoleInherits').respond(); - controller.onAddSave(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onRemove()', () => { - it('should remove a subrole', () => { - controller.$.data = [ - {id: 1, name: 'foo'}, - {id: 2, name: 'bar'} - ]; - - $httpBackend.expectDELETE('RoleInherits/1').respond(); - controller.onRemove(controller.$.data[0]); - $httpBackend.flush(); - - expect(controller.$.data).toEqual([{id: 2, name: 'bar'}]); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/role/subroles/locale/es.yml b/modules/account/front/role/subroles/locale/es.yml deleted file mode 100644 index 170882405..000000000 --- a/modules/account/front/role/subroles/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Role added! Changes will take a while to fully propagate.: > - ¡Rol añadido! Los cambios tardaran un tiempo en propagarse completamente. -Role removed. Changes will take a while to fully propagate.: > - Rol eliminado. Los cambios tardaran un tiempo en propagarse completamente. diff --git a/modules/account/front/role/summary/index.html b/modules/account/front/role/summary/index.html deleted file mode 100644 index f7971190c..000000000 --- a/modules/account/front/role/summary/index.html +++ /dev/null @@ -1,20 +0,0 @@ - -
{{summary.name}}
- - -

Basic data

- - - - - - -
-
-
\ No newline at end of file diff --git a/modules/account/front/role/summary/index.js b/modules/account/front/role/summary/index.js deleted file mode 100644 index 6c649a68f..000000000 --- a/modules/account/front/role/summary/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; - -class Controller extends Component { - set role(value) { - this._role = value; - this.$.summary = null; - if (!value) return; - this.$http.get(`VnRoles/${value.id}`) - .then(res => this.$.summary = res.data); - } - - get role() { - return this._role; - } -} - -ngModule.component('vnRoleSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - role: '<' - } -}); diff --git a/modules/account/front/roles/index.html b/modules/account/front/roles/index.html deleted file mode 100644 index 8c8583929..000000000 --- a/modules/account/front/roles/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - -
- {{::row.role.name}} -
-
- {{::row.role.description}} -
-
-
-
-
-
diff --git a/modules/account/front/roles/index.js b/modules/account/front/roles/index.js deleted file mode 100644 index 0982dcf10..000000000 --- a/modules/account/front/roles/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - let filter = { - where: { - prindicpalType: 'USER', - principalId: this.$params.id - }, - include: { - relation: 'role', - scope: { - fields: ['id', 'name', 'description'] - } - } - }; - this.$http.get('RoleMappings', {filter}) - .then(res => this.$.data = res.data); - } -} - -ngModule.component('vnUserRoles', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/routes.json b/modules/account/front/routes.json index d7845090b..9eadf2af2 100644 --- a/modules/account/front/routes.json +++ b/modules/account/front/routes.json @@ -7,31 +7,6 @@ "menus": { "main": [ {"state": "account.index", "icon": "face"}, - {"state": "account.role", "icon": "group"}, - {"state": "account.alias", "icon": "email"}, - {"state": "account.accounts", "icon": "accessibility"}, - {"state": "account.ldap", "icon": "account_tree"}, - {"state": "account.samba", "icon": "preview"}, - {"state": "account.acl", "icon": "check"}, - {"state": "account.connections", "icon": "share"} - ], - "card": [ - {"state": "account.card.basicData", "icon": "settings"}, - {"state": "account.card.roles", "icon": "group"}, - {"state": "account.card.mailForwarding", "icon": "forward"}, - {"state": "account.card.aliases", "icon": "email"}, - {"state": "account.card.privileges", "icon": "badge"}, - {"state": "account.card.log", "icon": "history"} - ], - "role": [ - {"state": "account.role.card.basicData", "icon": "settings"}, - {"state": "account.role.card.subroles", "icon": "groups"}, - {"state": "account.role.card.inherited", "icon": "account_tree"}, - {"state": "account.role.card.log", "icon": "history"} - ], - "alias": [ - {"state": "account.alias.card.basicData", "icon": "settings"}, - {"state": "account.alias.card.users", "icon": "groups"} ] }, "keybindings": [ @@ -50,224 +25,6 @@ "state": "account.index", "component": "vn-user-index", "description": "Users" - }, - { - "url": "/create", - "state": "account.create", - "component": "vn-user-create", - "description": "New user" - }, - { - "url": "/:id", - "state": "account.card", - "component": "vn-user-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "account.card.summary", - "component": "vn-user-summary", - "description": "Summary", - "params": { - "user": "$ctrl.user" - } - }, - { - "url": "/basic-data?emailConfirmed", - "state": "account.card.basicData", - "component": "vn-user-basic-data", - "description": "Basic data", - "params": { - "user": "$ctrl.user" - } - }, - { - "url" : "/log", - "state": "account.card.log", - "component": "vn-user-log", - "description": "Log" - }, - { - "url" : "/log", - "state": "account.role.card.log", - "component": "vn-role-log", - "description": "Log" - }, - { - "url": "/roles", - "state": "account.card.roles", - "component": "vn-user-roles", - "description": "Inherited roles" - }, - { - "url": "/mail-forwarding", - "state": "account.card.mailForwarding", - "component": "vn-user-mail-forwarding", - "description": "Mail forwarding" - }, - { - "url": "/aliases", - "state": "account.card.aliases", - "component": "vn-user-aliases", - "description": "Mail aliases" - }, - { - "url": "/privileges", - "state": "account.card.privileges", - "component": "vn-user-privileges", - "description": "Privileges", - "params": { - "user": "$ctrl.user" - } - }, - { - "url": "/role?q", - "state": "account.role", - "component": "vn-role", - "description": "Roles", - "acl": ["it"] - }, - { - "url": "/create", - "state": "account.role.create", - "component": "vn-role-create", - "description": "New role", - "acl": ["it"] - }, - { - "url": "/:id", - "state": "account.role.card", - "component": "vn-role-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "account.role.card.summary", - "component": "vn-role-summary", - "description": "Summary", - "params": { - "role": "$ctrl.role" - }, - "acl": ["it"] - }, - { - "url": "/basic-data", - "state": "account.role.card.basicData", - "component": "vn-role-basic-data", - "description": "Basic data", - "params": { - "role": "$ctrl.role" - }, - "acl": ["it"] - }, - { - "url": "/subroles", - "state": "account.role.card.subroles", - "component": "vn-role-subroles", - "description": "Subroles", - "acl": ["it"] - }, - { - "url": "/inherited", - "state": "account.role.card.inherited", - "component": "vn-role-inherited", - "description": "Inherited roles", - "acl": ["it"] - }, - { - "url": "/alias?q", - "state": "account.alias", - "component": "vn-alias", - "description": "Mail aliases" - }, - { - "url": "/create", - "state": "account.alias.create", - "component": "vn-alias-create", - "description": "New alias" - }, - { - "url": "/:id", - "state": "account.alias.card", - "component": "vn-alias-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "account.alias.card.summary", - "component": "vn-alias-summary", - "description": "Summary", - "params": { - "alias": "$ctrl.alias" - } - }, - { - "url": "/basic-data", - "state": "account.alias.card.basicData", - "component": "vn-alias-basic-data", - "description": "Basic data", - "params": { - "alias": "$ctrl.alias" - } - }, - { - "url": "/users", - "state": "account.alias.card.users", - "component": "vn-alias-users", - "description": "Users", - "acl": ["it"] - }, - { - "url": "/accounts", - "state": "account.accounts", - "component": "vn-account-accounts", - "description": "Accounts", - "acl": ["sysadmin"] - }, - { - "url": "/ldap", - "state": "account.ldap", - "component": "vn-account-ldap", - "description": "LDAP", - "acl": ["sysadmin"] - }, - { - "url": "/samba", - "state": "account.samba", - "component": "vn-account-samba", - "description": "Samba", - "acl": ["sysadmin"] - }, - { - "url": "/acl?q", - "state": "account.acl", - "component": "vn-acl-component", - "description": "ACLs", - "acl": ["developer"] - }, - { - "url": "/create", - "state": "account.acl.create", - "component": "vn-acl-create", - "description": "New ACL", - "acl": ["developer"] - }, - { - "url": "/:id/edit", - "state": "account.acl.edit", - "component": "vn-acl-create", - "description": "Edit ACL", - "acl": ["developer"] - }, - { - "url": "/connections", - "state": "account.connections", - "component": "vn-connections", - "description": "Connections", - "acl": ["developer"] } ] } diff --git a/modules/account/front/samba/index.html b/modules/account/front/samba/index.html deleted file mode 100644 index 0186cac7c..000000000 --- a/modules/account/front/samba/index.html +++ /dev/null @@ -1,71 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/samba/index.js b/modules/account/front/samba/index.js deleted file mode 100644 index 6a4969893..000000000 --- a/modules/account/front/samba/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onTestConection() { - this.$http.get(`SambaConfigs/test`) - .then(() => this.vnApp.showSuccess(this.$t('Samba connection established!'))); - } -} - -ngModule.component('vnAccountSamba', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/samba/locale/es.yml b/modules/account/front/samba/locale/es.yml deleted file mode 100644 index efa3b1597..000000000 --- a/modules/account/front/samba/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Enable synchronization: Habilitar sincronización -Domain controller: Controlador de dominio -AD domain: Dominio AD -AD user: Usuario AD -AD password: Contraseña AD -User DN (without domain part): DN usuarios (sin la parte del dominio) -Verify certificate: Verificar certificado -Test connection: Probar conexión -Samba connection established!: ¡Conexión con Samba establecida! diff --git a/modules/account/front/search-panel/index.html b/modules/account/front/search-panel/index.html deleted file mode 100644 index a539d9657..000000000 --- a/modules/account/front/search-panel/index.html +++ /dev/null @@ -1,31 +0,0 @@ -
-
- - - - - - - - - - - - - - - -
-
diff --git a/modules/account/front/search-panel/index.js b/modules/account/front/search-panel/index.js deleted file mode 100644 index fff3bf7b9..000000000 --- a/modules/account/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.component('vnUserSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/account/front/summary/index.html b/modules/account/front/summary/index.html deleted file mode 100644 index 41632aef6..000000000 --- a/modules/account/front/summary/index.html +++ /dev/null @@ -1,40 +0,0 @@ - -
- - - - {{summary.id}} - {{summary.nickname}} -
- - -

- - Basic Data - -

-

- Basic Data -

- - - - - - -
-
-
\ No newline at end of file diff --git a/modules/account/front/summary/index.js b/modules/account/front/summary/index.js deleted file mode 100644 index 53b66dbe2..000000000 --- a/modules/account/front/summary/index.js +++ /dev/null @@ -1,40 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; - -class Controller extends Summary { - set user(value) { - this._user = value; - this.$.summary = null; - if (!value) return; - - const filter = { - where: {id: value.id}, - include: { - relation: 'role', - scope: { - fields: ['id', 'name'] - } - } - }; - this.$http.get(`VnUsers/preview`, {filter}) - .then(res => { - const [summary] = res.data; - this.$.summary = summary; - }); - } - get isHr() { - return this.aclService.hasAny(['hr']); - } - - get user() { - return this._user; - } -} - -ngModule.component('vnUserSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - user: '<' - } -}); diff --git a/modules/account/front/user-log/index.html b/modules/account/front/user-log/index.html deleted file mode 100644 index 5a77ed7b9..000000000 --- a/modules/account/front/user-log/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modules/account/front/user-log/index.js b/modules/account/front/user-log/index.js deleted file mode 100644 index 7cd0bb378..000000000 --- a/modules/account/front/user-log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnUserLog', { - template: require('./index.html'), - controller: Section, -}); From bbe53060886a9f935159f68bee0db0ffb99cf269 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 12 Aug 2024 16:36:43 +0200 Subject: [PATCH 23/74] feat: refs #7524 add default limit --- loopback/common/models/vn-model.js | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 56a4f4dd0..a11bed11d 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -5,7 +5,6 @@ const utils = require('loopback/lib/utils'); module.exports = function(Self) { Self.ParameterizedSQL = ParameterizedSQL; - let isSelect; require('../methods/vn-model/getSetValues')(Self); require('../methods/vn-model/getEnumValues')(Self); @@ -28,7 +27,9 @@ module.exports = function(Self) { }; }); - this.beforeRemote('find', async ctx => { + this.beforeRemote('**', async ctx => { + if (!this.hasFilter(ctx)) return; + const defaultLimit = this.app.orm.selectLimit; const filter = ctx.args.filter || {limit: defaultLimit}; @@ -38,22 +39,10 @@ module.exports = function(Self) { } }); - this.afterRemote('find', async({result}) => { - const length = Array.isArray(result) ? result.length : result ? 1 : 0; - if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); - }); + this.afterRemote('**', async ctx => { + if (!this.hasFilter(ctx)) return; - this.beforeRemote('filter', async ctx => { - const defaultLimit = this.app.orm.selectLimit; - const filter = ctx.args.filter || {limit: defaultLimit}; - - if (filter.limit > defaultLimit) { - filter.limit = defaultLimit; - ctx.args.filter = filter; - } - }); - - this.afterRemote('filter', async({result}) => { + const {result} = ctx; const length = Array.isArray(result) ? result.length : result ? 1 : 0; if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); }); @@ -357,6 +346,12 @@ module.exports = function(Self) { checkInsertAcls(ctx) { return this.checkAcls(ctx, 'insert'); + }, + + hasFilter(ctx) { + return ctx.req.method.toUpperCase() === 'GET' && + ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); } + }); }; From 61d6efaea7f7b261b58b7a0ec7642877715c9ba7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 09:53:05 +0200 Subject: [PATCH 24/74] refactor: refs #7798 Drop bi.Greuges_comercial_detail --- db/versions/11185-maroonArborvitae/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11185-maroonArborvitae/00-firstScript.sql diff --git a/db/versions/11185-maroonArborvitae/00-firstScript.sql b/db/versions/11185-maroonArborvitae/00-firstScript.sql new file mode 100644 index 000000000..b07126e71 --- /dev/null +++ b/db/versions/11185-maroonArborvitae/00-firstScript.sql @@ -0,0 +1 @@ +DROP TABLE bi.Greuges_comercial_detail; \ No newline at end of file From 38cf5af23ee3061f0fe935e065aa469ea46388bd Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 12:21:03 +0200 Subject: [PATCH 25/74] feat: refs #7842 Added editorFk in vn.host --- db/routines/vn/triggers/host_beforeInsert.sql | 8 ++++++++ db/routines/vn/triggers/host_beforeUpdate.sql | 1 + db/versions/11187-yellowErica/00-firstScript.sql | 1 + 3 files changed, 10 insertions(+) create mode 100644 db/routines/vn/triggers/host_beforeInsert.sql create mode 100644 db/versions/11187-yellowErica/00-firstScript.sql diff --git a/db/routines/vn/triggers/host_beforeInsert.sql b/db/routines/vn/triggers/host_beforeInsert.sql new file mode 100644 index 000000000..c2cb82334 --- /dev/null +++ b/db/routines/vn/triggers/host_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`host_beforeInsert` + BEFORE INSERT ON `host` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/host_beforeUpdate.sql b/db/routines/vn/triggers/host_beforeUpdate.sql index 0b0962e86..dc5a18f3c 100644 --- a/db/routines/vn/triggers/host_beforeUpdate.sql +++ b/db/routines/vn/triggers/host_beforeUpdate.sql @@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`host_beforeUpdate` FOR EACH ROW BEGIN SET new.updated = util.VN_NOW(); + SET NEW.editorFk = account.myUser_getId(); END$$ DELIMITER ; diff --git a/db/versions/11187-yellowErica/00-firstScript.sql b/db/versions/11187-yellowErica/00-firstScript.sql new file mode 100644 index 000000000..fb75b1f2f --- /dev/null +++ b/db/versions/11187-yellowErica/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.host ADD editorFk int(10) unsigned DEFAULT NULL NULL; From 360e20545ae927f67b1d6a7e62e2e7d081bf7a9d Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 12:26:01 +0200 Subject: [PATCH 26/74] feat: refs #7799 Added Fk in vn.item.itemPackingTypeFk --- db/versions/11189-purplePaniculata/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11189-purplePaniculata/00-firstScript.sql diff --git a/db/versions/11189-purplePaniculata/00-firstScript.sql b/db/versions/11189-purplePaniculata/00-firstScript.sql new file mode 100644 index 000000000..3319bd154 --- /dev/null +++ b/db/versions/11189-purplePaniculata/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.item + ADD CONSTRAINT item_itemPackingType_FK FOREIGN KEY (itemPackingTypeFk) + REFERENCES vn.itemPackingType(code) ON DELETE RESTRICT ON UPDATE CASCADE; From 22ee4f18539bd5af31c5a1da49396ec5266472d7 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 13 Aug 2024 12:30:12 +0200 Subject: [PATCH 27/74] refactor: refs #7848 adapt to lilium --- back/models/vn-user.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/back/models/vn-user.js b/back/models/vn-user.js index 6ec5642a2..531561e04 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -101,9 +101,10 @@ module.exports = function(Self) { const headers = httpRequest.headers; const origin = headers.origin; - const defaultHash = '/reset-password?access_token=$token$'; + const defaultHash = '!/reset-password?access_token=$token$'; const recoverHashes = { - hedera: 'verificationToken=$token$' + hedera: '!verificationToken=$token$', + lilium: '/resetPassword?access_token=$token$' }; const app = info.options?.app; @@ -115,7 +116,7 @@ module.exports = function(Self) { const params = { recipient: info.email, lang: user.lang, - url: origin + '/#!' + recoverHash + url: origin + '/#' + recoverHash }; const options = Object.assign({}, info.options); From ef1b4ef0a4a01558fc9047edd475f732fe426b24 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 13 Aug 2024 12:30:37 +0200 Subject: [PATCH 28/74] feat(update-user): refs #7848 add twoFactor --- back/methods/vn-user/update-user.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/back/methods/vn-user/update-user.js b/back/methods/vn-user/update-user.js index ddaae8548..202b01c65 100644 --- a/back/methods/vn-user/update-user.js +++ b/back/methods/vn-user/update-user.js @@ -24,6 +24,10 @@ module.exports = Self => { arg: 'lang', type: 'string', description: 'The user lang' + }, { + arg: 'twoFactor', + type: 'string', + description: 'The user twoFactor' } ], http: { @@ -32,8 +36,8 @@ module.exports = Self => { } }); - Self.updateUser = async(ctx, id, name, nickname, email, lang) => { + Self.updateUser = async(ctx, id, name, nickname, email, lang, twoFactor) => { await Self.userSecurity(ctx, id); - await Self.upsertWithWhere({id}, {name, nickname, email, lang}); + await Self.upsertWithWhere({id}, {name, nickname, email, lang, twoFactor}); }; }; From dd5845abae6557774cc70a015e3e67ef23579006 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 12:49:56 +0200 Subject: [PATCH 29/74] fix: refs #7800 tpvMerchantEnable PRIMARY KEY --- db/versions/11190-blueLaurel/00-firstScript.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/versions/11190-blueLaurel/00-firstScript.sql diff --git a/db/versions/11190-blueLaurel/00-firstScript.sql b/db/versions/11190-blueLaurel/00-firstScript.sql new file mode 100644 index 000000000..484b77ad8 --- /dev/null +++ b/db/versions/11190-blueLaurel/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE hedera.tpvMerchantEnable DROP FOREIGN KEY tpvMerchantEnable_ibfk_1; +ALTER TABLE hedera.tpvMerchantEnable DROP PRIMARY KEY; +ALTER TABLE hedera.tpvMerchantEnable + ADD CONSTRAINT tpvMerchantEnable_pk PRIMARY KEY (merchantFk); +ALTER TABLE hedera.tpvMerchantEnable + ADD CONSTRAINT tpvMerchantEnable_tpvMerchant_FK FOREIGN KEY (merchantFk) REFERENCES hedera.tpvMerchant(id) ON DELETE RESTRICT ON UPDATE CASCADE; From 68ee5e3549a55b7ec8d48a859d9533ef3377631b Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 12:52:39 +0200 Subject: [PATCH 30/74] fix: refs #7800 tpvMerchantEnable PRIMARY KEY --- db/versions/11190-blueLaurel/00-firstScript.sql | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/db/versions/11190-blueLaurel/00-firstScript.sql b/db/versions/11190-blueLaurel/00-firstScript.sql index 484b77ad8..75e3f8e59 100644 --- a/db/versions/11190-blueLaurel/00-firstScript.sql +++ b/db/versions/11190-blueLaurel/00-firstScript.sql @@ -1,6 +1,9 @@ -ALTER TABLE hedera.tpvMerchantEnable DROP FOREIGN KEY tpvMerchantEnable_ibfk_1; -ALTER TABLE hedera.tpvMerchantEnable DROP PRIMARY KEY; ALTER TABLE hedera.tpvMerchantEnable - ADD CONSTRAINT tpvMerchantEnable_pk PRIMARY KEY (merchantFk); -ALTER TABLE hedera.tpvMerchantEnable - ADD CONSTRAINT tpvMerchantEnable_tpvMerchant_FK FOREIGN KEY (merchantFk) REFERENCES hedera.tpvMerchant(id) ON DELETE RESTRICT ON UPDATE CASCADE; + DROP FOREIGN KEY tpvMerchantEnable_ibfk_1, + DROP PRIMARY KEY, + ADD CONSTRAINT tpvMerchantEnable_pk PRIMARY KEY (merchantFk), + ADD CONSTRAINT tpvMerchantEnable_tpvMerchant_FK + FOREIGN KEY (merchantFk) + REFERENCES hedera.tpvMerchant(id) + ON DELETE RESTRICT + ON UPDATE CASCADE; From 3ee377156b173b6f41d19c9519a12c64d853b165 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 14 Aug 2024 12:38:38 +0200 Subject: [PATCH 31/74] fix: refs #7355 remove and tests accounts --- .../front/descriptor-popover/index.html | 4 + .../account/front/descriptor-popover/index.js | 9 + modules/account/front/descriptor/index.html | 192 ++++++++++++++++++ modules/account/front/descriptor/index.js | 145 +++++++++++++ .../account/front/descriptor/locale/es.yml | 35 ++++ modules/account/front/index.js | 3 + modules/account/front/summary/index.html | 40 ++++ modules/account/front/summary/index.js | 40 ++++ 8 files changed, 468 insertions(+) create mode 100644 modules/account/front/descriptor-popover/index.html create mode 100644 modules/account/front/descriptor-popover/index.js create mode 100644 modules/account/front/descriptor/index.html create mode 100644 modules/account/front/descriptor/index.js create mode 100644 modules/account/front/descriptor/locale/es.yml create mode 100644 modules/account/front/summary/index.html create mode 100644 modules/account/front/summary/index.js diff --git a/modules/account/front/descriptor-popover/index.html b/modules/account/front/descriptor-popover/index.html new file mode 100644 index 000000000..f3131a84b --- /dev/null +++ b/modules/account/front/descriptor-popover/index.html @@ -0,0 +1,4 @@ + + + + diff --git a/modules/account/front/descriptor-popover/index.js b/modules/account/front/descriptor-popover/index.js new file mode 100644 index 000000000..d7b052473 --- /dev/null +++ b/modules/account/front/descriptor-popover/index.js @@ -0,0 +1,9 @@ +import ngModule from '../module'; +import DescriptorPopover from 'salix/components/descriptor-popover'; + +class Controller extends DescriptorPopover {} + +ngModule.vnComponent('vnAccountDescriptorPopover', { + slotTemplate: require('./index.html'), + controller: Controller +}); diff --git a/modules/account/front/descriptor/index.html b/modules/account/front/descriptor/index.html new file mode 100644 index 000000000..86e78dfce --- /dev/null +++ b/modules/account/front/descriptor/index.html @@ -0,0 +1,192 @@ + + + + + + + Delete + + + Change password + + + Set password + + + Enable account + + + Disable account + + + Activate user + + + Deactivate user + + + Synchronize + + + +
+ + + + +
+
+ + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + Do you want to synchronize user? + + + + + + + + + + + + + + + diff --git a/modules/account/front/descriptor/index.js b/modules/account/front/descriptor/index.js new file mode 100644 index 000000000..de41d619d --- /dev/null +++ b/modules/account/front/descriptor/index.js @@ -0,0 +1,145 @@ +import ngModule from '../module'; +import Descriptor from 'salix/components/descriptor'; +import UserError from 'core/lib/user-error'; + +class Controller extends Descriptor { + get user() { + return this.entity; + } + + set user(value) { + this.entity = value; + } + + get entity() { + return super.entity; + } + + set entity(value) { + super.entity = value; + this.hasAccount = null; + if (!value) return; + + this.$http.get(`Accounts/${value.id}/exists`) + .then(res => this.hasAccount = res.data.exists); + } + + loadData() { + const filter = { + where: {id: this.$params.id}, + include: { + relation: 'role', + scope: { + fields: ['id', 'name'] + } + } + }; + + return Promise.all([ + this.$http.get(`VnUsers/preview`, {filter}) + .then(res => { + const [user] = res.data; + this.user = user; + }), + this.$http.get(`Accounts/${this.$params.id}/exists`) + .then(res => this.hasAccount = res.data.exists) + ]); + } + + onDelete() { + return this.$http.delete(`VnUsers/${this.id}`) + .then(() => this.$state.go('account.index')) + .then(() => this.vnApp.showSuccess(this.$t('User removed'))); + } + + onChangePassClick(askOldPass) { + this.$http.get('UserPasswords/findOne') + .then(res => { + this.passRequirements = res.data; + this.askOldPass = askOldPass; + this.$.changePass.show(); + }); + } + + onPassChange() { + if (!this.newPassword) + throw new UserError(`You must enter a new password`); + if (this.newPassword != this.repeatPassword) + throw new UserError(`Passwords don't match`); + + let method; + const params = {newPassword: this.newPassword}; + + if (this.askOldPass) { + method = 'change-password'; + params.oldPassword = this.oldPassword; + } else + method = 'setPassword'; + + return this.$http.patch(`Accounts/${this.id}/${method}`, params) + .then(() => { + this.emit('change'); + this.vnApp.showSuccess(this.$t('Password changed succesfully!')); + }); + } + + onPassClose() { + this.oldPassword = ''; + this.newPassword = ''; + this.repeatPassword = ''; + this.$.$apply(); + } + + onEnableAccount() { + return this.$http.post(`Accounts`, {id: this.id}) + .then(() => this.onSwitchAccount(true)); + } + + onDisableAccount() { + return this.$http.delete(`Accounts/${this.id}`) + .then(() => this.onSwitchAccount(false)); + } + + onSwitchAccount(enable) { + this.hasAccount = enable; + const message = enable + ? 'Account enabled!' + : 'Account disabled!'; + this.emit('change'); + this.vnApp.showSuccess(this.$t(message)); + } + + onSetActive(active) { + return this.$http.patch(`VnUsers/${this.id}`, {active}) + .then(() => { + this.user.active = active; + const message = active + ? 'User activated!' + : 'User deactivated!'; + this.emit('change'); + this.vnApp.showSuccess(this.$t(message)); + }); + } + + onSync() { + const params = {force: true}; + if (this.shouldSyncPassword) + params.password = this.syncPassword; + + return this.$http.patch(`Accounts/${this.user.name}/sync`, params) + .then(() => this.vnApp.showSuccess(this.$t('User synchronized!'))); + } + + onSyncClose() { + this.shouldSyncPassword = false; + this.syncPassword = undefined; + } +} + +ngModule.component('vnUserDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + user: '<' + } +}); diff --git a/modules/account/front/descriptor/locale/es.yml b/modules/account/front/descriptor/locale/es.yml new file mode 100644 index 000000000..98ced7694 --- /dev/null +++ b/modules/account/front/descriptor/locale/es.yml @@ -0,0 +1,35 @@ +User will be removed: El usuario será eliminado +User removed: Usuario eliminado +Are you sure you want to continue?: ¿Seguro que quieres continuar? +Account will be enabled: La cuenta será habilitada +Account will be disabled: La cuenta será deshabilitada +Account enabled!: ¡Cuenta habilitada! +Account disabled!: ¡Cuenta deshabilitada! +User will activated: El usuario será activado +User will be deactivated: El usuario será desactivado +User activated!: ¡Usuario activado! +User deactivated!: ¡Usuario desactivado! +Account enabled: Cuenta habilitada +User deactivated: Usuario desactivado +Change role: Modificar rol +Change password: Cambiar contraseña +Set password: Establecer contraseña +Enable account: Habilitar cuenta +Disable account: Deshabilitar cuenta +Activate user: Activar usuario +Deactivate user: Desactivar usuario +Old password: Contraseña antigua +New password: Nueva contraseña +Repeat password: Repetir contraseña +Password changed succesfully!: ¡Contraseña modificada correctamente! +Synchronize: Sincronizar +Do you want to synchronize user?: ¿Quieres sincronizar el usuario? +Synchronize password: Sincronizar contraseña +User synchronized!: ¡Usuario sincronizado! +Role changed succesfully!: ¡Rol modificado correctamente! +Password requirements: > + La contraseña debe tener al menos {{ length }} caracteres de longitud, + {{nAlpha}} caracteres alfabéticos, {{nUpper}} letras mayúsculas, {{nDigits}} + dígitos y {{nPunct}} símbolos (Ej: $%&.) +You must enter a new password: Debes introducir la nueva contraseña +Passwords don't match: Las contraseñas no coinciden diff --git a/modules/account/front/index.js b/modules/account/front/index.js index a7209a0bd..0f2208862 100644 --- a/modules/account/front/index.js +++ b/modules/account/front/index.js @@ -1,3 +1,6 @@ export * from './module'; import './main'; +import './descriptor'; +import './descriptor-popover'; +import './summary'; diff --git a/modules/account/front/summary/index.html b/modules/account/front/summary/index.html new file mode 100644 index 000000000..f3c11f25f --- /dev/null +++ b/modules/account/front/summary/index.html @@ -0,0 +1,40 @@ + +
+ + + + {{summary.id}} - {{summary.nickname}} +
+ + +

+ + Basic Data + +

+

+ Basic Data +

+ + + + + + +
+
+
diff --git a/modules/account/front/summary/index.js b/modules/account/front/summary/index.js new file mode 100644 index 000000000..53b66dbe2 --- /dev/null +++ b/modules/account/front/summary/index.js @@ -0,0 +1,40 @@ +import ngModule from '../module'; +import Summary from 'salix/components/summary'; + +class Controller extends Summary { + set user(value) { + this._user = value; + this.$.summary = null; + if (!value) return; + + const filter = { + where: {id: value.id}, + include: { + relation: 'role', + scope: { + fields: ['id', 'name'] + } + } + }; + this.$http.get(`VnUsers/preview`, {filter}) + .then(res => { + const [summary] = res.data; + this.$.summary = summary; + }); + } + get isHr() { + return this.aclService.hasAny(['hr']); + } + + get user() { + return this._user; + } +} + +ngModule.component('vnUserSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + user: '<' + } +}); From 575577d29b526cb43cb2d7f0d60d71d1eb896dea Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 16 Aug 2024 10:08:58 +0200 Subject: [PATCH 32/74] feat: refs #7346 add multiple feature --- db/dump/fixtures.before.sql | 2 +- db/routines/vn/functions/invoiceSerial.sql | 2 +- db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql | 2 ++ db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql | 2 +- modules/invoiceIn/back/methods/invoice-in/getSerial.js | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 6563292dd..5e6533b28 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -632,7 +632,7 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF ('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'), ('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'), ('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'), - ('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'quick'), + ('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'multiple'), ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL), ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick'); diff --git a/db/routines/vn/functions/invoiceSerial.sql b/db/routines/vn/functions/invoiceSerial.sql index 5ce20dc8b..0269275b1 100644 --- a/db/routines/vn/functions/invoiceSerial.sql +++ b/db/routines/vn/functions/invoiceSerial.sql @@ -12,7 +12,7 @@ BEGIN * @param vType Tipo de factura ['global','multiple','quick'] * @return vSerie de la factura */ - DECLARE vTaxArea VARCHAR(25); + DECLARE vTaxArea VARCHAR(25) COLLATE utf8mb3_general_ci; DECLARE vSerie CHAR(2); IF (SELECT hasInvoiceSimplified FROM client WHERE id = vClientFk) THEN diff --git a/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql b/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql index db476c4a5..09ac00401 100644 --- a/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql +++ b/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql @@ -1,2 +1,4 @@ ALTER TABLE vn.invoiceOutSerial MODIFY COLUMN `type` enum('global','quick','multiple') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; + +CREATE UNIQUE INDEX invoiceOutSerial_taxAreaFk_IDX USING BTREE ON vn.invoiceOutSerial (taxAreaFk,`type`); diff --git a/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql b/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql index 581a6f5f3..fad33b5dc 100644 --- a/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql +++ b/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql @@ -1,3 +1,3 @@ UPDATE vn.invoiceOutSerial SET `type`='multiple' - WHERE `description` LIKE '%multiple%'; + WHERE `description` LIKE '%Múltiple%'; diff --git a/modules/invoiceIn/back/methods/invoice-in/getSerial.js b/modules/invoiceIn/back/methods/invoice-in/getSerial.js index dcc1fbc3c..29c7cae2f 100644 --- a/modules/invoiceIn/back/methods/invoice-in/getSerial.js +++ b/modules/invoiceIn/back/methods/invoice-in/getSerial.js @@ -46,7 +46,7 @@ module.exports = Self => { } }); - filter = mergeFilters(args.filter, {where}); + const filter = mergeFilters(args.filter, {where}); const stmt = new ParameterizedSQL( `SELECT i.serial, SUM(IF(i.isBooked, 0,1)) pending, COUNT(*) total From fc1767cab4e8c832ee1e2baadb0b17e00a77dc79 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 08:45:04 +0200 Subject: [PATCH 33/74] refactor: refs #7756 Fix tests --- db/versions/11172-blueFern/15-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11172-blueFern/15-firstScript.sql diff --git a/db/versions/11172-blueFern/15-firstScript.sql b/db/versions/11172-blueFern/15-firstScript.sql new file mode 100644 index 000000000..5d34f1025 --- /dev/null +++ b/db/versions/11172-blueFern/15-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL; \ No newline at end of file From 0fcff01433db61f8af6fe21d601c51682820a47b Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 09:11:30 +0200 Subject: [PATCH 34/74] refactor: refs #7756 Fix tests --- db/versions/11172-blueFern/10-firstScript.sql | 3 +-- db/versions/11172-blueFern/11-firstScript.sql | 4 ++-- db/versions/11172-blueFern/12-firstScript.sql | 4 ++-- db/versions/11172-blueFern/13-firstScript.sql | 4 ++-- db/versions/11172-blueFern/14-firstScript.sql | 2 +- db/versions/11172-blueFern/15-firstScript.sql | 3 ++- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/db/versions/11172-blueFern/10-firstScript.sql b/db/versions/11172-blueFern/10-firstScript.sql index e1847a877..5d34f1025 100644 --- a/db/versions/11172-blueFern/10-firstScript.sql +++ b/db/versions/11172-blueFern/10-firstScript.sql @@ -1,2 +1 @@ -ALTER TABLE vn.ticket ADD CONSTRAINT ticket_invoiceOut_FK - FOREIGN KEY (refFk) REFERENCES vn.invoiceOut(`ref`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL; \ No newline at end of file diff --git a/db/versions/11172-blueFern/11-firstScript.sql b/db/versions/11172-blueFern/11-firstScript.sql index 720b7962e..e1847a877 100644 --- a/db/versions/11172-blueFern/11-firstScript.sql +++ b/db/versions/11172-blueFern/11-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK - FOREIGN KEY (correctingFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE vn.ticket ADD CONSTRAINT ticket_invoiceOut_FK + FOREIGN KEY (refFk) REFERENCES vn.invoiceOut(`ref`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/12-firstScript.sql b/db/versions/11172-blueFern/12-firstScript.sql index 35099bd5d..720b7962e 100644 --- a/db/versions/11172-blueFern/12-firstScript.sql +++ b/db/versions/11172-blueFern/12-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK_1 - FOREIGN KEY (correctedFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file +ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK + FOREIGN KEY (correctingFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/13-firstScript.sql b/db/versions/11172-blueFern/13-firstScript.sql index f1aa0a216..35099bd5d 100644 --- a/db/versions/11172-blueFern/13-firstScript.sql +++ b/db/versions/11172-blueFern/13-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.invoiceOutExpense ADD CONSTRAINT invoiceOutExpense_invoiceOut_FK - FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK_1 + FOREIGN KEY (correctedFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/versions/11172-blueFern/14-firstScript.sql b/db/versions/11172-blueFern/14-firstScript.sql index ba570e20c..f1aa0a216 100644 --- a/db/versions/11172-blueFern/14-firstScript.sql +++ b/db/versions/11172-blueFern/14-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.invoiceOutTax ADD CONSTRAINT invoiceOutTax_invoiceOut_FK +ALTER TABLE vn.invoiceOutExpense ADD CONSTRAINT invoiceOutExpense_invoiceOut_FK FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/15-firstScript.sql b/db/versions/11172-blueFern/15-firstScript.sql index 5d34f1025..ba570e20c 100644 --- a/db/versions/11172-blueFern/15-firstScript.sql +++ b/db/versions/11172-blueFern/15-firstScript.sql @@ -1 +1,2 @@ -ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL; \ No newline at end of file +ALTER TABLE vn.invoiceOutTax ADD CONSTRAINT invoiceOutTax_invoiceOut_FK + FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; From f9d0afa5da61834c0ac60a5f1b041d9bf90412da Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 09:30:25 +0200 Subject: [PATCH 35/74] feat: refs #7712 Fix --- db/routines/vn/procedures/collection_new.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index f7f342ea7..ee76f3994 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -181,6 +181,7 @@ BEGIN JOIN ticket t ON t.id = pb.ticketfk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk + GROUP BY pb.ticketFk ) sub ON sub.ticketFk = pb.ticketFk JOIN productionConfig pc WHERE pb.shipped <> util.VN_CURDATE() From 1f5145ba9e0a7439ff0165ad8ff0b15cc2ba17aa Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 09:34:02 +0200 Subject: [PATCH 36/74] feat: refs #7712 Unify --- db/versions/11171-maroonMoss/00-firstScript.sql | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/db/versions/11171-maroonMoss/00-firstScript.sql b/db/versions/11171-maroonMoss/00-firstScript.sql index 1bf0d646b..0632239ac 100644 --- a/db/versions/11171-maroonMoss/00-firstScript.sql +++ b/db/versions/11171-maroonMoss/00-firstScript.sql @@ -1,8 +1,3 @@ ALTER TABLE vn.operator - ADD sizeLimit int(10) unsigned DEFAULT 90 NULL - COMMENT 'Límite de altura en una colección para la asignación de pedidos' - AFTER volumeLimit; - -ALTER TABLE vn.operator - MODIFY COLUMN linesLimit int(10) unsigned DEFAULT 20 NULL - COMMENT 'Límite de lineas en una colección para la asignación de pedidos'; + ADD COLUMN sizeLimit int(10) unsigned DEFAULT 90 NULL COMMENT 'Límite de altura en una colección para la asignación de pedidos' AFTER volumeLimit, + MODIFY COLUMN linesLimit int(10) unsigned DEFAULT 20 NULL COMMENT 'Límite de lineas en una colección para la asignación de pedidos'; From 340348a38e4b91d22c4c2e8708a0f6e5830a4701 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 20 Aug 2024 10:11:42 +0200 Subject: [PATCH 37/74] feat: refs #7346 backTest checks new implementation --- db/routines/vn/functions/invoiceSerial.sql | 4 +- .../back/methods/invoiceOut/invoiceClient.js | 8 +- .../invoiceOut/specs/clientsToInvoice.spec.js | 75 +++++++++++++++++ .../invoiceOut/specs/invoiceClient.spec.js | 80 ++++++++++++++++--- 4 files changed, 151 insertions(+), 16 deletions(-) create mode 100644 modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js diff --git a/db/routines/vn/functions/invoiceSerial.sql b/db/routines/vn/functions/invoiceSerial.sql index 0269275b1..9df887cf5 100644 --- a/db/routines/vn/functions/invoiceSerial.sql +++ b/db/routines/vn/functions/invoiceSerial.sql @@ -1,10 +1,10 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(15)) - RETURNS char(1) CHARSET utf8mb3 COLLATE utf8mb3_general_ci + RETURNS char(2) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN /** - * Obtiene la serie de de una factura + * Obtiene la serie de una factura * dependiendo del area del cliente. * * @param vClientFk Id del cliente diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js index ef8a26efc..2c44cef34 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js @@ -31,7 +31,7 @@ module.exports = Self => { }, { arg: 'serialType', type: 'string', - description: 'Type of serial', + description: 'Invoice serial number type (see vn.invoiceOutSerial.type enum)', required: true } ], @@ -44,12 +44,10 @@ module.exports = Self => { verb: 'POST' } }); - Self.invoiceClient = async(ctx, options) => { const args = ctx.args; const models = Self.app.models; - options = typeof options == 'object' - ? Object.assign({}, options) : {}; + options = typeof options === 'object' ? {...options} : {}; options.userId = ctx.req.accessToken.userId; let tx; @@ -81,7 +79,7 @@ module.exports = Self => { const invoiceId = await models.Ticket.makeInvoice( ctx, - serialType, + args.serialType, args.companyFk, args.invoiceDate, null, diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js new file mode 100644 index 000000000..470690c5a --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js @@ -0,0 +1,75 @@ +const models = require('vn-loopback/server/server').models; + +describe('InvoiceOut clientsToInvoice()', () => { + const userId = 1; + const clientId = 1101; + const companyFk = 442; + const maxShipped = new Date(); + maxShipped.setMonth(11); + maxShipped.setDate(31); + maxShipped.setHours(23, 59, 59, 999); + const invoiceDate = new Date(); + const activeCtx = { + getLocale: () => { + return 'en'; + }, + accessToken: {userId: userId}, + __: value => { + return value; + }, + headers: {origin: 'http://localhost'} + }; + const ctx = {req: activeCtx}; + + it('should return a list of clients to invoice', async() => { + spyOn(models.InvoiceOut, 'rawSql').and.callFake(query => { + if (query.includes('ticketPackaging_add')) + return Promise.resolve(true); + else if (query.includes('SELECT c.id clientId')) { + return Promise.resolve([ + { + clientId: clientId, + clientName: 'Test Client', + id: 1, + nickname: 'Address 1' + } + ]); + } + }); + + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + const addresses = await models.InvoiceOut.clientsToInvoice( + ctx, clientId, invoiceDate, maxShipped, companyFk, options); + + expect(addresses.length).toBeGreaterThan(0); + expect(addresses[0].clientId).toBe(clientId); + expect(addresses[0].clientName).toBe('Test Client'); + expect(addresses[0].id).toBe(1); + expect(addresses[0].nickname).toBe('Address 1'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should handle errors and rollback transaction', async() => { + spyOn(models.InvoiceOut, 'rawSql').and.callFake(() => { + return Promise.reject(new Error('Test Error')); + }); + + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + await models.InvoiceOut.clientsToInvoice(ctx, clientId, invoiceDate, maxShipped, companyFk, options); + } catch (e) { + expect(e.message).toBe('Test Error'); + await tx.rollback(); + } + }); +}); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js index 0faa8fe1a..cffae394f 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js @@ -3,14 +3,13 @@ const models = require('vn-loopback/server/server').models; describe('InvoiceOut invoiceClient()', () => { const userId = 1; const clientId = 1101; - const addressId = 121; + const addressFk = 121; const companyFk = 442; const minShipped = Date.vnNew(); minShipped.setFullYear(minShipped.getFullYear() - 1); minShipped.setMonth(1); minShipped.setDate(1); minShipped.setHours(0, 0, 0, 0); - const invoiceSerial = 'A'; const activeCtx = { getLocale: () => { return 'en'; @@ -24,8 +23,8 @@ describe('InvoiceOut invoiceClient()', () => { }; const ctx = {req: activeCtx}; - it('should make a global invoicing', async() => { - spyOn(models.InvoiceOut, 'makePdf').and.returnValue(new Promise(resolve => resolve(true))); + it('should make a global invoicing by address and verify billing status', async() => { + spyOn(models.InvoiceOut, 'makePdf').and.returnValue(Promise.resolve(true)); spyOn(models.InvoiceOut, 'invoiceEmail'); const tx = await models.InvoiceOut.beginTransaction({}); @@ -34,20 +33,42 @@ describe('InvoiceOut invoiceClient()', () => { try { ctx.args = { clientId: clientId, - addressId: addressId, + addressId: addressFk, invoiceDate: Date.vnNew(), maxShipped: Date.vnNew(), companyFk: companyFk, - minShipped: minShipped + serialType: 'global' }; + const invoiceOutId = await models.InvoiceOut.invoiceClient(ctx, options); + const invoiceOut = await models.InvoiceOut.findById(invoiceOutId, null, options); - const [firstTicket] = await models.Ticket.find({ + + expect(invoiceOutId).toBeGreaterThan(0); + + const allClientTickets = await models.Ticket.find({ + where: { + clientFk: clientId, + or: [ + {refFk: null}, + {refFk: invoiceOut.ref} + ] + } + }, options); + + const billedTickets = await models.Ticket.find({ where: {refFk: invoiceOut.ref} }, options); - expect(invoiceOutId).toBeGreaterThan(0); - expect(firstTicket.refFk).toContain(invoiceSerial); + const allBilledTicketsHaveCorrectAddress = billedTickets.every(ticket => ticket.addressFk === addressFk); + + expect(allBilledTicketsHaveCorrectAddress).toBe(true); + + const addressTickets = allClientTickets.filter(ticket => ticket.addressFk === addressFk); + + const allAddressTicketsBilled = addressTickets.every(ticket => ticket.refFk === invoiceOut.ref); + + expect(allAddressTicketsBilled).toBe(true); await tx.rollback(); } catch (e) { @@ -55,4 +76,45 @@ describe('InvoiceOut invoiceClient()', () => { throw e; } }); + jasmine.DEFAULT_TIMEOUT_INTERVAL = 300000; + fit('should invoice all tickets regardless of address when hasToInvoiceByAddress is false', async() => { + spyOn(models.InvoiceOut, 'makePdf').and.returnValue(Promise.resolve(true)); + spyOn(models.InvoiceOut, 'invoiceEmail'); + + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + console.log('Searching for client with ID:', clientId); + const client = await models.Client.findById(clientId, options); + console.log('Found client:', JSON.stringify(client, null, 2)); + + if (!client) + throw new Error(`Client with id ${clientId} not found`); + + console.log('Client before update:', JSON.stringify(client, null, 2)); + console.log('Current hasToInvoiceByAddress value:', client.hasToInvoiceByAddress); + + try { + console.log('Attempting to update hasToInvoiceByAddress'); + await client.updateAttribute('hasToInvoiceByAddress', false, options); + console.log('Update successful'); + } catch (updateError) { + console.error('Error updating hasToInvoiceByAddress:', updateError); + console.error('Error stack:', updateError.stack); + throw updateError; + } + + console.log('Client after update:', JSON.stringify(client, null, 2)); + console.log('New hasToInvoiceByAddress value:', client.hasToInvoiceByAddress); + + console.log('Test completed successfully'); + await tx.rollback(); + } catch (e) { + console.error('Test failed:', e); + console.error('Error stack:', e.stack); + await tx.rollback(); + throw e; + } + }); }); From 65ba1d466453e9848ea1197f46808a4b35e2a18d Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 20 Aug 2024 10:11:56 +0200 Subject: [PATCH 38/74] feat: refs #7346 backTest checks new implementation --- .../invoiceOut/specs/invoiceClient.spec.js | 61 ++++++++++++------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js index cffae394f..369257ebe 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js @@ -1,4 +1,5 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('InvoiceOut invoiceClient()', () => { const userId = 1; @@ -22,6 +23,11 @@ describe('InvoiceOut invoiceClient()', () => { }; const ctx = {req: activeCtx}; + beforeAll(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); it('should make a global invoicing by address and verify billing status', async() => { spyOn(models.InvoiceOut, 'makePdf').and.returnValue(Promise.resolve(true)); @@ -85,34 +91,47 @@ describe('InvoiceOut invoiceClient()', () => { const options = {transaction: tx}; try { - console.log('Searching for client with ID:', clientId); - const client = await models.Client.findById(clientId, options); - console.log('Found client:', JSON.stringify(client, null, 2)); + const client = await models.Client.findById(clientId, null, options); + await client.updateAttribute('hasToInvoiceByAddress', false, options); - if (!client) - throw new Error(`Client with id ${clientId} not found`); + ctx.args = { + clientId: clientId, + invoiceDate: Date.vnNew(), + maxShipped: Date.vnNew(), + companyFk: companyFk, + serialType: 'global' + }; - console.log('Client before update:', JSON.stringify(client, null, 2)); - console.log('Current hasToInvoiceByAddress value:', client.hasToInvoiceByAddress); + const invoiceOutId = await models.InvoiceOut.invoiceClient(ctx, options); - try { - console.log('Attempting to update hasToInvoiceByAddress'); - await client.updateAttribute('hasToInvoiceByAddress', false, options); - console.log('Update successful'); - } catch (updateError) { - console.error('Error updating hasToInvoiceByAddress:', updateError); - console.error('Error stack:', updateError.stack); - throw updateError; - } + const invoiceOut = await models.InvoiceOut.findById(invoiceOutId, null, options); - console.log('Client after update:', JSON.stringify(client, null, 2)); - console.log('New hasToInvoiceByAddress value:', client.hasToInvoiceByAddress); + expect(invoiceOutId).toBeGreaterThan(0); + + const allClientTickets = await models.Ticket.find({ + where: { + clientFk: clientId, + or: [ + {refFk: null}, + {refFk: invoiceOut.ref} + ] + } + }, options); + + const billedTickets = await models.Ticket.find({ + where: {refFk: invoiceOut.ref} + }, options); + + const allTicketsBilled = allClientTickets.every(ticket => ticket.refFk === invoiceOut.ref); + + expect(allTicketsBilled).toBe(true); + + const billedAddresses = new Set(billedTickets.map(ticket => ticket.addressFk)); + + expect(billedAddresses.size).toBeGreaterThan(1); - console.log('Test completed successfully'); await tx.rollback(); } catch (e) { - console.error('Test failed:', e); - console.error('Error stack:', e.stack); await tx.rollback(); throw e; } From 55799719aec7f4565ad207122a04ea4472d7fac0 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 20 Aug 2024 10:16:59 +0200 Subject: [PATCH 39/74] fix: refs #7346 minor error --- .../back/methods/invoiceOut/specs/invoiceClient.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js index 369257ebe..c731912ec 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js @@ -82,8 +82,8 @@ describe('InvoiceOut invoiceClient()', () => { throw e; } }); - jasmine.DEFAULT_TIMEOUT_INTERVAL = 300000; - fit('should invoice all tickets regardless of address when hasToInvoiceByAddress is false', async() => { + + it('should invoice all tickets regardless of address when hasToInvoiceByAddress is false', async() => { spyOn(models.InvoiceOut, 'makePdf').and.returnValue(Promise.resolve(true)); spyOn(models.InvoiceOut, 'invoiceEmail'); From a995d80b46270d82e76f841f648f0f35c8222c6a Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 10:58:26 +0200 Subject: [PATCH 40/74] feat: refs #3199 Requested changes --- .../vn/procedures/ticket_recalcByScope.sql | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index 1541b532e..9199325ee 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -14,22 +14,26 @@ BEGIN DECLARE vTicketFk INT; DECLARE cTickets CURSOR FOR + SELECT DISTINCT t.id + FROM ticket t + LEFT JOIN tItemCalc tic ON tic.id = t.id + WHERE t.refFk IS NULL + AND ((vScope = 'client' AND t.clientFk = vId) + OR (vScope = 'address' AND t.addressFk = vId) + OR (vScope = 'item' AND tic.id) + ); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + CREATE OR REPLACE TEMPORARY TABLE tItemCalc SELECT DISTINCT t.id FROM ticket t JOIN sale s ON s.ticketFk = t.id JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk WHERE t.refFk IS NULL - AND ( - (vScope = 'client' AND t.clientFk = vId) - OR (vScope = 'address' AND t.addressFk = vId) - OR (vScope = 'item' AND itc.itemFk = vId) - ); - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; + AND (vScope = 'item' AND itc.itemFk = vId); OPEN cTickets; - myLoop: LOOP SET vDone = FALSE; FETCH cTickets INTO vTicketFk; @@ -40,7 +44,8 @@ BEGIN CALL ticket_recalc(vTicketFk, NULL); END LOOP; - CLOSE cTickets; + + DROP TEMPORARY TABLE tItemCalc; END$$ DELIMITER ; From d0f1362f85a534ad7e365f9b33060fc8fb36ee47 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 10:59:05 +0200 Subject: [PATCH 41/74] feat: refs #3199 Requested changes --- db/routines/vn/procedures/ticket_recalcByScope.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index 9199325ee..b872d3163 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -16,16 +16,16 @@ BEGIN DECLARE cTickets CURSOR FOR SELECT DISTINCT t.id FROM ticket t - LEFT JOIN tItemCalc tic ON tic.id = t.id + LEFT JOIN tItems ti ON ti.id = t.id WHERE t.refFk IS NULL AND ((vScope = 'client' AND t.clientFk = vId) OR (vScope = 'address' AND t.addressFk = vId) - OR (vScope = 'item' AND tic.id) + OR (vScope = 'item' AND ti.id) ); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - CREATE OR REPLACE TEMPORARY TABLE tItemCalc + CREATE OR REPLACE TEMPORARY TABLE tItems SELECT DISTINCT t.id FROM ticket t JOIN sale s ON s.ticketFk = t.id @@ -46,6 +46,6 @@ BEGIN END LOOP; CLOSE cTickets; - DROP TEMPORARY TABLE tItemCalc; + DROP TEMPORARY TABLE tItems; END$$ DELIMITER ; From d2bd408e316cb4b593f6711989ed9486123e339d Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 12:59:28 +0200 Subject: [PATCH 42/74] feat: refs #3199 Requested changes --- db/routines/vn/procedures/ticket_recalcByScope.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index b872d3163..ede755187 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -26,6 +26,8 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; CREATE OR REPLACE TEMPORARY TABLE tItems + (PRIMARY KEY (id)) + ENGINE = MEMORY SELECT DISTINCT t.id FROM ticket t JOIN sale s ON s.ticketFk = t.id From 92f01f79d336e175b0c2613d0b05dadf4b5082e1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 13:11:04 +0200 Subject: [PATCH 43/74] feat: refs #7800 Added company Fk --- db/versions/11192-maroonSalal/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11192-maroonSalal/00-firstScript.sql diff --git a/db/versions/11192-maroonSalal/00-firstScript.sql b/db/versions/11192-maroonSalal/00-firstScript.sql new file mode 100644 index 000000000..ac35a3db3 --- /dev/null +++ b/db/versions/11192-maroonSalal/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE hedera.tpvMerchantEnable + MODIFY COLUMN companyFk int(10) unsigned NOT NULL, + ADD CONSTRAINT tpvMerchantEnable_company_FK FOREIGN KEY (companyFk) REFERENCES vn.company(id) ON DELETE RESTRICT ON UPDATE CASCADE; From 2d4acd0f0097bd35f23415a8e796f9a7a2fc5510 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 15:03:34 +0200 Subject: [PATCH 44/74] feat: refs #7784 Changes in entry-order-pdf --- .../reports/entry-order/assets/css/style.css | 14 +++-- .../reports/entry-order/entry-order.html | 58 ++++++++++++------- .../reports/entry-order/entry-order.js | 18 +++--- .../reports/entry-order/locale/es.yml | 6 +- .../reports/entry-order/sql/buys.sql | 33 ++++++----- .../reports/entry-order/sql/entry.sql | 17 +++--- .../reports/entry-order/sql/supplier.sql | 21 ++++--- 7 files changed, 96 insertions(+), 71 deletions(-) diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css index cabdadf9f..767b1185a 100644 --- a/print/templates/reports/entry-order/assets/css/style.css +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -1,14 +1,20 @@ - - h3 { font-weight: 100; color: #555 } - .report-info { font-size: 20px } - .description strong { text-transform: uppercase; +} +.nowrap { + white-space: nowrap; +} +.padding { + padding: 16px; +} +.tags { + font-size: 10px; + margin: 0; } \ 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 ddf0e9b5d..420ccee9b 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -4,23 +4,23 @@
-
+

{{$t('title')}}

+
-

{{$t('title')}}

- + - + - - + +
{{$t('entryId')}}{{$t('entryId')}} {{entry.id}}
{{$t('date')}}{{$t('date')}} {{formatDate(entry.landed,'%d-%m-%Y')}}
{{$t('ref')}}{{entry.invoiceNumber}}{{$t('ref')}}{{entry.invoiceNumber || '---'}}
@@ -38,42 +38,56 @@
- +
+ - + + + + + - + + - + + + + + - - - - - - + + + + + + + + + + + +
{{$t('boxes')}} {{$t('packing')}}{{$t('concept')}}{{$t('concept')}}{{$t('reference')}}{{$t('tags')}} {{$t('quantity')}} {{$t('price')}} {{$t('amount')}}
{{buy.box}}{{buy.stickers}}x {{buy.packing}}{{buy.itemName}}{{buy.itemName}}{{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.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}
- {{buy.tag5}} {{buy.value5}} - {{buy.tag6}} {{buy.value6}} - {{buy.tag7}} {{buy.value7}} -
- {{$t('total')}} - {{getTotal() | currency('EUR', $i18n.locale)}}
{{getTotalBy('stickers')}}{{getTotalBy('quantity') | number($i18n.locale)}}{{getTotalBy('amount') | currency('EUR', $i18n.locale)}}
diff --git a/print/templates/reports/entry-order/entry-order.js b/print/templates/reports/entry-order/entry-order.js index d31ad1a36..56356e068 100755 --- a/print/templates/reports/entry-order/entry-order.js +++ b/print/templates/reports/entry-order/entry-order.js @@ -13,13 +13,17 @@ module.exports = { return {totalBalance: 0.00}; }, methods: { - getTotal() { - let total = 0.00; - this.buys.forEach(buy => { - total += buy.quantity * buy.buyingValue; - }); - - return total; + getTotalBy(property) { + return this.buys.reduce((total, buy) => { + switch (property) { + case 'amount': + return total + buy.quantity * buy.buyingValue; + case 'quantity': + return total + buy.quantity; + case 'stickers': + return total + buy.stickers; + } + }, 0); } }, props: { diff --git a/print/templates/reports/entry-order/locale/es.yml b/print/templates/reports/entry-order/locale/es.yml index 5c633aeaa..5a6716ba1 100644 --- a/print/templates/reports/entry-order/locale/es.yml +++ b/print/templates/reports/entry-order/locale/es.yml @@ -2,7 +2,7 @@ reportName: pedido-de-entrada title: Pedido supplierName: Proveedor supplierStreet: Dirección -entryId: Referencia interna +entryId: Nº Entrada date: Fecha ref: Nº Factura boxes: Cajas @@ -14,4 +14,6 @@ concept: Descripción total: Total entry: Entrada {0} supplierData: Datos del proveedor -notes: Notas \ No newline at end of file +notes: Notas +reference: Referencia +tags: Tags \ No newline at end of file diff --git a/print/templates/reports/entry-order/sql/buys.sql b/print/templates/reports/entry-order/sql/buys.sql index 5bf9f2dfe..b0f414a9d 100644 --- a/print/templates/reports/entry-order/sql/buys.sql +++ b/print/templates/reports/entry-order/sql/buys.sql @@ -1,16 +1,17 @@ -SELECT - b.itemFk, - b.quantity, - b.buyingValue, - b.stickers box, - b.packing, - i.name itemName, - i.tag5, - i.value5, - i.tag6, - i.value6, - i.tag7, - i.value7 -FROM buy b - JOIN item i ON i.id = b.itemFk -WHERE b.entryFk = ? \ No newline at end of file +SELECT b.itemFk, + b.quantity, + b.buyingValue, + b.stickers, + b.packing, + i.name itemName, + IF(i2.id, i2.comment, i.comment) comment, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7 + FROM buy b + JOIN item i ON i.id = b.itemFk + LEFT JOIN item i2 ON i2.id = b.itemOriginalFk + WHERE b.entryFk = ? diff --git a/print/templates/reports/entry-order/sql/entry.sql b/print/templates/reports/entry-order/sql/entry.sql index c30eebca8..2ab599123 100644 --- a/print/templates/reports/entry-order/sql/entry.sql +++ b/print/templates/reports/entry-order/sql/entry.sql @@ -1,9 +1,8 @@ -SELECT - e.id, - e.invoiceNumber, - c.code companyCode, - t.landed -FROM entry e - JOIN travel t ON t.id = e.travelFk - JOIN company c ON c.id = e.companyFk -WHERE e.id = ? +SELECT e.id, + e.invoiceNumber, + c.code companyCode, + t.landed + FROM entry e + JOIN travel t ON t.id = e.travelFk + JOIN company c ON c.id = e.companyFk + WHERE e.id = ? diff --git a/print/templates/reports/entry-order/sql/supplier.sql b/print/templates/reports/entry-order/sql/supplier.sql index 81ed7e883..214f7913f 100644 --- a/print/templates/reports/entry-order/sql/supplier.sql +++ b/print/templates/reports/entry-order/sql/supplier.sql @@ -1,11 +1,10 @@ -SELECT - s.name, - s.street, - s.nif, - s.postCode, - s.city, - p.name province -FROM supplier s - JOIN entry e ON e.supplierFk = s.id - LEFT JOIN province p ON p.id = s.provinceFk -WHERE e.id = ? +SELECT s.name, + s.street, + s.nif, + s.postCode, + s.city, + p.name province + FROM supplier s + JOIN entry e ON e.supplierFk = s.id + LEFT JOIN province p ON p.id = s.provinceFk + WHERE e.id = ? From cf7ee3d990973918ec74325956569e7ea392f870 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 21 Aug 2024 08:05:45 +0200 Subject: [PATCH 45/74] feat: refs #7784 Requested changes --- print/templates/reports/buy-label/sql/buy.sql | 2 +- print/templates/reports/entry-order/entry-order.html | 4 ++-- print/templates/reports/entry-order/sql/buys.sql | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/print/templates/reports/buy-label/sql/buy.sql b/print/templates/reports/buy-label/sql/buy.sql index 72765baa9..26efeb06e 100644 --- a/print/templates/reports/buy-label/sql/buy.sql +++ b/print/templates/reports/buy-label/sql/buy.sql @@ -22,7 +22,7 @@ labels AS ( b.id, b.itemFk, p.name producer, - IF(i2.id, i2.comment, i.comment) comment + IFNULL(i2.comment, i.comment) comment FROM buy b JOIN item i ON i.id = b.itemFk LEFT JOIN producer p ON p.id = i.producerFk diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index 420ccee9b..e5d3bfb6d 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -20,7 +20,7 @@ {{$t('ref')}} - {{entry.invoiceNumber || '---'}} + {{entry.invoiceNumber | dashIfEmpty}} @@ -59,7 +59,7 @@ {{buy.stickers}} x {{buy.packing}} - {{buy.itemName}} + {{buy.name}} {{buy.comment}} {{buy.tag5}} → {{buy.value5}} diff --git a/print/templates/reports/entry-order/sql/buys.sql b/print/templates/reports/entry-order/sql/buys.sql index b0f414a9d..92c055483 100644 --- a/print/templates/reports/entry-order/sql/buys.sql +++ b/print/templates/reports/entry-order/sql/buys.sql @@ -3,8 +3,8 @@ SELECT b.itemFk, b.buyingValue, b.stickers, b.packing, - i.name itemName, - IF(i2.id, i2.comment, i.comment) comment, + i.name, + IFNULL(i2.comment, i.comment) comment, i.tag5, i.value5, i.tag6, From d2709a871c171b723ef02118b1b0a142312bd79c Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 21 Aug 2024 08:29:32 +0200 Subject: [PATCH 46/74] feat: refs #7514 Changes to put srt log --- .../srt/triggers/buffer_afterDelete.sql | 12 ++++++++++++ .../srt/triggers/buffer_beforeInsert.sql | 8 ++++++++ .../srt/triggers/buffer_beforeUpdate.sql | 8 ++++++++ .../srt/triggers/config_afterDelete.sql | 12 ++++++++++++ .../srt/triggers/config_beforeInsert.sql | 8 ++++++++ .../srt/triggers/config_beforeUpdate.sql | 8 ++++++++ .../11193-bronzeAspidistra/00-firstScript.sql | 19 +++++++++++++++++++ .../11193-bronzeAspidistra/01-firstScript.sql | 1 + .../11193-bronzeAspidistra/02-firstScript.sql | 1 + 9 files changed, 77 insertions(+) create mode 100644 db/routines/srt/triggers/buffer_afterDelete.sql create mode 100644 db/routines/srt/triggers/buffer_beforeInsert.sql create mode 100644 db/routines/srt/triggers/buffer_beforeUpdate.sql create mode 100644 db/routines/srt/triggers/config_afterDelete.sql create mode 100644 db/routines/srt/triggers/config_beforeInsert.sql create mode 100644 db/routines/srt/triggers/config_beforeUpdate.sql create mode 100644 db/versions/11193-bronzeAspidistra/00-firstScript.sql create mode 100644 db/versions/11193-bronzeAspidistra/01-firstScript.sql create mode 100644 db/versions/11193-bronzeAspidistra/02-firstScript.sql diff --git a/db/routines/srt/triggers/buffer_afterDelete.sql b/db/routines/srt/triggers/buffer_afterDelete.sql new file mode 100644 index 000000000..d554e6364 --- /dev/null +++ b/db/routines/srt/triggers/buffer_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`buffer_afterDelete` + AFTER DELETE ON `buffer` + FOR EACH ROW +BEGIN + INSERT INTO buffer + SET `action` = 'delete', + `changedModel` = 'Buffer', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/triggers/buffer_beforeInsert.sql b/db/routines/srt/triggers/buffer_beforeInsert.sql new file mode 100644 index 000000000..6b1e05362 --- /dev/null +++ b/db/routines/srt/triggers/buffer_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`buffer_beforeInsert` + BEFORE INSERT ON `buffer` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/triggers/buffer_beforeUpdate.sql b/db/routines/srt/triggers/buffer_beforeUpdate.sql new file mode 100644 index 000000000..86418a551 --- /dev/null +++ b/db/routines/srt/triggers/buffer_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`buffer_beforeUpdate` + BEFORE UPDATE ON `buffer` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/triggers/config_afterDelete.sql b/db/routines/srt/triggers/config_afterDelete.sql new file mode 100644 index 000000000..1e4af9104 --- /dev/null +++ b/db/routines/srt/triggers/config_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`config_afterDelete` + AFTER DELETE ON `config` + FOR EACH ROW +BEGIN + INSERT INTO config + SET `action` = 'delete', + `changedModel` = 'Config', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/triggers/config_beforeInsert.sql b/db/routines/srt/triggers/config_beforeInsert.sql new file mode 100644 index 000000000..7d8389646 --- /dev/null +++ b/db/routines/srt/triggers/config_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`config_beforeInsert` + BEFORE INSERT ON `config` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/triggers/config_beforeUpdate.sql b/db/routines/srt/triggers/config_beforeUpdate.sql new file mode 100644 index 000000000..0002fb4d6 --- /dev/null +++ b/db/routines/srt/triggers/config_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`config_beforeUpdate` + BEFORE UPDATE ON `config` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/versions/11193-bronzeAspidistra/00-firstScript.sql b/db/versions/11193-bronzeAspidistra/00-firstScript.sql new file mode 100644 index 000000000..cc837d007 --- /dev/null +++ b/db/versions/11193-bronzeAspidistra/00-firstScript.sql @@ -0,0 +1,19 @@ +CREATE OR REPLACE TABLE `srt`.`bufferLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('Buffer', 'Config') NOT NULL DEFAULT 'Buffer', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `logBufferUserFk` (`userFk`), + KEY `bufferLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `bufferLog_originFk` (`originFk`,`creationDate`), + CONSTRAINT `bufferUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; diff --git a/db/versions/11193-bronzeAspidistra/01-firstScript.sql b/db/versions/11193-bronzeAspidistra/01-firstScript.sql new file mode 100644 index 000000000..748056f3a --- /dev/null +++ b/db/versions/11193-bronzeAspidistra/01-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE srt.buffer ADD editorFk int(10) unsigned DEFAULT NULL NULL; diff --git a/db/versions/11193-bronzeAspidistra/02-firstScript.sql b/db/versions/11193-bronzeAspidistra/02-firstScript.sql new file mode 100644 index 000000000..36aa938d5 --- /dev/null +++ b/db/versions/11193-bronzeAspidistra/02-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE srt.config ADD editorFk int(10) unsigned DEFAULT NULL NULL; From 62176b8517c83481070681b6b6953bb223262a79 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 21 Aug 2024 09:35:42 +0200 Subject: [PATCH 47/74] feat: refs #7567 Changed time to call event --- db/routines/srt/events/moving_clean.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/srt/events/moving_clean.sql b/db/routines/srt/events/moving_clean.sql index 650c15c62..18644a9f8 100644 --- a/db/routines/srt/events/moving_clean.sql +++ b/db/routines/srt/events/moving_clean.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `srt`.`moving_clean` - ON SCHEDULE EVERY 5 MINUTE + ON SCHEDULE EVERY 15 MINUTE STARTS '2022-01-21 00:00:00.000' ON COMPLETION PRESERVE ENABLE From 29b779d6ab78a14b1e7c55940979f9334996efd6 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 21 Aug 2024 12:03:49 +0200 Subject: [PATCH 48/74] feat: refs #7882 Added quadMindsConfig table --- db/versions/11194-orangeOrchid/00-firstScript.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/versions/11194-orangeOrchid/00-firstScript.sql diff --git a/db/versions/11194-orangeOrchid/00-firstScript.sql b/db/versions/11194-orangeOrchid/00-firstScript.sql new file mode 100644 index 000000000..604f4add8 --- /dev/null +++ b/db/versions/11194-orangeOrchid/00-firstScript.sql @@ -0,0 +1,9 @@ +CREATE TABLE vn.quadMindsConfig ( + id int(10) unsigned NULL, + apiKey varchar(255) DEFAULT NULL NULL, + CONSTRAINT quadMindsConfig_pk PRIMARY KEY (id), + CONSTRAINT quadMindsConfig_check CHECK (id = 1) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; From c641b47a9b859048b0133be5b85005167c657e2a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 21 Aug 2024 12:26:34 +0200 Subject: [PATCH 49/74] feat: refs #7882 Added quadMindsConfig table --- db/versions/11194-orangeOrchid/00-firstScript.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/versions/11194-orangeOrchid/00-firstScript.sql b/db/versions/11194-orangeOrchid/00-firstScript.sql index 604f4add8..bcee0c1fa 100644 --- a/db/versions/11194-orangeOrchid/00-firstScript.sql +++ b/db/versions/11194-orangeOrchid/00-firstScript.sql @@ -1,6 +1,7 @@ -CREATE TABLE vn.quadMindsConfig ( +CREATE TABLE vn.quadMindsApiConfig ( id int(10) unsigned NULL, - apiKey varchar(255) DEFAULT NULL NULL, + `url` varchar(255) DEFAULT NULL NULL, + `key` varchar(255) DEFAULT NULL NULL, CONSTRAINT quadMindsConfig_pk PRIMARY KEY (id), CONSTRAINT quadMindsConfig_check CHECK (id = 1) ) From d63a1c54976d379e2458e0c8900c21221158b08a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 21 Aug 2024 12:28:14 +0200 Subject: [PATCH 50/74] feat: refs #7882 Added quadMindsConfig table --- db/versions/11194-orangeOrchid/00-firstScript.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/versions/11194-orangeOrchid/00-firstScript.sql b/db/versions/11194-orangeOrchid/00-firstScript.sql index bcee0c1fa..59a616edf 100644 --- a/db/versions/11194-orangeOrchid/00-firstScript.sql +++ b/db/versions/11194-orangeOrchid/00-firstScript.sql @@ -1,8 +1,7 @@ CREATE TABLE vn.quadMindsApiConfig ( - id int(10) unsigned NULL, - `url` varchar(255) DEFAULT NULL NULL, + id int(10) unsigned NULL PRIMARY KEY, + `url` varchar(255) DEFAULT NULL NULL, `key` varchar(255) DEFAULT NULL NULL, - CONSTRAINT quadMindsConfig_pk PRIMARY KEY (id), CONSTRAINT quadMindsConfig_check CHECK (id = 1) ) ENGINE=InnoDB From 582fa5faebe80873c8db956b82d693342738a256 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 21 Aug 2024 14:42:03 +0200 Subject: [PATCH 51/74] feat: refs #7567 Requested changes --- db/routines/srt/procedures/moving_clean.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/routines/srt/procedures/moving_clean.sql b/db/routines/srt/procedures/moving_clean.sql index ab16aac99..a5bbc7e70 100644 --- a/db/routines/srt/procedures/moving_clean.sql +++ b/db/routines/srt/procedures/moving_clean.sql @@ -5,13 +5,12 @@ BEGIN * Elimina movimientos por inactividad */ DECLARE vExpeditionFk INT; - DECLARE vBufferToFk INT; DECLARE vBufferFromFk INT; DECLARE vStateOutFk INT DEFAULT (SELECT id FROM expeditionState WHERE `description` = 'OUT'); - DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vDone BOOL; DECLARE vSorter CURSOR FOR - SELECT m.expeditionFk, m.bufferToFk, m.bufferFromFk + SELECT m.expeditionFk, m.bufferFromFk FROM moving m JOIN ( SELECT bufferFk, SUM(isActive) hasBox @@ -32,7 +31,7 @@ BEGIN OPEN vSorter; l: LOOP SET vDone = FALSE; - FETCH vSorter INTO vExpeditionFk, vBufferToFk, vBufferFromFk; + FETCH vSorter INTO vExpeditionFk, vBufferFromFk; IF vDone THEN LEAVE l; From d9d2ae2f7baa400438e64466a2839f48296cae14 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 21 Aug 2024 16:45:46 +0200 Subject: [PATCH 52/74] feat: refs #7758 Add code mandateType and accountDetailType --- db/dump/fixtures.before.sql | 16 ++++++++-------- db/routines/vn2008/views/mandato_tipo.sql | 2 +- .../11191-chocolateBirch/00-firstScript.sql | 2 ++ .../11191-chocolateBirch/01-firstScript.sql | 2 ++ .../11191-chocolateBirch/02-firstScript.sql | 9 +++++++++ modules/client/back/models/client-sample.js | 2 +- modules/client/back/models/mandate-type.json | 2 +- modules/client/front/mandate/index.html | 2 +- modules/client/front/mandate/index.js | 2 +- 9 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 db/versions/11191-chocolateBirch/00-firstScript.sql create mode 100644 db/versions/11191-chocolateBirch/01-firstScript.sql create mode 100644 db/versions/11191-chocolateBirch/02-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 6563292dd..298f84b04 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -412,7 +412,7 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) (1103, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), (1104, -30, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)); -INSERT INTO `vn`.`mandateType`(`id`, `name`) +INSERT INTO `vn`.`mandateType`(`id`, `code`) VALUES (1, 'B2B'), (2, 'CORE'), @@ -3945,11 +3945,11 @@ VALUES (35, 'ES12346B12345679', 3, 241); INSERT INTO vn.accountDetailType -(id, description) +(id, description, code) VALUES - (1, 'IBAN'), - (2, 'SWIFT'), - (3, 'Referencia Remesas'), - (4, 'Referencia Transferencias'), - (5, 'Referencia Nominas'), - (6, 'ABA'); + (1, 'IBAN', 'IBAN'), + (2, 'SWIFT', 'SWIFT'), + (3, 'Referencia Remesas', 'REM'), + (4, 'Referencia Transferencias', 'TRAN'), + (5, 'Referencia Nominas', 'NOM'), + (6, 'ABA', 'ABA'); diff --git a/db/routines/vn2008/views/mandato_tipo.sql b/db/routines/vn2008/views/mandato_tipo.sql index a1b5b0a9f..bc3f74632 100644 --- a/db/routines/vn2008/views/mandato_tipo.sql +++ b/db/routines/vn2008/views/mandato_tipo.sql @@ -2,5 +2,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn2008`.`mandato_tipo` AS SELECT `m`.`id` AS `idmandato_tipo`, - `m`.`name` AS `Nombre` + `m`.`code` AS `Nombre` FROM `vn`.`mandateType` `m` diff --git a/db/versions/11191-chocolateBirch/00-firstScript.sql b/db/versions/11191-chocolateBirch/00-firstScript.sql new file mode 100644 index 000000000..929de87fe --- /dev/null +++ b/db/versions/11191-chocolateBirch/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.mandateType + CHANGE name code VARCHAR(45) DEFAULT NULL; \ No newline at end of file diff --git a/db/versions/11191-chocolateBirch/01-firstScript.sql b/db/versions/11191-chocolateBirch/01-firstScript.sql new file mode 100644 index 000000000..168eaef84 --- /dev/null +++ b/db/versions/11191-chocolateBirch/01-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.accountDetailType + ADD COLUMN code VARCHAR(45) DEFAULT NULL; \ No newline at end of file diff --git a/db/versions/11191-chocolateBirch/02-firstScript.sql b/db/versions/11191-chocolateBirch/02-firstScript.sql new file mode 100644 index 000000000..53b7317b6 --- /dev/null +++ b/db/versions/11191-chocolateBirch/02-firstScript.sql @@ -0,0 +1,9 @@ +UPDATE vn.accountDetailType + SET code = CASE id + WHEN 1 THEN 'IBAN' + WHEN 2 THEN 'SWIFT' + WHEN 3 THEN 'REM' + WHEN 4 THEN 'TRAN' + WHEN 5 THEN 'NOM' + WHEN 6 THEN 'ABA' + END; \ No newline at end of file diff --git a/modules/client/back/models/client-sample.js b/modules/client/back/models/client-sample.js index 5e4393042..b8ab6cff4 100644 --- a/modules/client/back/models/client-sample.js +++ b/modules/client/back/models/client-sample.js @@ -27,7 +27,7 @@ module.exports = Self => { // Renew mandate if (mandate) { const mandateType = await models.MandateType.findOne({ - where: {name: mandate.type} + where: {code: mandate.type} }); const oldMandate = await models.Mandate.findOne({ diff --git a/modules/client/back/models/mandate-type.json b/modules/client/back/models/mandate-type.json index ec189f089..b481e7c72 100644 --- a/modules/client/back/models/mandate-type.json +++ b/modules/client/back/models/mandate-type.json @@ -12,7 +12,7 @@ "type": "number", "description": "Identifier" }, - "name": { + "code": { "type": "string" } } diff --git a/modules/client/front/mandate/index.html b/modules/client/front/mandate/index.html index e2f2cd27b..1ee18737f 100644 --- a/modules/client/front/mandate/index.html +++ b/modules/client/front/mandate/index.html @@ -26,7 +26,7 @@ {{::mandate.id}} {{::mandate.company.code}} - {{::mandate.mandateType.name}} + {{::mandate.mandateType.code}} {{::mandate.created | date:'dd/MM/yyyy HH:mm' | dashIfEmpty}} {{::mandate.finished | date:'dd/MM/yyyy HH:mm' | dashIfEmpty}} diff --git a/modules/client/front/mandate/index.js b/modules/client/front/mandate/index.js index 114e2b570..605ae08cc 100644 --- a/modules/client/front/mandate/index.js +++ b/modules/client/front/mandate/index.js @@ -9,7 +9,7 @@ class Controller extends Section { { relation: 'mandateType', scope: { - fields: ['id', 'name'] + fields: ['id', 'code'] } }, { relation: 'company', From 7c545a379f00bc482aee197fdf8969584ab8ba4e Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 22 Aug 2024 17:02:59 +0200 Subject: [PATCH 53/74] feat: refs #7862 roadmap new fields --- db/routines/vn/triggers/roadmap_beforeInsert.sql | 12 ++++++++++++ db/routines/vn/triggers/roadmap_beforeUpdate.sql | 12 ++++++++++++ db/versions/11195-salmonPalmetto/00-firstScript.sql | 6 ++++++ 3 files changed, 30 insertions(+) create mode 100644 db/routines/vn/triggers/roadmap_beforeInsert.sql create mode 100644 db/routines/vn/triggers/roadmap_beforeUpdate.sql create mode 100644 db/versions/11195-salmonPalmetto/00-firstScript.sql diff --git a/db/routines/vn/triggers/roadmap_beforeInsert.sql b/db/routines/vn/triggers/roadmap_beforeInsert.sql new file mode 100644 index 000000000..df07d5540 --- /dev/null +++ b/db/routines/vn/triggers/roadmap_beforeInsert.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`roadmap_beforeInsert` + BEFORE INSERT ON `roadmap` + FOR EACH ROW +BEGIN + IF NEW.driver1Fk IS NOT NULL THEN + SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk); + ELSE + SET NEW.driverName = NULL; + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/roadmap_beforeUpdate.sql b/db/routines/vn/triggers/roadmap_beforeUpdate.sql new file mode 100644 index 000000000..4905a0442 --- /dev/null +++ b/db/routines/vn/triggers/roadmap_beforeUpdate.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`roadmap_beforeUpdate` + BEFORE UPDATE ON `roadmap` + FOR EACH ROW +BEGIN + IF NEW.driver1Fk IS NOT NULL THEN + SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk); + ELSE + SET NEW.driverName = NULL; + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/versions/11195-salmonPalmetto/00-firstScript.sql b/db/versions/11195-salmonPalmetto/00-firstScript.sql new file mode 100644 index 000000000..980b66c8d --- /dev/null +++ b/db/versions/11195-salmonPalmetto/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.roadmap + ADD COLUMN m3 INT UNSIGNED NULL, + ADD COLUMN driver2Fk INT UNSIGNED NULL, + ADD COLUMN driver1Fk INT UNSIGNED NULL, + ADD CONSTRAINT roadmap_worker_FK FOREIGN KEY (driver1Fk) REFERENCES vn.worker(id) ON DELETE RESTRICT ON UPDATE CASCADE, + ADD CONSTRAINT roadmap_worker_FK_2 FOREIGN KEY (driver2Fk) REFERENCES vn.worker(id) ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file From 340515968b44cecbc4fb4d9a6dde1c6d4048de5c Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 23 Aug 2024 10:57:35 +0200 Subject: [PATCH 54/74] feat: refs #7710 test fixed --- .../back/methods/invoiceOut/refund.js | 2 +- .../methods/invoiceOut/transferInvoice.js | 14 +--- .../front/descriptor-menu/index.html | 23 +----- .../invoiceOut/front/descriptor-menu/index.js | 15 ---- .../front/descriptor-menu/index.spec.js | 13 --- modules/ticket/back/methods/sale/clone.js | 72 ++++++++--------- .../back/methods/sale/specs/clone.spec.js | 8 +- modules/ticket/back/methods/ticket/clone.js | 54 ------------- .../ticket/back/methods/ticket/cloneAll.js | 80 +++++++++++++++++++ modules/ticket/back/methods/ticket/refund.js | 58 -------------- .../back/methods/ticket/specs/clone.spec.js | 43 ---------- .../methods/ticket/specs/cloneAll.spec.js | 53 ++++++++++++ modules/ticket/back/models/ticket-methods.js | 3 +- modules/ticket/front/descriptor-menu/index.js | 15 +++- .../front/descriptor-menu/index.spec.js | 18 ----- 15 files changed, 190 insertions(+), 281 deletions(-) delete mode 100644 modules/ticket/back/methods/ticket/clone.js create mode 100644 modules/ticket/back/methods/ticket/cloneAll.js delete mode 100644 modules/ticket/back/methods/ticket/refund.js delete mode 100644 modules/ticket/back/methods/ticket/specs/clone.spec.js create mode 100644 modules/ticket/back/methods/ticket/specs/cloneAll.spec.js diff --git a/modules/invoiceOut/back/methods/invoiceOut/refund.js b/modules/invoiceOut/back/methods/invoiceOut/refund.js index 1b7ccc1e4..4f43a7a84 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/refund.js +++ b/modules/invoiceOut/back/methods/invoiceOut/refund.js @@ -43,7 +43,7 @@ module.exports = Self => { const tickets = await models.Ticket.find(filter, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); - const refundedTickets = await models.Ticket.refund(ctx, ticketsIds, withWarehouse, myOptions); + const refundedTickets = await models.Ticket.cloneAll(ctx, ticketsIds, withWarehouse, true, myOptions); if (tx) await tx.commit(); diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js index 0c86e5810..220695fc9 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js @@ -82,20 +82,12 @@ module.exports = Self => { myOptions.transaction = tx; } try { - const filterRef = {where: {refFk: refFk}}; - const tickets = await models.Ticket.find(filterRef, myOptions); + const tickets = await models.Ticket.find({where: {refFk: refFk}}, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); - const refundTickets = await models.Ticket.refund(ctx, ticketsIds, null, myOptions); + const refundTickets = await models.Ticket.cloneAll(ctx, ticketsIds, false, true, myOptions); - const filterTicket = {where: {ticketFk: {inq: ticketsIds}}}; + const clonedTickets = await models.Ticket.cloneAll(ctx, ticketsIds, false, false, myOptions); - const services = await models.TicketService.find(filterTicket, myOptions); - const servicesIds = services.map(service => service.id); - - const sales = await models.Sale.find(filterTicket, myOptions); - const salesIds = sales.map(sale => sale.id); - - const clonedTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, false, myOptions); const clonedTicketIds = []; for (const clonedTicket of clonedTickets) { diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index da04c8e72..335ab87cc 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -88,28 +88,7 @@ translate> Show CITES letter - - Refund... - - - - with warehouse - - - without warehouse - - - - + { - const tickets = res.data; - const refundTickets = tickets.map(ticket => ticket.id); - - this.vnApp.showSuccess(this.$t('The following refund tickets have been created', { - ticketId: refundTickets.join(',') - })); - if (refundTickets.length == 1) - this.$state.go('ticket.card.sale', {id: refundTickets[0]}); - }); - } - transferInvoice() { const params = { id: this.invoiceOut.id, diff --git a/modules/invoiceOut/front/descriptor-menu/index.spec.js b/modules/invoiceOut/front/descriptor-menu/index.spec.js index d2ccfa117..a22ca7c2a 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.spec.js +++ b/modules/invoiceOut/front/descriptor-menu/index.spec.js @@ -105,17 +105,4 @@ describe('vnInvoiceOutDescriptorMenu', () => { expect(controller.vnApp.showMessage).toHaveBeenCalled(); }); }); - - describe('refundInvoiceOut()', () => { - it('should make a query and show a success message', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - const params = {ref: controller.invoiceOut.ref}; - - $httpBackend.expectPOST(`InvoiceOuts/refund`, params).respond([{id: 1}, {id: 2}]); - controller.refundInvoiceOut(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); }); diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index 9185a6e75..24346f3ba 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -1,40 +1,25 @@ module.exports = Self => { Self.remoteMethodCtx('clone', { - description: 'Clone sales and services provided', + description: 'Clone sales, services, and ticket packaging provided', accessType: 'WRITE', accepts: [ - { - arg: 'salesIds', - type: ['number'], - }, { - arg: 'servicesIds', - type: ['number'] - }, { - arg: 'withWarehouse', - type: 'boolean', - required: true - }, { - arg: 'negative', - type: 'boolean' - } + {arg: 'salesIds', type: ['number']}, + {arg: 'servicesIds', type: ['number']}, + {arg: 'ticketPackagingIds', type: ['number']}, + {arg: 'withWarehouse', type: 'boolean', required: true}, + {arg: 'negative', type: 'boolean'} ], - returns: { - type: ['object'], - root: true - }, - http: { - path: `/clone`, - verb: 'POST' - } + returns: {type: ['object'], root: true}, + http: {path: `/clone`, verb: 'POST'} }); - Self.clone = async(ctx, salesIds, servicesIds, withWarehouse, negative, options) => { + + Self.clone = async(ctx, salesIds, servicesIds, ticketPackagingIds, withWarehouse, negative, options) => { const models = Self.app.models; const myOptions = {}; let tx; const newTickets = []; - if (typeof options == 'object') - Object.assign(myOptions, options); + if (typeof options === 'object') Object.assign(myOptions, options); if (!myOptions.transaction) { tx = await Self.beginTransaction({}); @@ -44,8 +29,9 @@ module.exports = Self => { try { let sales; let services; + let ticketPackaging; - if (salesIds && salesIds.length) { + if (salesIds?.length) { sales = await models.Sale.find({ where: {id: {inq: salesIds}}, include: { @@ -57,12 +43,18 @@ module.exports = Self => { }, myOptions); } - if (servicesIds && servicesIds.length) { + if (servicesIds?.length) { services = await models.TicketService.find({ where: {id: {inq: servicesIds}} }, myOptions); } + if (ticketPackagingIds?.length) { + ticketPackaging = await models.TicketPackaging.find({ + where: {id: {inq: ticketPackagingIds}} + }, myOptions); + } + let ticketsIds = sales ? [...new Set(sales.map(sale => sale.ticketFk))] : [...new Set(services.map(service => service.ticketFk))]; @@ -74,12 +66,12 @@ module.exports = Self => { ctx, ticketId, withWarehouse, - negative, myOptions ); newTickets.push(newTicket); mappedTickets.set(ticketId, newTicket.id); } + if (sales) { for (const sale of sales) { const newTicketId = mappedTickets.get(sale.ticketFk); @@ -107,7 +99,7 @@ module.exports = Self => { await models.TicketService.create({ description: service.description, - quantity: negative ? - service.quantity : service.quantity, + quantity: negative ? -service.quantity : service.quantity, price: service.price, taxClassFk: service.taxClassFk, ticketFk: newTicketId, @@ -116,6 +108,18 @@ module.exports = Self => { } } + if (ticketPackaging) { + for (const packaging of ticketPackaging) { + const newTicketId = mappedTickets.get(packaging.ticketFk); + + await models.TicketPackaging.create({ + ticketFk: newTicketId, + packagingFk: packaging.packagingFk, + quantity: negative ? -packaging.quantity : packaging.quantity + }, myOptions); + } + } + if (tx) await tx.commit(); return newTickets; @@ -124,13 +128,7 @@ module.exports = Self => { throw e; } - async function createTicket( - ctx, - ticketId, - withWarehouse, - negative, - myOptions - ) { + async function createTicket(ctx, ticketId, withWarehouse, myOptions) { const models = Self.app.models; const now = Date.vnNew(); diff --git a/modules/ticket/back/methods/sale/specs/clone.spec.js b/modules/ticket/back/methods/sale/specs/clone.spec.js index 5b0dc84a7..1738cc08c 100644 --- a/modules/ticket/back/methods/sale/specs/clone.spec.js +++ b/modules/ticket/back/methods/sale/specs/clone.spec.js @@ -20,7 +20,7 @@ describe('Ticket cloning - clone function', () => { const servicesIds = []; const withWarehouse = true; const negative = false; - const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, withWarehouse, negative, options); + const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, withWarehouse, negative, options); expect(newTickets).toBeDefined(); expect(newTickets.length).toBeGreaterThan(0); @@ -30,7 +30,7 @@ describe('Ticket cloning - clone function', () => { const negative = true; const salesIds = [7, 8]; const servicesIds = []; - const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, false, negative, options); + const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, false, negative, options); for (const ticket of newTickets) { const sales = await models.Sale.find({where: {ticketFk: ticket.id}}, options); @@ -43,7 +43,7 @@ describe('Ticket cloning - clone function', () => { it('should create new components and services for cloned tickets', async() => { const servicesIds = [2]; const salesIds = [5]; - const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, false, false, options); + const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, false, false, options); for (const ticket of newTickets) { const sale = await models.Sale.findOne({where: {ticketFk: ticket.id}}, options); @@ -58,7 +58,7 @@ describe('Ticket cloning - clone function', () => { it('should create a ticket without sales', async() => { const servicesIds = [4]; - const tickets = await models.Sale.clone(ctx, null, servicesIds, false, false, options); + const tickets = await models.Sale.clone(ctx, null, servicesIds, null, false, false, options); const refundedTicket = await getTicketRefund(tickets[0].id, options); expect(refundedTicket).toBeDefined(); diff --git a/modules/ticket/back/methods/ticket/clone.js b/modules/ticket/back/methods/ticket/clone.js deleted file mode 100644 index 93bc2a94e..000000000 --- a/modules/ticket/back/methods/ticket/clone.js +++ /dev/null @@ -1,54 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('clone', { - description: 'clone a ticket and return the new ticket id', - accessType: 'WRITE', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'The ticket id', - http: {source: 'path'} - }, { - arg: 'shipped', - type: 'date', - }, { - arg: 'withWarehouse', - type: 'boolean', - } - ], - returns: { - type: 'number', - root: true - }, - http: { - path: `/:id/clone`, - verb: 'POST' - } - }); - - Self.clone = async(ctx, id, shipped, withWarehouse, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const [, [{clonedTicketId}]] = await Self.rawSql(` - CALL vn.ticket_cloneAll(?, ?, ?, @clonedTicketId); - SELECT @clonedTicketId clonedTicketId;`, - [id, shipped, withWarehouse], myOptions); - - if (tx) await tx.commit(); - return clonedTicketId; - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/ticket/back/methods/ticket/cloneAll.js b/modules/ticket/back/methods/ticket/cloneAll.js new file mode 100644 index 000000000..cc3672083 --- /dev/null +++ b/modules/ticket/back/methods/ticket/cloneAll.js @@ -0,0 +1,80 @@ +module.exports = Self => { + Self.remoteMethodCtx('cloneAll', { + description: 'Clone tickets, sales, services and packages', + accessType: 'WRITE', + accepts: [ + { + arg: 'ticketsIds', + type: ['number'], + required: true, + description: 'IDs of the tickets to clone' + }, + { + arg: 'withWarehouse', + type: 'boolean', + required: true, + description: 'true: keep original warehouse; false: set to null' + }, + { + arg: 'negative', + type: 'boolean', + required: true, + description: 'Whether to invert quantities (for credit notes)' + } + ], + returns: { + type: ['object'], + root: true, + description: 'The cloned tickets with associated data' + }, + http: { + path: `/cloneAll`, + verb: 'POST' + } + }); + + Self.cloneAll = async(ctx, ticketsIds, withWarehouse, negative, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const filter = {where: {ticketFk: {inq: ticketsIds}}}; + + const [sales, services, ticketPackaging] = await Promise.all([ + models.Sale.find(filter, myOptions), + models.TicketService.find(filter, myOptions), + models.TicketPackaging.find(filter, myOptions) + ]); + + const salesIds = sales.map(sale => sale.id); + const servicesIds = services.map(service => service.id); + const ticketPackagingIds = ticketPackaging.map(packaging => packaging.id); + + const clonedTickets = await models.Sale.clone( + ctx, + salesIds, + servicesIds, + ticketPackagingIds, + withWarehouse, + negative, + myOptions + ); + + if (tx) await tx.commit(); + + return clonedTickets; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/methods/ticket/refund.js b/modules/ticket/back/methods/ticket/refund.js deleted file mode 100644 index 7365f34df..000000000 --- a/modules/ticket/back/methods/ticket/refund.js +++ /dev/null @@ -1,58 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('refund', { - description: 'Create refund tickets with all their sales and services', - accessType: 'WRITE', - accepts: [ - { - arg: 'ticketsIds', - type: ['number'], - required: true - }, - { - arg: 'withWarehouse', - type: 'boolean', - required: true - } - ], - returns: { - type: ['object'], - root: true - }, - http: { - path: `/refund`, - verb: 'POST' - } - }); - - Self.refund = async(ctx, ticketsIds, withWarehouse, options) => { - const models = Self.app.models; - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const filter = {where: {ticketFk: {inq: ticketsIds}}}; - const sales = await models.Sale.find(filter, myOptions); - const salesIds = sales.map(sale => sale.id); - - const services = await models.TicketService.find(filter, myOptions); - const servicesIds = services.map(service => service.id); - - const refundedTickets = await models.Sale.clone(ctx, salesIds, servicesIds, withWarehouse, true, myOptions); - - if (tx) await tx.commit(); - - return refundedTickets; - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/ticket/back/methods/ticket/specs/clone.spec.js b/modules/ticket/back/methods/ticket/specs/clone.spec.js deleted file mode 100644 index ccc0dcdf3..000000000 --- a/modules/ticket/back/methods/ticket/specs/clone.spec.js +++ /dev/null @@ -1,43 +0,0 @@ -const models = require('vn-loopback/server/server').models; - -describe('Ticket cloning - clone function', () => { - const ctx = beforeAll.getCtx(); - let options; - let tx; - const ticketId = 1; - const shipped = Date.vnNew(); - - beforeEach(async() => { - options = {transaction: tx}; - tx = await models.Ticket.beginTransaction({}); - options.transaction = tx; - }); - - afterEach(async() => { - await tx.rollback(); - }); - - it('should clone a new ticket without warehouse', async() => { - const originalTicket = await models.Ticket.findById(ticketId, null, options); - - const newTicketId = await models.Ticket.clone(ctx, ticketId, shipped, false, options); - const newTicket = await models.Ticket.findById(newTicketId, null, options); - - expect(newTicket.clientFk).toEqual(originalTicket.clientFk); - expect(newTicket.companyFk).toEqual(originalTicket.companyFk); - expect(newTicket.addressFk).toEqual(originalTicket.addressFk); - expect(newTicket.warehouseFk).toBeFalsy(); - }); - - it('should clone a new ticket with warehouse', async() => { - const originalTicket = await models.Ticket.findById(ticketId, null, options); - - const newTicketId = await models.Ticket.clone(ctx, ticketId, shipped, true, options); - const newTicket = await models.Ticket.findById(newTicketId, null, options); - - expect(newTicket.clientFk).toEqual(originalTicket.clientFk); - expect(newTicket.companyFk).toEqual(originalTicket.companyFk); - expect(newTicket.addressFk).toEqual(originalTicket.addressFk); - expect(newTicket.warehouseFk).toEqual(originalTicket.warehouseFk); - }); -}); diff --git a/modules/ticket/back/methods/ticket/specs/cloneAll.spec.js b/modules/ticket/back/methods/ticket/specs/cloneAll.spec.js new file mode 100644 index 000000000..4788df2c2 --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/cloneAll.spec.js @@ -0,0 +1,53 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +describe('Ticket cloning - cloneAll function', () => { + const activeCtx = { + accessToken: {userId: 1}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + const ctx = {req: activeCtx}; + let options; + let tx; + const ticketIds = [1, 2]; + const withWarehouse = true; + const negative = false; + + beforeEach(async() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req}); + tx = await models.Ticket.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + if (tx) + await tx.rollback(); + }); + + it('should clone all provided tickets with their associated sales, services, and packages', async() => { + const originalTickets = await models.Ticket.find({where: {id: {inq: ticketIds}}}, options); + const originalSales = await models.Sale.find({where: {ticketFk: {inq: ticketIds}}}, options); + const originalServices = await models.TicketService.find({where: {ticketFk: {inq: ticketIds}}}, options); + const originalTicketPackaging = + await models.TicketPackaging.find({where: {ticketFk: {inq: ticketIds}}}, options); + + // Pass the ctx correctly to the cloneAll function + const clonedTickets = await models.Ticket.cloneAll(ctx, ticketIds, withWarehouse, negative, options); + + expect(clonedTickets.length).toEqual(originalTickets.length); + + const clonedSales = await models.Sale.find({where: {ticketFk: {inq: clonedTickets.map(t => t.id)}}}, options); + const clonedServices = + await models.TicketService.find({where: {ticketFk: {inq: clonedTickets.map(t => t.id)}}}, options); + const clonedTicketPackaging = + await models.TicketPackaging.find({where: {ticketFk: {inq: clonedTickets.map(t => t.id)}}}, options); + + expect(clonedSales.length).toEqual(originalSales.length); + expect(clonedServices.length).toEqual(originalServices.length); + expect(clonedTicketPackaging.length).toEqual(originalTicketPackaging.length); + }); +}); diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 5582dde5c..462862cb3 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -26,7 +26,7 @@ module.exports = function(Self) { require('../methods/ticket/isLocked')(Self); require('../methods/ticket/freightCost')(Self); require('../methods/ticket/getComponentsSum')(Self); - require('../methods/ticket/refund')(Self); + require('../methods/ticket/cloneAll')(Self); require('../methods/ticket/deliveryNotePdf')(Self); require('../methods/ticket/deliveryNoteEmail')(Self); require('../methods/ticket/deliveryNoteCsv')(Self); @@ -46,5 +46,4 @@ module.exports = function(Self) { require('../methods/ticket/invoiceTicketsAndPdf')(Self); require('../methods/ticket/docuwareDownload')(Self); require('../methods/ticket/myLastModified')(Self); - require('../methods/ticket/clone')(Self); }; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 32f245454..93948def2 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -287,15 +287,24 @@ class Controller extends Section { } refund(withWarehouse) { - const params = {ticketsIds: [this.id], withWarehouse: withWarehouse}; - const query = 'Tickets/refund'; + const params = { + ticketsIds: [this.id], + withWarehouse: withWarehouse, + negative: true // Asumimos que queremos cantidades negativas para reembolsos + }; + const query = 'Tickets/cloneAll'; return this.$http.post(query, params) .then(res => { const [refundTicket] = res.data; - this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { + this.vnApp.showSuccess(this.$t('The following refund ticket has been created', { ticketId: refundTicket.id })); this.$state.go('ticket.card.sale', {id: refundTicket.id}); + }) + .catch(error => { + this.vnApp.showError(this.$t('Error creating refund ticket', { + error: error.data?.error?.message || 'Unknown error' + })); }); } diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 94a991db8..cffbad62e 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -217,24 +217,6 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { }); }); - describe('refund()', () => { - it('should make a query and go to ticket.card.sale', () => { - controller.$state.go = jest.fn(); - - controller._id = ticket.id; - - const params = { - ticketsIds: [16] - }; - const response = {id: 99}; - $httpBackend.expectPOST('Tickets/refund', params).respond([response]); - controller.refund(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', response); - }); - }); - describe('sendChangesSms()', () => { it('should make a query and open the sms dialog', () => { controller.$.sms = {open: () => {}}; From 94461cff58812ea8fe38c73b40c1d7a8eff53fab Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 23 Aug 2024 11:34:26 +0200 Subject: [PATCH 55/74] feat: refs #7758 Modify code lowerCamelCase and UNIQUE --- db/dump/fixtures.before.sql | 12 ++++++------ .../11191-chocolateBirch/00-firstScript.sql | 3 ++- .../11191-chocolateBirch/01-firstScript.sql | 3 ++- .../11191-chocolateBirch/02-firstScript.sql | 14 +++++++------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 7ed2b9b7c..4533b67af 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3947,9 +3947,9 @@ VALUES INSERT INTO vn.accountDetailType (id, description, code) VALUES - (1, 'IBAN', 'IBAN'), - (2, 'SWIFT', 'SWIFT'), - (3, 'Referencia Remesas', 'REM'), - (4, 'Referencia Transferencias', 'TRAN'), - (5, 'Referencia Nominas', 'NOM'), - (6, 'ABA', 'ABA'); + (1, 'IBAN', 'iban'), + (2, 'SWIFT', 'swift'), + (3, 'Referencia Remesas', 'remRef'), + (4, 'Referencia Transferencias', 'trnRef'), + (5, 'Referencia Nominas', 'payRef'), + (6, 'ABA', 'aba'); diff --git a/db/versions/11191-chocolateBirch/00-firstScript.sql b/db/versions/11191-chocolateBirch/00-firstScript.sql index 929de87fe..4c9924a42 100644 --- a/db/versions/11191-chocolateBirch/00-firstScript.sql +++ b/db/versions/11191-chocolateBirch/00-firstScript.sql @@ -1,2 +1,3 @@ ALTER TABLE vn.mandateType - CHANGE name code VARCHAR(45) DEFAULT NULL; \ No newline at end of file + CHANGE name code VARCHAR(45) NOT NULL, + ADD UNIQUE (code); \ No newline at end of file diff --git a/db/versions/11191-chocolateBirch/01-firstScript.sql b/db/versions/11191-chocolateBirch/01-firstScript.sql index 168eaef84..50b27fdbd 100644 --- a/db/versions/11191-chocolateBirch/01-firstScript.sql +++ b/db/versions/11191-chocolateBirch/01-firstScript.sql @@ -1,2 +1,3 @@ ALTER TABLE vn.accountDetailType - ADD COLUMN code VARCHAR(45) DEFAULT NULL; \ No newline at end of file + ADD COLUMN code VARCHAR(45) NOT NULL, + ADD UNIQUE (code); \ No newline at end of file diff --git a/db/versions/11191-chocolateBirch/02-firstScript.sql b/db/versions/11191-chocolateBirch/02-firstScript.sql index 53b7317b6..733cffd63 100644 --- a/db/versions/11191-chocolateBirch/02-firstScript.sql +++ b/db/versions/11191-chocolateBirch/02-firstScript.sql @@ -1,9 +1,9 @@ UPDATE vn.accountDetailType - SET code = CASE id - WHEN 1 THEN 'IBAN' - WHEN 2 THEN 'SWIFT' - WHEN 3 THEN 'REM' - WHEN 4 THEN 'TRAN' - WHEN 5 THEN 'NOM' - WHEN 6 THEN 'ABA' + SET code = CASE description + WHEN 'IBAN' THEN 'iban' + WHEN 'SWIFT' THEN 'swift' + WHEN 'Referencia Remesas' THEN 'remRef' + WHEN 'Referencia Transferencias' THEN 'trnRef' + WHEN 'Referencia Nominas' THEN 'payRef' + WHEN 'ABA' THEN 'aba' END; \ No newline at end of file From c5210157b1aef53fd30d2407ad61412ca446aa74 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 23 Aug 2024 13:55:51 +0200 Subject: [PATCH 56/74] feat: refs #7758 accountDetailType fix deploy error --- db/versions/11191-chocolateBirch/01-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11191-chocolateBirch/01-firstScript.sql b/db/versions/11191-chocolateBirch/01-firstScript.sql index 50b27fdbd..c69e92d51 100644 --- a/db/versions/11191-chocolateBirch/01-firstScript.sql +++ b/db/versions/11191-chocolateBirch/01-firstScript.sql @@ -1,3 +1,3 @@ ALTER TABLE vn.accountDetailType - ADD COLUMN code VARCHAR(45) NOT NULL, + ADD COLUMN code VARCHAR(45), ADD UNIQUE (code); \ No newline at end of file From 32d36cda21edc883c3260ce4b1c78791440a0133 Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 23 Aug 2024 14:28:25 +0200 Subject: [PATCH 57/74] feat: refs #7710 pr revision --- .../11197-aquaSalal/00-firstScript.sql | 24 +++++++++++++++++++ .../methods/invoiceOut/transferInvoice.js | 2 +- .../ticket/back/methods/ticket/cloneAll.js | 13 ++++------ 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 db/versions/11197-aquaSalal/00-firstScript.sql diff --git a/db/versions/11197-aquaSalal/00-firstScript.sql b/db/versions/11197-aquaSalal/00-firstScript.sql new file mode 100644 index 000000000..f07368d3e --- /dev/null +++ b/db/versions/11197-aquaSalal/00-firstScript.sql @@ -0,0 +1,24 @@ +DELETE FROM `salix`.`ACL` + WHERE `model` = 'Ticket' + AND `property` = 'refund' + AND `accessType` = 'WRITE' + AND `permission` = 'ALLOW' + AND `principalType` = 'ROLE' + AND `principalId` = 'salesAssistant'; + +UPDATE `salix`.`ACL` + SET `property` = 'cloneAll' + WHERE `model` = 'Ticket' + AND `property` = 'refund' + AND `accessType` = 'WRITE' + AND `permission` = 'ALLOW' + AND `principalType` = 'ROLE' + AND `principalId` IN ('invoicing', 'claimManager', 'logistic'); + +DELETE FROM `salix`.`ACL` + WHERE `model` = 'Ticket' + AND `property` = 'clone' + AND `accessType` = 'WRITE' + AND `permission` = 'ALLOW' + AND `principalType` = 'ROLE' + AND `principalId` = 'administrative'; diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js index 220695fc9..c31f381d9 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js @@ -82,7 +82,7 @@ module.exports = Self => { myOptions.transaction = tx; } try { - const tickets = await models.Ticket.find({where: {refFk: refFk}}, myOptions); + const tickets = await models.Ticket.find({where: {refFk}}, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); const refundTickets = await models.Ticket.cloneAll(ctx, ticketsIds, false, true, myOptions); diff --git a/modules/ticket/back/methods/ticket/cloneAll.js b/modules/ticket/back/methods/ticket/cloneAll.js index cc3672083..cf99a7edc 100644 --- a/modules/ticket/back/methods/ticket/cloneAll.js +++ b/modules/ticket/back/methods/ticket/cloneAll.js @@ -19,7 +19,7 @@ module.exports = Self => { arg: 'negative', type: 'boolean', required: true, - description: 'Whether to invert quantities (for credit notes)' + description: 'true: invert quantities; false: keep as is.' } ], returns: { @@ -35,12 +35,9 @@ module.exports = Self => { Self.cloneAll = async(ctx, ticketsIds, withWarehouse, negative, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = typeof options == 'object' ? {...options} : {}; let tx; - if (typeof options == 'object') - Object.assign(myOptions, options); - if (!myOptions.transaction) { tx = await Self.beginTransaction({}); myOptions.transaction = tx; @@ -55,9 +52,9 @@ module.exports = Self => { models.TicketPackaging.find(filter, myOptions) ]); - const salesIds = sales.map(sale => sale.id); - const servicesIds = services.map(service => service.id); - const ticketPackagingIds = ticketPackaging.map(packaging => packaging.id); + const salesIds = sales.map(({id}) => id); + const servicesIds = services.map(({id}) => id); + const ticketPackagingIds = ticketPackaging.map(({id}) => id); const clonedTickets = await models.Sale.clone( ctx, From aaf95e3cff648e74eea6cc80b60e435e62c561af Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 26 Aug 2024 14:39:30 +0200 Subject: [PATCH 58/74] fix: refs #7756 id 0 --- db/versions/11172-blueFern/10-firstScript.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/versions/11172-blueFern/10-firstScript.sql b/db/versions/11172-blueFern/10-firstScript.sql index 5d34f1025..47ddaff14 100644 --- a/db/versions/11172-blueFern/10-firstScript.sql +++ b/db/versions/11172-blueFern/10-firstScript.sql @@ -1 +1,5 @@ -ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL; \ No newline at end of file +UPDATE vn.invoiceOut + SET id = (SELECT MAX(id) + 1 FROM vn.invoiceOut) + WHERE id = 0; + +ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL; From ef26d7f437ba42ced41cab64f14224f9603cb669 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 27 Aug 2024 06:05:39 +0000 Subject: [PATCH 59/74] fix(salix): #7283 ItemFixedPrice duplicated --- modules/item/back/methods/fixed-price/filter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/item/back/methods/fixed-price/filter.js b/modules/item/back/methods/fixed-price/filter.js index 9c91886c1..edc804dc4 100644 --- a/modules/item/back/methods/fixed-price/filter.js +++ b/modules/item/back/methods/fixed-price/filter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; @@ -134,7 +133,7 @@ module.exports = Self => { const stmts = []; const stmt = new ParameterizedSQL(` - SELECT fp.id, + SELECT DISTINCT fp.id, fp.itemFk, fp.warehouseFk, fp.rate2, From ce2058ec8b06356b2236de72e2feb180c453962a Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 27 Aug 2024 08:36:14 +0200 Subject: [PATCH 60/74] version --- db/versions/11200-brownDendro/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/11200-brownDendro/00-firstScript.sql diff --git a/db/versions/11200-brownDendro/00-firstScript.sql b/db/versions/11200-brownDendro/00-firstScript.sql new file mode 100644 index 000000000..943368b06 --- /dev/null +++ b/db/versions/11200-brownDendro/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +ALTER TABLE vn.saleGroup ADD stateFk TINYINT(3) UNSIGNED; + +ALTER TABLE vn.saleGroup ADD CONSTRAINT saleGroup_state_FK FOREIGN KEY (stateFk) REFERENCES vn.state(id) ON DELETE RESTRICT ON UPDATE CASCADE; From b833fd50818d033e7eb8c09fc34a1be5cf1e2306 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 27 Aug 2024 14:45:11 +0200 Subject: [PATCH 61/74] chore: refs #7524 modify ormConfig table col --- db/versions/11204-navyMonstera/00-firstScript.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/versions/11204-navyMonstera/00-firstScript.sql diff --git a/db/versions/11204-navyMonstera/00-firstScript.sql b/db/versions/11204-navyMonstera/00-firstScript.sql new file mode 100644 index 000000000..492e3d607 --- /dev/null +++ b/db/versions/11204-navyMonstera/00-firstScript.sql @@ -0,0 +1,5 @@ +ALTER TABLE vn.ormConfig +MODIFY COLUMN id INT NOT NULL, +DROP PRIMARY KEY, +ADD CONSTRAINT ormConfig_check CHECK (id = 1), +ADD PRIMARY KEY (id); \ No newline at end of file From 3dda49b3c56a1a9f5f542db83393e521e3af9e33 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 28 Aug 2024 08:40:03 +0200 Subject: [PATCH 62/74] fix: refs #pako Deleted duplicated version --- db/versions/11200-brownDendro/00-firstScript.sql | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 db/versions/11200-brownDendro/00-firstScript.sql diff --git a/db/versions/11200-brownDendro/00-firstScript.sql b/db/versions/11200-brownDendro/00-firstScript.sql deleted file mode 100644 index 943368b06..000000000 --- a/db/versions/11200-brownDendro/00-firstScript.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Place your SQL code here -ALTER TABLE vn.saleGroup ADD stateFk TINYINT(3) UNSIGNED; - -ALTER TABLE vn.saleGroup ADD CONSTRAINT saleGroup_state_FK FOREIGN KEY (stateFk) REFERENCES vn.state(id) ON DELETE RESTRICT ON UPDATE CASCADE; From 7b1a34e249e7e9743e712e93f6f0af9683007260 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 30 Aug 2024 12:47:05 +0200 Subject: [PATCH 63/74] feat: refs #7860 Update new packagings --- db/versions/11208-limeRoebelini/00-firstScript.vn.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/versions/11208-limeRoebelini/00-firstScript.vn.sql diff --git a/db/versions/11208-limeRoebelini/00-firstScript.vn.sql b/db/versions/11208-limeRoebelini/00-firstScript.vn.sql new file mode 100644 index 000000000..22b3dc924 --- /dev/null +++ b/db/versions/11208-limeRoebelini/00-firstScript.vn.sql @@ -0,0 +1,7 @@ +UPDATE vn.packaging SET id='25E' WHERE id='cactus200'; +UPDATE vn.packaging SET id='35E' WHERE id='kalan330'; +UPDATE vn.packaging SET id='45E' WHERE id='kalan400'; +UPDATE vn.packaging SET id='60E' WHERE id='kalan577'; +UPDATE vn.packaging SET id='60A' WHERE id='guzma650'; +UPDATE vn.packaging SET id='120A' WHERE id='guzma1200'; +UPDATE vn.packaging SET id='140A' WHERE id='guzma1400'; From 3da6a700ae97694b6aa27342a52a6f5dd33be34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 30 Aug 2024 13:08:15 +0200 Subject: [PATCH 64/74] fix: refs #7213 problem rounding --- .../sale_setProblemRoundingByBuy.sql | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql diff --git a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql b/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql new file mode 100644 index 000000000..cb7322c22 --- /dev/null +++ b/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql @@ -0,0 +1,71 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRoundingByBuy`( + vBuyFk INT +) +/** + * Update rounding problem for all sales related to a buy + * @param vBuyFk Id buy + */ + DECLARE vItemFk INT, + DECLARE vWareHouseFk INT + DECLARE vMaxDated DATE; + DECLARE vMinDated DATE; + DECLARE vLanding DATE; + DECLARE vLastBuy INT; + DECLARE vCurrentBuy INT; + DECLARE vGrouping INT; + + SELECT b.itemFk, t.warehouseInFk + INTO vItemFk, vWareHouseFk + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel t ON t.id = e.travelFk + WHERE b.id = vBuyFk; + + SELECT DATE(MAX(t.shipped)) + INTERVAL 1 DAY, DATE(MIN(t.shipped)) + INTO vMaxDated, vMinDated + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + WHERE t.shipped >= CURDATE() + AND s.itemFk = vItemFk + AND s.quantity > 0; + + CALL buy_getUltimate(vItemFk, vWareHouseFk, vMinDated); + + SELECT bu.buyFk, b.grouping INTO vLastBuy, vGrouping + FROM tmp.buyUltimate bu + JOIN buy b ON b.id = bu.buyFk; + + DROP TEMPORARY TABLE tmp.buyUltimate; + + SET vLanding = vMaxDated; + + WHILE vCurrentBuy <> vLastBuy OR vLanding > vMinDated DO + SET vMaxDated = vLanding - INTERVAL 1 DAY; + + CALL buy_getUltimate(vItemFk, vWareHouseFk, vMaxDated); + + SELECT buyFk, landing + INTO vCurrentBuy, vLanding + FROM tmp.buyUltimate; + + DROP TEMPORARY TABLE tmp.buyUltimate; + END WHILE; + + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + (INDEX(saleFk, isProblemCalcNeeded)) + SELECT s.id saleFk , + MOD(s.quantity, vGrouping) hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + WHERE s.itemFk = vItemFk + AND s.quantity > 0 + AND t.shipped BETWEEN vMinDated + AND util.dayEnd(vMaxDated); + + CALL sale_setProblem('hasRounding'); + + DROP TEMPORARY TABLE tmp.sale; +END$$ +DELIMITER ; \ No newline at end of file From beb54aedf85ca6f83e867a6e1564691b262199b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 30 Aug 2024 13:14:45 +0200 Subject: [PATCH 65/74] fix: refs #7213 problem rounding --- db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql b/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql index cb7322c22..60b495a75 100644 --- a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql +++ b/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql @@ -2,12 +2,13 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRoundingByBuy`( vBuyFk INT ) +BEGIN /** * Update rounding problem for all sales related to a buy * @param vBuyFk Id buy */ - DECLARE vItemFk INT, - DECLARE vWareHouseFk INT + DECLARE vItemFk INT; + DECLARE vWareHouseFk INT; DECLARE vMaxDated DATE; DECLARE vMinDated DATE; DECLARE vLanding DATE; From 4ed5811042b00b54eb65755023dac28a7bdab5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 30 Aug 2024 14:14:06 +0200 Subject: [PATCH 66/74] fix: refs #7213 problem rounding --- .../sale_setProblemRoundingByBuy.sql | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql b/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql index 60b495a75..efa1a65fb 100644 --- a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql +++ b/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql @@ -4,8 +4,9 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRoun ) BEGIN /** - * Update rounding problem for all sales related to a buy - * @param vBuyFk Id buy + * Update rounding problem for all sales related to a buy. + * + * @param vBuyFk Buy id */ DECLARE vItemFk INT; DECLARE vWareHouseFk INT; @@ -18,16 +19,16 @@ BEGIN SELECT b.itemFk, t.warehouseInFk INTO vItemFk, vWareHouseFk - FROM vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel t ON t.id = e.travelFk + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk WHERE b.id = vBuyFk; SELECT DATE(MAX(t.shipped)) + INTERVAL 1 DAY, DATE(MIN(t.shipped)) INTO vMaxDated, vMinDated FROM sale s JOIN ticket t ON t.id = s.ticketFk - WHERE t.shipped >= CURDATE() + WHERE t.shipped >= util.VN_CURDATE() AND s.itemFk = vItemFk AND s.quantity > 0; @@ -54,16 +55,16 @@ BEGIN END WHILE; CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk, isProblemCalcNeeded)) - SELECT s.id saleFk , + (INDEX(saleFk, isProblemCalcNeeded)) + ENGINE = MEMORY + SELECT s.id saleFk, MOD(s.quantity, vGrouping) hasProblem, ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded FROM sale s JOIN ticket t ON t.id = s.ticketFk WHERE s.itemFk = vItemFk AND s.quantity > 0 - AND t.shipped BETWEEN vMinDated - AND util.dayEnd(vMaxDated); + AND t.shipped BETWEEN vMinDated AND util.dayEnd(vMaxDated); CALL sale_setProblem('hasRounding'); From c88b069ac344695c8f0abcdd60abf19196d7fa2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 30 Aug 2024 14:16:03 +0200 Subject: [PATCH 67/74] fix: refs #7213 problem rounding --- db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql b/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql index efa1a65fb..a1362c222 100644 --- a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql +++ b/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql @@ -56,7 +56,7 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.sale (INDEX(saleFk, isProblemCalcNeeded)) - ENGINE = MEMORY + ENGINE = MEMORY SELECT s.id saleFk, MOD(s.quantity, vGrouping) hasProblem, ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded From 89f8e987dc7827a32eace416a3d7ebd202d99c6a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Sep 2024 14:27:04 +0200 Subject: [PATCH 68/74] feat: refs #7562 Requested changes --- db/versions/11209-pinkOrchid/00-firstScript.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/versions/11209-pinkOrchid/00-firstScript.sql diff --git a/db/versions/11209-pinkOrchid/00-firstScript.sql b/db/versions/11209-pinkOrchid/00-firstScript.sql new file mode 100644 index 000000000..92a7a7569 --- /dev/null +++ b/db/versions/11209-pinkOrchid/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.operator + MODIFY COLUMN sizeLimit int(10) unsigned DEFAULT NULL NULL COMMENT 'Límite de altura en una colección para la asignación de pedidos'; + +UPDATE vn.operator + SET sizeLimit = 90 + WHERE itemPackingTypeFk = 'V'; From b436ac051833540353aedc5d604dbbc5d89b56f4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 3 Sep 2024 07:45:25 +0200 Subject: [PATCH 69/74] fix: refs #7916 itemShelving_transfer --- .../vn/procedures/itemShelving_transfer.sql | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/db/routines/vn/procedures/itemShelving_transfer.sql b/db/routines/vn/procedures/itemShelving_transfer.sql index 47a9a7cf0..94d2308a1 100644 --- a/db/routines/vn/procedures/itemShelving_transfer.sql +++ b/db/routines/vn/procedures/itemShelving_transfer.sql @@ -5,28 +5,26 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_transf ) BEGIN /** - * Transfiere producto de una ubicación a otra, fusionando si coincide el - * packing y la fecha. + * Transfiere producto de una ubicación a otra + * fusionando si coincide el packing y la fecha. * * @param vItemShelvingFk Identificador de itemShelving * @param vShelvingFk Identificador de shelving */ - DECLARE vNewItemShelvingFk INT DEFAULT 0; + DECLARE vNewItemShelvingFk INT; - SELECT MAX(ish.id) - INTO vNewItemShelvingFk + SELECT MAX(ish.id) INTO vNewItemShelvingFk FROM itemShelving ish JOIN ( - SELECT - itemFk, - packing, - created, - buyFk + SELECT itemFk, + packing, + created, + buyFk FROM itemShelving WHERE id = vItemShelvingFk ) ish2 ON ish2.itemFk = ish.itemFk AND ish2.packing = ish.packing - AND date(ish2.created) = date(ish.created) + AND DATE(ish2.created) = DATE(ish.created) AND ish2.buyFk = ish.buyFk WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; @@ -39,10 +37,16 @@ BEGIN DELETE FROM itemShelving WHERE id = vItemShelvingFk; ELSE - UPDATE itemShelving - SET shelvingFk = vShelvingFk - WHERE id = vItemShelvingFk; + IF (SELECT EXISTS(SELECT id FROM shelving + WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN + + UPDATE itemShelving + SET shelvingFk = vShelvingFk + WHERE id = vItemShelvingFk; + ELSE + CALL util.throw('The shelving not exists'); + END IF; END IF; - SELECT true; + SELECT TRUE; END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; From e0a0b987b20d862a6cee9a0025521e7edce79740 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 3 Sep 2024 08:05:02 +0200 Subject: [PATCH 70/74] feat(salix): refs #7897 #7897 update changelog.md --- CHANGELOG.md | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6db79a40a..74109c7c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,113 @@ +# Version 24.36 - 2024-09-03 + +### Added 🆕 + +- chore: refs #7524 WIP limit call by:jorgep +- chore: refs #7524 modify ormConfig table col (origin/7524-warmfix-modifyColumn) by:jorgep +- feat(update-user): refs #7848 add twoFactor by:alexm +- feat: #3199 Requested changes by:guillermo +- feat: refs #3199 Added more scopes ticket_recalcByScope by:guillermo +- feat: refs #3199 Added one more scope ticket_recalcByScope by:guillermo +- feat: refs #3199 Created ticket_recalcItemTaxCountryByScope by:guillermo +- feat: refs #3199 Requested changes by:guillermo +- feat: refs #7346 add multiple feature by:jgallego +- feat: refs #7346 backTest checks new implementation by:jgallego +- feat: refs #7346 mas intuitivo by:jgallego +- feat: refs #7514 Changes to put srt log (origin/7514-srtLog) by:guillermo +- feat: refs #7524 add default limit (origin/7524-limitSelect) by:jorgep +- feat: refs #7524 add mock limit on find query by:jorgep +- feat: refs #7524 wip remote hooks by:jorgep +- feat: refs #7562 Requested changes by:guillermo +- feat: refs #7567 Changed time to call event by:guillermo +- feat: refs #7567 Requested changes by:guillermo +- feat: refs #7710 pr revision by:jgallego +- feat: refs #7710 test fixed (origin/7710-cloneWithTicketPackaging, 7710-cloneWithTicketPackaging) by:jgallego +- feat: refs #7712 Fix by:guillermo +- feat: refs #7712 Unify by:guillermo +- feat: refs #7712 sizeLimit (origin/7712-sizeLimit) by:guillermo +- feat: refs #7758 Add code mandateType and accountDetailType by:ivanm +- feat: refs #7758 Modify code lowerCamelCase and UNIQUE by:ivanm +- feat: refs #7758 accountDetailType fix deploy error by:ivanm +- feat: refs #7784 Changes in entry-order-pdf by:guillermo +- feat: refs #7784 Requested changes by:guillermo +- feat: refs #7799 Added Fk in vn.item.itemPackingTypeFk by:guillermo +- feat: refs #7800 Added company Fk by:guillermo +- feat: refs #7842 Added editorFk in vn.host by:guillermo +- feat: refs #7860 Update new packagings (origin/7860-newPackaging) by:guillermo +- feat: refs #7862 roadmap new fields by:ivanm +- feat: refs #7882 Added quadMindsConfig table by:guillermo + +### Changed 📦 + +- refactor: refs #7567 Fix and improvement by:guillermo +- refactor: refs #7567 Minor change by:guillermo +- refactor: refs #7756 Fix tests by:guillermo +- refactor: refs #7798 Drop bi.Greuges_comercial_detail by:guillermo +- refactor: refs #7848 adapt to lilium by:alexm + +### Fixed 🛠️ + +- feat: refs #7710 test fixed (origin/7710-cloneWithTicketPackaging, 7710-cloneWithTicketPackaging) by:jgallego +- feat: refs #7758 accountDetailType fix deploy error by:ivanm +- fix(salix): #7283 ItemFixedPrice duplicated (origin/7283_itemFixedPrice_duplicated) by:Javier Segarra +- fix: refs #7346 minor error (origin/7346, 7346) by:jgallego +- fix: refs #7355 remove and tests accounts (origin/7355-accountMigration2) by:carlossa +- fix: refs #7355 remove and tests accounts by:carlossa +- fix: refs #7524 default limit select by:jorgep +- fix: refs #7756 Foreign keys invoiceOut (origin/7756-fixRefFk) by:guillermo +- fix: refs #7756 id 0 by:guillermo +- fix: refs #7800 tpvMerchantEnable PRIMARY KEY (origin/7800-tpvMerchantEnable) by:guillermo +- fix: refs #7800 tpvMerchantEnable PRIMARY KEY by:guillermo +- fix: refs #7916 itemShelving_transfer (origin/test, test) by:guillermo +- fix: refs #pako Deleted duplicated version by:guillermo + +# Version 24.34 - 2024-08-20 + +### Added 🆕 + +- #6900 feat: clear empty by:jorgep +- #6900 feat: empty commit by:jorgep +- chore: refs #6900 beautify code by:jorgep +- chore: refs #6989 add config model by:jorgep +- feat workerActivity refs #6078 by:sergiodt +- feat: #6453 Refactor (origin/6453-orderConfirm) by:guillermo +- feat: #6453 Rollback always split by itemPackingType by:guillermo +- feat: deleted worker module code & redirect to Lilium by:Jon +- feat: refs #6453 Added new ticket search by:guillermo +- feat: refs #6453 Fixes by:guillermo +- feat: refs #6453 Minor changes by:guillermo +- feat: refs #6453 Requested changes by:guillermo +- feat: refs #6900 drop section by:jorgep +- feat: refs #7283 order by desc date by:jorgep +- feat: refs #7323 add locale by:jorgep +- feat: refs #7323 redirect to lilium by:jorgep +- feat: refs #7646 delete scannableCodeType by:robert +- feat: refs #7713 Created ACLLog by:guillermo +- feat: refs #7774 (origin/7774-ticket_cloneWeekly) by:robert +- feat: refs #7774 #7774 Changes ticket_cloneWeekly by:guillermo +- feat: refs #7774 ticket_cloneWeekly by:robert + +### Changed 📦 + +- refactor: refs #6453 Major changes by:guillermo +- refactor: refs #6453 Minor changes by:guillermo +- refactor: refs #6453 order_confirmWithUser by:guillermo +- refactor: refs #7646 #7646 Deleted scannable* variables productionConfig by:guillermo +- refactor: refs #7820 Deprecated silexACL by:guillermo + +### Fixed 🛠️ + +- #6900 fix: #6900 rectificative filter by:jorgep +- #6900 fix: empty commit by:jorgep +- fix(orders_filter): add sourceApp accepts by:alexm +- fix: refs #6130 commit lint by:pablone +- fix: refs #6453 order_confirmWithUser by:guillermo +- fix: refs #7283 sql by:jorgep +- fix: refs #7713 ACL Log by:guillermo +- test: fix claim descriptor redirect to lilium by:alexm +- test: fix ticket redirect to lilium by:alexm +- test: fix ticket sale e2e by:alexm + # Version 24.32 - 2024-08-06 ### Added 🆕 From 7632f333226df77c76041a574c2fb962d001f311 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 3 Sep 2024 09:22:55 +0200 Subject: [PATCH 71/74] fix: refs #7712 sizeLimit --- db/routines/vn/procedures/collection_new.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index ee76f3994..6e112634e 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -194,9 +194,9 @@ BEGIN OR (NOT pb.V AND vItemPackingTypeFk = 'V') OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) OR LENGTH(pb.problem) > 0 - OR (pb.lines > vLinesLimit AND vLinesLimit IS NOT NULL) - OR (pb.m3 > vVolumeLimit AND vVolumeLimit IS NOT NULL) - OR ((sub.maxSize > vSizeLimit OR sub.maxSize IS NOT NULL) AND vSizeLimit IS NOT NULL); + OR pb.lines > vLinesLimit + OR pb.m3 > vVolumeLimit + OR sub.maxSize > vSizeLimit; END IF; -- Es importante que el primer ticket se coja en todos los casos From 6f97d1b83a359081c920316ba10f1452aad97942 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 3 Sep 2024 09:57:18 +0200 Subject: [PATCH 72/74] fix: refs #7844 salesFilter and isTooLittle condition --- .../vn/procedures/sale_getProblems.sql | 6 ++++- .../back/methods/sales-monitor/salesFilter.js | 27 ++++++++----------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 6f65a3722..7e84900eb 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -70,11 +70,15 @@ BEGIN LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250), NULL ) hasRounding, - IF(FIND_IN_SET('isTooLittle', t.problem), TRUE, FALSE) isTooLittle + IF(FIND_IN_SET('isTooLittle', t.problem) + AND util.VN_NOW() < (util.VN_CURDATE() + INTERVAL HOUR(zc.`hour`) HOUR) + INTERVAL MINUTE(zc.`hour`) MINUTE, + TRUE, FALSE) isTooLittle FROM tmp.sale_getProblems sgp JOIN ticket t ON t.id = sgp.ticketFk LEFT JOIN sale s ON s.ticketFk = t.id LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + AND zc.dated = util.VN_CURDATE() WHERE s.problem <> '' OR t.problem <> '' OR t.risk GROUP BY t.id, s.id; diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 33b37d8a4..308c27f3f 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -239,9 +239,8 @@ module.exports = Self => { stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`); // Get client debt balance - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt'); stmts.push(` - CREATE TEMPORARY TABLE tmp.clientGetDebt + CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt (PRIMARY KEY (clientFk)) ENGINE = MEMORY SELECT DISTINCT clientFk FROM tmp.filter`); @@ -250,9 +249,8 @@ module.exports = Self => { stmts.push(stmt); stmts.push('DROP TEMPORARY TABLE tmp.clientGetDebt'); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.tickets'); stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.tickets + CREATE OR REPLACE TEMPORARY TABLE tmp.tickets (PRIMARY KEY (id)) ENGINE = MEMORY SELECT f.*, r.risk AS debt @@ -279,10 +277,8 @@ module.exports = Self => { WHERE t.debt + t.credit >= 0 `); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); - stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped @@ -303,14 +299,13 @@ module.exports = Self => { risk = t.debt + t.credit, totalProblems = totalProblems + 1 `); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getWarnings'); - stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getWarnings - (INDEX (ticketFk, agencyModeFk)) - ENGINE = MEMORY - SELECT f.id ticketFk, f.agencyModeFk - FROM tmp.filter f`); + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getWarnings + (INDEX (ticketFk, agencyModeFk)) + ENGINE = MEMORY + SELECT f.id ticketFk, f.agencyModeFk + FROM tmp.filter f + `); stmts.push(stmt); stmts.push('CALL ticket_getWarnings()'); @@ -318,12 +313,12 @@ module.exports = Self => { stmt = new ParameterizedSQL(` SELECT t.*, tp.*, - ((tp.risk) + cc.riskTolerance < 0) AS hasHighRisk, + tp.hasHighRisk, tw.* FROM tmp.tickets t LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = t.id LEFT JOIN tmp.ticket_warnings tw ON tw.ticketFk = t.id - JOIN clientConfig cc`); + `); const hasProblems = args.problems; if (hasProblems != undefined && (!args.from && !args.to)) From 04c8f87c00e1cfea47500d1c2edd0a19f10fa525 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 3 Sep 2024 12:02:55 +0200 Subject: [PATCH 73/74] feat: rollback limit --- loopback/common/models/vn-model.js | 30 +++++++++++++++--------------- loopback/server/boot/orm.js | 12 ++++++------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index a11bed11d..6fcb6f0e3 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -27,25 +27,25 @@ module.exports = function(Self) { }; }); - this.beforeRemote('**', async ctx => { - if (!this.hasFilter(ctx)) return; + // this.beforeRemote('**', async ctx => { + // if (!this.hasFilter(ctx)) return; - const defaultLimit = this.app.orm.selectLimit; - const filter = ctx.args.filter || {limit: defaultLimit}; + // const defaultLimit = this.app.orm.selectLimit; + // const filter = ctx.args.filter || {limit: defaultLimit}; - if (filter.limit > defaultLimit) { - filter.limit = defaultLimit; - ctx.args.filter = filter; - } - }); + // if (filter.limit > defaultLimit) { + // filter.limit = defaultLimit; + // ctx.args.filter = filter; + // } + // }); - this.afterRemote('**', async ctx => { - if (!this.hasFilter(ctx)) return; + // this.afterRemote('**', async ctx => { + // if (!this.hasFilter(ctx)) return; - const {result} = ctx; - const length = Array.isArray(result) ? result.length : result ? 1 : 0; - if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); - }); + // const {result} = ctx; + // const length = Array.isArray(result) ? result.length : result ? 1 : 0; + // if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); + // }); // Register field ACL validation /* diff --git a/loopback/server/boot/orm.js b/loopback/server/boot/orm.js index 8bbd969e1..ccd9d4eca 100644 --- a/loopback/server/boot/orm.js +++ b/loopback/server/boot/orm.js @@ -1,6 +1,6 @@ -module.exports = async function(app) { - if (!app.orm) { - const ormConfig = await app.models.OrmConfig.findOne(); - app.orm = ormConfig; - } -}; +// module.exports = async function(app) { +// if (!app.orm) { +// const ormConfig = await app.models.OrmConfig.findOne(); +// app.orm = ormConfig; +// } +// }; From 0c3349dc036aa8d6d23ba843a36b1e2a8bbf5d55 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 3 Sep 2024 12:06:31 +0200 Subject: [PATCH 74/74] fix: refs #7844 salesFilter and tmp.ticket_problems.totalProblems --- .../vn/procedures/sale_getProblems.sql | 3 + .../vn/procedures/ticket_getProblems.sql | 27 +++--- .../back/methods/sales-monitor/salesFilter.js | 94 +++++-------------- .../sales-monitor/specs/salesFilter.spec.js | 8 +- 4 files changed, 46 insertions(+), 86 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 7e84900eb..8df28dbc0 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -35,6 +35,7 @@ BEGIN saleFk INT(11), isFreezed INTEGER(1) DEFAULT 0, risk DECIMAL(10,1) DEFAULT 0, + hasRisk TINYINT(1) DEFAULT 0, hasHighRisk TINYINT(1) DEFAULT 0, hasTicketRequest INTEGER(1) DEFAULT 0, itemShortage VARCHAR(255), @@ -52,6 +53,7 @@ BEGIN saleFk, isFreezed, risk, + hasRisk, hasHighRisk, hasTicketRequest, isTaxDataChecked, @@ -62,6 +64,7 @@ BEGIN s.id, IF(FIND_IN_SET('isFreezed', t.problem), TRUE, FALSE) isFreezed, t.risk, + IF(FIND_IN_SET('hasRisk', t.problem), TRUE, FALSE) hasRisk, IF(FIND_IN_SET('hasHighRisk', t.problem), TRUE, FALSE) hasHighRisk, IF(FIND_IN_SET('hasTicketRequest', t.problem), TRUE, FALSE) hasTicketRequest, IF(FIND_IN_SET('isTaxDataChecked', t.problem), FALSE, TRUE) isTaxDataChecked, diff --git a/db/routines/vn/procedures/ticket_getProblems.sql b/db/routines/vn/procedures/ticket_getProblems.sql index e9becab2a..49485e5f5 100644 --- a/db/routines/vn/procedures/ticket_getProblems.sql +++ b/db/routines/vn/procedures/ticket_getProblems.sql @@ -18,6 +18,7 @@ BEGIN SELECT ticketFk, MAX(isFreezed) isFreezed, MAX(risk) risk, + MAX(hasRisk) hasRisk, MAX(hasHighRisk) hasHighRisk, MAX(hasTicketRequest) hasTicketRequest, MAX(itemShortage) itemShortage, @@ -32,19 +33,19 @@ BEGIN FROM tmp.sale_problems GROUP BY ticketFk; - UPDATE tmp.ticket_problems tp - SET tp.totalProblems = ( - (tp.isFreezed) + - IF(tp.risk,TRUE, FALSE) + - (tp.hasTicketRequest) + - (tp.isTaxDataChecked = 0) + - (tp.hasComponentLack) + - (tp.itemDelay) + - (tp.isTooLittle) + - (tp.itemLost) + - (tp.hasRounding) + - (tp.itemShortage) + - (tp.isVip) + UPDATE tmp.ticket_problems + SET totalProblems = ( + (isFreezed) + + (hasRisk) + + (hasTicketRequest) + + (isTaxDataChecked) + + (hasComponentLack) + + (itemDelay IS NOT NULL) + + (isTooLittle) + + (itemLost IS NOT NULL) + + (hasRounding IS NOT NULL) + + (itemShortage IS NOT NULL) + + (isVip) ); DROP TEMPORARY TABLE tmp.sale_problems; diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 308c27f3f..dbf2ea468 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -238,45 +238,6 @@ module.exports = Self => { stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`); - // Get client debt balance - stmts.push(` - CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT DISTINCT clientFk FROM tmp.filter`); - - stmt = new ParameterizedSQL('CALL client_getDebt(?)', [args.to]); - stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE tmp.clientGetDebt'); - - stmt = new ParameterizedSQL(` - CREATE OR REPLACE TEMPORARY TABLE tmp.tickets - (PRIMARY KEY (id)) - ENGINE = MEMORY - SELECT f.*, r.risk AS debt - FROM tmp.filter f - LEFT JOIN tmp.risk r ON f.clientFk = r.clientFk`); - stmts.push(stmt); - - // Sum risk to future - stmts.push(`SET @client:= 0`); - stmts.push('SET @risk := 0'); - stmts.push(` - UPDATE tmp.tickets - SET debt = IF(@client <> @client:= clientFk, - -totalWithVat + @risk:= - debt + totalWithVat, - -totalWithVat + @risk:= @risk + totalWithVat - ) - ORDER BY clientFk, shipped DESC - `); - - // Remove positive risks - stmts.push(` - UPDATE tmp.tickets t - SET debt = 0 - WHERE t.debt + t.credit >= 0 - `); - stmt = new ParameterizedSQL(` CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) @@ -290,15 +251,6 @@ module.exports = Self => { stmts.push('CALL ticket_getProblems(FALSE)'); - stmts.push(` - INSERT INTO tmp.ticket_problems (ticketFk, risk, totalProblems) - SELECT t.id, t.debt + t.credit AS risk, 1 - FROM tmp.tickets t - WHERE (t.debt + t.credit) < 0 - ON DUPLICATE KEY UPDATE - risk = t.debt + t.credit, totalProblems = totalProblems + 1 - `); - stmt = new ParameterizedSQL(` CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getWarnings (INDEX (ticketFk, agencyModeFk)) @@ -311,14 +263,18 @@ module.exports = Self => { stmts.push('CALL ticket_getWarnings()'); stmt = new ParameterizedSQL(` - SELECT t.*, - tp.*, - tp.hasHighRisk, - tw.* - FROM tmp.tickets t - LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = t.id - LEFT JOIN tmp.ticket_warnings tw ON tw.ticketFk = t.id + UPDATE tmp.ticket_problems + SET risk = IF(hasRisk AND risk > 0, risk, 0) `); + stmts.push(stmt); + + stmt = new ParameterizedSQL(` + SELECT * + FROM tmp.filter f + LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id + LEFT JOIN tmp.ticket_warnings tw ON tw.ticketFk = f.id + `); + stmts.push(stmt); const hasProblems = args.problems; if (hasProblems != undefined && (!args.from && !args.to)) @@ -354,23 +310,23 @@ module.exports = Self => { switch (param) { case 'search': return /^\d+$/.test(value) - ? {'t.id': {inq: value}} - : {'t.nickname': {like: `%${value}%`}}; + ? {'f.id': {inq: value}} + : {'f.nickname': {like: `%${value}%`}}; case 'nickname': - return {'t.nickname': {like: `%${value}%`}}; + return {'f.nickname': {like: `%${value}%`}}; case 'refFk': - return {'t.refFk': value}; + return {'f.refFk': value}; case 'provinceFk': - return {'t.provinceFk': value}; + return {'f.provinceFk': value}; case 'stateFk': - return {'t.stateFk': value}; + return {'f.stateFk': value}; case 'alertLevel': - return {'t.alertLevel': value}; + return {'f.alertLevel': value}; case 'pending': if (value) { - return {'t.alertLevelCode': {inq: [ + return {'f.alertLevelCode': {inq: [ 'FIXING', 'FREE', 'NOT_READY', @@ -380,7 +336,7 @@ module.exports = Self => { 'WAITING_FOR_PAYMENT' ]}}; } else { - return {'t.alertLevelCode': {inq: [ + return {'f.alertLevelCode': {inq: [ 'ON_PREPARATION', 'ON_CHECKING', 'CHECKED', @@ -404,7 +360,7 @@ module.exports = Self => { } case 'agencyModeFk': case 'warehouseFk': - param = `t.${param}`; + param = `f.${param}`; return {[param]: value}; } }); @@ -417,14 +373,14 @@ module.exports = Self => { stmt.merge(conn.makeLimit(filter)); const ticketsIndex = stmts.push(stmt) - 1; - stmts.push( - `DROP TEMPORARY TABLE + stmts.push(` + DROP TEMPORARY TABLE tmp.filter, tmp.ticket_problems, tmp.sale_getProblems, tmp.sale_getWarnings, - tmp.ticket_warnings, - tmp.risk`); + tmp.ticket_warnings + `); const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); diff --git a/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js index c3da7f08b..cd55c471a 100644 --- a/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js +++ b/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js @@ -39,7 +39,7 @@ describe('SalesMonitor salesFilter()', () => { const filter = {}; const result = await models.SalesMonitor.salesFilter(ctx, filter, options); - expect(result.length).toBeGreaterThan(11); + expect(result.length).toBeGreaterThan(10); await tx.rollback(); } catch (e) { @@ -68,7 +68,7 @@ describe('SalesMonitor salesFilter()', () => { const filter = {}; const result = await models.SalesMonitor.salesFilter(ctx, filter, options); - expect(result.length).toEqual(0); + expect(result.length).toEqual(4); await tx.rollback(); } catch (e) { @@ -218,8 +218,8 @@ describe('SalesMonitor salesFilter()', () => { const firstTicket = result.shift(); const secondTicket = result.shift(); - expect(firstTicket.totalProblems).toEqual(1); - expect(secondTicket.totalProblems).toEqual(1); + expect(firstTicket.totalProblems).toEqual(4); + expect(secondTicket.totalProblems).toEqual(4); await tx.rollback(); } catch (e) {