Zum Inhalt springen

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#

ConstantValueDescription
SNAPSHOT_VERSION1Version of the format of toSnapshot(); a new version comes with an upcaster.

Properties#

PropertyTypeDescription
$allowances readonlylist<DocumentAllowance>
$bonus readonly?BonusStatement
$buyer readonlyBuyerParty
$buyerReference readonly?string
$charges readonlylist<DocumentCharge>
$currency readonlystring
$delivery readonly?Delivery
$dunning readonly?Dunning
$issueDate readonlyDate
$lineOptions readonlyarray<string, DocumentLineOptions>keyed by line identifier
$lines readonlylist<InvoiceLine>
$meta readonlyMeta
$notes readonlylist<Note>
$number readonlystring
$packages readonlylist<Package>
$paymentInstructions readonly?PaymentInstructions
$paymentTerms readonly?PaymentTerms
$presentation readonly?Presentation
$purchaseOrderReference readonly?string
$reference readonly?string
$referenceDate readonly?Date
$seller readonlySellerParty
$statement readonly?AccountStatement
$totals readonly?Totals
$type readonlyDocumentType
$validUntil readonly?Date
$vatBreakdown readonlylist<VatBreakdown>

Methods#

MethodDescription
->__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,
)
ParameterTypeDescription
$typeDocumentType
$numberstring
$issueDateDate
$currencystring
$sellerSellerParty
$buyerBuyerParty
$lineslist<InvoiceLine> = []
$lineOptionsarray<string, DocumentLineOptions> = []keyed by line identifier
$allowanceslist<DocumentAllowance> = []
$chargeslist<DocumentCharge> = []
$noteslist<Note> = []
$validUntil?Date = null
$reference?string = null
$referenceDate?Date = null
$buyerReference?string = null
$purchaseOrderReference?string = null
$delivery?Delivery = null
$packageslist<Package> = []
$dunning?Dunning = null
$statement?AccountStatement = null
$paymentTerms?PaymentTerms = null
$paymentInstructions?PaymentInstructions = null
$totals?Totals = null
$vatBreakdownlist<VatBreakdown> = []
$presentation?Presentation = null
$metaMeta = 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): self

static

The document from an array of toArray().

ParameterTypeDescription
$dataarray<string, mixed>
Returns
self
Throws
HydrationException – for missing, unknown or invalid values

fromJson()#

public static function fromJson(string $json): self

static

ParameterTypeDescription
$jsonstring
Returns
self
Throws
HydrationException – for invalid JSON or invalid values

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 (default: SnapshotUpcasterChain::documentDefault()). Snapshots without "_version" are version 1.

ParameterTypeDescription
$snapshotarray<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).

ParameterTypeDescription
$localestring = 'en'
Returns
list<ValidationMessage>

options()#

public function options(string $lineId): DocumentLineOptions
ParameterTypeDescription
$lineIdstring
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): InvoiceData

The document as invoice data, e.g. for calculation or rendering. Never use it as an invoice.

ParameterTypeDescription
$billableOnlybool = true
Returns
InvoiceData

toJson()#

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

The document as JSON of toArray().

ParameterTypeDescription
$flagsint = 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): static

Returns a copy with the given properties replaced.

ParameterTypeDescription
$changesarray<string, mixed>
Returns
static

Die Open-Core-Pakete stehen unter der MIT-Lizenz. Die rechtlichen Formulierungen der Länderpakete sind mit einer Steuerberatung abzustimmen.