rename setAmountDisplayPrefs to canonicaliseAmounts
This commit is contained in:
parent
514f015849
commit
ea5a87815b
@ -81,11 +81,11 @@ filterRawLedgerTransactionsByRealness True (RawLedger ms ps es f) =
|
|||||||
where filtertxns e@Entry{etransactions=ts} = e{etransactions=filter isReal ts}
|
where filtertxns e@Entry{etransactions=ts} = e{etransactions=filter isReal ts}
|
||||||
|
|
||||||
-- | Give all a ledger's amounts their canonical display settings. That
|
-- | Give all a ledger's amounts their canonical display settings. That
|
||||||
-- is, in each commodity all amounts will use the display settings of the
|
-- is, in each commodity, amounts will use the display settings of the
|
||||||
-- first amount detected, and the greatest precision of all amounts
|
-- first amount detected, and the greatest precision of the amounts
|
||||||
-- detected.
|
-- detected.
|
||||||
setAmountDisplayPrefs :: RawLedger -> RawLedger
|
canonicaliseAmounts :: RawLedger -> RawLedger
|
||||||
setAmountDisplayPrefs l@(RawLedger ms ps es f) = RawLedger ms ps (map fixEntryAmounts es) f
|
canonicaliseAmounts l@(RawLedger ms ps es f) = RawLedger ms ps (map fixEntryAmounts es) f
|
||||||
where
|
where
|
||||||
fixEntryAmounts (Entry d s c de co ts pr) = Entry d s c de co (map fixRawTransactionAmounts ts) pr
|
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
|
fixRawTransactionAmounts (RawTransaction ac a c t) = RawTransaction ac (fixMixedAmount a) c t
|
||||||
|
|||||||
4
Tests.hs
4
Tests.hs
@ -87,8 +87,8 @@ misc_tests = TestList [
|
|||||||
assertparseequal (Mixed [dollars 47.18]) (parsewith transactionamount " $47.18")
|
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.")
|
assertparseequal (Mixed [Amount (Commodity {symbol="$",side=L,spaced=False,comma=False,precision=0}) 1 Nothing]) (parsewith transactionamount " $1.")
|
||||||
,
|
,
|
||||||
"setAmountDisplayPrefs" ~: do
|
"canonicaliseAmounts" ~: do
|
||||||
let l = setAmountDisplayPrefs $ rawLedgerWithAmounts ["1","2.00"]
|
let l = canonicaliseAmounts $ rawLedgerWithAmounts ["1","2.00"]
|
||||||
assertequal [2,2] (rawLedgerPrecisions l) -- use greatest precision everywhere
|
assertequal [2,2] (rawLedgerPrecisions l) -- use greatest precision everywhere
|
||||||
|
|
||||||
] where
|
] where
|
||||||
|
|||||||
@ -73,7 +73,7 @@ parseLedgerAndDo :: [Opt] -> [String] -> ([Opt] -> [String] -> Ledger -> IO ())
|
|||||||
parseLedgerAndDo opts args cmd =
|
parseLedgerAndDo opts args cmd =
|
||||||
ledgerFilePathFromOpts opts >>= parseLedgerFile >>= either printParseError runcmd
|
ledgerFilePathFromOpts opts >>= parseLedgerFile >>= either printParseError runcmd
|
||||||
where
|
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)
|
b = parsemaybedate (beginDateFromOpts opts)
|
||||||
e = parsemaybedate (endDateFromOpts opts)
|
e = parsemaybedate (endDateFromOpts opts)
|
||||||
dpats = snd $ parseAccountDescriptionArgs args
|
dpats = snd $ parseAccountDescriptionArgs args
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user