From ea2a418811017ff0609073c5e3e50759b35c4a47 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 15 Oct 2008 19:28:36 +0000 Subject: [PATCH] fix a bug in commodity detection --- Ledger/RawLedger.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Ledger/RawLedger.hs b/Ledger/RawLedger.hs index cd85d5d53..57414ce77 100644 --- a/Ledger/RawLedger.hs +++ b/Ledger/RawLedger.hs @@ -105,8 +105,10 @@ normaliseRawLedgerAmounts l@(RawLedger ms ps es f) = RawLedger ms ps es' f normaliseRawTransactionAmounts (RawTransaction acct a c) = RawTransaction acct a' c where a' = normaliseAmount a normaliseAmount (Amount c q) = Amount (firstoccurrenceof c) q + firstcommodities = nubBy samesymbol $ allcommodities + allcommodities = map (commodity . amount) $ rawLedgerTransactions l + samesymbol (Commodity {symbol=s1}) (Commodity {symbol=s2}) = s1==s2 firstoccurrenceof c@(Commodity {symbol=s}) = fromMaybe (error "failed to normalise commodity") -- shouldn't happen (find (\(Commodity {symbol=sym}) -> sym==s) firstcommodities) - firstcommodities = nub $ map (commodity . amount) $ rawLedgerTransactions l