eprbell / rp2

Privacy-focused, free, open-source cryptocurrency tax calculator for multiple countries: it handles multiple coins/exchanges and computes long/short-term capital gains, cost bases, in/out lot relationships/fractioning, and account balances. It supports FIFO, LIFO, HIFO and it outputs in form 8949 format. It has a programmable plugin architecture
https://pypi.org/project/rp2/
Apache License 2.0
256 stars 42 forks source link

JP Tax Report #84

Closed macanudo527 closed 1 year ago

macanudo527 commented 1 year ago

This is the long-awaited Japan Tax Report. It is a modified version of the Excel spreadsheet they distribute to calculate taxes. They actually don't require this at all, but if they sense something fishy they might request it and some people send it in.

I just worked through and passed 'crypto_example' for now, but I'll be working through the other datasets over this week. I just thought I would submit this for some advice in the meantime. So, the 'test_ods_output_diff_jp.py' is a work in progress at the moment.

eprbell commented 1 year ago

Exciting to see this starting to take shape! I will review in a couple of days.

macanudo527 commented 1 year ago

This is no longer WIP. It should be the final draft.

One major change was that I added a row of styles for JPY in the full report. For each new currency, we will have to add a row of styles and update COMPATIBLE_FIAT in rp2_full_report.py as well as add a line to the styles sheet. The reason for this is that declaring the currency with ezodf just adds "JPY" to the end of the numbers. And it also has no effect on hyperlinks or formulas.

Even if the default did work, we would probably need to implement specific formatting anyway. For example, JPY typically doesn't have any decimal places, but the NTA (Japanese IRS) prefers two decimal places.

Also, the JP tax report needs the whole dataset, so setting to_date and from_date throws an exception. I'm not sure if there is a more elegant/pythonic way to do that.

Just FYI, I need to add fiat deposit to Dali-RP2, so I'll be headed over there next and then everything will be working.

PS documentation is on its way.

macanudo527 commented 1 year ago

I commented out the documentation for the -m switch. I don't see a need for it at the moment. Hopefully, we can resolve the accounting method issues soon.

Let me know your thoughts on keeping it / deleting / commenting it out.

eprbell commented 1 year ago

I commented out the documentation for the -m switch. I don't see a need for it at the moment. Hopefully, we can resolve the accounting method issues soon.

Let me know your thoughts on keeping it / deleting / commenting it out.

I'm OK with commenting it out for now.

macanudo527 commented 1 year ago

isort wants to fix the following files:

Fixing /home/john_snow/workspace/rp2/src/rp2/configuration.py Fixing /home/john_snow/workspace/rp2/src/rp2/abstract_accounting_method.py Fixing /home/john_snow/workspace/rp2/src/rp2/tax_engine.py Fixing /home/john_snow/workspace/rp2/src/rp2/accounting_engine.py Fixing /home/john_snow/workspace/rp2/src/rp2/rp2_configuration_translator.py Fixing /home/john_snow/workspace/rp2/src/rp2/plugin/accounting_method/hifo.py Fixing /home/john_snow/workspace/rp2/src/rp2/plugin/accounting_method/fifo.py Fixing /home/john_snow/workspace/rp2/src/rp2/plugin/accounting_method/lifo.py Fixing /home/john_snow/workspace/rp2/tests/test_gain_loss_set.py Fixing /home/john_snow/workspace/rp2/tests/test_configuration.py Fixing /home/john_snow/workspace/rp2/tests/test_tax_engine.py

And pre-commit wants to fix the end-of-file on these:

Fixing config/crypto_example.ini Fixing config/test_bad_data.ini Fixing config/test_data4.ini Fixing src/rp2/locales/kl/LC_MESSAGES/messages.po Fixing config/test_data_multi_method.ini Fixing config/test_large_input.ini Fixing src/rp2/locales/messages.pot Fixing config/test_data.ini Fixing src/rp2/locales/en/LC_MESSAGES/messages.po Fixing src/rp2/locales/ja/LC_MESSAGES/messages.po

Should I include that with this PR? or create another housekeeping PR?

I think it is going to create too much clutter.

eprbell commented 1 year ago

Could you try to make clean and install again? I wonder if you have an out of date isort.

macanudo527 commented 1 year ago

What do you mean by "make clean and install"?

I ran .venv/bin/pip3 install -e '.[dev]' and restored one of the files and it fixed it again.

Just eyeballing it, it doesn't look like it is making any big changes. Maybe it is reorganizing line breaks or spaces or something?

macanudo527 commented 1 year ago

Ok, now I see. It wants to put json first (for configuration.py):

+import json from configparser import ConfigParser, SectionProxy +from datetime import date, datetime from enum import Enum -import json -from datetime import date, datetime from pathlib import Path from typing import Any, Dict, List, Set

eprbell commented 1 year ago

That's fine: just leave it and commit everything. It's imports and end of files: shouldn't be too bad.

macanudo527 commented 1 year ago

This should be ready now. Let me know if I missed something.

eprbell commented 1 year ago

Sounds good: I'll review in the weekend.

eprbell commented 1 year ago

Congrats: the first non-US country has been merged!