feat: comprobaciones facturas contabilizadas refs #6932
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Carlos Andrés 2024-02-23 18:04:43 +01:00
parent e54d2d1162
commit bed4faceb7
2 changed files with 29 additions and 0 deletions

View File

@ -47,5 +47,19 @@ BEGIN
OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN
SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk);
END IF; 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$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -17,5 +17,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 vHanAnyInvoiceBooked BOOL;
SELECT COUNT(*) INTO vHanAnyInvoiceBooked
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$$ END$$
DELIMITER ; DELIMITER ;