module

MinimumCashFlow

Class methods

balances_from_weighted_expenses(expenses : Array(WeightedExpense)) : Hash(Int64, Int32)

Computes net balances from per-expense weight splits. Positive means the member should receive money; negative means they owe.

Source
pairwise_debts_from_balances(balances : Hash(Int64, Int32)) : Array(Debt)

Turns balances into a minimal, deterministic set of pairwise payments.

Source
split_amount_by_weight(amount_cents : Int32, member_weights : Hash(Int64, Int32)) : Hash(Int64, Int32)

Splits amount_cents among members proportional to their weights.

The split is:

  • deterministic (tie-break by member id)
  • exact in cents (sums back to amount_cents)

Remainder cents are distributed to members with the largest fractional remainders first.

Source

Nested types