allocate

Allocates a Money according to the by parameter:

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]

Receiver

Money

Return

A Result with the allocation result.

Parameters

by

The parameter to calculate the allocations.


infix fun Money.allocate(parts: Int): Result(source)

Allocates a Money in equal parts. Example:

val money = 100 money "USD"

money.allocate(3) // [USD 33.34, USD 33.33, USD 33.33]

Receiver

Money

Return

A Result with the allocation result.

Parameters

parts

The number of parts to allocate.

Throws

When parts is zero or negative.


infix fun Money.allocate(ratios: List<Percentage>): Result(source)

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]

Receiver

Money

Return

A Result with the allocation result.

Parameters

ratios

The ratios to allocate.

Throws

When ratios contain elements with a negative value.


fun Money.allocate(vararg ratios: Percentage): Result(source)

Allocates a Money in ratios. Example:

val money = 100 money "USD"

money.allocate(75.percent(), 25.percent())) // [USD 75.00, USD 25.00]

Receiver

Money

Return

A Result with the allocation result.

Parameters

ratios

The ratios to allocate.

Throws

When ratios contain elements with a negative value.