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
286 stars 45 forks source link

Add Support for Australia #53

Open eprbell opened 2 years ago

eprbell commented 2 years ago

RP2 and DaLI have a programmable plugin architecture for countries, accounting methods, report generators and more. Adding support for a new country is a high-impact activity because it allows many new potential users to get access to RP2 and DaLI.

Here's how to add support for a new country:

  1. add a new country plugin to RP2;
  2. if the country requires accounting methods that aren't already supported in RP2, add the necessary accounting method plugins;
  3. ensure any newly added accounting methods are reflected in the country plugin's get_default_accounting_method() and get_accounting_methods() methods;
  4. optionally, new country-specific report generators can be added. The built-in report generators (i.e. rp2_full_report and open_positions) are automatically supported;
  5. only for non-English speaking countries: translations for the built-in report generators and for any new report generator can be added;
  6. ensure any newly added report generators are reflected in the country plugin's get_report_generators() method;
  7. add the same country plugin to DaLI. The implementation on the DaLI side is trivial: it's just an entry point instantiating the RP2 country plugin and passing it to the main function;
  8. update the documentation of RP2 and DaLI to reflect the new country, accounting methods (if any) and report generators (if any).

If you notice the country-specific infrastructure is missing a feature that is required to express taxes for the new country, open an issue to let the RP2 community know.

peterpicard commented 1 year ago

Hi @eprbell, Australia's tax year is from 1st July to 30th June. I don't see any way to change the default behaviour of report generation (1st January to 31st December) through the exposed class methods. Any suggestions?

macanudo527 commented 1 year ago

There is nothing blocking you from sorting the data into years based on that calendar. RP2 gives you all the data by default and you can then sort that however you want. For example, in the tax report for Japan I sorted tax years like this:

# Sort all in and out transactions by year, the fee from intra transactions must be reported
for entry in chain(in_transaction_set, out_transaction_set, intra_transaction_set):  # type: ignore
  transaction: AbstractTransaction = cast(AbstractTransaction, entry)
  years_2_transaction_sets.setdefault(transaction.timestamp.year, []).append(entry)

I just used the timestamp year, but you could easily change that to filter the data however you want.

eprbell commented 1 year ago

What @macanudo527 is correct. I'll only add a couple of details:

  1. there is one class in RP2 that computes yearly summaries (YearlyGainLoss). It has hard-coded year start at Jan 1st. However the generator plugins for Australia (or another country) can simply ignore it (and compute its own summaries, if needed, or no summaries).
  2. tax year begin date could become a new method of country plugins
  3. YearlyGainLoss could use the new tax year begin date method to adjust its computation.

Point 1 is available today. Points 2 and 3 could be done as an enhancement.