AUD amount modelling

Test the half-cent before testing the million-dollar invoice

Small boundary values expose rounding defects that large round numbers conceal. Exercise scale, signs, allocation and serialisation together.

In this article

Write expected results independently

Have the calculation owner approve a small set of worked examples before running the implementation. Include exact inputs, operation order, rounding mode and the point where precision is reduced.

Use a tie value such as 0.335 under the chosen policy, a negative reversal and a rate smaller than one cent multiplied by a large quantity. The last case catches a rate rounded to zero before multiplication.

Keep these examples independent of the production calculation function. A test that calls the same helper to produce its expected answer cannot detect a mistaken rule in that helper.

Cross the storage and wire boundaries

Save and retrieve the highest supported amount and a value with the maximum permitted intermediate scale. Send them through the real API serialiser and database driver.

Inspect exact values, not just formatted screens. A formatter can hide a precision loss by rounding both the correct and incorrect value to the same visible text.

Reject out-of-range inputs, non-finite values and unsupported precision according to the contract. Silent coercion makes a malformed request look like an intentional financial instruction.

Exercise conservation and reversal

Split 1,000 cents across three synthetic allocations. Confirm that all allocations are valid cent amounts and sum to exactly 1,000. Repeat with a stable tie-breaking order and then reverse the original allocation.

Test a partial reversal followed by another partial reversal. The system should enforce the domain's remaining reversible amount and must not derive it from an imprecise displayed balance.

Change the current calculation policy before reversing an older transaction. Verify that the application uses the recorded original evidence where required instead of recalculating history under the new rule.

Detect currency and scale mistakes explicitly

Attempt to add AUD and USD values without a conversion instruction. The domain should reject that operation rather than treating both dollar symbols as equivalent.

Test the payment adapter with a known AUD 123.45 example and assert the exact provider amount representation. Then feed an already converted value through the wrong path in a negative test. A double multiplication by 100 should be caught before a payment is created.

Primary sources

PostgreSQL: numeric typesStripe: currency and amount representation

References checked 11 September 2026.