Docs
Dashboard

Money and rounding

Last updated View as Markdown

Money and rounding

Thor money values use centAmount, currencyCode, and fractionDigits. Despite the name centAmount, the integer is expressed in the currency’s minor unit. Use the returned fraction digits when formatting it.

Display, do not recalculate

For EUR, 1099 with two fraction digits represents EUR 10.99. An amount with zero fraction digits represents whole currency units. Use a currency formatter for display and keep stored amounts as integers or a suitable decimal money type.

Format money
Code in typescript

This helper formats one returned amount. It is not a checkout calculator. If your client receives amounts outside JavaScript’s safe integer range, use a representation that preserves their precision before formatting.

Rounding belongs to commerce calculation

Stores have separate price and tax rounding defaults. Supported modes include TO_EVEN, AWAY_FROM_ZERO, and TO_ZERO. Read the rounding enum when choosing a policy.

Render returned line totals, discounts, tax portions, shipping, and grand total. Summing formatted unit prices can disagree with a calculated total because discounts and rounding apply at different levels. See Cart calculation and totals.