feat: comprobaciones facturas contabilizadas refs #6932 #2091
|
@ -43,9 +43,9 @@ BEGIN
|
|||
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);
|
||||
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;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -3,9 +3,11 @@ 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)
|
||||
IF NOT (NEW.landed <=> OLD.landed)
|
||||
OR NOT (NEW.shipped <=> OLD.shipped) THEN
|
||||
CALL travel_checkDates(NEW.shipped, NEW.landed);
|
||||
END IF;
|
||||
|
@ -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
|
||||
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 ;
|
||||
|
|
Loading…
Reference in New Issue
duplicat