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 17 additions and 18 deletions
Showing only changes of commit f1329a4624 - Show all commits

View File

@ -6,7 +6,6 @@ BEGIN
DECLARE vIsVirtual BOOL;
DECLARE vPrintedCount INT;
DECLARE vHasDistinctWarehouses BOOL;
DECLARE vHasAnyInvoiceBooked BOOL;
SET NEW.editorFk = account.myUser_getId();
@ -43,22 +42,5 @@ BEGIN
CALL supplier_checkIsActive(NEW.supplierFk);
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
END IF;
IF NOT (NEW.travelFk <=> OLD.travelFk)
OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN
SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk);
END IF;
IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk)THEN
SELECT COUNT(*) INTO vHasAnyInvoiceBooked
FROM entry e
JOIN invoiceIn ii ON ii.id = e.invoiceInFk
WHERE e.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 ;

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,20 @@ BEGIN
IF NOT (NEW.warehouseInFk <=> OLD.warehouseInFk) THEN
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
END IF;
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
DECLARE vHasAnyInvoiceBooked BOOL;
carlosap marked this conversation as resolved
Review

duplicat

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