feat: comprobaciones facturas contabilizadas refs #6932
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Carlos Andrés 2024-02-23 18:10:23 +01:00
parent bed4faceb7
commit 5fe4f794cc
2 changed files with 9 additions and 9 deletions

View File

@ -6,6 +6,7 @@ BEGIN
DECLARE vIsVirtual BOOL;
DECLARE vPrintedCount INT;
DECLARE vHasDistinctWarehouses BOOL;
DECLARE vHasAnyInvoiceBooked BOOL;
SET NEW.editorFk = account.myUser_getId();
@ -49,15 +50,13 @@ BEGIN
END IF;
IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk)THEN
DECLARE vHanAnyInvoiceBooked BOOL;
SELECT COUNT(*) INTO vHanAnyInvoiceBooked
SELECT COUNT(*) INTO vHasAnyInvoiceBooked
FROM entry e
JOIN invoiceIn ii ON ii.id = e.invoiceInFk
WHERE e.id = NEW.id
AND ii.isBooked;
IF vHanAnyInvoiceBooked THEN
IF vHasAnyInvoiceBooked THEN
CALL util.throw('The travel has entries with booked invoices')
END IF;
END IF;

View File

@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_beforeUpdate`
BEFORE UPDATE ON `travel`
FOR EACH ROW
BEGIN
DECLARE vHasAnyInvoiceBooked BOOL;
SET NEW.editorFk = account.myUser_getId();
IF NOT (NEW.landed <=> OLD.landed)
@ -19,16 +21,15 @@ BEGIN
END IF;
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
DECLARE vHanAnyInvoiceBooked BOOL;
SELECT COUNT(*) INTO vHanAnyInvoiceBooked
SELECT COUNT(*) INTO vHasAnyInvoiceBooked
FROM travel t
JOIN entry e ON e.travelFk =t.id
JOIN invoiceIn ii ON ii.id = e.invoiceInFk
WHERE t.id = NEW.id
AND ii.isBooked;
IF vHanAnyInvoiceBooked THEN
IF vHasAnyInvoiceBooked THEN
CALL util.throw('The travel has entries with booked invoices')
END IF;
END IF;