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

should be possible to use balance assertions/assignments when reading csv #1000

Open
simonmichael opened this Issue Apr 3, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@simonmichael
Copy link
Owner

simonmichael commented Apr 3, 2019

From apo on IRC: balance assertions/balance assignments are not being applied when reading CSV. Also, it should let you omit the amount field assignment if there's a balance field assignment.

2018-10-15,100
2018-10-16,200
2018-10-17,300
fields date,bal
# Currently an amount field is required, but we can leave it blank.
# The following blank line is required to avoid a parsing bug.
amount 

balance EUR %bal
date-format %Y-%m-%d
description Assets Update
account1 assets
account2 income
$ hledger -f a.csv reg assets
2018/10/15 Assets Update           assets                             0             0
2018/10/16 Assets Update           assets                             0             0
2018/10/17 Assets Update           assets                             0             0
$ hledger -f a.csv print -x
2018/10/15 Assets Update
    assets     = EUR 100
    income

2018/10/16 Assets Update
    assets     = EUR 200
    income

2018/10/17 Assets Update
    assets     = EUR 300
    income

We should see:

$ hledger -f a.csv print -x
2018/10/15 Assets Update
    assets         EUR 100 = EUR 100
    income        EUR -100

2018/10/16 Assets Update
    assets         EUR 100 = EUR 200
    income        EUR -100

2018/10/17 Assets Update
    assets         EUR 100 = EUR 300
    income        EUR -100

You can work around by parsing a second time:

$ hledger -f a.csv print | hledger -f- print -x
@simonmichael

This comment has been minimized.

Copy link
Owner Author

simonmichael commented Apr 3, 2019

Related (tested with 61e8ccb):

  • currency should not add a currency symbol when the amount field is empty

  • amount*/balance* rule validation should be more robust, eg these malformed rules:

    amount-in %3
    balance %4
    

    give the following error:

    hledger: found values for amount and for amount-in/amount-out
    please use either amount or amount-in/amount-out
    

    It should be more precise, mentioning balance, and possibly should reuse the other message:

    Please specify (as a top level CSV rule) either the amount field,
    both the amount-in and amount-out fields, or the balance field. Eg:
    amount %2
    

simonmichael added a commit that referenced this issue Apr 3, 2019

simonmichael added a commit that referenced this issue Apr 3, 2019

simonmichael added a commit that referenced this issue Apr 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.