API reference / Quittio \ Core \ Documents
DocumentData
final readonly class in quittio/core · uses Immutable
Quittio\Core\Documents\DocumentData · Source
Quote, order confirmation, delivery note, proforma invoice, payment reminder, account statement or bonus statement. Shares parties, lines and calculation with {@see InvoiceData}, but never produces e-invoice XML. Payment reminders and account statements have no lines: their amount comes from {@see Dunning} and {@see AccountStatement}.
Constants#
| Constant | Value | Description |
|---|---|---|
SNAPSHOT_VERSION | 1 | Version of the format of toSnapshot(); a new version comes with an upcaster. |
Properties#
| Property | Type | Description |
|---|---|---|
$allowances readonly | list<DocumentAllowance> | |
$bonus readonly | ?BonusStatement | |
$buyer readonly | BuyerParty | |
$buyerReference readonly | ?string | |
$charges readonly | list<DocumentCharge> | |
$currency readonly | string | |
$delivery readonly | ?Delivery | |
$dunning readonly | ?Dunning | |
$issueDate readonly | Date | |
$lineOptions readonly | array<string, DocumentLineOptions> | keyed by line identifier |
$lines readonly | list<InvoiceLine> | |
$meta readonly | Meta | |
$notes readonly | list<Note> | |
$number readonly | string | |
$packages readonly | list<Package> | |
$paymentInstructions readonly | ?PaymentInstructions | |
$paymentTerms readonly | ?PaymentTerms | |
$presentation readonly | ?Presentation | |
$purchaseOrderReference readonly | ?string | |
$reference readonly | ?string | |
$referenceDate readonly | ?Date | |
$seller readonly | SellerParty | |
$statement readonly | ?AccountStatement | |
$totals readonly | ?Totals | |
$type readonly | DocumentType | |
$validUntil readonly | ?Date | |
$vatBreakdown readonly | list<VatBreakdown> |
Methods#
| Method | Description |
|---|---|
->__construct() | |
->billableLines() | Lines that count towards the totals (without optional and alternative lines). |
::fromArray() | The document from an array of toArray(). |
::fromJson() | |
::fromSnapshot() | Restores a stored snapshot of any older version through the upcaster chain (default: SnapshotUpcasterChain::documentDefault()). Snapshots without "_version" are version 1. |
->isCalculated() | |
->notices() | Notices on the document; documents are not validated, so these are plausibility hints only. QUITTIO-DUNNING-FLAT-RATE-FEES (warning): a reminder to a business claims the flat rate for recovery costs and reminder fees of its own, which count towards the flat rate (Article 6 (3) Directive 2011/7/EU, section 288 (5) sentence 3 BGB). |
->options() | |
->toArray() | The document as plain array (scalars only); values equal to their default are left out. |
->toInvoiceDraft() | The document as invoice data, e.g. for calculation or rendering. Never use it as an invoice. |
->toJson() | The document as JSON of toArray(). |
->toSnapshot() | The document for storage, with the version of the format ("_version"), e.g. for a queued render job. Read it with fromSnapshot(). |
->with() | Returns a copy with the given properties replaced. |
__construct()#
public function __construct(
DocumentType $type,
string $number,
Date $issueDate,
string $currency,
SellerParty $seller,
BuyerParty $buyer,
list<InvoiceLine> $lines = [],
array<string, DocumentLineOptions> $lineOptions = [],
list<DocumentAllowance> $allowances = [],
list<DocumentCharge> $charges = [],
list<Note> $notes = [],
?Date $validUntil = null,
?string $reference = null,
?Date $referenceDate = null,
?string $buyerReference = null,
?string $purchaseOrderReference = null,
?Delivery $delivery = null,
list<Package> $packages = [],
?Dunning $dunning = null,
?AccountStatement $statement = null,
?PaymentTerms $paymentTerms = null,
?PaymentInstructions $paymentInstructions = null,
?Totals $totals = null,
list<VatBreakdown> $vatBreakdown = [],
?Presentation $presentation = null,
Meta $meta = new \Quittio\Core\Data\Meta(),
?BonusStatement $bonus = null,
)| Parameter | Type | Description |
|---|---|---|
$type | DocumentType | |
$number | string | |
$issueDate | Date | |
$currency | string | |
$seller | SellerParty | |
$buyer | BuyerParty | |
$lines | list<InvoiceLine> = [] | |
$lineOptions | array<string, DocumentLineOptions> = [] | keyed by line identifier |
$allowances | list<DocumentAllowance> = [] | |
$charges | list<DocumentCharge> = [] | |
$notes | list<Note> = [] | |
$validUntil | ?Date = null | |
$reference | ?string = null | |
$referenceDate | ?Date = null | |
$buyerReference | ?string = null | |
$purchaseOrderReference | ?string = null | |
$delivery | ?Delivery = null | |
$packages | list<Package> = [] | |
$dunning | ?Dunning = null | |
$statement | ?AccountStatement = null | |
$paymentTerms | ?PaymentTerms = null | |
$paymentInstructions | ?PaymentInstructions = null | |
$totals | ?Totals = null | |
$vatBreakdown | list<VatBreakdown> = [] | |
$presentation | ?Presentation = null | |
$meta | Meta = new \Quittio\Core\Data\Meta() | |
$bonus | ?BonusStatement = null |
billableLines()#
public function billableLines(): list<InvoiceLine>Lines that count towards the totals (without optional and alternative lines).
- Returns
list<InvoiceLine>
fromArray()#
public static function fromArray(array<string, mixed> $data): selfThe document from an array of toArray().
| Parameter | Type | Description |
|---|---|---|
$data | array<string, mixed> |
- Returns
self- Throws
HydrationException– for missing, unknown or invalid values
fromJson()#
public static function fromJson(string $json): self| Parameter | Type | Description |
|---|---|---|
$json | string |
- Returns
self- Throws
HydrationException– for invalid JSON or invalid values
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 (default: SnapshotUpcasterChain::documentDefault()). Snapshots without "_version" are version 1.
| Parameter | Type | Description |
|---|---|---|
$snapshot | array<array-key, mixed> | |
$chain | ?SnapshotUpcasterChain = null |
- Returns
self- Throws
SnapshotVersionException– for a version that this installation cannot read- Throws
HydrationException– for missing, unknown or invalid values
isCalculated()#
public function isCalculated(): bool- Returns
bool
notices()#
public function notices(string $locale = 'en'): list<ValidationMessage>Notices on the document; documents are not validated, so these are plausibility hints only. QUITTIO-DUNNING-FLAT-RATE-FEES (warning): a reminder to a business claims the flat rate for recovery costs and reminder fees of its own, which count towards the flat rate (Article 6 (3) Directive 2011/7/EU, section 288 (5) sentence 3 BGB).
| Parameter | Type | Description |
|---|---|---|
$locale | string = 'en' |
- Returns
list<ValidationMessage>
options()#
public function options(string $lineId): DocumentLineOptions| Parameter | Type | Description |
|---|---|---|
$lineId | string |
- Returns
DocumentLineOptions
toArray()#
public function toArray(): array<string, mixed>The document as plain array (scalars only); values equal to their default are left out.
- Returns
array<string, mixed>
toInvoiceDraft()#
public function toInvoiceDraft(bool $billableOnly = true): InvoiceDataThe document as invoice data, e.g. for calculation or rendering. Never use it as an invoice.
| Parameter | Type | Description |
|---|---|---|
$billableOnly | bool = true |
- Returns
InvoiceData
toJson()#
public function toJson(int $flags = 0): stringThe document as JSON of toArray().
| Parameter | Type | Description |
|---|---|---|
$flags | int = 0 |
- Returns
string
toSnapshot()#
public function toSnapshot(): array<string, mixed>The document for storage, with the version of the format ("_version"), e.g. for a queued render job. Read it with fromSnapshot().
- Returns
array<string, mixed>
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