feat: comprobaciones facturas contabilizadas refs #6932 #2091

Merged
carlosap merged 9 commits from 6932-cambios-en-ENT-con-facturas-contabilzadas into dev 2024-02-26 16:22:27 +00:00
2 changed files with 19 additions and 4 deletions

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)
@ -17,5 +19,18 @@ BEGIN
IF NOT (NEW.warehouseInFk <=> OLD.warehouseInFk) THEN
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
END IF;
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
SELECT COUNT(*) INTO vHasAnyInvoiceBooked
carlosap marked this conversation as resolved
Review

duplicat

duplicat
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 vHasAnyInvoiceBooked THEN
CALL util.throw('The travel has entries with booked invoices');
END IF;
END IF;
END$$
DELIMITER ;