diff --git a/Makefile b/Makefile index 3d6aa82ef..4d37d70dc 100644 --- a/Makefile +++ b/Makefile @@ -1392,26 +1392,27 @@ doc/lib.m4: $(VERSIONFILE) setversion: $(VERSIONSENSITIVEFILES) #$(call def-help,setversion, update version strings & bounds from $(VERSIONFILE) (might need -B) ) updateversion: setversion $(call def-help,updateversion, update version strings & bounds from $(VERSIONFILE) and commit (might need -B) ) - @read -p "please review changes then press enter to commit: $(VERSIONFILE) $(VERSIONSENSITIVEFILES)" + @read -p "please review changes then press enter to commit $(VERSIONFILE) $(VERSIONSENSITIVEFILES)" git commit -m "bump version strings & lower bounds to $(VERSION)" $(VERSIONFILE) $(VERSIONSENSITIVEFILES) # (re)generate a cabal file from its package.yaml definition # XXX to avoid warnings, this hpack should be the same version as stack's built-in hpack -%.cabal: $$(dir $$@)package.yaml - hpack --silent $(dir $*) +#%.cabal: $$(dir $$@)package.yaml +# hpack --silent $(dir $*) +# +gencabal: $(call def-help,gencabal, regenerate cabal files from package.yaml files with stack ) + stack build --dry-run --silent -gencabal: $$(CABALFILES) #$(call def-help,gencabal, regenerate cabal files from package.yamls (might need -B) ) - -updatecabal: gencabal $(call def-help,updatecabal, regenerate and commit cabal files (might need -B) ) - @read -p "please review changes then press enter to commit: $(CABALFILES)" - git commit -m "update cabal files" $(CABALFILES) +updatecabal: gencabal $(call def-help,updatecabal, regenerate cabal files and commit ) + @read -p "please review changes then press enter to commit $(shell ls */*.cabal)" + git commit -m "update cabal files" $(shell ls */*.cabal) # we call in shake for this job; so dependencies aren't checked here genmanuals: Shake #$(call def-help,genmanuals, regenerate embedded manuals (might need -B) ) ./Shake manuals updatemanuals: genmanuals $(call def-help,updatemanuals, regenerate embedded manuals and commit (might need -B) ) - @read -p "please review changes then press enter to commit: $(shell ls hledger*/hledger*.{1,5,info,txt})" + @read -p "please review changes then press enter to commit $(shell ls hledger*/hledger*.{1,5,info,txt})" git commit -m "update embedded manuals" hledger*/hledger*.{1,5,info,txt} diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index ea3a1bc04..85dac541f 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -24,6 +24,7 @@ import Prelude.Compat hiding (readFile) import Control.Monad.Compat import Control.Monad.Except (ExceptT(..), runExceptT, throwError) --, catchError) import Control.Monad.State.Strict +import Data.Char import Data.Data import Data.Default import Data.Functor.Identity @@ -599,7 +600,7 @@ rawnumberp = do (firstSep, groups) <- option (Nothing, []) $ do leadingDigits <- some digitChar option (Nothing, [leadingDigits]) . try $ do - firstSep <- oneOf sepChars + firstSep <- oneOf sepChars <|> whitespaceChar groups <- some digitChar `sepBy1` char firstSep return (Just firstSep, leadingDigits : groups) @@ -614,11 +615,14 @@ rawnumberp = do return (lastSep, fromMaybe [] digits) -- make sure we didn't leading part of mistyped number - notFollowedBy $ oneOf sepChars + notFollowedBy $ oneOf sepChars <|> (whitespaceChar >> digitChar) return $ dbg8 "rawnumberp" (firstSep, groups, extraGroup) "rawnumberp" +-- | Parse a unicode char that represents any non-control space char (Zs general category). +whitespaceChar :: TextParser m Char +whitespaceChar = charCategory Space -- test_numberp = do -- let s `is` n = assertParseEqual (parseWithState mempty numberp s) n diff --git a/hledger-lib/hledger-lib.cabal b/hledger-lib/hledger-lib.cabal index 2da545266..3dcc8615f 100644 --- a/hledger-lib/hledger-lib.cabal +++ b/hledger-lib/hledger-lib.cabal @@ -1,4 +1,4 @@ --- This file has been generated from package.yaml by hpack version 0.21.2. +-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack -- diff --git a/hledger-lib/hledger_journal.m4.md b/hledger-lib/hledger_journal.m4.md index fb55737d7..9d0bb45e2 100644 --- a/hledger-lib/hledger_journal.m4.md +++ b/hledger-lib/hledger_journal.m4.md @@ -267,7 +267,8 @@ Amounts consist of a number and (usually) a currency symbol or commodity name. S `3 "green apples"`\ `-$1,000,000.00`\ `INR 9,99,99,999.00`\ - `EUR -2.000.000,00` + `EUR -2.000.000,00`\ + `1 999 999.9455` As you can see, the amount format is somewhat flexible: @@ -275,7 +276,8 @@ As you can see, the amount format is somewhat flexible: - the commodity is a symbol, word, or phrase, on the left or right, with or without a separating space. If the commodity contains numbers, spaces or non-word punctuation it must be enclosed in double quotes. - negative amounts with a commodity on the left can have the minus sign before or after it -- digit groups (thousands, or any other grouping) can be separated by commas (in which case period is used for decimal point) or periods (in which case comma is used for decimal point) +- digit groups (thousands, or any other grouping) can be separated by space or comma or period and should be used as separator between all groups +- decimal part can be separated by comma or period and should be different from digit groups separator You can use any of these variations when recording data. However, there is some ambiguous way of representing numbers like `$1.000` and `$1,000` both may mean either one thousand or one dollar. By default hledger will assume that this is sole delimiter is used only for decimals. On the other hand commodity format declared prior to that line will help to resolve that ambiguity differently: diff --git a/hledger-ui/hledger-ui.cabal b/hledger-ui/hledger-ui.cabal index 591f98dea..47244773c 100644 --- a/hledger-ui/hledger-ui.cabal +++ b/hledger-ui/hledger-ui.cabal @@ -1,4 +1,4 @@ --- This file has been generated from package.yaml by hpack version 0.21.2. +-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack -- diff --git a/hledger-web/Foundation.hs b/hledger-web/Foundation.hs index 59e60ec6f..90bc5d913 100644 --- a/hledger-web/Foundation.hs +++ b/hledger-web/Foundation.hs @@ -100,11 +100,13 @@ type Form x = Html -> MForm (HandlerT App IO) (FormResult x, Widget) instance Yesod App where approot = ApprootMaster $ appRoot . settings - -- Store session data on the client in encrypted cookies, - -- default session idle timeout is 120 minutes - makeSessionBackend _ = fmap Just $ defaultClientSessionBackend - (120 * 60) - ".hledger-web_client_session_key.aes" +-- -- Store session data on the client in encrypted cookies, +-- -- default session idle timeout is 120 minutes +-- makeSessionBackend _ = fmap Just $ defaultClientSessionBackend +-- (120 * 60) +-- ".hledger-web_client_session_key.aes" + -- don't use session data + makeSessionBackend _ = return Nothing defaultLayout widget = do master <- getYesod diff --git a/hledger/hledger.cabal b/hledger/hledger.cabal index 0d9cddf00..eaae680a7 100644 --- a/hledger/hledger.cabal +++ b/hledger/hledger.cabal @@ -1,4 +1,4 @@ --- This file has been generated from package.yaml by hpack version 0.21.2. +-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack -- diff --git a/tests/journal/numbers.test b/tests/journal/numbers.test index b81669c95..01e169173 100644 --- a/tests/journal/numbers.test +++ b/tests/journal/numbers.test @@ -43,6 +43,32 @@ hledger bal -f - >>> >>>=1 +# Space between digits groups +hledger bal -f - --no-total +<<< +2017/1/1 + a 1 000.00 EUR + b -1 000.00 EUR +>>> + 1 000.00 EUR a + -1 000.00 EUR b +>>>2 +>>>=0 + +# Space between digits groups in commodity directive +hledger bal -f - --no-total +<<< +commodity 1 000.00 EUR + +2017/1/1 + a 1,000.00 EUR + b -1,000.00 EUR +>>> + 1 000.00 EUR a + -1 000.00 EUR b +>>>2 +>>>=0 + # Default commodity hledger bal -f - <<<