hledger/Ledger/RawTransaction.hs

34 lines
1003 B
Haskell
Raw Normal View History

{-|
A 'RawTransaction' represents a single transaction line within a ledger
entry. We call it raw to distinguish from the cached 'Transaction'.
-}
module Ledger.RawTransaction
where
import Ledger.Utils
2008-10-03 04:12:59 +04:00
import Ledger.Types
import Ledger.Amount
2008-10-15 23:14:34 +04:00
import Ledger.AccountName
instance Show RawTransaction where show = showRawTransaction
showRawTransaction :: RawTransaction -> String
showRawTransaction (RawTransaction a amt _ ttype) =
showaccountname a ++ " " ++ (showamount amt)
where
showaccountname = printf "%-22s" . bracket . elideAccountName width
showamount = printf "%12s" . showMixedAmountOrZero
(bracket,width) = case ttype of
BalancedVirtualTransaction -> (\s -> "["++s++"]", 20)
VirtualTransaction -> (\s -> "("++s++")", 20)
otherwise -> (id,22)
isReal :: RawTransaction -> Bool
isReal t = rttype t == RegularTransaction
hasAmount :: RawTransaction -> Bool
2008-10-19 00:29:42 +04:00
hasAmount = (/= missingamt) . tamount