Amount and Commodity Functions¶
- type amount¶
An amount is a value with a currency/commodity.
Examples:
10.50 USD,5 HOOL.
Commodities (synonymous to currencies) are not represented by their own type
but are simply stated as all-caps strings.
An amount is wrapped in a position when it is registered in an account,
potentially with the original cost attached.
Amounts can be summed up, resulting in inventories
The following functions are available that involve amounts and currencies:
bool()- Convert to bool value.commodity()- Extract the currency from an Amount.commodity_meta()- Get the metadata dict of the commodity directive of the currency.convert()- Coerce an amount to a particular currency.currency()- Extract the currency from an Amount.currency_meta()- Get the metadata dict of the commodity directive of the currency.neg()- Negative value.number()- Extract the number from an Amount.only()- Get one currency’s amount from the inventory.possign()- Correct sign of an Amount based on the usual balance of associated account.repr()- Convert the argument to a string via repr().str()- Convert any object to a string.