refactor: refs #7937 improve transaction handling in report_print procedure and enhance claimEnd filter
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Javi Gallego 2025-02-20 15:02:19 +01:00
parent 25ad28d019
commit 5eb981165e
3 changed files with 15 additions and 12 deletions

View File

@ -28,13 +28,11 @@ BEGIN
DECLARE vPrinterSize VARCHAR(255);
DECLARE vPriorityFk INT;
DECLARE vReportFk INT;
DECLARE vTx BOOLEAN DEFAULT @@in_transaction;
DECLARE vTx BOOLEAN DEFAULT NOT @@in_transaction;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
IF NOT vTx THEN
ROLLBACK;
END IF;
CALL util.tx_rollback(vTx);
RESIGNAL;
END;
@ -62,10 +60,7 @@ BEGIN
IF vReportSize <> vPrinterSize THEN
CALL util.throw('incorrectSize');
END IF;
IF NOT vTx THEN
START TRANSACTION;
END IF;
CALL util.tx_start(vTx);
INSERT INTO printQueue
SET printerFk = vPrinterFk,
priorityFk = vPriorityFk,
@ -86,8 +81,6 @@ BEGIN
SET vI = vI + 1;
END WHILE;
IF NOT vTx THEN
COMMIT;
END IF;
CALL util.tx_commit(vTx);
END$$
DELIMITER ;

View File

@ -0,0 +1,8 @@
UPDATE vn.claimDestination cd
SET cd.addressFk = NULL
WHERE code IN ('garbage/loss','manufacturing','supplierClaim','corrected');
UPDATE vn.claimDestination cd
JOIN vn.addressWaste aw ON aw.`type` = 'fault'
SET cd.addressFk = aw.addressFk
WHERE code IN ('good');

View File

@ -52,10 +52,12 @@ module.exports = Self => {
s.price,
s.discount,
s.quantity * s.price * ((100 - s.discount) / 100) total,
ce.shelvingFk
ce.shelvingFk,
sh.code shelvingCode
FROM vn.claimEnd ce
LEFT JOIN vn.sale s ON s.id = ce.saleFk
LEFT JOIN vn.ticket t ON t.id = s.ticketFk
LEFT JOIN vn.shelving sh ON sh.id = ce.shelvingFk
) ce`
);