import: apply journal's commodity styles to imported amounts
This commit is contained in:
parent
687494834b
commit
78894d46c8
@ -32,7 +32,7 @@ importcmd opts@CliOpts{rawopts_=rawopts,inputopts_=iopts} j = do
|
|||||||
inputstr = intercalate ", " $ map quoteIfNeeded inputfiles
|
inputstr = intercalate ", " $ map quoteIfNeeded inputfiles
|
||||||
catchup = boolopt "catchup" rawopts
|
catchup = boolopt "catchup" rawopts
|
||||||
dryrun = boolopt "dry-run" rawopts
|
dryrun = boolopt "dry-run" rawopts
|
||||||
iopts' = iopts{new_=True, new_save_=not dryrun}
|
iopts' = iopts{new_=True, new_save_=not dryrun, commoditystyles_=Just $ journalCommodityStyles j}
|
||||||
case inputfiles of
|
case inputfiles of
|
||||||
[] -> error' "please provide one or more input files as arguments" -- PARTIAL:
|
[] -> error' "please provide one or more input files as arguments" -- PARTIAL:
|
||||||
fs -> do
|
fs -> do
|
||||||
|
|||||||
@ -37,3 +37,8 @@ $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE
|
|||||||
|
|
||||||
(If you think import should leave amounts implicit like print does,
|
(If you think import should leave amounts implicit like print does,
|
||||||
please test it and send a pull request.)
|
please test it and send a pull request.)
|
||||||
|
|
||||||
|
### Commodity display styles
|
||||||
|
|
||||||
|
Imported amounts will be formatted according to the canonical [commodity styles](journal.html#commodity-display-style)
|
||||||
|
(declared or inferred) in the main journal file.
|
||||||
1
tests/import/a.csv
Normal file
1
tests/import/a.csv
Normal file
@ -0,0 +1 @@
|
|||||||
|
2020-01-01,"1.000.000,00"
|
||||||
|
2
tests/import/a.csv.rules
Normal file
2
tests/import/a.csv.rules
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fields date,amount
|
||||||
|
decimal-mark ,
|
||||||
2
tests/import/a.j
Normal file
2
tests/import/a.j
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
2020-01-01
|
||||||
|
(a) €1.00
|
||||||
9
tests/import/import.test
Normal file
9
tests/import/import.test
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# import applies the receiving journal's commodity styles to imported amounts
|
||||||
|
$ hledger -f a.j import --dry-run a.csv
|
||||||
|
; would import 1 new transactions from a.csv:
|
||||||
|
|
||||||
|
2020-01-01
|
||||||
|
expenses:unknown 1.000.000,00
|
||||||
|
income:unknown -1.000.000,00
|
||||||
|
|
||||||
|
>=
|
||||||
Loading…
Reference in New Issue
Block a user