This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk / formatMoney

formatMoney() ​

formatMoney(amountMinor, currency, locale?): string

Formats an amount in minor units with Intl.NumberFormat, using the currency's decimal places. Accepts negatives (balance, statement). Without locale, the runtime's applies: in SSR, pass the same locale on the server and in the browser to avoid a hydration mismatch.

Parameters ​

amountMinor ​

number

Amount in minor units (a safe integer), e.g. 123456 = R$ 1.234,56 when formatted for pt-BR.

currency ​

CurrencyInfo

The operator's currency (config.currency).

locale? ​

string

BCP 47 locale, e.g. pt-BR. Default: the runtime's.

Returns ​

string

Example ​

ts
const { currency } = await enginex.config.get()
formatMoney(123456, currency, 'pt-BR') // 'R$ 1.234,56'

Throws ​

amountMinor is not a safe integer or decimalPlaces is invalid.