Add details to convert entries

48 views
Skip to first unread message

Matthieu Talbot

unread,
Feb 5, 2019, 4:22:56 AM2/5/19
to Ledger
Hello,
New user here :) I have hacked some bash to convert the bank csv to a ledger csv on which I run "convert" and store the result in an "imported folder". Then in my main ledger file, I include every file from the imported folder. Now, some transactions need more fine tuning for example health ones, for which I pay a certain amount but will be reimbursed by the assurance later (if I got it correctly, the expense should be split into an asset:reimbursable and a later transaction will balance it). How can I specify a transaction from a different file? I tried to use uuid but the difference makes ledger stop so that's not the good approach. How do you manager this situation? :) best, Matthieu


Matthieu Talbot

unread,
Nov 27, 2022, 5:10:41 PM11/27/22
to Ledger
Answering myself there, for the record.

The workflow looks like this:

1) download all csvs from bank into one folder
2) run this makefile
```makefile
%.ledger: %.csv
    sed -i '1d' $<
    # "Date","Payee","Account number","Transaction type","Payment reference","Category","Amount (EUR)","Amount (Foreign Currency)","Type Foreign Currency","Exchange Rate"
    sed -i '1i date,payee,Account number,Transaction type,note,category,amount' $<
    touch main.ledger
    touch empty.ledger
    ledger convert $< --account Assets:my_bank_csv --rich-data --invert -f empty.ledger > $@
    echo "add currency to expenses"
    sed -i 's/Expenses.*[0-9]$$/& EUR/' $@
    rm empty.ledger
ledger_files:= $(patsubst %.csv,%.ledger,$(wildcard *.csv))
main.ledger: $(ledger_files)
    find *.ledger -type f -exec cat '{}' \; >> main.ledger.tmp
    echo "Inject our rules in"
    ledger print -f rules.ledger -f main.ledger.tmp > main.ledger
```

then, in rules.ledger, one can inject custom payees, and then accounts too for entries that are too generic (amazon for example, or paypal)
```
; careful to use "uuid" and not "UUID" here
payee CUSTOM Amazon 9fa2b323d58d031afe7b776c5106949acf1
    uuid 9fa2b323d58d031afe7b776c5106949acf1

account Expenses:House:Fixing Materials
    payee ^CUSTOM Amazon 9fa2b323d58d031afe7b776c5106949acf1
```
Reply all
Reply to author
Forward
0 new messages