Revised the cash account summary in the accounting application.

This commit is contained in:
依瑪貓 2020-07-17 00:13:52 +08:00
parent 70c3f01368
commit 3156bc97c0

View File

@ -297,7 +297,8 @@ def cash_summary(request, subject_code):
f"""SELECT
{month_definition} AS month,
SUM(CASE WHEN r.is_credit THEN r.amount ELSE 0 END) AS credit_amount,
SUM(CASE WHEN r.is_credit THEN 0 ELSE r.amount END) AS debit_amount
SUM(CASE WHEN r.is_credit THEN 0 ELSE r.amount END) AS debit_amount,
SUM(CASE WHEN r.is_credit THEN 1 ELSE -1 END * r.amount) AS balance
FROM accounting_records AS r
INNER JOIN (SELECT
t1.sn AS sn,
@ -324,7 +325,8 @@ ORDER BY month"""))
f"""SELECT
{month_definition} AS month,
SUM(CASE WHEN r.is_credit THEN r.amount ELSE 0 END) AS credit_amount,
SUM(CASE WHEN r.is_credit THEN 0 ELSE r.amount END) AS debit_amount
SUM(CASE WHEN r.is_credit THEN 0 ELSE r.amount END) AS debit_amount,
SUM(CASE WHEN r.is_credit THEN 1 ELSE -1 END * r.amount) AS balance
FROM accounting_records AS r
INNER JOIN (SELECT
t1.sn AS sn,