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#
| Constant | Value | Description |
|---|---|---|
SNAPSHOT_VERSION | 1 | Schema version of serialised snapshots, used by upcasters. |
Properties#
| Property | Type | Description |
|---|---|---|
$allowances readonly | list<DocumentAllowance> | |
$attachments readonly | list<Attachment> | |
$businessProcess readonly | ?string | |
$buyer readonly | BuyerParty | |
$buyerAccountingReference readonly | ?string | |
$buyerReference readonly | ?string | |
$charges readonly | list<DocumentCharge> | |
$contractReference readonly | ?string | |
$currency readonly | string | |
$delivery readonly | ?Delivery | |
$despatchAdviceReference readonly | ?string | |
$dueDate readonly | ?Date | |
$extended readonly | ?ExtendedData | |
$invoicedObject readonly | ?Identifier | |
$invoicingPeriod readonly | ?Period | |
$issueDate readonly | Date | |
$lines readonly | list<InvoiceLine> | |
$meta readonly | Meta | |
$notes readonly | list<Note> | |
$number readonly | string | |
$payee readonly | ?PayeeParty | |
$paymentInstructions readonly | ?PaymentInstructions | |
$paymentTerms readonly | ?PaymentTerms | |
$precedingInvoices readonly | list<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 readonly | SellerParty | |
$sellerTaxRepresentative readonly | ?TaxRepresentativeParty | |
$standardVersion readonly | StandardVersion | |
$taxCurrency readonly | ?string | |
$taxPointDate readonly | ?Date | |
$taxPointDateCode readonly | TaxPointDateCode|RawCode|null | |
$tenderReference readonly | ?string | |
$totals readonly | ?Totals | |
$typeCode readonly | InvoiceTypeCode|RawCode | |
$vatBreakdown readonly | list<VatBreakdown> | |
$xrechnungExtension readonly | ?XRechnungExtensionData |
Methods#
| Method | Description |
|---|---|
->__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,
)| Parameter | Type | Description |
|---|---|---|
$number | string | |
$issueDate | Date | |
$typeCode | InvoiceTypeCode|RawCode | |
$currency | string | |
$seller | SellerParty | |
$buyer | BuyerParty | |
$lines | list<InvoiceLine> | |
$taxCurrency | ?string = null | |
$taxPointDate | ?Date = null | |
$taxPointDateCode | TaxPointDateCode|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 | |
$notes | list<Note> = [] | |
$businessProcess | ?string = null | |
$precedingInvoices | list<PrecedingInvoiceReference> = [] | |
$payee | ?PayeeParty = null | |
$sellerTaxRepresentative | ?TaxRepresentativeParty = null | |
$delivery | ?Delivery = null | |
$invoicingPeriod | ?Period = null | |
$paymentInstructions | ?PaymentInstructions = null | |
$allowances | list<DocumentAllowance> = [] | |
$charges | list<DocumentCharge> = [] | |
$totals | ?Totals = null | |
$vatBreakdown | list<VatBreakdown> = [] | |
$attachments | list<Attachment> = [] | |
$prepaidAmount | ?Brick\Money\Money = null | |
$roundingAmount | ?Brick\Money\Money = null | |
$extended | ?ExtendedData = null | |
$xrechnungExtension | ?XRechnungExtensionData = null | |
$presentation | ?Presentation = null | |
$meta | Meta = new \Quittio\Core\Data\Meta() | |
$standardVersion | StandardVersion = \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(): InvoiceFactoryDeterministic test data, e.g. InvoiceData::factory()->reverseCharge()->withLines(5)->make().
- Returns
InvoiceFactory
fromArray()#
public static function fromArray(array<string, mixed> $data): self| Parameter | Type | Description |
|---|---|---|
$data | array<string, mixed> |
- Returns
self
fromJson()#
public static function fromJson(string $json): self| Parameter | Type | Description |
|---|---|---|
$json | string |
- Returns
self
fromSnapshot()#
public static function fromSnapshot(
array<array-key, mixed> $snapshot,
?SnapshotUpcasterChain $chain = null,
): selfRestores a stored snapshot of any older version through the upcaster chain. Snapshots without "_version" are treated as version 1.
| Parameter | Type | Description |
|---|---|---|
$snapshot | array<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| Parameter | Type | Description |
|---|---|---|
$flags | int = 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): staticReturns a copy with the given properties replaced.
| Parameter | Type | Description |
|---|---|---|
$changes | array<string, mixed> |
- Returns
static
withImpliedExchangeRate()#
public function withImpliedExchangeRate(): selfCopy 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| Parameter | Type | Description |
|---|---|---|
$issueDate | Date |
- Returns
self
withNumber()#
public function withNumber(string $number): self| Parameter | Type | Description |
|---|---|---|
$number | string |
- Returns
self