InvoiceData
in package
uses
Immutable
Root of the semantic invoice model (EN 16931, superset of the 2017 and 2026 versions).
The specification identifier (BT-24) is not part of the data: it is derived from the profile. Totals (BG-22) and the VAT breakdown (BG-23) are set by the calculator.
Table of Contents
Constants
- SNAPSHOT_VERSION : int = 1
- Schema version of serialised snapshots, used by upcasters.
Properties
- $allowances : array<string|int, mixed>
- $attachments : array<string|int, mixed>
- $businessProcess : string|null
- $buyer : BuyerParty
- $buyerAccountingReference : string|null
- $buyerReference : string|null
- $charges : array<string|int, mixed>
- $contractReference : string|null
- $currency : string
- $delivery : Delivery|null
- $despatchAdviceReference : string|null
- $dueDate : Date|null
- $extended : ExtendedData|null
- $invoicedObject : Identifier|null
- $invoicingPeriod : Period|null
- $issueDate : Date
- $lines : array<string|int, mixed>
- $meta : Meta
- $notes : array<string|int, mixed>
- $number : string
- $payee : PayeeParty|null
- $paymentInstructions : PaymentInstructions|null
- $paymentTerms : PaymentTerms|null
- $precedingInvoices : array<string|int, mixed>
- $prepaidAmount : Money|null
- $presentation : Presentation|null
- $projectReference : ProjectReference|null
- $purchaseOrderReference : string|null
- $receivingAdviceReference : string|null
- $roundingAmount : Money|null
- $salesOrderReference : string|null
- $seller : SellerParty
- $sellerTaxRepresentative : TaxRepresentativeParty|null
- $standardVersion : StandardVersion
- $taxCurrency : string|null
- $taxPointDate : Date|null
- $taxPointDateCode : TaxPointDateCode|RawCode|null
- $tenderReference : string|null
- $totals : Totals|null
- $typeCode : InvoiceTypeCode|RawCode
- $vatBreakdown : array<string|int, mixed>
- $xrechnungExtension : XRechnungExtensionData|null
Methods
- __construct() : mixed
- allLines() : array<int, InvoiceLine>
- All lines including sub lines, depth first.
- factory() : InvoiceFactory
- Deterministic test data, e.g. InvoiceData::factory()->reverseCharge()->withLines(5)->make().
- fromArray() : self
- fromJson() : self
- fromSnapshot() : self
- Restores a stored snapshot of any older version through the upcaster chain.
- isCalculated() : bool
- isCreditNote() : bool
- toArray() : array<string, mixed>
- toJson() : string
- toSnapshot() : array<string, mixed>
- Serialised form for storage (Managed layer). Includes the snapshot version.
- typeCodeValue() : string
- with() : static
- Returns a copy with the given properties replaced.
- withImpliedExchangeRate() : self
- Copy with the exchange rate implied by the declared VAT totals (BT-111 / BT-110, ten decimals), e.g. for data read from XML, which carries no exchange rate. A recalculation then reproduces BT-111, also with changed or negated amounts. Data with an exchange rate, without a VAT accounting currency (BT-6) or without a declared non-zero BT-110 is returned unchanged.
- withIssueDate() : self
- withNumber() : self
Constants
SNAPSHOT_VERSION
Schema version of serialised snapshots, used by upcasters.
public
int
SNAPSHOT_VERSION
= 1
Properties
$allowances
public
array<string|int, mixed>
$allowances
= []
Attributes
- #[Bt]
- 'BG-20'
- #[Cardinality]
- '0..n'
- #[Cii]
- 'ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator="false"]'
- #[Level]
- ProfileLevel::BasicWl
- #[ListOf]
- DocumentAllowance::class
- #[Ubl]
- 'cac:AllowanceCharge[cbc:ChargeIndicator="false"]'
$attachments
public
array<string|int, mixed>
$attachments
= []
Attributes
- #[Bt]
- 'BG-24'
- #[Cardinality]
- '0..n'
- #[Cii]
- 'ram:AdditionalReferencedDocument[ram:TypeCode="916"]'
- #[ListOf]
- Attachment::class
- #[Ubl]
- 'cac:AdditionalDocumentReference'
$businessProcess
public
string|null
$businessProcess
= null
Attributes
- #[Bt]
- 'BT-23'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID'
- #[Level]
- ProfileLevel::Minimum
- #[Ubl]
- 'cbc:ProfileID'
$buyer
public
BuyerParty
$buyer
Attributes
- #[Bt]
- 'BG-7'
- #[Cardinality]
- '1'
- #[Cii]
- 'ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty'
- #[Level]
- ProfileLevel::Minimum
- #[Ubl]
- 'cac:AccountingCustomerParty'
$buyerAccountingReference
public
string|null
$buyerAccountingReference
= null
Attributes
- #[Bt]
- 'BT-19'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:ReceivableSpecifiedTradeAccountingAccount/ram:ID'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cbc:AccountingCost'
$buyerReference
public
string|null
$buyerReference
= null
Attributes
- #[Bt]
- 'BT-10'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:ApplicableHeaderTradeAgreement/ram:BuyerReference'
- #[Level]
- ProfileLevel::Minimum
- #[RequiredIn]
- 'xrechnung'
- #[Ubl]
- 'cbc:BuyerReference'
$charges
public
array<string|int, mixed>
$charges
= []
Attributes
- #[Bt]
- 'BG-21'
- #[Cardinality]
- '0..n'
- #[Cii]
- 'ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator="true"]'
- #[Level]
- ProfileLevel::BasicWl
- #[ListOf]
- DocumentCharge::class
- #[Ubl]
- 'cac:AllowanceCharge[cbc:ChargeIndicator="true"]'
$contractReference
public
string|null
$contractReference
= null
Attributes
- #[Bt]
- 'BT-12'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:ContractReferencedDocument/ram:IssuerAssignedID'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cac:ContractDocumentReference/cbc:ID'
$currency
public
string
$currency
Attributes
- #[Bt]
- 'BT-5'
- #[Cardinality]
- '1'
- #[Cii]
- 'ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode'
- #[Level]
- ProfileLevel::Minimum
- #[Ubl]
- 'cbc:DocumentCurrencyCode'
$delivery
public
Delivery|null
$delivery
= null
Attributes
- #[Bt]
- 'BG-13'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:ApplicableHeaderTradeDelivery'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cac:Delivery'
$despatchAdviceReference
public
string|null
$despatchAdviceReference
= null
Attributes
- #[Bt]
- 'BT-16'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:DespatchAdviceReferencedDocument/ram:IssuerAssignedID'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cac:DespatchDocumentReference/cbc:ID'
$dueDate
public
Date|null
$dueDate
= null
Attributes
- #[Bt]
- 'BT-9'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:SpecifiedTradePaymentTerms/ram:DueDateDateTime'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cbc:DueDate (CreditNote: cac:PaymentMeans/cbc:PaymentDueDate)'
$extended
public
ExtendedData|null
$extended
= null
Attributes
- #[ExtendedOnly]
$invoicedObject
public
Identifier|null
$invoicedObject
= null
Attributes
- #[Bt]
- 'BT-18'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:AdditionalReferencedDocument[ram:TypeCode="130"]/ram:IssuerAssignedID'
- #[Ubl]
- 'cac:AdditionalDocumentReference[cbc:DocumentTypeCode="130"]/cbc:ID'
$invoicingPeriod
public
Period|null
$invoicingPeriod
= null
Attributes
- #[Bt]
- 'BG-14'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:BillingSpecifiedPeriod'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cac:InvoicePeriod'
$issueDate
public
Date
$issueDate
Attributes
- #[Bt]
- 'BT-2'
- #[Cardinality]
- '1'
- #[Cii]
- 'rsm:ExchangedDocument/ram:IssueDateTime'
- #[Level]
- ProfileLevel::Minimum
- #[Ubl]
- 'cbc:IssueDate'
$lines
public
array<string|int, mixed>
$lines
Attributes
- #[Bt]
- 'BG-25'
- #[Cardinality]
- '1..n'
- #[Cii]
- 'rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem'
- #[Level]
- ProfileLevel::Basic
- #[ListOf]
- InvoiceLine::class
- #[Ubl]
- 'cac:InvoiceLine | cac:CreditNoteLine'
$meta
public
Meta
$meta
= new Meta()
Attributes
- #[Internal]
$notes
public
array<string|int, mixed>
$notes
= []
Attributes
- #[Bt]
- 'BG-1'
- #[Cardinality]
- '0..n'
- #[Cii]
- 'rsm:ExchangedDocument/ram:IncludedNote'
- #[Level]
- ProfileLevel::BasicWl
- #[ListOf]
- Note::class
- #[Ubl]
- 'cbc:Note'
$number
public
string
$number
Attributes
- #[Bt]
- 'BT-1'
- #[Cardinality]
- '1'
- #[Cii]
- 'rsm:ExchangedDocument/ram:ID'
- #[Level]
- ProfileLevel::Minimum
- #[Ubl]
- 'cbc:ID'
$payee
public
PayeeParty|null
$payee
= null
Attributes
- #[Bt]
- 'BG-10'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:PayeeTradeParty'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cac:PayeeParty'
$paymentInstructions
public
PaymentInstructions|null
$paymentInstructions
= null
Attributes
- #[Bt]
- 'BG-16'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:SpecifiedTradeSettlementPaymentMeans'
- #[Level]
- ProfileLevel::BasicWl
- #[RequiredIn]
- 'xrechnung'
- #[Ubl]
- 'cac:PaymentMeans'
$paymentTerms
public
PaymentTerms|null
$paymentTerms
= null
Attributes
- #[Bt]
- 'BT-20'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:SpecifiedTradePaymentTerms'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cac:PaymentTerms'
$precedingInvoices
public
array<string|int, mixed>
$precedingInvoices
= []
Attributes
- #[Bt]
- 'BG-3'
- #[Cardinality]
- '0..n'
- #[Cii]
- 'ram:InvoiceReferencedDocument'
- #[Level]
- ProfileLevel::BasicWl
- #[ListOf]
- PrecedingInvoiceReference::class
- #[Ubl]
- 'cac:BillingReference'
$prepaidAmount
public
Money|null
$prepaidAmount
= null
Attributes
- #[InputFor]
- 'BT-113'
$presentation
public
Presentation|null
$presentation
= null
Attributes
- #[PdfOnly]
$projectReference
public
ProjectReference|null
$projectReference
= null
Attributes
- #[Bt]
- 'BT-11'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:ApplicableHeaderTradeAgreement/ram:SpecifiedProcuringProject'
- #[Ubl]
- 'cac:ProjectReference/cbc:ID'
$purchaseOrderReference
public
string|null
$purchaseOrderReference
= null
Attributes
- #[Bt]
- 'BT-13'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:BuyerOrderReferencedDocument/ram:IssuerAssignedID'
- #[Level]
- ProfileLevel::Minimum
- #[Ubl]
- 'cac:OrderReference/cbc:ID'
$receivingAdviceReference
public
string|null
$receivingAdviceReference
= null
Attributes
- #[Bt]
- 'BT-15'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:ReceivingAdviceReferencedDocument/ram:IssuerAssignedID'
- #[Ubl]
- 'cac:ReceiptDocumentReference/cbc:ID'
$roundingAmount
public
Money|null
$roundingAmount
= null
Attributes
- #[InputFor]
- 'BT-114'
$salesOrderReference
public
string|null
$salesOrderReference
= null
Attributes
- #[Bt]
- 'BT-14'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:SellerOrderReferencedDocument/ram:IssuerAssignedID'
- #[Ubl]
- 'cac:OrderReference/cbc:SalesOrderID'
$seller
public
SellerParty
$seller
Attributes
- #[Bt]
- 'BG-4'
- #[Cardinality]
- '1'
- #[Cii]
- 'ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty'
- #[Level]
- ProfileLevel::Minimum
- #[Ubl]
- 'cac:AccountingSupplierParty'
$sellerTaxRepresentative
public
TaxRepresentativeParty|null
$sellerTaxRepresentative
= null
Attributes
- #[Bt]
- 'BG-11'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:SellerTaxRepresentativeTradeParty'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cac:TaxRepresentativeParty'
$standardVersion
public
StandardVersion
$standardVersion
= StandardVersion::En16931_2017
Attributes
- #[Internal]
$taxCurrency
public
string|null
$taxCurrency
= null
Attributes
- #[Bt]
- 'BT-6'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:ApplicableHeaderTradeSettlement/ram:TaxCurrencyCode'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cbc:TaxCurrencyCode'
$taxPointDate
public
Date|null
$taxPointDate
= null
Attributes
- #[Bt]
- 'BT-7'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:ApplicableTradeTax/ram:TaxPointDate'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cbc:TaxPointDate'
$taxPointDateCode
public
TaxPointDateCode|RawCode|null
$taxPointDateCode
= null
Attributes
- #[Bt]
- 'BT-8'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:ApplicableTradeTax/ram:DueDateTypeCode'
- #[Level]
- ProfileLevel::BasicWl
- #[Ubl]
- 'cac:InvoicePeriod/cbc:DescriptionCode'
$tenderReference
public
string|null
$tenderReference
= null
Attributes
- #[Bt]
- 'BT-17'
- #[Cardinality]
- '0..1'
- #[Cii]
- 'ram:AdditionalReferencedDocument[ram:TypeCode="50"]/ram:IssuerAssignedID'
- #[Ubl]
- 'cac:OriginatorDocumentReference/cbc:ID'
$totals
public
Totals|null
$totals
= null
Attributes
- #[Bt]
- 'BG-22'
- #[Cardinality]
- '1'
- #[Cii]
- 'ram:SpecifiedTradeSettlementHeaderMonetarySummation'
- #[Computed]
- #[Level]
- ProfileLevel::Minimum
- #[Ubl]
- 'cac:LegalMonetaryTotal'
$typeCode
public
InvoiceTypeCode|RawCode
$typeCode
Attributes
- #[Bt]
- 'BT-3'
- #[Cardinality]
- '1'
- #[Cii]
- 'rsm:ExchangedDocument/ram:TypeCode'
- #[Level]
- ProfileLevel::Minimum
- #[Ubl]
- 'cbc:InvoiceTypeCode | cbc:CreditNoteTypeCode'
$vatBreakdown
public
array<string|int, mixed>
$vatBreakdown
= []
Attributes
- #[Bt]
- 'BG-23'
- #[Cardinality]
- '1..n'
- #[Cii]
- 'ram:ApplicableTradeTax'
- #[Computed]
- #[Level]
- ProfileLevel::BasicWl
- #[ListOf]
- VatBreakdown::class
- #[Ubl]
- 'cac:TaxTotal/cac:TaxSubtotal'
$xrechnungExtension
public
XRechnungExtensionData|null
$xrechnungExtension
= null
Attributes
Methods
__construct()
public
__construct(string $number, Date $issueDate, InvoiceTypeCode|RawCode $typeCode, string $currency, SellerParty $seller, BuyerParty $buyer, array<int, InvoiceLine> $lines[, string|null $taxCurrency = null ][, Date|null $taxPointDate = null ][, TaxPointDateCode|RawCode|null $taxPointDateCode = null ][, Date|null $dueDate = null ][, string|null $buyerReference = null ][, ProjectReference|null $projectReference = null ][, string|null $contractReference = null ][, string|null $purchaseOrderReference = null ][, string|null $salesOrderReference = null ][, string|null $receivingAdviceReference = null ][, string|null $despatchAdviceReference = null ][, string|null $tenderReference = null ][, Identifier|null $invoicedObject = null ][, string|null $buyerAccountingReference = null ][, PaymentTerms|null $paymentTerms = null ][, array<int, Note> $notes = [] ][, string|null $businessProcess = null ][, array<int, PrecedingInvoiceReference> $precedingInvoices = [] ][, PayeeParty|null $payee = null ][, TaxRepresentativeParty|null $sellerTaxRepresentative = null ][, Delivery|null $delivery = null ][, Period|null $invoicingPeriod = null ][, PaymentInstructions|null $paymentInstructions = null ][, array<int, DocumentAllowance> $allowances = [] ][, array<int, DocumentCharge> $charges = [] ][, Totals|null $totals = null ][, array<int, VatBreakdown> $vatBreakdown = [] ][, array<int, Attachment> $attachments = [] ][, Money|null $prepaidAmount = null ][, Money|null $roundingAmount = null ][, ExtendedData|null $extended = null ][, XRechnungExtensionData|null $xrechnungExtension = null ][, Presentation|null $presentation = null ][, Meta $meta = new Meta() ][, StandardVersion $standardVersion = StandardVersion::En16931_2017 ]) : mixed
Parameters
- $number : string
- $issueDate : Date
- $typeCode : InvoiceTypeCode|RawCode
- $currency : string
- $seller : SellerParty
- $buyer : BuyerParty
- $lines : array<int, InvoiceLine>
- $taxCurrency : string|null = null
- $taxPointDate : Date|null = null
- $taxPointDateCode : TaxPointDateCode|RawCode|null = null
- $dueDate : Date|null = null
- $buyerReference : string|null = null
- $projectReference : ProjectReference|null = null
- $contractReference : string|null = null
- $purchaseOrderReference : string|null = null
- $salesOrderReference : string|null = null
- $receivingAdviceReference : string|null = null
- $despatchAdviceReference : string|null = null
- $tenderReference : string|null = null
- $invoicedObject : Identifier|null = null
- $buyerAccountingReference : string|null = null
- $paymentTerms : PaymentTerms|null = null
- $notes : array<int, Note> = []
- $businessProcess : string|null = null
- $precedingInvoices : array<int, PrecedingInvoiceReference> = []
- $payee : PayeeParty|null = null
- $sellerTaxRepresentative : TaxRepresentativeParty|null = null
- $delivery : Delivery|null = null
- $invoicingPeriod : Period|null = null
- $paymentInstructions : PaymentInstructions|null = null
- $allowances : array<int, DocumentAllowance> = []
- $charges : array<int, DocumentCharge> = []
- $totals : Totals|null = null
- $vatBreakdown : array<int, VatBreakdown> = []
- $attachments : array<int, Attachment> = []
- $prepaidAmount : Money|null = null
- $roundingAmount : Money|null = null
- $extended : ExtendedData|null = null
- $xrechnungExtension : XRechnungExtensionData|null = null
- $presentation : Presentation|null = null
- $meta : Meta = new Meta()
- $standardVersion : StandardVersion = StandardVersion::En16931_2017
allLines()
All lines including sub lines, depth first.
public
allLines() : array<int, InvoiceLine>
Return values
array<int, InvoiceLine>factory()
Deterministic test data, e.g. InvoiceData::factory()->reverseCharge()->withLines(5)->make().
public
static factory() : InvoiceFactory
Return values
InvoiceFactoryfromArray()
public
static fromArray(array<string, mixed> $data) : self
Parameters
- $data : array<string, mixed>
Return values
selffromJson()
public
static fromJson(string $json) : self
Parameters
- $json : string
Return values
selffromSnapshot()
Restores a stored snapshot of any older version through the upcaster chain.
public
static fromSnapshot(array<string|int, mixed> $snapshot[, SnapshotUpcasterChain|null $chain = null ]) : self
Snapshots without "_version" are treated as version 1.
Parameters
- $snapshot : array<string|int, mixed>
- $chain : SnapshotUpcasterChain|null = null
Return values
selfisCalculated()
public
isCalculated() : bool
Return values
boolisCreditNote()
public
isCreditNote() : bool
Return values
booltoArray()
public
toArray() : array<string, mixed>
Return values
array<string, mixed>toJson()
public
toJson([int $flags = 0 ]) : string
Parameters
- $flags : int = 0
Return values
stringtoSnapshot()
Serialised form for storage (Managed layer). Includes the snapshot version.
public
toSnapshot() : array<string, mixed>
Return values
array<string, mixed>typeCodeValue()
public
typeCodeValue() : string
Return values
stringwith()
Returns a copy with the given properties replaced.
public
with(array<string, mixed> $changes) : static
Parameters
- $changes : array<string, mixed>
Return values
staticwithImpliedExchangeRate()
Copy with the exchange rate implied by the declared VAT totals (BT-111 / BT-110, ten decimals), e.g. for data read from XML, which carries no exchange rate. A recalculation then reproduces BT-111, also with changed or negated amounts. Data with an exchange rate, without a VAT accounting currency (BT-6) or without a declared non-zero BT-110 is returned unchanged.
public
withImpliedExchangeRate() : self
Return values
selfwithIssueDate()
public
withIssueDate(Date $issueDate) : self
Parameters
- $issueDate : Date
Return values
selfwithNumber()
public
withNumber(string $number) : self
Parameters
- $number : string