A large replacement cost does not occur on every trip. Treating it as zero on ordinary days can nevertheless remove its share from a distance-based comparison.

I inspected the actual tool’s replacement, interval and monthly-budget structure and built a new synthetic reserve function. This is a maker’s account of allocation rules, not a recommendation about when to replace a component.

Align an occasional expense with repeated distance

The original implementation accepts one replacement cost separately from its recorded replacement interval. Dividing those values creates an allocation per kilometer. A monthly irregular-maintenance budget uses monthly distance as a different denominator. Sharing the label maintenance does not make the original units interchangeable.

Intervals are caller records or plans, not observations made by this function. It cannot inspect wear or vehicle condition. Allocating a budget does not establish that a component is safe or will last that distance. The interface must keep cost-review values separate from inspection judgments and describe each result within its actual responsibility.

Avoid rounding every row before adding

Rounding every per-distance allocation into an integer can erase or inflate small contributions. The new function adds exact Fraction values, multiplies by the target distance and rounds once. It independently reproduces the source’s fraction-based intention while keeping display precision separate from the aggregation rule.

Two synthetic items each with cost one and interval three sum to two-thirds per kilometer. A target distance of three produces two. Rounding each row first would destroy that relationship. These are mathematical demonstration values rather than actual tire prices or service intervals, chosen to make the allocation boundary easy to check.

Require the monthly pair together

A monthly budget without a distance has no denominator. A distance without a specified budget is equally ambiguous. The function requires both values or neither, exposing the relationship between interval-based allocation and the monthly portion instead of silently folding unidentified amounts into one number.

Differently named inputs may still represent the same underlying expense twice. Rejecting duplicate identifiers catches one repeated item but cannot understand semantic duplication under different identifiers. An adopter must review which expenses belong in periodic replacements and which genuinely belong in the additional budget.

Bounds and basis labels are part of the contract

The synthetic implementation requires positive intervals and target distance, a declared cost basis, known fields and unique item identifiers. Paid and supply are caller declarations, not a tax decision or verification of supporting receipts. I state narrowly which meanings the numeric interface actually establishes.

Item and number bounds describe this small experiment. It is neither an operational data store nor a universal company expense form. Equipment used by time or cycles needs another explicit denominator. Replacing the word kilometer in a label would not automatically preserve a valid allocation contract for those businesses.

Show what was allocated, not only an amount to reserve

Tests cover exact aggregation, paired monthly inputs, duplicate identifiers and a zero interval. Recorded output retains the fraction and target-distance amount. The ZIP contains new synthetic code and tests, with no company maintenance history or actual receipt. It provides no rendered-browser printing or physical-device verification.

A visitor adapting the calculation should first inspect the expense boundary and measurement basis. Showing denominators and assumptions is therefore more useful than one prominent amount. I share a module whose allocation can be reconstructed later, rather than a formula that merely makes an occasional large expense appear small.