class Zugpferd::Invoice

Overview

A ZUGFeRD 2.x invoice. Construct via Invoice.build and call #to_xml to validate and serialise.

Defined in:

zugpferd/invoice.cr

Constructors

Instance Method Summary

Constructor Detail

def self.build(profile : Profile = Profile::EN16931, &) : Invoice #

Primary entry point for constructing invoices. Yields a Builder and returns a fully constructed Invoice on block exit. Raises GenerationError if document, seller, buyer, or settlement are not set.


[View source]
def self.new(profile : Profile, document : ExchangedDocument, seller : TradeParty, buyer : TradeParty, settlement : TradeSettlement, line_items : Array(SupplyChainTradeLineItem) = [] of SupplyChainTradeLineItem, *, buyer_order_reference : String | Nil = nil, contract_reference : String | Nil = nil, despatch_advice_reference : String | Nil = nil, delivery_date : Time | Nil = nil) #

[View source]

Instance Method Detail

def buyer : TradeParty #

Buyer party (BG-7).


[View source]
def buyer=(buyer : TradeParty) #

Buyer party (BG-7).


[View source]
def buyer_order_reference : String | Nil #

Purchase order reference from the buyer (BT-13).


[View source]
def buyer_order_reference=(buyer_order_reference : String | Nil) #

Purchase order reference from the buyer (BT-13).


[View source]
def contract_reference : String | Nil #

Contract reference (BT-12).


[View source]
def contract_reference=(contract_reference : String | Nil) #

Contract reference (BT-12).


[View source]
def delivery_date : Time | Nil #

Actual delivery date (BT-72). Required for BASIC and above (BR-FX-EN-04).


[View source]
def delivery_date=(delivery_date : Time | Nil) #

Actual delivery date (BT-72). Required for BASIC and above (BR-FX-EN-04).


[View source]
def despatch_advice_reference : String | Nil #

Despatch advice document reference (BT-16).


[View source]
def despatch_advice_reference=(despatch_advice_reference : String | Nil) #

Despatch advice document reference (BT-16).


[View source]
def document : ExchangedDocument #

Invoice header metadata: number, date, type code, and notes (BG-1).


[View source]
def document=(document : ExchangedDocument) #

Invoice header metadata: number, date, type code, and notes (BG-1).


[View source]
def line_items : Array(SupplyChainTradeLineItem) #

Invoice lines (BG-25). Required for BASIC and above; empty for MINIMUM and BASIC_WL.


[View source]
def line_items=(line_items : Array(SupplyChainTradeLineItem)) #

Invoice lines (BG-25). Required for BASIC and above; empty for MINIMUM and BASIC_WL.


[View source]
def profile : Profile #

The compliance profile; controls which fields are required or forbidden during validation and generation.


[View source]
def profile=(profile : Profile) #

The compliance profile; controls which fields are required or forbidden during validation and generation.


[View source]
def seller : TradeParty #

Seller party (BG-4).


[View source]
def seller=(seller : TradeParty) #

Seller party (BG-4).


[View source]
def settlement : TradeSettlement #

Currency, VAT breakdown, payment means, and all monetary totals.


[View source]
def settlement=(settlement : TradeSettlement) #

Currency, VAT breakdown, payment means, and all monetary totals.


[View source]
def to_xml(indent : String = " ") : String #

Validates the invoice against EN 16931 business rules, then serialises to CII XML. Raises ValidationError if any business rule is violated.


[View source]