Skip to content

Documentation / @facturometro/validator / DocumentView

Interface: DocumentView ​

Defined in: packages/validator/src/engine/view.ts:224

A memoized, document-kind-agnostic view of an invoice or credit note, passed to every rule's context selector.

Example ​

ts
import type { DocumentView } from '@facturometro/validator';

const lineCount = (view: DocumentView) => view.lines().length;

Properties ​

kind ​

readonly kind: "CreditNote" | "Invoice"

Defined in: packages/validator/src/engine/view.ts:280

Which document this is.


root ​

readonly root: UncheckedDocument

Defined in: packages/validator/src/engine/view.ts:338

The document itself.

Methods ​

amounts() ​

amounts(): readonly AmountLeaf[]

Defined in: packages/validator/src/engine/view.ts:231

Every amount element present, in schema order: cbc:Amount, cbc:PayableAmount, cbc:PriceAmount, ... The walker skips values that are not objects.

Returns ​

readonly AmountLeaf[]

The amounts.


attributes() ​

attributes(): readonly AttributeLeaf[]

Defined in: packages/validator/src/engine/view.ts:237

Every attribute present, in schema order.

Returns ​

readonly AttributeLeaf[]

The attributes.


docAllowances() ​

docAllowances(semantics, selection?): readonly Hit<UncheckedAllowanceCharge, unknown>[]

Defined in: packages/validator/src/engine/view.ts:250

Document level allowances (/cac:AllowanceCharge[cbc:ChargeIndicator = false()] under cen, [normalize-space(cbc:ChargeIndicator) = 'false'] under peppol).

An indicator that is not an xs:boolean is excluded by default; a rule that sums the selection asks for { unreadable: 'throw' } instead (see AllowanceChargeSelection).

Parameters ​

semantics ​

ChargeIndicatorSemantics

Which reading of cbc:ChargeIndicator to apply.

selection? ​

AllowanceChargeSelection

What to do with an indicator that is not an xs:boolean.

Returns ​

readonly Hit<UncheckedAllowanceCharge, unknown>[]

The allowances.

Throws ​

Under throw, when a cbc:ChargeIndicator is not an xs:boolean.


docCharges() ​

docCharges(semantics, selection?): readonly Hit<UncheckedAllowanceCharge, unknown>[]

Defined in: packages/validator/src/engine/view.ts:262

Document level charges, the true counterpart of docAllowances.

Parameters ​

semantics ​

ChargeIndicatorSemantics

Which reading of cbc:ChargeIndicator to apply.

selection? ​

AllowanceChargeSelection

What to do with an indicator that is not an xs:boolean.

Returns ​

readonly Hit<UncheckedAllowanceCharge, unknown>[]

The charges.

Throws ​

Under throw, when a cbc:ChargeIndicator is not an xs:boolean.


dueDate() ​

dueDate(): Hit<string, unknown> | undefined

Defined in: packages/validator/src/engine/view.ts:272

The due date: cbc:DueDate of an invoice, the first cac:PaymentMeans/cbc:PaymentDueDate of a credit note.

Returns ​

Hit<string, unknown> | undefined

The date with its path, or undefined when there is none.


emptyElements() ​

emptyElements(): readonly EmptyElement[]

Defined in: packages/validator/src/engine/view.ts:278

Every element that has neither child elements nor text, the document root included.

Returns ​

readonly EmptyElement[]

The empty elements, in schema order.


lineAllowances() ​

lineAllowances(semantics, line?, selection?): readonly Hit<UncheckedLineAllowanceCharge, unknown>[]

Defined in: packages/validator/src/engine/view.ts:292

Line level allowances of one line, or of every line; see docAllowances for an indicator that is not an xs:boolean. Under throw, only the selected lines' indicators are cast.

Parameters ​

semantics ​

ChargeIndicatorSemantics

Which reading of cbc:ChargeIndicator to apply.

line? ​

Hit<UncheckedLine, unknown>

The line; all lines when omitted.

selection? ​

AllowanceChargeSelection

What to do with an indicator that is not an xs:boolean.

Returns ​

readonly Hit<UncheckedLineAllowanceCharge, unknown>[]

The allowances.

Throws ​

Under throw, when a cbc:ChargeIndicator is not an xs:boolean.


lineCharges() ​

lineCharges(semantics, line?, selection?): readonly Hit<UncheckedLineAllowanceCharge, unknown>[]

Defined in: packages/validator/src/engine/view.ts:307

