tarioch / beancounttools

Beancount Tools
MIT License
79 stars 23 forks source link

[Revolut] Support importing the fees #115

Closed alvarogarcia7 closed 3 months ago

alvarogarcia7 commented 3 months ago

Support importing the fees from Revolut.

Based on https://github.com/tarioch/beancounttools/pull/105 by @Dr-Nuke

Status:

Usage

When creating the Revolut Importer, pass an optional parameter fee:

revolut_importer = revolutimp.Importer(
  "data/revolut.*.csv",
  "Assets:Revolut:EUR", 
  "EUR", 
  fee={'account': "Expenses:Revolut:Fees"} # new attribute
)
CONFIG = [revolut_importer]

Smart Importer,

As discussed in https://github.com/tarioch/beancounttools/pull/105, when the transaction has more than one posting, smart import won't work anymore.

Proposed workflow:

  1. Would it be possible to import once, without fee; then apply smart import.
  2. Then import again, with fee
  3. Then merge the transactions, given that:
    • The exports will be usually small (~10-100 entries)
    • The order is respected, hence the merge can be O(n), where n is the number of entries on the CSV file.

If you would be so kind to guide me along those lines, I'll be happy to implement such workflow.

alvarogarcia7 commented 3 months ago

As I kept investigating about this, I came up with an alternative:

A line of the Revolut CSV is turned into two transactions:

  1. Actual expense
  2. Revolut fee

an example:

2023-03-06 * "Cash ATM 3"
  Assets:Revolut:EUR                   -8.47 EUR
  Expenses:CashWithdrawal

2023-03-06 * "Fees for Cash ATM 3"
  Assets:Revolut:EUR                   -0.08 EUR
  Expenses:Revolut:Fees                 0.08 EUR 

This allows for the smart_importer to still work.

What are your thoughts, @tarioch ?

tarioch commented 3 months ago

I think the split keeps it simple to work with smart importer and I don't have a better idea, let's use that.

tarioch commented 3 months ago

@alvarogarcia7 do you want me to merge it like this or do you want to change it into the split transactions?

alvarogarcia7 commented 3 months ago

I have submitted the change in code, to add the fee as a new transaction. thanks,

alvarogarcia7 commented 3 months ago

May I suggest to squash the changes, to actually lose the intermediate history?

alvarogarcia7 commented 3 months ago

Status:

tarioch commented 3 months ago

I think there is now a pre-commit failure with the latest changes, if you can fix that, I think we can merge it. Honestly I keep the tests a bit limited in here (I have some real data based tests for some of the importers in my personal repo). I think it's ok not to add a test for it.