diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index f2f4c2f26..dbf61fa60 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -246,6 +246,7 @@ directivep = (do ,defaultcommoditydirectivep ,commodityconversiondirectivep ,ignoredpricecommoditydirectivep + ,decimalmarkdirectivep ] ) "directive" @@ -317,6 +318,7 @@ includedirectivep = do jparsedefaultyear = jparsedefaultyear j ,jparsedefaultcommodity = jparsedefaultcommodity j ,jparseparentaccounts = jparseparentaccounts j + ,jparsedecimalmark = jparsedecimalmark j ,jparsealiases = jparsealiases j ,jcommodities = jcommodities j -- ,jparsetransactioncount = jparsetransactioncount j @@ -599,6 +601,18 @@ commodityconversiondirectivep = do lift restofline return () +-- | Read a valid decimal mark from the decimal-mark directive e.g +-- +-- decimal-mark , +decimalmarkdirectivep :: JournalParser m () +decimalmarkdirectivep = do + string "decimal-mark" "decimal mark" + lift skipNonNewlineSpaces1 + mark <- satisfy isDecimalMark + modify' $ \j -> j{jparsedecimalmark=Just mark} + lift restofline + return () + --- *** transactions -- | Parse a transaction modifier (auto postings) rule. diff --git a/hledger/test/journal/commas.journal b/hledger/test/journal/commas.journal new file mode 100644 index 000000000..c3e1ee4bc --- /dev/null +++ b/hledger/test/journal/commas.journal @@ -0,0 +1,4 @@ +decimal-mark , +2021-05-01 YANDEX.PLUS + Assets:Yandex -199,00 RUB + Expenses:Unknown:RUB diff --git a/hledger/test/journal/directive-decimal-mark.test b/hledger/test/journal/directive-decimal-mark.test new file mode 100644 index 000000000..016a4ac22 --- /dev/null +++ b/hledger/test/journal/directive-decimal-mark.test @@ -0,0 +1,22 @@ +# 1. Commas specified as decimal mark +$ hledger -f commas.journal bal + -199,00 RUB Assets:Yandex + 199,00 RUB Expenses:Unknown:RUB +-------------------- + 0 +>=0 + +# 2. Include file with different decimal mark +< +commodity 1000.00 RUB +include commas.journal +2021-05-19 MTS Phone + Assets:Yandex -100.5 RUB + Expenses:Phone 100.5 RUB +$ hledger -f - bal + -299.50 RUB Assets:Yandex + 100.50 RUB Expenses:Phone + 199.00 RUB Expenses:Unknown:RUB +-------------------- + 0 +>=0