moneymanagerex / general-reports

Bunch of general reports for Money Manager Ex
http://moneymanagerex.org/
MIT License
72 stars 47 forks source link

Report to forecast near term cash flow #72

Open vomikan opened 3 years ago

vomikan commented 3 years ago

I had a desire for a report to forecast my cash flow for the next month. The Upcoming Transactions pane on the MMEX home page does not forecast far enough ahead for my desires. The built-in Cash Flow report when the Monthly option is selected gives you the aggregate information but I wanted detail lines as well as the total. I hope other MMEX users find this helpful. And I would appreciate your telling me if you find any errors. Thank you very much.

SELECT TRANSDATE, b.PAYEENAME AS PAYEES, case when TRANSCODE = 'Deposit' then TRANSAMOUNT else NULL end AS CREDITS, case when TRANSCODE = 'Withdrawal' then -TRANSAMOUNT else NULL end AS DEBITS FROM BILLSDEPOSITS_V1 a join payee_v1 b USING(PAYEEID)
WHERE TRANSDATE < date('now','+32 days') 
UNION ALL
SELECT date('now','+32 days') AS TRANSDATE, ' '  AS PAYEES, NULL AS CREDITS, ' ' AS DEBITS 
UNION ALL
SELECT date('now','+32 days')  AS TRANSDATE, ' ' AS PAYEES, NULL AS CREDITS, ' ' AS DEBITS 
UNION ALL
SELECT  date('now', '+32 days' ) AS TRANSDATE, 'TOTAL NEAR TERM EXPENSES' AS PAYEES, NULL AS CREDITS, sum(case when TRANSCODE = 'Withdrawal' then -TRANSAMOUNT else 0 end )  AS DEBITS FROM BILLSDEPOSITS_V1 WHERE TRANSDATE < date('now','+32 days') 
UNION ALL
SELECT date('now','+32 days' ) AS TRANSDATE, 'TOTAL NEAR TERM INCOME' AS PAYEES, sum(case when TRANSCODE = 'Deposit' then TRANSAMOUNT else 0 end )  AS CREDITS, NULL AS DEBITS FROM BILLSDEPOSITS_V1 WHERE TRANSDATE < date('now','+32 days')  ORDER BY TRANSDATE

https://forum.moneymanagerex.org/viewtopic.php?f=16&t=9580