provinzio / CoinTaxman

Calculate your taxes from cryptocurrency gains
GNU Affero General Public License v3.0
142 stars 31 forks source link

How to create a report for former years? #134

Open tobias-p opened 2 years ago

tobias-p commented 2 years ago

Another - maybe stupid - question and/or a feature request:

Is it possible to create reports for each year without having a file for each year and running the app several times?

provinzio commented 2 years ago

You can currently only run and get the report for a specific year (selected in config.ini).

How long does it take for you to create a report for a year? (Without price fetching as this will be saved for future runs)

Consecutive runs shouldn't take as long as the first one

What do you mean by "a file for each year". Do you want s report that covers more than one year? I don't see the reason for that.

Please explain further.

tobias-p commented 2 years ago

You can currently only run and get the report for a specific year (selected in config.ini).

This was something I missed in config (overread it)... I just wanted to be able to create a report for each year I had coins but never thought about reaching them in in my tax (never really sold some of them before 2020, so that shouldn't be a problem).

Creating the report for 2021 didn't took so long since the price fetching was done... it was at max 3 mins...

provinzio commented 2 years ago

Ok. 3 min is not perfect but I find it acceptable for now.

Price fetching is currently really bad as each price is fetched on its own. So each line is one price fetch. Adding this information to the readme is a good idea.

16 does work on that by grouping the required prices and fetching them all at once.

tobias-p commented 2 years ago

3 mins for the really huge report is pretty good i thin (check out in discussion, I wrote how many lines I've got for each part).. Checked out the log, it was less than 2 mins

Another thing I found after creating all reports from former years: in 2021 I have everything of all former years within... This shouldn't happen, because sellings/airdrops/etc of former years should not appear in 2021

maybe I missed another thing in the config?

provinzio commented 2 years ago

There is only one tax year option in the config file. Sounds like a bug. Please debug the taxman.py and checkt that the function is_in_tax_year is called before something is added to the export. Looking forward to your findings.

tobias-p commented 2 years ago

There is only one tax year option in the config file. Sounds like a bug. Please debug the taxman.py and checkt that the function is_in_tax_year is called before something is added to the export. Looking forward to your findings.

the bug is in the book.py where you only check if utc_time.year <= config.TAX_YEAR and change != 0 since everything in eg 2014 happened befor 2021, everything will be added... EDIT1: found this in _append_operation and append_operation

EDIT 2: strikethrough wrong suggestion.

EDIT3: the upper ones were wrong... here's the correct destination: I think the bug is in the taxman.py where you assert op.utc_time.year <= config.TAX_YEAR in line 621

EDIT 4: the striked suggestion is possibly not so wrong as I thought, since you add the single operations in book after you got the prices... so the bug is in the book.py where you only check if utc_time.year <= config.TAX_YEAR and change != 0 and this should be the right one 😄

provinzio commented 2 years ago

Each evaluation is done by scratch. It's necessary to add all operations to the book and balance them to calculate the correct balance at the beginning of the year.

So in evaluation: everything has to be balanced. But only the tax year operations should be added to the export. (TaxReportEntry)

provinzio commented 2 years ago

Another thing I found after creating all reports from former years: in 2021 I have everything of all former years within... This shouldn't happen, because sellings/airdrops/etc of former years should not appear in 2021

I checked this out and this doesn't happen for me. I can not reproduce your problem. All transactions before TAX_YEAR are added to the operations variable. All operations are balanced but only the transactions in TAX_YEAR are added to the report (see taxman.py).

Please debug your evaluation. You might want to set a breakpoint in taxman.export_evaluation_as_excel and check which older operations get added and debug from there. Looking forward for your reply.