-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Category report #48
Comments
Hi @vomikan, Nice work, looks beautiful. There are bugs though :-(. As I've been writing quite some time ago in moneymanagerex/moneymanagerex#789 it is a somewhat challenge to get accounts in different currencies to play well for this report within the bounds of the GRF framework. I hadn't been following changes in GRF framework since than so I'm not sure if things hadn't changed now but at least I can state that the report you posted here produces incorrect results for my main database. My main DB currency is RUR but I've got several accounts billed in EUR and USD. It looks like all expenditures and reciepts for these accounts are treated to be RUR without taking rates conversion into the account. Also there's an UI bug in MMEx (the build I used is from git commit 51e4e669, master branch): when you select period to be anything else than "Current month" and then click on any other report and then click back on the "Categories_v4" you will end up with report generated for "Current month" period while "Period" dropdown list will show your last choice instead. It is not related to this issue and your report, it is a bug in MMEx, I just thought it'd worth mentioning as chances are you'd be faster than me chasing this one. |
My original SQL from moneymanagerex/moneymanagerex#1689 should correctly report all amounts in base currency using historical rates (or 1:1 if not defined): select
CATEGNAME || coalesce(':' || SUBCATEGNAME, '') as ID,
sum(TRANSAMOUNT) as amount
from (
select
coalesce(s.CATEGID, c.CATEGID) as CATEGID,
coalesce(s.SUBCATEGID, c.SUBCATEGID) as SUBCATEGID,
coalesce(CURRVALUE,1)*coalesce(SPLITTRANSAMOUNT,TRANSAMOUNT)*(case TRANSCODE when 'Withdrawal' then -1 else 1 end) as TRANSAMOUNT
from CHECKINGACCOUNT c
left join SPLITTRANSACTIONS s on s.TRANSID = c.TRANSID
left join ACCOUNTLIST a on a.ACCOUNTID = c.ACCOUNTID
left join CURRENCYHISTORY hist on (hist.CURRENCYID = a.CURRENCYID AND CURRDATE = (
select max(h2.CURRDATE)
from CURRENCYHISTORY h2
where h2.CURRDATE<=TRANSDATE
))
where TOACCOUNTID <> 32702 and TRANSCODE <> 'Transfer'
) as trans
left join CATEGORY cat on cat.CATEGID = trans.CATEGID
left join SUBCATEGORY subcat on subcat.SUBCATEGID = trans.SUBCATEGID
group by ID
having amount < 0 -- <0 == Withdrawal, >0 == Deposit
; |
@slodki, thanks for your example query. In attachment you may find an updated Categories_v4 report with SQL query utilizing currency history in a similar way you did in your report. I had also done some minor changes to template (replaced toLocaleString with toFixed(2) at relevant places) |
This sql would work fine if currency exchange rates has been set correctly for all transaction date range. |
This select max(h2.CURRDATE)
from CURRENCYHISTORY h2
where h2.CURRDATE<=TRANSDATE will:
|
In htt file the following line may be replaced by next one:
|
Regarding this issue I've created GRM adapted report
moneymanagerex/moneymanagerex#1689
Categories_v4.zip
The text was updated successfully, but these errors were encountered: