Skip to content
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

add monthly income-expense report #88

Merged
merged 1 commit into from
Aug 20, 2020
Merged

Conversation

kain88-de
Copy link
Contributor

My monthly income and expenses vary a bit during the year. I usually generate this report manually to know which month has been expensive and check if the income looks reasonable for each month. This level of detail is a lot more helpful for me to see how I am doing in the current year.

I'm new to haskell. Are there any tests for the report that should be added to this PR as well?

@apauley
Copy link
Owner

apauley commented Aug 14, 2020

My monthly income and expenses vary a bit during the year. I usually generate this report manually to know which month has been expensive and check if the income looks reasonable for each month. This level of detail is a lot more helpful for me to see how I am doing in the current year.

Thanks for taking the time to submit this pull request @kain88-de, great stuff.
I can see that it would be useful to have monthly versions of the income statement (and possibly some of the other reports?)

I'm new to haskell. Are there any tests for the report that should be added to this PR as well?

I don't think we need more report tests yet, while we're still figuring out what reports people want.
We just need the existing tests to pass.

But I noticed the change didn't compile - luckily it looks as if we need a very small change to get it to compile.
I will comment on the line where the problem is, and then you can try again.

I noticed the commit was done via the Github web interface - can you compile it on your own machine?
The feedback cycle will be faster if you compile it yourself.
Otherwise you can wait for the Travis CI and CircleCI results after each commit. But that will be slow.

@@ -59,7 +59,7 @@ generateReports' opts ch = do
ownerParams <- ownerParameters opts ch owners
let ownerWithAggregateParams = (if length owners > 1 then [aggregateParams] else []) ++ ownerParams
let sharedOptions = ["--pretty-tables", "--depth", "2"]
let ownerWithAggregateReports = List.concat $ fmap (reportActions opts ch [incomeStatement sharedOptions, balanceSheet sharedOptions]) ownerWithAggregateParams
let ownerWithAggregateReports = List.concat $ fmap (reportActions opts ch [incomeStatement incomeMonthlyStatement sharedOptions, balanceSheet sharedOptions]) ownerWithAggregateParams
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list [incomeStatement sharedOptions, balanceSheet sharedOptions] (baseline code) is a list of ReportGenerators

In Haskell incomeStatement sharedOptions means we are supplying one argument (sharedOptions) to the function named incomeStatement, and in this case the result type is then ReportGenerator.

To use your new monthly function, I think you should add an element to the list like this:
[incomeStatement sharedOptions, incomeMonthlyStatement sharedOptions, balanceSheet sharedOptions]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thanks, I overlooked that yesterday. This also explains where the sharedOptions come from. I was wondering where that variable comes from.

@apauley
Copy link
Owner

apauley commented Aug 14, 2020

Another reason to compile it yourself is so that you can run it first and look at the results.

A lot of the time when I look at the output of what I did it triggers ideas to do it better, or I find out that I actually want to do something a bit differently.

My monthly income and expenses vary a bit during the year. I usually generate this report manually to know which month has been expensive and check if the income looks reasonable for each month. This level of detail is a lot more helpful for me to see how I am doing in the current year.
@kain88-de
Copy link
Contributor Author

Another reason to compile it yourself is so that you can run it first and look at the results.

A lot of the time when I look at the output of what I did it triggers ideas to do it better, or I find out that I actually want to do something a bit differently.

Normally I do that too. I'm just trying to do it extra hard and try to run all my builds in Docker containers or VMs.

@apauley apauley merged commit 31c42cd into apauley:master Aug 20, 2020
@apauley
Copy link
Owner

apauley commented Aug 20, 2020

Thanks @kain88-de, it is merged. I want to make a small change before this is released.

Instead of the current reports/john/2020/income-expenses-monthly.txt filename, I would like to make a monthly directory where this and future monthly reports can live.

The above example would then become reports/john/2020/monthly/income-expenses.txt.

If you want to do it please let me know, otherwise I will look at it when I get a chance.

@kain88-de kain88-de deleted the patch-1 branch August 20, 2020 19:28
@kain88-de
Copy link
Contributor Author

I'm not super into that idea. I thought it could be possible to place the reports into a config file. I do not see why this feature should require to recompile the program to add a new report. The program could have a build-in standard config for the current reports.

For the config, I would tend to simple key:value design with filename:hledger options. But it means it cannot say in which folder the file should be saved. We could also use a more verbose config that stores a folder to save the file. Or if the report should be calculated for all accounts or individual ones.

@apauley
Copy link
Owner

apauley commented Aug 29, 2020

@kain88-de All of your suggestions sound good to me.

Adding some config is something I've thought about doing in the past (see #18), but with the amount of free time I currently have to spend on this project I haven't been able to do it.

@apauley
Copy link
Owner

apauley commented Aug 29, 2020

I've changed the location of the monthly income statement to be in a monthly directory:

56554dd

@kain88-de
Copy link
Contributor Author

I can give it a try. But I’m not entirely sure how much time I’ll have either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants