diff --git a/Ledger/Amount.hs b/Ledger/Amount.hs index 3de146346..37a899f52 100644 --- a/Ledger/Amount.hs +++ b/Ledger/Amount.hs @@ -45,20 +45,18 @@ import Ledger.Currency tests = runTestTT $ test [ show (dollars 1) ~?= "$1.00" ,show (hours 1) ~?= "1h" -- currently h1.00 - ,parseAmount "$1" ~?= dollars 1 -- currently 0 ] -nullamt = dollars 0 - -parseAmount :: String -> Amount -parseAmount s = nullamt - instance Show Amount where show = showAmountRounded +-- | Get the string representation of an amount, rounded to its native precision. +-- Unlike ledger, we show the decimal digits even if they are all 0, and +-- we always show currency symbols on the left. showAmountRounded :: Amount -> String showAmountRounded (Amount c q p) = (symbol c) ++ ({-punctuatethousands $ -}printf ("%."++show p++"f") q) +-- | Get the string representation of an amount, rounded, or showing just "0" if it's zero. showAmountRoundedOrZero :: Amount -> String showAmountRoundedOrZero a | isZeroAmount a = "0" @@ -85,7 +83,7 @@ punctuatethousands s = instance Num Amount where abs (Amount c q p) = Amount c (abs q) p signum (Amount c q p) = Amount c (signum q) p - fromInteger i = Amount (getcurrency "$") (fromInteger i) amtintprecision + fromInteger i = Amount (getcurrency "") (fromInteger i) amtintprecision (+) = amountop (+) (-) = amountop (-) (*) = amountop (*) @@ -105,4 +103,4 @@ toCurrency :: Currency -> Amount -> Amount toCurrency newc (Amount oldc q p) = Amount newc (q * (conversionRate oldc newc)) p - +nullamt = Amount (getcurrency "") 0 2 diff --git a/Ledger/Transaction.hs b/Ledger/Transaction.hs index d249115fb..a9c0e367e 100644 --- a/Ledger/Transaction.hs +++ b/Ledger/Transaction.hs @@ -43,7 +43,7 @@ showTransactionsWithBalances [] _ = [] showTransactionsWithBalances ts b = unlines $ showTransactionsWithBalances' ts dummyt b where - dummyt = Transaction 0 "" "" "" (dollars 0) + dummyt = Transaction 0 "" "" "" nullamt showTransactionsWithBalances' [] _ _ = [] showTransactionsWithBalances' (t:ts) tprev b = (if sameentry t tprev diff --git a/README b/README index 7b47191eb..17ce098a8 100644 --- a/README +++ b/README @@ -30,5 +30,4 @@ possible, see the ledger manual for more info: Bugs: -* register report adds $ when no currency is specified * timelog parser doesn't work