Skip to content

Documentation / @facturometro/validator / chargeIndicatorKind

Function: chargeIndicatorKind() ​

chargeIndicatorKind(raw, semantics): AllowanceOrCharge | undefined

Defined in: packages/validator/src/engine/selectors.ts:90

Reads a cbc:ChargeIndicator the way one of the two Schematron files does.

Under cen semantics the text is cast to xs:boolean, so true and 1 are charges and false and 0 are allowances; under peppol semantics only the literals true and false (after normalize-space()) are recognised. Anything else, including an absent indicator, is neither.

Parameters ​

raw ​

string | undefined

The indicator's text, exactly as it appears in the document.

semantics ​

ChargeIndicatorSemantics

Which file's reading to apply.

Returns ​

AllowanceOrCharge | undefined

allowance, charge, or undefined when the text is neither.

Example ​

ts
import { chargeIndicatorKind } from '@facturometro/validator';

chargeIndicatorKind('1', 'cen'); // 'charge'
chargeIndicatorKind('1', 'peppol'); // undefined

MIT licensed. Specification artefacts belong to OpenPEPPOL, CEN and OASIS.