Money
Factories, arithmetic, rounding boundaries, and allocation for Money.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Money.type
Members list
Type members
Classlikes
Weights that admit no allocation: empty, negative, or summing to nothing.
Weights that admit no allocation: empty, negative, or summing to nothing.
Attributes
- Companion
- object
- Supertypes
-
class WorldErrorclass TypedErrortrait NoStackTraceclass Exceptionclass Throwabletrait Serializableclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object Unallocatable
Attributes
- Companion
- class
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Producttrait Equalsclass Unallocatableclass WorldErrorclass TypedErrortrait NoStackTraceclass Exceptionclass Throwabletrait Serializableclass Objecttrait Matchableclass AnyShow all
- Self type
-
Unallocatable.type
The storage and wire form: the currency explicit beside its amount. Re-enter the typed world by binding the currency, as v match { case Money.Value(c, a) => c(a) }.
The storage and wire form: the currency explicit beside its amount. Re-enter the typed world by binding the currency, as v match { case Money.Value(c, a) => c(a) }.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
Splits the exact amount by integer weights at its own scale.
Splits the exact amount by integer weights at its own scale.
Attributes
Allocation by exact ratio weights.
Allocation by exact ratio weights.
Attributes
The printed schedule behind the annuity.
The printed schedule behind the annuity.
Attributes
The level payment amortising this principal on the reducing balance.
The level payment amortising this principal on the reducing balance.
Attributes
The deterministic rendering a ledger key, an audit hash, or a deduplication compares: trailing zeros stripped, then padded to the currency's minor unit where it has one, so anything finer survives.
The deterministic rendering a ledger key, an audit hash, or a deduplication compares: trailing zeros stripped, then padded to the currency's minor unit where it has one, so anything finer survives.
Attributes
Rounds to the cash increment the territory's recorded practice sets for this currency.
Rounds to the cash increment the territory's recorded practice sets for this currency.
Attributes
The selling price at a margin, rounded at the currency's scale.
The selling price at a margin, rounded at the currency's scale.
Attributes
The selling price at a markup over this cost.
The selling price at a markup over this cost.
Attributes
Rounds to the currency's minor unit. Identity for currencies without one (metals, special codes), whose amounts have no legal-tender scale; use rounded(scale, mode) to impose one.
Rounds to the currency's minor unit. Identity for currencies without one (metals, special codes), whose amounts have no legal-tender scale; use rounded(scale, mode) to impose one.
Attributes
Scales by an exact ratio, rounded at the currency's scale.
Scales by an exact ratio, rounded at the currency's scale.
Attributes
Givens
Givens
Extensions
Extensions
Splits the exact amount by integer weights at its own scale: the parts always sum to the whole, a zero weight receives zero, and the remainder goes to the largest fractional shares (ties to the earliest). Round first to allocate legal tender.
Splits the exact amount by integer weights at its own scale: the parts always sum to the whole, a zero weight receives zero, and the remainder goes to the largest fractional shares (ties to the earliest). Round first to allocate legal tender.
Attributes
Allocation by exact ratio weights - proportional-to-balances splits and the like.
Allocation by exact ratio weights - proportional-to-balances splits and the like.
Attributes
The printed schedule behind annuity: each instalment's interest is the period's opening balance at rate, its principal the payment's remainder, and the last instalment absorbs the rounding residual, so the balance closes at exactly zero and the principals sum to exactly this amount. Unlike allocate, which spreads the remainder, a schedule closes on its final row. Undefined as annuity.
The printed schedule behind annuity: each instalment's interest is the period's opening balance at rate, its principal the payment's remainder, and the last instalment absorbs the rounding residual, so the balance closes at exactly zero and the principals sum to exactly this amount. Unlike allocate, which spreads the remainder, a schedule closes on its final row. Undefined as annuity.
Attributes
The same at an explicit scale.
The same at an explicit scale.
Attributes
The exact amount, at whatever scale arithmetic has produced.
The exact amount, at whatever scale arithmetic has produced.
Attributes
The level payment amortising this principal over periods at the periodic rate rate on the reducing balance, exact until the currency-scale rounding by mode. A zero rate degenerates to the equal split; non-positive periods and a degenerate rate are Undefined.
The level payment amortising this principal over periods at the periodic rate rate on the reducing balance, exact until the currency-scale rounding by mode. A zero rate degenerates to the equal split; non-positive periods and a degenerate rate are Undefined.
Named rather than left to the caller because flat-rate quoting is a plain multiplication and the two are a costly confusion.
Attributes
The same at an explicit scale - schedule analysis below the posting scale, and the controlled form for currencies without a minor unit.
The same at an explicit scale - schedule analysis below the posting scale, and the controlled form for currencies without a minor unit.
Attributes
Rounds to the cash increment the territory's recorded practice sets for this currency. Cash practice is the jurisdiction's fact, never the currency's: one euro rounds to five cents by statute in Finland, by voluntary agreement in the Netherlands, and not at all in Germany. The caller names the territory; one recording no practice for this currency falls back to minor-unit half-even.
Rounds to the cash increment the territory's recorded practice sets for this currency. Cash practice is the jurisdiction's fact, never the currency's: one euro rounds to five cents by statute in Finland, by voluntary agreement in the Netherlands, and not at all in Germany. The caller names the territory; one recording no practice for this currency falls back to minor-unit half-even.
Attributes
Cash rounding with the midpoint mode imposed at the call site.
Cash rounding with the midpoint mode imposed at the call site.
Attributes
Converts through an exchange rate, exactly; rounding remains the caller's boundary.
Converts through an exchange rate, exactly; rounding remains the caller's boundary.
Attributes
The selling price at a margin - cost / (1 - margin) - rounded at the currency's scale by mode (the quotient need not terminate). Undefined at a 100% margin.
The selling price at a margin - cost / (1 - margin) - rounded at the currency's scale by mode (the quotient need not terminate). Undefined at a 100% margin.
Attributes
The same at an explicit scale - sub-minor pricing (fuel-grade precision), and the controlled form for currencies without a minor unit.
The same at an explicit scale - sub-minor pricing (fuel-grade precision), and the controlled form for currencies without a minor unit.
Attributes
The amount in minor units, when exactly representable at the currency's scale.
The amount in minor units, when exactly representable at the currency's scale.
Attributes
Scales by an exact ratio - a day-count fraction, an apportionment share - rounded at the currency's scale by mode (the quotient need not terminate, so the boundary is named).
Scales by an exact ratio - a day-count fraction, an apportionment share - rounded at the currency's scale by mode (the quotient need not terminate, so the boundary is named).
Attributes
The same scaling at an explicit scale: sub-minor-unit accrual (a ledger carries interest at four places before posting), and the controlled form for currencies that record no minor unit, which the currency-scale form rounds to whole units.
The same scaling at an explicit scale: sub-minor-unit accrual (a ledger carries interest at four places before posting), and the controlled form for currencies that record no minor unit, which the currency-scale form rounds to whole units.
Attributes
Splits into parts equal shares; equivalent to allocating unit weights.
Splits into parts equal shares; equivalent to allocating unit weights.