added view "ReconstructedBankStatement" to compare with the actual statement from the club's bank
This commit is contained in:
parent
f2f1bdf036
commit
36f8c2315f
20
schema.sql
20
schema.sql
@ -238,3 +238,23 @@ CREATE VIEW Balance AS
|
|||||||
) AS pr ON Account.ID=pr.ID
|
) AS pr ON Account.ID=pr.ID
|
||||||
;
|
;
|
||||||
|
|
||||||
|
CREATE VIEW ReconstructedBankStatement AS
|
||||||
|
SELECT c.date AS date,
|
||||||
|
c.purpose AS purpose,
|
||||||
|
account,
|
||||||
|
c.value AS credit,
|
||||||
|
NULL AS debit
|
||||||
|
FROM Credit AS c
|
||||||
|
LEFT OUTER JOIN Debit AS d ON c.ID=d.targetCredit
|
||||||
|
GROUP BY c.ID
|
||||||
|
HAVING count(d.billId) == 0 -- exclude internal transfers
|
||||||
|
UNION
|
||||||
|
SELECT date,
|
||||||
|
purpose,
|
||||||
|
debtor AS account,
|
||||||
|
NULL AS credit,
|
||||||
|
value AS debit
|
||||||
|
FROM Debit
|
||||||
|
WHERE targetCredit IS NULL -- exclude internal transfers
|
||||||
|
ORDER BY date ASC
|
||||||
|
;
|
||||||
|
Loading…
Reference in New Issue
Block a user