ledger-mode icon indicating copy to clipboard operation
ledger-mode copied to clipboard

Context at point doesn't handle negative commoditized amounts properly

Open kevinjfoley opened this issue 4 years ago • 3 comments

This seems to be because ledger-commoditized-amount-regexp doesn't properly handle negated amounts like -$100, so ledger-extract-context-info returns the account context with the separator and amount included in the account name.

For example calling ledger-context-at-point with point at | below:

2011/01/27 Book Store
    Expenses:Books                            $20.00
    Liabilities:MasterCard                   -$20.00|

returns: (acct-transaction account ((indent " " 76) (status nil nil) (account "Liabilities:MasterCard -$20.00" 80)))

I believe I have a fix and will open a PR shortly.

kevinjfoley avatar Nov 09 '19 18:11 kevinjfoley

I'm surprised that -$20.00 works like that. I'd figure that ledger would interpret -$ as a commodity.

jabranham avatar Nov 11 '19 14:11 jabranham

Yeah I'm surprised as well, maybe it's best to just avoid using this notation since there's probably lots of features in ledger-mode where it isn't accounted for?

I only use it because that's how ledger-autosync formats transactions, maybe it would be better to add some support for $-100.00 formatting there (assuming it doesn't already have it, I couldn't find it when I looked)

kevinjfoley avatar Nov 11 '19 15:11 kevinjfoley

@jabranham - is somewhat special. "-$" is how you would specify such a commodity.

jwiegley avatar Nov 11 '19 23:11 jwiegley