module Ledger.Transaction
where
import Ledger.Utils
import Ledger.Types
import Ledger.Dates
import Ledger.Entry
import Ledger.RawTransaction
import Ledger.Amount
instance Show Transaction where show=showTransaction
showTransaction :: Transaction -> String
showTransaction (Transaction eno stat d desc a amt ttype) =
s ++ unwords [showDate d,desc,a,show amt,show ttype]
where s = if stat then " *" else ""
flattenEntry :: (Entry, Int) -> [Transaction]
flattenEntry (Entry d s _ desc _ ts _, e) =
[Transaction e s d desc (taccount t) (tamount t) (rttype t) | t <- ts]
accountNamesFromTransactions :: [Transaction] -> [AccountName]
accountNamesFromTransactions ts = nub $ map account ts
sumTransactions :: [Transaction] -> MixedAmount
sumTransactions = sum . map amount
nulltxn = Transaction 0 False (parsedate "1900/1/1") "" "" nullmixedamt RegularTransaction