From 33e823675edd2820d5f249296184178fd12830b1 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 28 May 2024 10:08:15 +0200 Subject: [PATCH 1/6] feat: refs #6404 default weight --- back/methods/mrw-config/createShipment.ejs | 9 ++++++++- back/models/mrw-config.json | 12 ++++++++++++ db/versions/11075-salmonLilium/00-firstScript.sql | 5 +++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 db/versions/11075-salmonLilium/00-firstScript.sql diff --git a/back/methods/mrw-config/createShipment.ejs b/back/methods/mrw-config/createShipment.ejs index bf8a07dab..b7a1cd897 100644 --- a/back/methods/mrw-config/createShipment.ejs +++ b/back/methods/mrw-config/createShipment.ejs @@ -33,9 +33,16 @@ <%= expeditionData.serviceType %> 1 <%= expeditionData.weekDays %> - <%= expeditionData.kg %> + + + <%= mrw.defaultHeight %> + <%= mrw.defaultLength %> + <%= mrw.defaultWidth %> + <%= mrw.defaultWeight %> + + diff --git a/back/models/mrw-config.json b/back/models/mrw-config.json index 50cf7e8fc..b0e9754bd 100644 --- a/back/models/mrw-config.json +++ b/back/models/mrw-config.json @@ -27,6 +27,18 @@ }, "subscriberCode": { "type": "string" + }, + "defaultHeight": { + "type": "number" + }, + "defaultLength": { + "type": "number" + }, + "defaultWidth": { + "type": "number" + }, + "defaultWeight": { + "type": "number" } } } diff --git a/db/versions/11075-salmonLilium/00-firstScript.sql b/db/versions/11075-salmonLilium/00-firstScript.sql new file mode 100644 index 000000000..6e487e503 --- /dev/null +++ b/db/versions/11075-salmonLilium/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultHeight INT UNSIGNED NULL COMMENT 'default height in centimeters'; +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultLength INT UNSIGNED NULL COMMENT 'default length in centimeters'; +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultWidth INT UNSIGNED NULL COMMENT 'default width in centimeters'; +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultWeight INT UNSIGNED NULL COMMENT 'default weight in centimeters'; From 6e5b41a886463e2c2fdf5dedbeb3dc26cafa8221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 28 May 2024 12:30:17 +0200 Subject: [PATCH 2/6] Hotfix contabilizar DUA Ticket #188682 --- .../vn/procedures/duaInvoiceInBooking.sql | 53 +++++++++---------- .../vn/procedures/invoiceIn_booking.sql | 22 ++++++-- .../back/methods/invoice-in/toBook.js | 2 +- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index 981f3026d..9658bed52 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -6,12 +6,12 @@ BEGIN * * @param vDuaFk Id del dua a recalcular */ - DECLARE done BOOL DEFAULT FALSE; + DECLARE vDone BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; - DECLARE vASIEN BIGINT DEFAULT 0; - DECLARE vCounter INT DEFAULT 0; + DECLARE vBookEntry INT; + DECLARE vFiscalYear INT; - DECLARE rs CURSOR FOR + DECLARE vInvoicesIn CURSOR FOR SELECT DISTINCT e.invoiceInFk FROM entry e JOIN duaEntry de ON de.entryFk = e.id @@ -20,9 +20,7 @@ BEGIN AND de.customsValue AND ii.isBooked = FALSE; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - - OPEN rs; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; UPDATE invoiceIn ii JOIN entry e ON e.invoiceInFk = ii.id @@ -36,35 +34,32 @@ BEGIN e.isConfirmed = TRUE WHERE d.id = vDuaFk; - SELECT IFNULL(ASIEN,0) INTO vASIEN - FROM dua - WHERE id = vDuaFk; + SELECT ASIEN INTO vBookEntry FROM dua WHERE id = vDuaFk; - FETCH rs INTO vInvoiceFk; + IF vBookEntry IS NULL THEN + SELECT YEAR(IFNULL(ii.bookEntried, d.bookEntried)) INTO vFiscalYear + FROM invoiceIn ii + JOIN entry e ON e.invoiceInFk = ii.id + JOIN duaEntry de ON de.entryFk = e.id + JOIN dua d ON d.id = de.duaFk + WHERE d.id = vDuaFk; + CALL ledger_next(vFiscalYear, vBookEntry); + END IF; - WHILE NOT done DO + OPEN vInvoicesIn; - CALL invoiceIn_booking(vInvoiceFk); - - IF vCounter > 0 OR vASIEN > 0 THEN - - UPDATE XDiario x - JOIN ledgerConfig lc ON lc.lastBookEntry = x.ASIEN - SET x.ASIEN = vASIEN; - - ELSE - - SELECT lastBookEntry INTO vASIEN FROM ledgerConfig; +l: LOOP + SET vDone = FALSE; + FETCH vInvoicesIn INTO vInvoiceFk; + IF vDone THEN + LEAVE l; END IF; - SET vCounter = vCounter + 1; + CALL invoiceIn_booking(vInvoiceFk, vBookEntry); + END LOOP; - FETCH rs INTO vInvoiceFk; - - END WHILE; - - CLOSE rs; + CLOSE vInvoicesIn; UPDATE dua SET ASIEN = vASIEN diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index 4b015750f..fd0e72c44 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -1,6 +1,17 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(vSelf INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`( + vSelf INT, + vBookEntry INT +) BEGIN +/** + * Genera la contabilidad para una factura y la marca como contabilizada + * Cuadra el asiento generado en si encuentra problemas derivados + * de los calculos con decimales + * + * @param vSelf Id invoiceIn + * @param vBookEntry Id de asiento, si es NULL se genera uno nuevo + */ DECLARE vBookNumber INT; DECLARE vFiscalYear INT; @@ -58,7 +69,12 @@ BEGIN WHERE ii.id = vSelf; SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1; - CALL ledger_next(vFiscalYear, vBookNumber); + + IF vBookEntry IS NULL THEN + CALL ledger_next(vFiscalYear, vBookNumber); + ELSE + SET vBookNumber = vBookEntry; + END IF; -- Apunte del proveedor INSERT INTO XDiario( @@ -187,7 +203,7 @@ BEGIN LEFT JOIN ( SELECT e.id FROM tInvoiceIn tii - JOIN expense e ON e.id = tii.expenseFk + JOIN expense e ON e.id = tii.expenseFk WHERE e.isWithheld LIMIT 1 ) eWithheld ON TRUE diff --git a/modules/invoiceIn/back/methods/invoice-in/toBook.js b/modules/invoiceIn/back/methods/invoice-in/toBook.js index 778742911..c3be5f8fc 100644 --- a/modules/invoiceIn/back/methods/invoice-in/toBook.js +++ b/modules/invoiceIn/back/methods/invoice-in/toBook.js @@ -32,7 +32,7 @@ module.exports = Self => { } try { - await Self.rawSql(`CALL vn.invoiceIn_booking(?)`, [id], myOptions); + await Self.rawSql(`CALL vn.invoiceIn_booking(?, NULL)`, [id], myOptions); if (tx) await tx.commit(); } catch (e) { if (tx) await tx.rollback(); From cf84aa72567323b14b5c9a40ead714a0956d4c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 28 May 2024 13:01:27 +0200 Subject: [PATCH 3/6] Hotfix contabilizar DUA Ticket #188682 --- db/routines/vn/procedures/invoiceIn_booking.sql | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index fd0e72c44..cad86a12e 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`( vSelf INT, - vBookEntry INT + vBookNumber INT ) BEGIN /** @@ -12,7 +12,6 @@ BEGIN * @param vSelf Id invoiceIn * @param vBookEntry Id de asiento, si es NULL se genera uno nuevo */ - DECLARE vBookNumber INT; DECLARE vFiscalYear INT; CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn @@ -70,10 +69,8 @@ BEGIN SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1; - IF vBookEntry IS NULL THEN + IF vBookNumber IS NULL THEN CALL ledger_next(vFiscalYear, vBookNumber); - ELSE - SET vBookNumber = vBookEntry; END IF; -- Apunte del proveedor From 7dd1ecfd6753b4bfc98cf96ded5219a619baeb6d Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 28 May 2024 14:38:26 +0200 Subject: [PATCH 4/6] fix: refs #6404 Version increased --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index be3dcca04..661d5b8b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.22.1", + "version": "24.22.2", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From a022ed0854a9bdae0f4396c8d8819e10127d25f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 28 May 2024 14:50:58 +0200 Subject: [PATCH 5/6] Hotfix payments ticket 188787 --- .../vn/procedures/duaInvoiceInBooking.sql | 7 ++--- db/routines/vn/procedures/duaTaxBooking.sql | 2 +- .../vn/procedures/invoiceIn_booking.sql | 2 +- .../vn/procedures/invoiceOutBooking.sql | 2 +- .../vn/procedures/ledger_doCompensation.sql | 2 +- db/routines/vn/procedures/ledger_next.sql | 27 +++++++++++-------- db/routines/vn/procedures/xdiario_new.sql | 2 +- .../vn/triggers/payment_beforeInsert.sql | 5 ++-- 8 files changed, 27 insertions(+), 22 deletions(-) diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index 9658bed52..035b4eab1 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -42,8 +42,9 @@ BEGIN JOIN entry e ON e.invoiceInFk = ii.id JOIN duaEntry de ON de.entryFk = e.id JOIN dua d ON d.id = de.duaFk - WHERE d.id = vDuaFk; - CALL ledger_next(vFiscalYear, vBookEntry); + WHERE d.id = vDuaFk + LIMIT 1; + CALL ledger_next(vFiscalYear, FALSE, vBookEntry); END IF; OPEN vInvoicesIn; @@ -62,7 +63,7 @@ l: LOOP CLOSE vInvoicesIn; UPDATE dua - SET ASIEN = vASIEN + SET ASIEN = vBookEntry WHERE id = vDuaFk; UPDATE invoiceIn ii diff --git a/db/routines/vn/procedures/duaTaxBooking.sql b/db/routines/vn/procedures/duaTaxBooking.sql index 5d4a98933..8d8effe90 100644 --- a/db/routines/vn/procedures/duaTaxBooking.sql +++ b/db/routines/vn/procedures/duaTaxBooking.sql @@ -12,7 +12,7 @@ BEGIN WHERE id = vDuaFk; IF vBookNumber IS NULL OR NOT vBookNumber THEN - CALL ledger_next(YEAR(vBookDated), vBookNumber); + CALL ledger_next(YEAR(vBookDated), FALSE, vBookNumber); END IF; -- Apunte de la aduana diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index cad86a12e..cd311ba9d 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -70,7 +70,7 @@ BEGIN SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1; IF vBookNumber IS NULL THEN - CALL ledger_next(vFiscalYear, vBookNumber); + CALL ledger_next(vFiscalYear, FALSE, vBookNumber); END IF; -- Apunte del proveedor diff --git a/db/routines/vn/procedures/invoiceOutBooking.sql b/db/routines/vn/procedures/invoiceOutBooking.sql index 913035576..b50b89eaf 100644 --- a/db/routines/vn/procedures/invoiceOutBooking.sql +++ b/db/routines/vn/procedures/invoiceOutBooking.sql @@ -61,7 +61,7 @@ BEGIN WHERE io.id = vInvoice; SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1; - CALL ledger_next(vFiscalYear, vBookNumber); + CALL ledger_next(vFiscalYear, FALSE, vBookNumber); -- Linea del cliente INSERT INTO XDiario( ASIEN, diff --git a/db/routines/vn/procedures/ledger_doCompensation.sql b/db/routines/vn/procedures/ledger_doCompensation.sql index 80475ac08..a9e4e4251 100644 --- a/db/routines/vn/procedures/ledger_doCompensation.sql +++ b/db/routines/vn/procedures/ledger_doCompensation.sql @@ -28,7 +28,7 @@ BEGIN DECLARE vIsOriginalAClient BOOL; DECLARE vPayMethodCompensation INT; - CALL ledger_next(YEAR(vDated), vNewBookEntry); + CALL ledger_next(YEAR(vDated), FALSE, vNewBookEntry); SELECT COUNT(id) INTO vIsOriginalAClient FROM client diff --git a/db/routines/vn/procedures/ledger_next.sql b/db/routines/vn/procedures/ledger_next.sql index dccce3a76..2d565ff99 100644 --- a/db/routines/vn/procedures/ledger_next.sql +++ b/db/routines/vn/procedures/ledger_next.sql @@ -1,6 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`( IN vFiscalYear INT, + IN vIsManageTransaction BOOLEAN, OUT vLastBookEntry INT ) BEGIN @@ -22,13 +23,15 @@ BEGIN CALL util.throw('Fiscal year is required'); END IF; - SELECT @@in_transaction INTO vHasStartTransaction; + IF NOT vIsManageTransaction THEN + SELECT @@in_transaction INTO vHasStartTransaction; - IF NOT vHasStartTransaction THEN - START TRANSACTION; - ELSE - SAVEPOINT sp; - END IF; + IF NOT vHasStartTransaction THEN + START TRANSACTION; + ELSE + SAVEPOINT sp; + END IF; + END IF; SELECT bookEntry + 1 INTO vLastBookEntry FROM ledgerCompany @@ -46,10 +49,12 @@ BEGIN SET bookEntry = vLastBookEntry WHERE fiscalYear = vFiscalYear; - IF vHasStartTransaction THEN - RELEASE SAVEPOINT sp; - ELSE - COMMIT; - END IF; + IF NOT vIsManageTransaction THEN + IF vHasStartTransaction THEN + RELEASE SAVEPOINT sp; + ELSE + COMMIT; + END IF; + END IF; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/xdiario_new.sql b/db/routines/vn/procedures/xdiario_new.sql index 8204f4652..83e1afa16 100644 --- a/db/routines/vn/procedures/xdiario_new.sql +++ b/db/routines/vn/procedures/xdiario_new.sql @@ -39,7 +39,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`xdiario_new`( */ BEGIN IF vBookNumber IS NULL THEN - CALL ledger_next(YEAR(vDated), vBookNumber); + CALL ledger_next(YEAR(vDated), FALSE, vBookNumber); END IF; INSERT INTO XDiario diff --git a/db/routines/vn/triggers/payment_beforeInsert.sql b/db/routines/vn/triggers/payment_beforeInsert.sql index 0a4cd1f12..337a54172 100644 --- a/db/routines/vn/triggers/payment_beforeInsert.sql +++ b/db/routines/vn/triggers/payment_beforeInsert.sql @@ -9,13 +9,12 @@ BEGIN DECLARE vIsCash BOOLEAN; DECLARE vIsSupplierActive BOOLEAN; - -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH SELECT (at2.code = 'cash') INTO vIsCash FROM accounting a JOIN accountingType at2 ON at2.id = a.accountingTypeFk WHERE a.id = NEW.bankFk; - IF vIsCash THEN + IF vIsCash THEN SELECT account INTO vBankAccount FROM accounting WHERE id = NEW.bankFk; @@ -24,7 +23,7 @@ BEGIN FROM supplier WHERE id = NEW.supplierFk; - CALL ledger_next(YEAR(NEW.received), NEW.companyFk, vNewBookEntry); + CALL ledger_next(YEAR(NEW.received), TRUE, vNewBookEntry); INSERT INTO XDiario ( ASIEN, From f770bce54ce903cf80e481dfad90da71a6d1edac Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 29 May 2024 07:55:33 +0200 Subject: [PATCH 6/6] fix: refs #7486 Deleted get_lock collection_assign --- .../vn/procedures/collection_assign.sql | 42 ++----------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index c1a4087ff..fc9f9a711 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -13,28 +13,12 @@ BEGIN * @param vCollectionFk Id de colección */ DECLARE vHasTooMuchCollections BOOL; - DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vWarehouseFk INT; - DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 30; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - IF vLockName IS NOT NULL THEN - DO RELEASE_LOCK(vLockName); - CALL util.debugAdd('releaseLock', vLockName); -- Tmp - END IF; - - RESIGNAL; - END; -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, - collection_assign_lockname - INTO vHasTooMuchCollections, - vLockName + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 + INTO vHasTooMuchCollections FROM productionConfig pc LEFT JOIN tCollection ON TRUE; @@ -44,21 +28,6 @@ BEGIN CALL util.throw('Hay colecciones pendientes'); END IF; - SELECT warehouseFk, itemPackingTypeFk - INTO vWarehouseFk, vItemPackingTypeFk - FROM operator - WHERE workerFk = vUserFk; - - SET vLockName = CONCAT_WS('/', - vLockName, - vWarehouseFk, - vItemPackingTypeFk - ); - - IF NOT GET_LOCK(vLockName, vLockTime) THEN - CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); - END IF; - -- Se eliminan las colecciones sin asignar que estan obsoletas INSERT INTO ticketTracking(stateFk, ticketFk) SELECT s.id, tc.ticketFk @@ -66,7 +35,7 @@ BEGIN JOIN ticketCollection tc ON tc.collectionFk = c.id JOIN `state` s ON s.code = 'PRINTED_AUTO' JOIN productionConfig pc - WHERE c.workerFk IS NULL + WHERE c.workerFk IS NULL AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; DELETE c.* @@ -80,8 +49,7 @@ BEGIN VALUES(vUserFk); -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion - SELECT MIN(c.id) - INTO vCollectionFk + SELECT MIN(c.id) INTO vCollectionFk FROM `collection` c JOIN operator o ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL) @@ -107,7 +75,5 @@ BEGIN UPDATE `collection` SET workerFk = vUserFk WHERE id = vCollectionFk; - - DO RELEASE_LOCK(vLockName); END$$ DELIMITER ;