clarify built-in commodities rounding
This commit is contained in:
parent
f83590021a
commit
099a1de3b6
@ -100,8 +100,10 @@ module Hledger.Data.Amount (
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Char (isDigit)
|
import Data.Char (isDigit)
|
||||||
#ifndef DOUBLE
|
#ifdef DOUBLE
|
||||||
import Data.Decimal
|
roundTo = flip const
|
||||||
|
#else
|
||||||
|
import Data.Decimal (roundTo)
|
||||||
#endif
|
#endif
|
||||||
import Data.Function (on)
|
import Data.Function (on)
|
||||||
import Data.List
|
import Data.List
|
||||||
@ -150,10 +152,8 @@ nullamt = amount
|
|||||||
missingamt :: Amount
|
missingamt :: Amount
|
||||||
missingamt = amount{acommodity="AUTO"}
|
missingamt = amount{acommodity="AUTO"}
|
||||||
|
|
||||||
-- handy amount constructors for tests
|
-- Handy amount constructors for tests.
|
||||||
#ifdef DOUBLE
|
-- usd/eur/gbp round their argument to a whole number of pennies/cents.
|
||||||
roundTo = flip const
|
|
||||||
#endif
|
|
||||||
num n = amount{acommodity="", aquantity=n}
|
num n = amount{acommodity="", aquantity=n}
|
||||||
usd n = amount{acommodity="$", aquantity=roundTo 2 n, astyle=amountstyle{asprecision=2}}
|
usd n = amount{acommodity="$", aquantity=roundTo 2 n, astyle=amountstyle{asprecision=2}}
|
||||||
eur n = amount{acommodity="€", aquantity=roundTo 2 n, astyle=amountstyle{asprecision=2}}
|
eur n = amount{acommodity="€", aquantity=roundTo 2 n, astyle=amountstyle{asprecision=2}}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user