allocate
Allocates a Money according to the by parameter:
If by is of type EvenParts, allocates the Money in equal parts
If by is of type Ratios, allocate the Money in the given ratios
Example:
val money = 100 money "USD"
val evenParts = EvenParts(3)
val ratios = Ratios(75.percent(), 25.percent())
money.allocate(evenParts).result() // [USD 33.34, USD 33.33, USD 33.33]
money.allocate(ratios).result() // [USD 75.00, USD 25.00]
Content copied to clipboard
Receiver
Return
A Result with the allocation result.
Parameters
by
The parameter to calculate the allocations.
Allocates a Money in equal parts. Example:
val money = 100 money "USD"
money.allocate(3) // [USD 33.34, USD 33.33, USD 33.33]
Content copied to clipboard
Receiver
Return
A Result with the allocation result.
Parameters
parts
The number of parts to allocate.
Throws
When parts is zero or negative.
Allocates a Money in ratios. Example:
val money = 100 money "USD"
val ratios = Ratios(75.percent(), 25.percent())
money.allocate(ratios) // [USD 75.00, USD 25.00]
Content copied to clipboard
Receiver
Return
A Result with the allocation result.
Parameters
ratios
The ratios to allocate.
Throws
When ratios contain elements with a negative value.
Allocates a Money in ratios. Example:
val money = 100 money "USD"
money.allocate(75.percent(), 25.percent())) // [USD 75.00, USD 25.00]
Content copied to clipboard
Receiver
Return
A Result with the allocation result.
Parameters
ratios
The ratios to allocate.
Throws
When ratios contain elements with a negative value.