Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Case Study: A Three-Line Cart Priced in Minor Units, Not Floats

Описание и применение

В примере показано, как использование целочисленных единиц валюты и строгих правил округления устраняет расхождения в счётах, возникающие из-за плавающей точности.

Задача

A cart priced with floating point arithmetic can drift by a cent, causing reconciliation errors with the ledger.

Результат

The helper produces a deterministic total of 58.42 USD (5842 minor units) for the sample cart, preventing one-cent drift and ensuring finance reconciliation matches the invoice.

Рабочий процесс

  • Freeze pricing rules and sample numbers in the repository before prompting an agent.
  • Write a helper module that defines currency scales, rounding, and validation.
  • Implement invoice_total to compute net, discount, tax, and total in minor units.
  • Create tests that assert the expected total of 5842 minor units for the sample cart.
  • Run tests locally and on a disposable server to verify consistency.
  • Review and reject any changes that alter the frozen rules or sample numbers.

Доказательства

A three-line cart can look correct in a demo and still miss the ledger by one cent after tax.

Источник

The expected USD total for the sample cart is 5842 minor units, which is 58.42 after the rules above.

Источник

You want a pure function that prices one cart in integer minor units and fails closed when the currency scale is unknown.

Источник

  • Дата записи: 2026-10-09T15:55:52.485Z