fix:add: rethink adding default commodity symbol; fix doc instead [#815]

This commit is contained in:
Simon Michael 2024-01-04 17:12:58 -10:00
parent 034d37c3be
commit d462611d6a
3 changed files with 10 additions and 3 deletions

View File

@ -348,9 +348,10 @@ amountAndCommentWizard PrevInput{..} EntryState{..} = do
where
parseAmountAndComment s = if s == "<" then return Nothing else either (const Nothing) (return . Just) $
runParser
(evalStateT (amountandcommentp <* eof) esJournal)
(evalStateT (amountandcommentp <* eof) nodefcommodityj)
""
(T.pack s)
nodefcommodityj = esJournal{jparsedefaultcommodity=Nothing}
amountandcommentp :: JournalParser Identity (Amount, Text)
amountandcommentp = do
a <- amountp

View File

@ -62,6 +62,12 @@ Starting the next transaction (. or ctrl-D/ctrl-C to quit)
Date [2015/05/22]: <CTRL-D> $
```
If you enter a number with no commodity symbol,
and you have declared a default commodity with a `D` directive,
you might expect `add` to add this symbol for you.
It does not do this; we assume that if you are using a `D` directive
you prefer not to see the commodity symbol repeated on amounts in the journal.
On Microsoft Windows, the add command makes sure that no part of the
file path ends with a period, as that would cause problems
([#1056](https://github.com/simonmichael/hledger/issues/1056)).

View File

@ -60,7 +60,7 @@ $ printf 'D A1000.0\n' >t$$.j; hledger -f t$$.j add >/dev/null; cat t$$.j; rm -
> /a +A1000\.00/
>2 //
# ** 6. default commodity symbol is added when not entered
# ** 6. default commodity symbol is not added when not provided (#815)
<
@ -71,7 +71,7 @@ b
.
$ printf 'D A1000.00\n' >t$$.j; hledger -f t$$.j add >/dev/null; cat t$$.j; rm -f t$$.j
> /a +A1000\.00/
> /a +1000\.00/
>2 //
# ** 7. existing commodity with greater precision