Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV import rules, define commodity style #2161

Open
PSLLSP opened this issue Jan 30, 2024 · 0 comments
Open

CSV import rules, define commodity style #2161

PSLLSP opened this issue Jan 30, 2024 · 0 comments

Comments

@PSLLSP
Copy link

PSLLSP commented Jan 30, 2024

I would like to have an option to define commodity style in CSV import rules, to support keyword commodity.

Example:

$ cat demo-eur.csv
2023-01-23,test,1 234.56,EUR
$ cat demo-eur.csv.rules
# hledger import rules, test

date  %1
description DEMO|%2

amount %3 %4

account1 expenses:assorted
account2 assets:cash

# debug
comment \n%1,%2,%3,%4

When I create journal with hledger print then hledger uses amount format from CSV file and there is no way to overwrite commodity format in CSV import rules file.

$ hledger -f demo-eur.csv print
2023-01-23 DEMO|test
    ; 2023-01-23,test,1 234.56,EUR
    expenses:assorted     1 234.56 EUR
    assets:cash          -1 234.56 EUR

I can use command line option to define "commodity", that is a current solution:

$ hledger -f demo-eur.csv print -c "1.00 EUR"
2023-01-23 DEMO|test
    ; 2023-01-23,test,1 234.56,EUR
    expenses:assorted     1234.56 EUR
    assets:cash          -1234.56 EUR

or

$ hledger -f demo-eur.csv print -c "1,000.00 EUR"
2023-01-23 DEMO|test
    ; 2023-01-23,test,1 234.56,EUR
    expenses:assorted     1,234.56 EUR
    assets:cash          -1,234.56 EUR

Is it possible to add support for keyword commodity to CSV import file rules?

When CSV file has several currencies, it starts to be complicated, each currency has to be defined on command line. I do not store details here, just output (csv file and import rules evolved...). I prefer to define default commodity formats in CSV import rules...

$ hledger -f demo-eur.csv print
2023-01-24 DEMO|test2
    ; 2023-01-24,test2,2 345.56,USD,2 456.78,EUR
    expenses:assorted      2 345.56 USD @@ 2 456.78 EUR
    assets:cash          -2 345.56 USD @@ -2 456.78 EUR
    equity:conversion
$ hledger -f demo-eur.csv print -c "1.00 EUR" -c "1.00 USD"
2023-01-24 DEMO|test2
    ; 2023-01-24,test2,2 345.56,USD,2 456.78,EUR
    expenses:assorted      2345.56 USD @@ 2456.78 EUR
    assets:cash          -2345.56 USD @@ -2456.78 EUR
    equity:conversion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant