whitespace

This commit is contained in:
Simon Michael 2009-07-31 17:02:47 +00:00
parent fa4ea69026
commit 472b65c5ab
4 changed files with 16 additions and 16 deletions

View File

@ -1,6 +1,6 @@
{-| {-|
A ledger-compatible @balance@ command. A ledger-compatible @balance@ command.
ledger's balance command is easy to use but not easy to describe ledger's balance command is easy to use but not easy to describe
precisely. In the examples below we'll use sample.ledger, which has the precisely. In the examples below we'll use sample.ledger, which has the
@ -114,7 +114,7 @@ balance opts args = putStr . showBalanceReport opts args
-- | Generate a balance report with the specified options for this ledger. -- | Generate a balance report with the specified options for this ledger.
showBalanceReport :: [Opt] -> [String] -> Ledger -> String showBalanceReport :: [Opt] -> [String] -> Ledger -> String
showBalanceReport opts _ l = acctsstr ++ totalstr showBalanceReport opts _ l = acctsstr ++ totalstr
where where
acctsstr = unlines $ map showacct interestingaccts acctsstr = unlines $ map showacct interestingaccts
where where
showacct = showInterestingAccount l interestingaccts showacct = showInterestingAccount l interestingaccts

View File

@ -1,4 +1,4 @@
{-| {-|
Print some statistics for the ledger. Print some statistics for the ledger.
@ -19,7 +19,7 @@ stats opts args l = do
putStr $ showStats opts args l today putStr $ showStats opts args l today
showStats :: [Opt] -> [String] -> Ledger -> Day -> String showStats :: [Opt] -> [String] -> Ledger -> Day -> String
showStats _ _ l today = showStats _ _ l today =
heading ++ unlines (map (\(a,b) -> printf fmt a b) stats) heading ++ unlines (map (\(a,b) -> printf fmt a b) stats)
where where
heading = underline $ printf "Ledger statistics as of %s" (show today) heading = underline $ printf "Ledger statistics as of %s" (show today)
@ -42,7 +42,7 @@ showStats _ _ l today =
-- Days since reconciliation : %(reconcileelapsed)s -- Days since reconciliation : %(reconcileelapsed)s
-- Days since last transaction : %(recentelapsed)s -- Days since last transaction : %(recentelapsed)s
] ]
where where
ts = sortBy (comparing ltdate) $ ledger_txns $ rawledger l ts = sortBy (comparing ltdate) $ ledger_txns $ rawledger l
lastdate | null ts = Nothing lastdate | null ts = Nothing
| otherwise = Just $ ltdate $ last ts | otherwise = Just $ ltdate $ last ts

View File

@ -71,7 +71,7 @@ rawLedgerAccountNameTree = accountNameTreeFrom . rawLedgerAccountNames
-- Keep only those which fall between the begin and end dates, and match -- Keep only those which fall between the begin and end dates, and match
-- the description pattern, and are cleared or real if those options are active. -- the description pattern, and are cleared or real if those options are active.
filterRawLedger :: DateSpan -> [String] -> Maybe Bool -> Bool -> RawLedger -> RawLedger filterRawLedger :: DateSpan -> [String] -> Maybe Bool -> Bool -> RawLedger -> RawLedger
filterRawLedger span pats clearedonly realonly = filterRawLedger span pats clearedonly realonly =
filterRawLedgerPostingsByRealness realonly . filterRawLedgerPostingsByRealness realonly .
filterRawLedgerTransactionsByClearedStatus clearedonly . filterRawLedgerTransactionsByClearedStatus clearedonly .
filterRawLedgerTransactionsByDate span . filterRawLedgerTransactionsByDate span .
@ -79,17 +79,17 @@ filterRawLedger span pats clearedonly realonly =
-- | Keep only ledger transactions whose description matches the description patterns. -- | Keep only ledger transactions whose description matches the description patterns.
filterRawLedgerTransactionsByDescription :: [String] -> RawLedger -> RawLedger filterRawLedgerTransactionsByDescription :: [String] -> RawLedger -> RawLedger
filterRawLedgerTransactionsByDescription pats (RawLedger ms ps ts tls hs f fp) = filterRawLedgerTransactionsByDescription pats (RawLedger ms ps ts tls hs f fp) =
RawLedger ms ps (filter matchdesc ts) tls hs f fp RawLedger ms ps (filter matchdesc ts) tls hs f fp
where matchdesc = matchpats pats . ltdescription where matchdesc = matchpats pats . ltdescription
-- | Keep only ledger transactions which fall between begin and end dates. -- | Keep only ledger transactions which fall between begin and end dates.
-- We include transactions on the begin date and exclude transactions on the end -- We include transactions on the begin date and exclude transactions on the end
-- date, like ledger. An empty date string means no restriction. -- date, like ledger. An empty date string means no restriction.
filterRawLedgerTransactionsByDate :: DateSpan -> RawLedger -> RawLedger filterRawLedgerTransactionsByDate :: DateSpan -> RawLedger -> RawLedger
filterRawLedgerTransactionsByDate (DateSpan begin end) (RawLedger ms ps ts tls hs f fp) = filterRawLedgerTransactionsByDate (DateSpan begin end) (RawLedger ms ps ts tls hs f fp) =
RawLedger ms ps (filter matchdate ts) tls hs f fp RawLedger ms ps (filter matchdate ts) tls hs f fp
where where
matchdate t = maybe True (ltdate t>=) begin && maybe True (ltdate t<) end matchdate t = maybe True (ltdate t>=) begin && maybe True (ltdate t<) end
-- | Keep only ledger transactions which have the requested -- | Keep only ledger transactions which have the requested
@ -112,7 +112,7 @@ filterRawLedgerPostingsByRealness True (RawLedger mts pts ts tls hs f fp) =
filterRawLedgerPostingsByDepth :: Int -> RawLedger -> RawLedger filterRawLedgerPostingsByDepth :: Int -> RawLedger -> RawLedger
filterRawLedgerPostingsByDepth depth (RawLedger mts pts ts tls hs f fp) = filterRawLedgerPostingsByDepth depth (RawLedger mts pts ts tls hs f fp) =
RawLedger mts pts (filter (not . null . ltpostings) $ map filtertxns ts) tls hs f fp RawLedger mts pts (filter (not . null . ltpostings) $ map filtertxns ts) tls hs f fp
where filtertxns t@LedgerTransaction{ltpostings=ps} = where filtertxns t@LedgerTransaction{ltpostings=ps} =
t{ltpostings=filter ((<= depth) . accountNameLevel . paccount) ps} t{ltpostings=filter ((<= depth) . accountNameLevel . paccount) ps}
-- | Keep only ledger transactions which affect accounts matched by the account patterns. -- | Keep only ledger transactions which affect accounts matched by the account patterns.
@ -124,7 +124,7 @@ filterRawLedgerTransactionsByAccount apats (RawLedger ms ps ts tls hs f fp) =
-- actual or effective date. -- actual or effective date.
rawLedgerSelectingDate :: WhichDate -> RawLedger -> RawLedger rawLedgerSelectingDate :: WhichDate -> RawLedger -> RawLedger
rawLedgerSelectingDate ActualDate rl = rl rawLedgerSelectingDate ActualDate rl = rl
rawLedgerSelectingDate EffectiveDate rl = rawLedgerSelectingDate EffectiveDate rl =
rl{ledger_txns=map (ledgerTransactionWithDate EffectiveDate) $ ledger_txns rl} rl{ledger_txns=map (ledgerTransactionWithDate EffectiveDate) $ ledger_txns rl}
-- | Give all a ledger's amounts their canonical display settings. That -- | Give all a ledger's amounts their canonical display settings. That
@ -134,13 +134,13 @@ rawLedgerSelectingDate EffectiveDate rl =
-- active. -- active.
canonicaliseAmounts :: Bool -> RawLedger -> RawLedger canonicaliseAmounts :: Bool -> RawLedger -> RawLedger
canonicaliseAmounts costbasis l@(RawLedger ms ps ts tls hs f fp) = RawLedger ms ps (map fixledgertransaction ts) tls hs f fp canonicaliseAmounts costbasis l@(RawLedger ms ps ts tls hs f fp) = RawLedger ms ps (map fixledgertransaction ts) tls hs f fp
where where
fixledgertransaction (LedgerTransaction d ed s c de co ts pr) = LedgerTransaction d ed s c de co (map fixrawposting ts) pr fixledgertransaction (LedgerTransaction d ed s c de co ts pr) = LedgerTransaction d ed s c de co (map fixrawposting ts) pr
fixrawposting (Posting s ac a c t) = Posting s ac (fixmixedamount a) c t fixrawposting (Posting s ac a c t) = Posting s ac (fixmixedamount a) c t
fixmixedamount (Mixed as) = Mixed $ map fixamount as fixmixedamount (Mixed as) = Mixed $ map fixamount as
fixamount = fixcommodity . (if costbasis then costOfAmount else id) fixamount = fixcommodity . (if costbasis then costOfAmount else id)
fixcommodity a = a{commodity=c} where c = canonicalcommoditymap ! symbol (commodity a) fixcommodity a = a{commodity=c} where c = canonicalcommoditymap ! symbol (commodity a)
canonicalcommoditymap = canonicalcommoditymap =
Map.fromList [(s,firstc{precision=maxp}) | s <- commoditysymbols, Map.fromList [(s,firstc{precision=maxp}) | s <- commoditysymbols,
let cs = commoditymap ! s, let cs = commoditymap ! s,
let firstc = head cs, let firstc = head cs,

View File

@ -50,7 +50,7 @@ main :: IO ()
main = do main = do
(opts, cmd, args) <- parseArguments (opts, cmd, args) <- parseArguments
run cmd opts args run cmd opts args
where where
run cmd opts args run cmd opts args
| Help `elem` opts = putStr usage | Help `elem` opts = putStr usage
| Version `elem` opts = putStrLn versionmsg | Version `elem` opts = putStrLn versionmsg