Added check so that debits cannot be linked with an incoming payment as target
This commit is contained in:
parent
acad2118c5
commit
d915d32e3b
@ -58,6 +58,15 @@ BEGIN
|
||||
!= (SELECT account FROM Credit WHERE Id=NEW.fromCredit)
|
||||
;
|
||||
|
||||
SELECT RAISE(FAIL, "Target of a debit cannot be an incoming payment")
|
||||
FROM Credit c
|
||||
JOIN Debit d ON c.Id = d.targetCredit
|
||||
WHERE c.Id = NEW.fromCredit
|
||||
AND c.value > 0
|
||||
GROUP BY c.Id
|
||||
HAVING count(d.billId) == 0
|
||||
;
|
||||
|
||||
INSERT INTO _temp
|
||||
SELECT remainingDebt, remainingCredit, min(remainingDebt,remainingCredit)
|
||||
FROM (SELECT
|
||||
|
@ -9,9 +9,9 @@ john: 0 +0 0
|
||||
Club: 0 +0 -16250
|
||||
alex: 7200 +16250 0
|
||||
# Some updates and deletes that could, unless denied, destroy consistency ...
|
||||
Error: near line 338: paid is set and adjusted automatically according to added Transfer records
|
||||
Error: near line 339: Debt is involved in transfers to revoke at first
|
||||
Error: near line 340: FOREIGN KEY constraint failed
|
||||
Error: near line 347: paid is set and adjusted automatically according to added Transfer records
|
||||
Error: near line 348: Debt is involved in transfers to revoke at first
|
||||
Error: near line 349: FOREIGN KEY constraint failed
|
||||
# After revoking transactions, you are free to change or delete debts and credits ...
|
||||
Club: 7200 +0 0
|
||||
alex: 0 +0 0
|
||||
|
Loading…
Reference in New Issue
Block a user