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

wish: hledger add should balance cost, not both entered commodities #1838

Open
simonmichael opened this issue Mar 10, 2022 · 1 comment
Open
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. add investing Related to investments, lots, capital gains, etc.

Comments

@simonmichael
Copy link
Owner

simonmichael commented Mar 10, 2022

Discussed in #hledger today: when entering a stock sale with hledger add, including the cost basis with @ notation, if you leave the last amount blank, expecting hledger to calculate the capital gain/loss, instead it will balance the transaction with both amounts. Ie you end up with the not-so-useful:

2021-07-18 ZEC sale
    Assets:Wallet          -0.5 ZEC @ $60
    Assets:Cash                       $40
    Income:CapitalGains              $-40
    Income:CapitalGains     0.5 ZEC @ $60

rather than:

2021-07-18 ZEC sale
    Assets:Wallet          -0.5 ZEC @ $60
    Assets:Cash                       $40
    Income:CapitalGains              $-10

or (equivalently):

2021-07-18 ZEC sale
    Assets:Wallet          -0.5 ZEC @ $60
    Assets:Cash                       $40
    Income:CapitalGains               

When parsing this entry hledger normally converts to cost and infers a $-10 balancing amount for the last posting; we think hledger add should do the same.

@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. add investing Related to investments, lots, capital gains, etc. labels Mar 10, 2022
@the-solipsist
Copy link
Collaborator

the-solipsist commented Mar 18, 2022

It might be useful for hledger add to check what the commonly-used commodity is for any particular account (so, using USD for Income:CapitalGains if USD is the most common commodity for that account).

There's a similar discussion going on for hledger-iadd: hpdeifel/hledger-iadd#65 (comment)

But then again, the two issues aren't fully equivalent. In this issue, it's a matter of explicit conversion, where cost is provided, and in the other, no cost is provided and so it is a question of whether an implicit conversion ought to be performed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. add investing Related to investments, lots, capital gains, etc.
Projects
None yet
Development

No branches or pull requests

2 participants