nullamt and nullmixedamt

This commit is contained in:
Simon Michael 2008-11-22 17:21:49 +00:00
parent d5a145f7e4
commit 54b164a7ab
5 changed files with 11 additions and 6 deletions

View File

@ -19,5 +19,5 @@ instance Show Account where
instance Eq Account where instance Eq Account where
(==) (Account n1 t1 b1) (Account n2 t2 b2) = n1 == n2 && t1 == t2 && b1 == b2 (==) (Account n1 t1 b1) (Account n2 t2 b2) = n1 == n2 && t1 == t2 && b1 == b2
nullacct = Account "" [] nullamt nullacct = Account "" [] nullmixedamt

View File

@ -137,9 +137,14 @@ normaliseMixedAmount (Mixed as) = Mixed $ map sum $ grouped
symbols = sort $ nub $ map (symbol . commodity) as symbols = sort $ nub $ map (symbol . commodity) as
hassymbol s a = s == (symbol $ commodity a) hassymbol s a = s == (symbol $ commodity a)
-- | The empty simple amount.
nullamt :: Amount
nullamt = Amount unknown 0 Nothing
-- | The empty mixed amount. -- | The empty mixed amount.
nullamt :: MixedAmount nullmixedamt :: MixedAmount
nullamt = Mixed [] nullmixedamt = Mixed []
-- | A temporary value for parsed transactions which had no amount specified. -- | A temporary value for parsed transactions which had no amount specified.
missingamt :: MixedAmount missingamt :: MixedAmount

View File

@ -15,7 +15,7 @@ import Ledger.AccountName
instance Show RawTransaction where show = showRawTransaction instance Show RawTransaction where show = showRawTransaction
nullrawtxn = RawTransaction "" nullamt "" RegularTransaction nullrawtxn = RawTransaction "" nullmixedamt "" RegularTransaction
showRawTransaction :: RawTransaction -> String showRawTransaction :: RawTransaction -> String
showRawTransaction (RawTransaction a amt _ ttype) = showRawTransaction (RawTransaction a amt _ ttype) =

View File

@ -32,4 +32,4 @@ accountNamesFromTransactions ts = nub $ map account ts
sumTransactions :: [Transaction] -> MixedAmount sumTransactions :: [Transaction] -> MixedAmount
sumTransactions = sum . map amount sumTransactions = sum . map amount
nulltxn = Transaction 0 (parsedate "1900/1/1") "" "" nullamt RegularTransaction nulltxn = Transaction 0 (parsedate "1900/1/1") "" "" nullmixedamt RegularTransaction

View File

@ -26,7 +26,7 @@ DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaaaaa AAAAAAAAAAA AAAAAAAAAAAA
@ @
-} -}
showRegisterReport :: [Opt] -> [String] -> Ledger -> String showRegisterReport :: [Opt] -> [String] -> Ledger -> String
showRegisterReport opts args l = showtxns ts nulltxn nullamt showRegisterReport opts args l = showtxns ts nulltxn nullmixedamt
where where
ts = filter matchtxn $ ledgerTransactions l ts = filter matchtxn $ ledgerTransactions l
matchtxn Transaction{account=a} = matchpats apats a matchtxn Transaction{account=a} = matchpats apats a