[**@bondsports/general**](../README.md) • **Docs**

***

[@bondsports/general](../globals.md) / splitRoundingAmount

# Function: splitRoundingAmount()

> **splitRoundingAmount**\<`T`\>(`amount`, `items`, `totalField`?, `getCapacity`?): `void`

Splits a given amount across a list of items, adjusting their total field values
to account for rounding differences.

When getCapacity is supplied, it is a hard ceiling on **success**: no item is
raised above `getCapacity(item)`. Capacities bound upward corrections only; a downward
correction from at-or-below cap is never blocked. An item that already starts above its
cap cannot be made valid by rounding cents — throws `Failed to split rounding amount to
resources` and leaves `items` untouched, same as when no item can absorb the next cent
without breaching its cap. Callers must clamp amount to the summed capacity first.
Omit getCapacity for unbounded items; when supplied, it must return a non-negative price.

## Type Parameters

• **T**

The type of the items in the list.

## Parameters

• **amount**: `number`

The total amount to be split among the items.

• **items**: `T`[]

The list of items to split the amount across.

• **totalField?**: [`PriceFieldEnum`](../enumerations/PriceFieldEnum.md) = `PriceFieldEnum.TOTAL_PRICE`

The field in each item that represents the total price.

• **getCapacity?**

Optional per-item ceiling for the field being adjusted; omit for unbounded. Must return a non-negative price.

## Returns

`void`

## Defined in

[utils/split-amount.util.ts:31](https://github.com/Bond-Sports/bondUtils/blob/545f16ceb055481acfd7641d7809c0f252d3a5e6/packages/general/src/utils/split-amount.util.ts#L31)
