Documentation / @facturometro/einvoice / fractionDigits
Function: fractionDigits() ​
fractionDigits(
raw):number
Defined in: packages/core/src/decimal.ts:557
Counts the digits a raw value writes after its decimal point.
This is XPath's string-length(substring-after($value, '.')), which the UBL-DT-01 and PEPPOL-EN16931-DEC rules apply to the text as it appears in the document: '100.500' has three fraction digits, and a trailing space counts as one.
Parameters ​
raw ​
string
The value exactly as it appears in the document, not normalised.
Returns ​
number
The number of characters after the first decimal point; 0 when there is none.
Example ​
ts
import { fractionDigits } from '@facturometro/core';
fractionDigits('100.500'); // 3
fractionDigits('100'); // 0
fractionDigits('100.50 '); // 3