DistributableAllocation

Allocates the Money difference by distributing every unit of it according to allocator. For example, a difference of USD 0.03 will be allocated by distributing USD 0.01 three times.

This interface implements the Template Method pattern. Subclasses need to override the method distribute, which will receive a list of Money representing the difference units and use the allocator to distribute them. A difference unit is always equal to the smallest possible value for a Money in a given Currency, examples:

  • A difference of USD 0.03 yields a list with three items with the USD 0.01 value

  • A difference of JPY 2 yields a list with two items with the JPY 1 value

Inheritors

Properties

Link copied to clipboard

The DifferenceAllocation instance to allocate the difference units.

Functions

Link copied to clipboard
open override fun allocate(difference: Money, allocations: List<Money>): List<Money>

Allocates the difference in the allocations list.

Link copied to clipboard
abstract fun distribute(units: List<Money>, allocations: List<Money>): List<Money>

Distributes the difference units in the allocations list.