From ebcf695240a9bd5f9fc598154df303b75bbb4c09 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 18 Oct 2008 09:02:19 +0000 Subject: [PATCH] simplify, remove dead code --- Ledger/Amount.hs | 11 +++++------ Ledger/Entry.hs | 11 +++-------- Ledger/RawTransaction.hs | 3 --- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Ledger/Amount.hs b/Ledger/Amount.hs index 6ca89c492..5d306d94d 100644 --- a/Ledger/Amount.hs +++ b/Ledger/Amount.hs @@ -45,7 +45,6 @@ import Ledger.Commodity instance Show Amount where show = showAmount --- instance Show MixedAmount where show = showMixedAmount instance Num Amount where abs (Amount c q) = Amount c (abs q) @@ -98,11 +97,11 @@ punctuatethousands s = triples [] = [] triples l = [take 3 l] ++ (triples $ drop 3 l) --- | Get the string representation of an amount, rounded, or showing just "0" if it's zero. -showAmountOrZero :: Amount -> String -showAmountOrZero a - | isZeroAmount a = "0" - | otherwise = showAmount a +-- -- | Get the string representation of an amount, rounded, or showing just "0" if it's zero. +-- showAmountOrZero :: Amount -> String +-- showAmountOrZero a +-- | isZeroAmount a = "0" +-- | otherwise = showAmount a -- | Get the string representation of an amount, rounded, or showing just "0" if it's zero. showMixedAmountOrZero :: MixedAmount -> String diff --git a/Ledger/Entry.hs b/Ledger/Entry.hs index 72e9168b6..2143237c6 100644 --- a/Ledger/Entry.hs +++ b/Ledger/Entry.hs @@ -60,10 +60,8 @@ showEntry e = showDate = printf "%-10s" isEntryBalanced :: Entry -> Bool -isEntryBalanced (Entry {etransactions=ts}) = isZeroMixedAmount sum - where - sum = sumRawTransactions realts - realts = filter isReal ts +isEntryBalanced (Entry {etransactions=ts}) = + isZeroMixedAmount $ sumMixedAmounts $ map tamount $ filter isReal ts -- | Fill in a missing balance in this entry, if we have enough -- information to do that. Excluding virtual transactions, there should be @@ -76,10 +74,7 @@ balanceEntry e@(Entry{etransactions=ts}) = e{etransactions=ts'} 0 -> ts 1 -> map balance ts otherwise -> error $ "could not balance this entry, too many missing amounts:\n" ++ show e - otherstotal = sumRawTransactions withamounts --- simpleotherstotal --- | length otherstotal == 1 = head otherstotal --- | otherwise = error $ "sorry, can't balance a mixed-commodity entry yet:\n" ++ show e + otherstotal = sumMixedAmounts $ map tamount withamounts balance t | isReal t && not (hasAmount t) = t{tamount = -otherstotal} | otherwise = t diff --git a/Ledger/RawTransaction.hs b/Ledger/RawTransaction.hs index 1a47984ba..5482a8348 100644 --- a/Ledger/RawTransaction.hs +++ b/Ledger/RawTransaction.hs @@ -31,6 +31,3 @@ isReal t = rttype t == RegularTransaction hasAmount :: RawTransaction -> Bool hasAmount = (/= autoamt) . tamount - -sumRawTransactions :: [RawTransaction] -> MixedAmount -sumRawTransactions = normaliseMixedAmount . sumMixedAmounts . map tamount