Line level charges of one line, or of every line, the true counterpart of lineAllowances.

Parameters ​

semantics ​

ChargeIndicatorSemantics

Which reading of cbc:ChargeIndicator to apply.

line? ​

Hit<UncheckedLine, unknown>

The line; all lines when omitted.

selection? ​

AllowanceChargeSelection

What to do with an indicator that is not an xs:boolean.

Returns ​

readonly Hit<UncheckedLineAllowanceCharge, unknown>[]

The charges.

Throws ​

Under throw, when a cbc:ChargeIndicator is not an xs:boolean.


lines() ​

lines(): readonly Hit<UncheckedLine, unknown>[]

Defined in: packages/validator/src/engine/view.ts:317

The lines (cac:InvoiceLine or cac:CreditNoteLine).

Returns ​

readonly Hit<UncheckedLine, unknown>[]

The lines, in document order.


parties() ​

parties(): Parties

Defined in: packages/validator/src/engine/view.ts:323

The parties present in the document.

Returns ​

Parties

The parties.


priceAllowances() ​

priceAllowances(): readonly Hit<UncheckedPriceAllowanceCharge, unknown>[]

Defined in: packages/validator/src/engine/view.ts:329

The price allowances (cac:Price/cac:AllowanceCharge) of every line.

Returns ​

readonly Hit<UncheckedPriceAllowanceCharge, unknown>[]

The price allowances.


quantity() ​

quantity(line): Hit<UncheckedQuantity, unknown> | undefined

Defined in: packages/validator/src/engine/view.ts:336

The quantity of a line (cbc:InvoicedQuantity or cbc:CreditedQuantity).

Parameters ​

line ​

Hit<UncheckedLine>

The line.

Returns ​

Hit<UncheckedQuantity, unknown> | undefined

The quantity with its path, or undefined when the line has none.


select() ​

select(key): readonly Hit<object, unknown>[]

Defined in: packages/validator/src/engine/view.ts:345

The aggregates at a DocumentPaths key, memoized per key.

Parameters ​

key ​

string

The dotted key.

Returns ​

readonly Hit<object, unknown>[]

The hits.


taxSubtotals() ​

taxSubtotals(): readonly Hit<UncheckedTaxSubtotal, unknown>[]

Defined in: packages/validator/src/engine/view.ts:351

Every VAT breakdown subtotal (cac:TaxTotal/cac:TaxSubtotal).

Returns ​

readonly Hit<UncheckedTaxSubtotal, unknown>[]

The subtotals, in document order.


taxTotals() ​

taxTotals(): readonly Hit<UncheckedTaxTotal, unknown>[]

Defined in: packages/validator/src/engine/view.ts:357

Every cac:TaxTotal.

Returns ​

readonly Hit<UncheckedTaxTotal, unknown>[]

The tax totals, in document order.


taxTotalWithoutSubtotals() ​

taxTotalWithoutSubtotals(): readonly Hit<UncheckedTaxTotal, unknown>[]

Defined in: packages/validator/src/engine/view.ts:364

cac:TaxTotal[not(cac:TaxSubtotal)]: the tax totals without a breakdown (the one in the VAT accounting currency).

Returns ​

readonly Hit<UncheckedTaxTotal, unknown>[]

The tax totals.


taxTotalWithSubtotals() ​

taxTotalWithSubtotals(): readonly Hit<UncheckedTaxTotal, unknown>[]

Defined in: packages/validator/src/engine/view.ts:370

cac:TaxTotal[cac:TaxSubtotal]: the tax totals that carry a breakdown.

Returns ​

readonly Hit<UncheckedTaxTotal, unknown>[]

The tax totals.


typeCode() ​

typeCode(): string | undefined

Defined in: packages/validator/src/engine/view.ts:376

The document type code (cbc:InvoiceTypeCode or cbc:CreditNoteTypeCode).

Returns ​

string | undefined

The code, raw.


vatCategories() ​

vatCategories(code, scheme?): VatCategoryIndex

Defined in: packages/validator/src/engine/view.ts:385

Everything that carries a VAT category code, indexed once per scheme match: subtotals, lines and document level allowances and charges whose normalize-space(cbc:ID) equals the code.

Parameters ​

code ​

string

The category code, e.g. S.

scheme? ​

VatSchemeMatch

How the tax scheme must match; any by default.

Returns ​

VatCategoryIndex

The index for the code; empty lists when nothing carries it.

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