From 099a1de3b6eea4f6eda35151fcbda84a4698126a Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 27 Feb 2015 05:23:07 -0800 Subject: [PATCH] clarify built-in commodities rounding --- hledger-lib/Hledger/Data/Amount.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hledger-lib/Hledger/Data/Amount.hs b/hledger-lib/Hledger/Data/Amount.hs index 7aaf06176..6974e38ac 100644 --- a/hledger-lib/Hledger/Data/Amount.hs +++ b/hledger-lib/Hledger/Data/Amount.hs @@ -100,8 +100,10 @@ module Hledger.Data.Amount ( ) where import Data.Char (isDigit) -#ifndef DOUBLE -import Data.Decimal +#ifdef DOUBLE +roundTo = flip const +#else +import Data.Decimal (roundTo) #endif import Data.Function (on) import Data.List @@ -150,10 +152,8 @@ nullamt = amount missingamt :: Amount missingamt = amount{acommodity="AUTO"} --- handy amount constructors for tests -#ifdef DOUBLE -roundTo = flip const -#endif +-- Handy amount constructors for tests. +-- usd/eur/gbp round their argument to a whole number of pennies/cents. num n = amount{acommodity="", aquantity=n} usd n = amount{acommodity="$", aquantity=roundTo 2 n, astyle=amountstyle{asprecision=2}} eur n = amount{acommodity="€", aquantity=roundTo 2 n, astyle=amountstyle{asprecision=2}}