From 5c23ebd01b6fb11b05bd18115370c04050540722 Mon Sep 17 00:00:00 2001 From: Roman Cheplyaka Date: Sat, 26 Sep 2009 22:52:30 +0000 Subject: [PATCH] Add Ledger.Amount.convertMixedAmountTo function --- Ledger/Amount.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Ledger/Amount.hs b/Ledger/Amount.hs index e423a71ed..fa9140bfd 100644 --- a/Ledger/Amount.hs +++ b/Ledger/Amount.hs @@ -97,6 +97,11 @@ costOfAmount (Amount _ q (Just price)) | otherwise = Amount pc (pq*q) Nothing where (Amount pc pq _) = head $ amounts price +-- | Convert an amount to the specified commodity using the appropriate +-- exchange rate (which is currently always 1). +convertAmountTo :: Commodity -> Amount -> Amount +convertAmountTo c2 (Amount c1 q _) = Amount c2 (q * conversionRate c1 c2) Nothing + -- | Get the string representation of an amount, based on its commodity's -- display settings. showAmount :: Amount -> String