Skip to content

API reference / Quittio \ Core \ Data

InvoiceData

final readonly class in quittio/core · uses Immutable

Quittio\Core\Data\InvoiceData · Source

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.

Constants#

ConstantValueDescription
SNAPSHOT_VERSION1Schema version of serialised snapshots, used by upcasters.

Properties#

PropertyTypeDescription
$allowances readonlylist<DocumentAllowance>
$attachments readonlylist<Attachment>
$businessProcess readonly?string
$buyer readonlyBuyerParty
$buyerAccountingReference readonly?string
$buyerReference readonly?string
$charges readonlylist<DocumentCharge>
$contractReference readonly?string
$currency readonlystring
$delivery readonly?Delivery
$despatchAdviceReference readonly?string
$dueDate readonly?Date
$extended readonly?ExtendedData
$invoicedObject readonly?Identifier
$invoicingPeriod readonly?Period
$issueDate readonlyDate
$lines readonlylist<InvoiceLine>
$meta readonlyMeta
$notes readonlylist<Note>
$number readonlystring
$payee readonly?PayeeParty
$paymentInstructions readonly?PaymentInstructions
$paymentTerms readonly?PaymentTerms
$precedingInvoices readonlylist<PrecedingInvoiceReference>
$prepaidAmount readonly?Brick\Money\Money
$presentation readonly?Presentation
$projectReference readonly?ProjectReference
$purchaseOrderReference readonly?string
$receivingAdviceReference readonly?string
$roundingAmount readonly?Brick\Money\Money
$salesOrderReference readonly?string
$seller readonlySellerParty
$sellerTaxRepresentative readonly?TaxRepresentativeParty
$standardVersion readonlyStandardVersion
$taxCurrency readonly?string
$taxPointDate readonly?Date
$taxPointDateCode readonlyTaxPointDateCode|RawCode|null
$tenderReference readonly?string
$totals readonly?Totals
$typeCode readonlyInvoiceTypeCode|RawCode
$vatBreakdown readonlylist<VatBreakdown>
$xrechnungExtension readonly?XRechnungExtensionData

Methods#

MethodDescription
->__construct()
->allLines()All lines including sub lines, depth first.
::factory()Deterministic test data, e.g. InvoiceData::factory()->reverseCharge()->withLines(5)->make().
::fromArray()
::fromJson()
::fromSnapshot()Restores a stored snapshot of any older version through the upcaster chain. Snapshots without "_version" are treated as version 1.
->isCalculated()
->isCreditNote()
->toArray()
->toJson()
->toSnapshot()Serialised form for storage (Managed layer). Includes the snapshot version.
->typeCodeValue()
->with()Returns a copy with the given properties replaced.
->withImpliedExchangeRate()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()
->withNumber()

__construct()#

