diff --git a/Ledger/RawLedger.hs b/Ledger/RawLedger.hs index 72845b473..319fc2dd9 100644 --- a/Ledger/RawLedger.hs +++ b/Ledger/RawLedger.hs @@ -81,11 +81,11 @@ filterRawLedgerTransactionsByRealness True (RawLedger ms ps es f) = where filtertxns e@Entry{etransactions=ts} = e{etransactions=filter isReal ts} -- | Give all a ledger's amounts their canonical display settings. That --- is, in each commodity all amounts will use the display settings of the --- first amount detected, and the greatest precision of all amounts +-- is, in each commodity, amounts will use the display settings of the +-- first amount detected, and the greatest precision of the amounts -- detected. -setAmountDisplayPrefs :: RawLedger -> RawLedger -setAmountDisplayPrefs l@(RawLedger ms ps es f) = RawLedger ms ps (map fixEntryAmounts es) f +canonicaliseAmounts :: RawLedger -> RawLedger +canonicaliseAmounts l@(RawLedger ms ps es f) = RawLedger ms ps (map fixEntryAmounts es) f where fixEntryAmounts (Entry d s c de co ts pr) = Entry d s c de co (map fixRawTransactionAmounts ts) pr fixRawTransactionAmounts (RawTransaction ac a c t) = RawTransaction ac (fixMixedAmount a) c t diff --git a/Tests.hs b/Tests.hs index 7d791c181..eeaf5ff92 100644 --- a/Tests.hs +++ b/Tests.hs @@ -87,8 +87,8 @@ misc_tests = TestList [ assertparseequal (Mixed [dollars 47.18]) (parsewith transactionamount " $47.18") assertparseequal (Mixed [Amount (Commodity {symbol="$",side=L,spaced=False,comma=False,precision=0}) 1 Nothing]) (parsewith transactionamount " $1.") , - "setAmountDisplayPrefs" ~: do - let l = setAmountDisplayPrefs $ rawLedgerWithAmounts ["1","2.00"] + "canonicaliseAmounts" ~: do + let l = canonicaliseAmounts $ rawLedgerWithAmounts ["1","2.00"] assertequal [2,2] (rawLedgerPrecisions l) -- use greatest precision everywhere ] where diff --git a/hledger.hs b/hledger.hs index 128befbe4..58cd0a88d 100644 --- a/hledger.hs +++ b/hledger.hs @@ -73,7 +73,7 @@ parseLedgerAndDo :: [Opt] -> [String] -> ([Opt] -> [String] -> Ledger -> IO ()) parseLedgerAndDo opts args cmd = ledgerFilePathFromOpts opts >>= parseLedgerFile >>= either printParseError runcmd where - runcmd = cmd opts args . cacheLedger . setAmountDisplayPrefs . filterRawLedger b e dpats c r + runcmd = cmd opts args . cacheLedger . canonicaliseAmounts . filterRawLedger b e dpats c r b = parsemaybedate (beginDateFromOpts opts) e = parsemaybedate (endDateFromOpts opts) dpats = snd $ parseAccountDescriptionArgs args