6995-testToMaster_2410 #2139
|
@ -6,7 +6,6 @@ BEGIN
|
||||||
DECLARE vIsVirtual BOOL;
|
DECLARE vIsVirtual BOOL;
|
||||||
DECLARE vPrintedCount INT;
|
DECLARE vPrintedCount INT;
|
||||||
DECLARE vHasDistinctWarehouses BOOL;
|
DECLARE vHasDistinctWarehouses BOOL;
|
||||||
DECLARE vHasAnyInvoiceBooked BOOL;
|
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
|
@ -43,22 +42,5 @@ BEGIN
|
||||||
CALL supplier_checkIsActive(NEW.supplierFk);
|
CALL supplier_checkIsActive(NEW.supplierFk);
|
||||||
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
|
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
|
||||||
END IF;
|
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$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_beforeUpdate`
|
||||||
BEFORE UPDATE ON `travel`
|
BEFORE UPDATE ON `travel`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
DECLARE vHasAnyInvoiceBooked BOOL;
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
IF NOT (NEW.landed <=> OLD.landed)
|
IF NOT (NEW.landed <=> OLD.landed)
|
||||||
|
@ -17,5 +19,20 @@ BEGIN
|
||||||
IF NOT (NEW.warehouseInFk <=> OLD.warehouseInFk) THEN
|
IF NOT (NEW.warehouseInFk <=> OLD.warehouseInFk) THEN
|
||||||
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
|
||||||
|
DECLARE vHasAnyInvoiceBooked BOOL;
|
||||||
|
|
||||||
|
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$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue