$1 £-50 EUR 3.44 GOOG 500 1.5h 90 apples 0
It may also have an assigned
Price, representing this amount's per-unit
or total cost in a different commodity. If present, this is rendered like
EUR 2 @ $1.50 (unit price) EUR 2 @@ $3 (total price)
MixedAmount is zero or more simple amounts, so can represent multiple
commodities; this is the type most often used:
0 $50 + EUR 3 16h + $13.55 + AAPL 500 + 6 oranges
When a mixed amount has been "normalised", it has no more than one amount in each commodity and no zero amounts; or it has just a single zero amount and no others.
Limited arithmetic with simple and mixed amounts is supported, best used with similar amounts since it mostly ignores assigned prices and commodity exchange rates.
- nullamt :: Amount
- missingamt :: Amount
- amountWithCommodity :: Commodity -> Amount -> Amount
- canonicaliseAmountCommodity :: Maybe (Map String Commodity) -> Amount -> Amount
- setAmountPrecision :: Int -> Amount -> Amount
- costOfAmount :: Amount -> Amount
- divideAmount :: Amount -> Double -> Amount
- showAmount :: Amount -> String
- showAmountDebug :: Amount -> String
- showAmountWithoutPrice :: Amount -> String
- maxprecision :: Int
- maxprecisionwithpoint :: Int
- nullmixedamt :: MixedAmount
- missingmixedamt :: MixedAmount
- amounts :: MixedAmount -> [Amount]
- normaliseMixedAmountPreservingFirstPrice :: MixedAmount -> MixedAmount
- canonicaliseMixedAmountCommodity :: Maybe (Map String Commodity) -> MixedAmount -> MixedAmount
- mixedAmountWithCommodity :: Commodity -> MixedAmount -> Amount
- setMixedAmountPrecision :: Int -> MixedAmount -> MixedAmount
- costOfMixedAmount :: MixedAmount -> MixedAmount
- divideMixedAmount :: MixedAmount -> Double -> MixedAmount
- isNegativeMixedAmount :: MixedAmount -> Maybe Bool
- isZeroMixedAmount :: MixedAmount -> Bool
- isReallyZeroMixedAmountCost :: MixedAmount -> Bool
- showMixedAmount :: MixedAmount -> String
- showMixedAmountDebug :: MixedAmount -> String
- showMixedAmountWithoutPrice :: MixedAmount -> String
- showMixedAmountWithPrecision :: Int -> MixedAmount -> String
- tests_Hledger_Data_Amount :: Test
Convert an amount to the specified commodity, ignoring and discarding any assigned prices and assuming an exchange rate of 1.
Replace an amount's commodity with the canonicalised version from the provided commodity map.
Set the display precision in the amount's commodity.
Convert an amount to the commodity of its assigned price, if any. Notes:
- price amounts must be MixedAmounts with exactly one component Amount (or there will be a runtime error)
- price amounts should be positive, though this is not currently enforced
Get the string representation of an amount, based on its commodity's display settings. String representations equivalent to zero are converted to just "0".
Get the unambiguous string representation of an amount, for debugging.
Get the string representation of an amount, without any @ price.
For rendering: a special precision value which means show all available digits.
For rendering: a special precision value which forces display of a decimal point.
Simplify a mixed amount's component amounts: combine amounts with the same commodity, using the first amount's price for subsequent amounts in each commodity (ie, this function alters the amount and is best used as a rendering helper.). Also remove any zero amounts and replace an empty amount list with a single zero amount.
Replace a mixed amount's commodity with the canonicalised version from the provided commodity map.
Set the display precision in the amount's commodities.
Convert a mixed amount's component amounts to the commodity of their assigned price, if any.
Divide a mixed amount's quantities by a constant.
Is this mixed amount negative, if it can be normalised to a single commodity ?
Does this mixed amount appear to be zero when displayed with its given precision ?
Is this mixed amount really zero, after converting to cost commodities where possible ?
Get the string representation of a mixed amount, showing each of its component amounts. NB a mixed amount can have an empty amounts list in which case it shows as "".
Get an unambiguous string representation of a mixed amount for debugging.
Get the string representation of a mixed amount, but without any @ prices.
Get the string representation of a mixed amount, showing each of its component amounts with the specified precision, ignoring their commoditys' display precision settings.