public function __construct(
    string $number,
    Date $issueDate,
    InvoiceTypeCode|RawCode $typeCode,
    string $currency,
    SellerParty $seller,
    BuyerParty $buyer,
    list<InvoiceLine> $lines,
    ?string $taxCurrency = null,
    ?Date $taxPointDate = null,
    TaxPointDateCode|RawCode|null $taxPointDateCode = null,
    ?Date $dueDate = null,
    ?string $buyerReference = null,
    ?ProjectReference $projectReference = null,
    ?string $contractReference = null,
    ?string $purchaseOrderReference = null,
    ?string $salesOrderReference = null,
    ?string $receivingAdviceReference = null,
    ?string $despatchAdviceReference = null,
    ?string $tenderReference = null,
    ?Identifier $invoicedObject = null,
    ?string $buyerAccountingReference = null,
    ?PaymentTerms $paymentTerms = null,
    list<Note> $notes = [],
    ?string $businessProcess = null,
    list<PrecedingInvoiceReference> $precedingInvoices = [],
    ?PayeeParty $payee = null,
    ?TaxRepresentativeParty $sellerTaxRepresentative = null,
    ?Delivery $delivery = null,
    ?Period $invoicingPeriod = null,
    ?PaymentInstructions $paymentInstructions = null,
    list<DocumentAllowance> $allowances = [],
    list<DocumentCharge> $charges = [],
    ?Totals $totals = null,
    list<VatBreakdown> $vatBreakdown = [],
    list<Attachment> $attachments = [],
    ?Money $prepaidAmount = null,
    ?Money $roundingAmount = null,
    ?ExtendedData $extended = null,
    ?XRechnungExtensionData $xrechnungExtension = null,
    ?Presentation $presentation = null,
    Meta $meta = new \Quittio\Core\Data\Meta(),
    StandardVersion $standardVersion = \Quittio\Core\Standards\StandardVersion::En16931_2017,
)
ParameterTypeDescription
$numberstring
$issueDateDate
$typeCodeInvoiceTypeCode|RawCode
$currencystring
$sellerSellerParty
$buyerBuyerParty
$lineslist<InvoiceLine>
$taxCurrency?string = null
$taxPointDate?Date = null
$taxPointDateCodeTaxPointDateCode|RawCode|null = null
$dueDate?Date = null
$buyerReference?string = null
$projectReference?ProjectReference = null
$contractReference?string = null
$purchaseOrderReference?string = null
$salesOrderReference?string = null
$receivingAdviceReference?string = null
$despatchAdviceReference?string = null
$tenderReference?string = null
$invoicedObject?Identifier = null
$buyerAccountingReference?string = null
$paymentTerms?PaymentTerms = null
$noteslist<Note> = []
$businessProcess?string = null
$precedingInvoiceslist<PrecedingInvoiceReference> = []
$payee?PayeeParty = null
$sellerTaxRepresentative?TaxRepresentativeParty = null
$delivery?Delivery = null
$invoicingPeriod?Period = null
$paymentInstructions?PaymentInstructions = null
$allowanceslist<DocumentAllowance> = []
$chargeslist<DocumentCharge> = []
$totals?Totals = null
$vatBreakdownlist<VatBreakdown> = []
$attachmentslist<Attachment> = []
$prepaidAmount?Brick\Money\Money = null
$roundingAmount?Brick\Money\Money = null
$extended?ExtendedData = null
$xrechnungExtension?XRechnungExtensionData = null
$presentation?Presentation = null
$metaMeta = new \Quittio\Core\Data\Meta()
$standardVersionStandardVersion = \Quittio\Core\Standards\StandardVersion::En16931_2017

allLines()#

public function allLines(): list<InvoiceLine>

All lines including sub lines, depth first.

Returns
list<InvoiceLine>

factory()#

public static function factory(): InvoiceFactory

static

Deterministic test data, e.g. InvoiceData::factory()->reverseCharge()->withLines(5)->make().

Returns
InvoiceFactory

fromArray()#

public static function fromArray(array<string, mixed> $data): self

static

ParameterTypeDescription
$dataarray<string, mixed>
Returns
self

fromJson()#

public static function fromJson(string $json): self

static

ParameterTypeDescription
$jsonstring
Returns
self

fromSnapshot()#

public static function fromSnapshot(
    array<array-key, mixed> $snapshot,
    ?SnapshotUpcasterChain $chain = null,
): self

static

Restores a stored snapshot of any older version through the upcaster chain. Snapshots without "_version" are treated as version 1.

ParameterTypeDescription
$snapshotarray<array-key, mixed>
$chain?SnapshotUpcasterChain = null
Returns
self

isCalculated()#

public function isCalculated(): bool
Returns
bool

isCreditNote()#

public function isCreditNote(): bool
Returns
bool

toArray()#

public function toArray(): array<string, mixed>
Returns
array<string, mixed>

toJson()#

public function toJson(int $flags = 0): string
ParameterTypeDescription
$flagsint = 0
Returns
string

toSnapshot()#

public function toSnapshot(): array<string, mixed>

Serialised form for storage (Managed layer). Includes the snapshot version.

Returns
array<string, mixed>

typeCodeValue()#

public function typeCodeValue(): string
Returns
string

with()#

public function with(array<string, mixed> $changes): static

Returns a copy with the given properties replaced.

ParameterTypeDescription
$changesarray<string, mixed>
Returns
static

withImpliedExchangeRate()#

public function 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.

Returns
self

withIssueDate()#

public function withIssueDate(Date $issueDate): self
ParameterTypeDescription
$issueDateDate
Returns
self

withNumber()#

public function withNumber(string $number): self
ParameterTypeDescription
$numberstring
Returns
self

The open core packages are MIT licensed. The legal wording of the country packs must be confirmed by a tax adviser.