feat: comprobaciones facturas contabilizadas refs #6932 #2091
|
@ -47,5 +47,19 @@ BEGIN
|
|||
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
|
||||
DECLARE vHanAnyInvoiceBooked BOOL;
|
||||
|
||||
SELECT COUNT(*) INTO vHanAnyInvoiceBooked
|
||||
FROM entry e
|
||||
JOIN invoiceIn ii ON ii.id = e.invoiceInFk
|
||||
WHERE e.id = NEW.id
|
||||
AND ii.isBooked;
|
||||
|
||||
IF vHanAnyInvoiceBooked THEN
|
||||
|
||||
CALL util.throw('The travel has entries with booked invoices')
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -17,5 +17,20 @@ BEGIN
|
|||
IF NOT (NEW.warehouseInFk <=> OLD.warehouseInFk) THEN
|
||||
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
||||
END IF;
|
||||
|
||||
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
|
||||
DECLARE vHanAnyInvoiceBooked BOOL;
|
||||
|
||||
SELECT COUNT(*) INTO vHanAnyInvoiceBooked
|
||||
carlosap marked this conversation as resolved
jgallego
commented
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 vHanAnyInvoiceBooked THEN
|
||||
CALL util.throw('The travel has entries with booked invoices')
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue
Ademés de que estem repentint codi, crec que teniem un altre cau de fer que en les entrades pasara igual que en tpv que si un ticket esta facturat ja no es pot modificar, es pot fer igual? si el contabilicen mirar quines coses no es poden tocar.
Si vols seguir en la linea que ho has plantejat, jo faria una funcion travel_hasInvoiceBooked o similar que li pases el travel et torna l'error i estos dos triggers que li pasen el travel. La unica diferencia es que en el trigger de entry tu estas sols comprobant l'entrada actual i en el que jo planteje es comprobarien totes les del travel, pero llegint el mensage d'error crec que es lo correcte.
Se decide dejar solamente las verificaciones a nivel de travel