InvoiceBuilder
in package
uses
BuildsAllowancesAndCharges, BuildsDelivery, BuildsExtensions, BuildsHeader, BuildsLines, BuildsNotesAndAttachments, BuildsParties, BuildsPayment, BuildsPresentationAndMeta, BuildsReferences, Macroable
Fluent builder for InvoiceData.
Amounts, prices and quantities are passed as strings or integers, never as floats. The result is not yet calculated; totals and the VAT breakdown are set by the calculator.
Table of Contents
Properties
- $macros : array<string, callable>
Methods
- __call() : mixed
- __construct() : mixed
- addPrepaid() : static
- Adds to the amount already paid (BT-113), e.g. one of several advance payments.
- allowance() : static
- Document level allowance (BG-20) for one VAT category and rate.
- applyDefaults() : static
- Applies the defaults of a seller, e.g. the seller of config/quittio.php with its bank account and small business flag (Quittio::invoice()) or a Managed issuer. The builder remembers what they set: seller() with another seller removes it again.
- attachment() : static
- Supporting document (BG-24), either embedded ($content) or as external link.
- build() : InvoiceData
- The invoice data, not calculated yet (the calculator or a render run adds the totals).
- buildDraft() : InvoiceData
- Builds without requiring lines, e.g. for payment reminders or account statements, or for drafts. Data without lines can be calculated (its line sum is zero; document allowances and charges still count), but it is not a valid invoice: EN 16931 requires at least one line (BR-16), so validation reports it.
- businessProcess() : static
- Business process identifier (BT-23); Peppol and XRechnung write their process when it is not set. null removes it.
- buyer() : static
- The buyer (BG-7): a BuyerParty, a PartyBuilder (Party::make()) or an application model (ProvidesParty), e.g. ->buyer($customer), replace the buyer set before; a callable receives the builder of the buyer set before and changes it.
- buyerAccountingReference() : static
- The buyer's accounting reference (BT-19), e.g. a cost centre; null removes it.
- buyerReference() : static
- Buyer reference (BT-10). For public sector buyers in Germany this is the Leitweg-ID.
- cashDiscount() : static
- Cash discount ("Skonto") of $percent for payment within $days days after the issue date, optionally on a base amount; repeatable for several tiers. Continues the payment terms.
- charge() : static
- Document level charge (BG-21) for one VAT category and rate. See allowance() for the exemption reason.
- contractReference() : static
- Contract reference (BT-12); null removes it.
- creditTransfer() : static
- Adds a further bank account (BG-17).
- currency() : static
- Invoice currency (BT-5), ISO 4217; stored in upper case. Default EUR.
- custom() : static
- Free data for templates (view model key meta.custom); the same key replaces the value.
- defaultVat() : static
- VAT treatment of the lines that set none (also sub lines), with the arguments of LineBuilder::vat(). Without it, the application default of useDefaultVat() applies.
- deliverTo() : static
- Deliver-to party and address (BT-70, BG-15).
- delivery() : static
- Replaces the whole delivery information (BG-13), including the delivery date (BT-72).
- deliveryDate() : static
- Actual delivery or service date (BT-72).
- despatchAdviceReference() : static
- Despatch advice reference (BT-16); null removes it.
- directDebit() : static
- SEPA direct debit (BG-19): mandate reference (BT-89), creditor identifier (BT-90) and the debited IBAN (BT-91, spaces removed). Without payment instructions it starts them with SepaDirectDebit (59).
- discountAmount() : static
- Absolute discount distributed over all VAT groups in proportion to their line totals.
- discountPercent() : static
- Percentage discount on all lines. Split into one allowance per VAT group.
- dueDate() : static
- Due date (BT-9). Without it the calculator derives it from dueInDays(); otherwise the configured due_days apply when rendering, never for credit notes.
- dueInDays() : static
- Payment target: the due date (BT-9) is the issue date plus $days unless dueDate() is set, and the payment terms say "Payable within … days without deduction." Continues the payment terms set before.
- exchangeRate() : static
- Exchange rate from the invoice currency to the VAT accounting currency (BT-6), used to calculate the VAT total in that currency (BT-111), with the date of the rate. Replaces a rate implied by declared amounts (see from()).
- extended() : static
- Data of the profile EXTENDED of ZUGFeRD/Factur-X (further parties, delivery terms, instalments …); other profiles do not write it.
- flag() : static
- Sets a flag that country packs evaluate (e.g. a small amount invoice in Germany).
- flushMacros() : void
- from() : static
- Starts a builder from existing data, e.g. to change a draft.
- fromDocument() : static
- Starts an invoice from a quote, order confirmation, delivery note or proforma invoice: parties, billable lines, document allowances and charges and payment data are taken over; number and issue date must be set.
- fromUsing() : static
- Like from(), with the calculator that decides whether the declared amounts of the data differ from a recalculation, e.g. the calculator of the Quittio instance.
- group() : static
- Defines a line group for the PDF. Lines join it via LineBuilder::group().
- hasMacro() : bool
- invoicedObject() : static
- Identifier of the invoiced object (BT-18), e.g. a meter or subscription number, with its scheme (BT-18-1).
- invoicingPeriod() : static
- Invoicing period (BG-14).
- issueDate() : static
- Issue date (BT-2); default today. A DateTimeInterface is converted in the time zone of timezone(), so call timezone() first.
- lateFee() : static
- Late payment terms: days, percentage and text. Continues the payment terms.
- line() : static
- Adds a line (BG-25): a name with the common values (->line('Consulting', netPrice: '120.00', quantity: 4, unit: UnitCode::Hour)), a LineBuilder (Line::make()), an array with the keys of LineBuilder::ARRAY_KEYS, an application model (ProvidesInvoiceLine), a callable that receives a new LineBuilder, or a finished InvoiceLine.
- lines() : static
- locale() : static
- Language of the invoice: labels, generated texts and the exemption texts of presets.
- macro() : void
- make() : static
- A new, empty builder; type code 380 and the issue date today unless set.
- note() : static
- Adds an invoice note (BG-1): the text (BT-22) and an optional subject code (BT-21, UNTDID 4451, e.g. "REG" for regulatory information). Unknown codes are kept as RawCode.
- number() : static
- Invoice number (BT-1). Not checked here; the validation requires it.
- payee() : static
- Payee (BG-10), if different from the seller (e.g. a factoring company): the name with the identifier (BT-60) and the legal registration identifier (BT-61) and their schemes, a PartyBuilder (Party::make('Factoring AG')->identifier(…)), a PayeeParty, or a callable that receives a PartyBuilder and, like seller() and buyer(), continues an earlier payee.
- payment() : static
- Payment instructions (BG-16) with an optional credit transfer account (BG-17).
- paymentCard() : static
- Payment card (BG-18): the last 4 to 6 digits of the card number (BT-87) and the holder (BT-88). Without payment instructions it starts them with BankCard (48).
- paymentTerms() : static
- Payment terms (BT-20): a PaymentTerms object or a text replace earlier terms; a callable receives a PaymentTermsBuilder that continues the earlier terms, also those of a PaymentTerms object or of from(), like seller() and buyer().
- precedingInvoice() : static
- Adds a reference to a preceding invoice (BG-3): its number (BT-25) and issue date (BT-26), e.g. for a corrected invoice or a credit note.
- prepaid() : static
- Amount already paid (BT-113), e.g. received advance payments.
- presentation() : static
- Design of this invoice in PDF and HTML: a Presentation replaces it, an array changes single values (->presentation(['introText' => 'Thank you for your order.', 'showGrossPrices' => true])), a callable receives the current Presentation and returns the new one.
- projectReference() : static
- Project reference (BT-11) with the project name, which CII requires in addition to the identifier.
- purchaseOrderReference() : static
- The buyer's purchase order reference (BT-13); null removes it.
- receivingAdviceReference() : static
- Receiving advice reference (BT-15); null removes it.
- removeLine() : static
- Removes an existing line by its identifier (BT-126).
- rounding() : static
- Rounding amount (BT-114), e.g. cash rounding. Never use it to fix wrong totals.
- salesOrderReference() : static
- The seller's sales order reference (BT-14); null removes it.
- seller() : static
- The seller (BG-4).
- source() : static
- Origin of the data, e.g. "shop" (view model key meta.source).
- standard() : static
- Version of EN 16931 (BT-24 of the profile): 2017 (default) or 2026, which only the profile EN 16931 supports.
- taxCurrency() : static
- VAT accounting currency (BT-6). With an exchange rate, BT-111 is calculated.
- taxPointDate() : static
- Date when VAT becomes chargeable (BT-7), if it differs from the issue date. EN 16931 allows BT-7 or BT-8, not both (BR-CO-03).
- taxPointDateCode() : static
- Code of the date when VAT becomes chargeable (BT-8): issue, delivery or payment date.
- taxRepresentative() : static
- The seller's tax representative (BG-11): name (BT-62), VAT identifier (BT-63) and postal address (BG-12).
- tenderReference() : static
- Tender or lot reference (BT-17); null removes it.
- timezone() : static
- Time zone for DateTimeInterface values and for the default issue date; call it before the date setters.
- type() : static
- Type code (BT-3) from UNTDID 1001, e.g. 381 for a credit note; default 380. Unknown codes are kept as RawCode and reported by the validation.
- updateLine() : static
- Changes an existing line, e.g. of a correction draft started with {@see self::from()}: with the named values ->updateLine('2', netPrice: '80.00', quantity: 3), or with a callable that receives the InvoiceLine and returns the changed one, e.g.
- useDefaultVat() : void
- Application default VAT of lines that set none, for invoices without defaultVat(): a preset, or a callable that receives the seller's country code and whether the invoice is flagged as small business invoice (Meta::FLAG_SMALL_BUSINESS) and returns a preset or null, e.g. Quittio\Core\Tax\CountryDefaultVat. The Laravel integration sets it from quittio.defaults.vat; null removes it. Lines without VAT and without a default make build() fail (BG-30).
- xrechnungExtension() : static
- Data of the XRechnung extension (e.g. third party payments), written only with the profile xrechnung-extension.
Properties
$macros
protected
static array<string, callable>
$macros
= []
Methods
__call()
public
__call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
__construct()
public
final __construct() : mixed
addPrepaid()
Adds to the amount already paid (BT-113), e.g. one of several advance payments.
public
addPrepaid(BigDecimal|int|float|string $amount) : static
Parameters
- $amount : BigDecimal|int|float|string
Return values
staticallowance()
Document level allowance (BG-20) for one VAT category and rate.
public
allowance(VatCategory $category, BigDecimal|int|float|string|null $rate[, string|null $amount = null ][, string|null $percent = null ][, string|null $reason = null ][, AllowanceReasonCode|RawCode|string|null $reasonCode = null ][, string|null $baseAmount = null ][, string|null $exemptionReason = null ][, VatExemptionReasonCode|RawCode|string|null $exemptionReasonCode = null ]) : static
The exemption reason (BT-120/BT-121) is used for the VAT breakdown when no invoice line of the same VAT group provides one, e.g. an exempt charge on a standard rated invoice.
Parameters
- $category : VatCategory
- $rate : BigDecimal|int|float|string|null
- $amount : string|null = null
- $percent : string|null = null
- $reason : string|null = null
- $reasonCode : AllowanceReasonCode|RawCode|string|null = null
- $baseAmount : string|null = null
- $exemptionReason : string|null = null
- $exemptionReasonCode : VatExemptionReasonCode|RawCode|string|null = null
Return values
staticapplyDefaults()
Applies the defaults of a seller, e.g. the seller of config/quittio.php with its bank account and small business flag (Quittio::invoice()) or a Managed issuer. The builder remembers what they set: seller() with another seller removes it again.
public
applyDefaults(callable(static): mixed $apply) : static
Parameters
- $apply : callable(static): mixed
Return values
staticattachment()
Supporting document (BG-24), either embedded ($content) or as external link.
public
attachment(string $id[, string|null $content = null ][, MimeType|string|null $mimeType = null ][, string|null $filename = null ][, string|null $description = null ][, string|null $externalUri = null ]) : static
Parameters
- $id : string
- $content : string|null = null
- $mimeType : MimeType|string|null = null
- $filename : string|null = null
- $description : string|null = null
- $externalUri : string|null = null
Return values
staticbuild()
The invoice data, not calculated yet (the calculator or a render run adds the totals).
public
build() : InvoiceData
Tags
Return values
InvoiceDatabuildDraft()
Builds without requiring lines, e.g. for payment reminders or account statements, or for drafts. Data without lines can be calculated (its line sum is zero; document allowances and charges still count), but it is not a valid invoice: EN 16931 requires at least one line (BR-16), so validation reports it.
public
buildDraft() : InvoiceData
Return values
InvoiceDatabusinessProcess()
Business process identifier (BT-23); Peppol and XRechnung write their process when it is not set. null removes it.
public
businessProcess(string|null $process) : static
Parameters
- $process : string|null
Return values
staticbuyer()
The buyer (BG-7): a BuyerParty, a PartyBuilder (Party::make()) or an application model (ProvidesParty), e.g. ->buyer($customer), replace the buyer set before; a callable receives the builder of the buyer set before and changes it.
public
buyer(BuyerParty|PartyBuilder|ProvidesParty|callable(PartyBuilder): mixed $buyer) : static
Parameters
- $buyer : BuyerParty|PartyBuilder|ProvidesParty|callable(PartyBuilder): mixed
Return values
staticbuyerAccountingReference()
The buyer's accounting reference (BT-19), e.g. a cost centre; null removes it.
public
buyerAccountingReference(string|null $reference) : static
Parameters
- $reference : string|null
Return values
staticbuyerReference()
Buyer reference (BT-10). For public sector buyers in Germany this is the Leitweg-ID.
public
buyerReference(string|null $reference) : static
Parameters
- $reference : string|null
Return values
staticcashDiscount()
Cash discount ("Skonto") of $percent for payment within $days days after the issue date, optionally on a base amount; repeatable for several tiers. Continues the payment terms.
public
cashDiscount(int $days, string $percent[, string|null $baseAmount = null ]) : static
Parameters
- $days : int
- $percent : string
- $baseAmount : string|null = null
Return values
staticcharge()
Document level charge (BG-21) for one VAT category and rate. See allowance() for the exemption reason.
public
charge(VatCategory $category, BigDecimal|int|float|string|null $rate[, string|null $amount = null ][, string|null $percent = null ][, string|null $reason = null ][, ChargeReasonCode|RawCode|string|null $reasonCode = null ][, string|null $baseAmount = null ][, string|null $exemptionReason = null ][, VatExemptionReasonCode|RawCode|string|null $exemptionReasonCode = null ]) : static
Parameters
- $category : VatCategory
- $rate : BigDecimal|int|float|string|null
- $amount : string|null = null
- $percent : string|null = null
- $reason : string|null = null
- $reasonCode : ChargeReasonCode|RawCode|string|null = null
- $baseAmount : string|null = null
- $exemptionReason : string|null = null
- $exemptionReasonCode : VatExemptionReasonCode|RawCode|string|null = null
Return values
staticcontractReference()
Contract reference (BT-12); null removes it.
public
contractReference(string|null $reference) : static
Parameters
- $reference : string|null
Return values
staticcreditTransfer()
Adds a further bank account (BG-17).
public
creditTransfer(string $accountId[, string|null $bic = null ][, string|null $accountName = null ]) : static
Parameters
- $accountId : string
- $bic : string|null = null
- $accountName : string|null = null
Return values
staticcurrency()
Invoice currency (BT-5), ISO 4217; stored in upper case. Default EUR.
public
currency(string $currency) : static
Parameters
- $currency : string
Return values
staticcustom()
Free data for templates (view model key meta.custom); the same key replaces the value.
public
custom(string $key, mixed $value) : static
Parameters
- $key : string
- $value : mixed
Return values
staticdefaultVat()
VAT treatment of the lines that set none (also sub lines), with the arguments of LineBuilder::vat(). Without it, the application default of useDefaultVat() applies.
public
defaultVat(TaxPreset|VatCategory $presetOrCategory[, BigDecimal|int|float|string|null $rate = null ][, string|null $exemptionReason = null ][, VatExemptionReasonCode|RawCode|string|null $exemptionReasonCode = null ]) : static
Parameters
- $presetOrCategory : TaxPreset|VatCategory
- $rate : BigDecimal|int|float|string|null = null
- $exemptionReason : string|null = null
- $exemptionReasonCode : VatExemptionReasonCode|RawCode|string|null = null
Return values
staticdeliverTo()
Deliver-to party and address (BT-70, BG-15).
public
deliverTo(string|null $recipientName[, Address|null $address = null ][, Identifier|null $locationId = null ]) : static
Parameters
- $recipientName : string|null
- $address : Address|null = null
- $locationId : Identifier|null = null
Return values
staticdelivery()
Replaces the whole delivery information (BG-13), including the delivery date (BT-72).
public
delivery(Delivery $delivery) : static
Parameters
- $delivery : Delivery
Return values
staticdeliveryDate()
Actual delivery or service date (BT-72).
public
deliveryDate(Date|DateTimeInterface|string $date) : static
Parameters
- $date : Date|DateTimeInterface|string
Return values
staticdespatchAdviceReference()
Despatch advice reference (BT-16); null removes it.
public
despatchAdviceReference(string|null $reference) : static
Parameters
- $reference : string|null
Return values
staticdirectDebit()
SEPA direct debit (BG-19): mandate reference (BT-89), creditor identifier (BT-90) and the debited IBAN (BT-91, spaces removed). Without payment instructions it starts them with SepaDirectDebit (59).
public
directDebit(string|null $mandateReference[, string|null $creditorId = null ][, string|null $debitedIban = null ]) : static
Parameters
- $mandateReference : string|null
- $creditorId : string|null = null
- $debitedIban : string|null = null
Return values
staticdiscountAmount()
Absolute discount distributed over all VAT groups in proportion to their line totals.
public
discountAmount(BigDecimal|int|float|string $amount[, string|null $reason = null ][, AllowanceReasonCode|RawCode|string|null $reasonCode = AllowanceReasonCode::Discount ]) : static
Parameters
- $amount : BigDecimal|int|float|string
- $reason : string|null = null
- $reasonCode : AllowanceReasonCode|RawCode|string|null = AllowanceReasonCode::Discount
Return values
staticdiscountPercent()
Percentage discount on all lines. Split into one allowance per VAT group.
public
discountPercent(BigDecimal|int|float|string $percent[, string|null $reason = null ][, AllowanceReasonCode|RawCode|string|null $reasonCode = AllowanceReasonCode::Discount ]) : static
Parameters
- $percent : BigDecimal|int|float|string
- $reason : string|null = null
- $reasonCode : AllowanceReasonCode|RawCode|string|null = AllowanceReasonCode::Discount
Return values
staticdueDate()
Due date (BT-9). Without it the calculator derives it from dueInDays(); otherwise the configured due_days apply when rendering, never for credit notes.
public
dueDate(Date|DateTimeInterface|string $date) : static
Parameters
- $date : Date|DateTimeInterface|string
Return values
staticdueInDays()
Payment target: the due date (BT-9) is the issue date plus $days unless dueDate() is set, and the payment terms say "Payable within … days without deduction." Continues the payment terms set before.
public
dueInDays(int $days) : static
Parameters
- $days : int
Return values
staticexchangeRate()
Exchange rate from the invoice currency to the VAT accounting currency (BT-6), used to calculate the VAT total in that currency (BT-111), with the date of the rate. Replaces a rate implied by declared amounts (see from()).
public
exchangeRate(BigDecimal|int|float|string $rate[, Date|DateTimeInterface|string|null $date = null ]) : static
Parameters
- $rate : BigDecimal|int|float|string
- $date : Date|DateTimeInterface|string|null = null
Tags
Return values
staticextended()
Data of the profile EXTENDED of ZUGFeRD/Factur-X (further parties, delivery terms, instalments …); other profiles do not write it.
public
extended(ExtendedData $extended) : static
Parameters
- $extended : ExtendedData
Return values
staticflag()
Sets a flag that country packs evaluate (e.g. a small amount invoice in Germany).
public
flag(string $flag[, bool $enabled = true ]) : static
Parameters
- $flag : string
- $enabled : bool = true
Return values
staticflushMacros()
public
static flushMacros() : void
from()
Starts a builder from existing data, e.g. to change a draft.
public
static from(InvoiceData $data) : static
For data with a declared VAT total in accounting currency (BT-111) but without exchange rate (e.g. read from XML) the implied rate is taken over, so that BT-111 is recalculated. Once lines, allowances, charges or the VAT accounting currency (BT-6) change, the implied rate is dropped: it is only as precise as the declared amounts and holds only for the declared currency, so set the rate with exchangeRate() (BR-53 otherwise). Percentage document allowances and charges on the line sum of their VAT group, and discounts split over the VAT groups (discountAmount(), discountPercent()), follow the lines when lines are added, changed or removed.
As long as nothing amount-relevant changes, declared line net amounts and the VAT breakdown that the recalculation does not reproduce (e.g. rounded per line by another system) are kept by the calculator (Meta::FLAG_DECLARED_AMOUNTS with a fingerprint of the amount inputs). Data flagged earlier whose amount inputs no longer match its fingerprint (e.g. changed with with() or in stored JSON) is treated as changed lines and recalculated.
The declared amounts are compared with the result of the default En16931Calculator; use fromUsing() or Quittio::edit() to compare with another calculator.
Parameters
- $data : InvoiceData
Return values
staticfromDocument()
Starts an invoice from a quote, order confirmation, delivery note or proforma invoice: parties, billable lines, document allowances and charges and payment data are taken over; number and issue date must be set.
public
static fromDocument(DocumentData $document) : static
Parameters
- $document : DocumentData
Return values
staticfromUsing()
Like from(), with the calculator that decides whether the declared amounts of the data differ from a recalculation, e.g. the calculator of the Quittio instance.
public
static fromUsing(InvoiceData $data, TotalsCalculator $calculator) : static
Parameters
- $data : InvoiceData
- $calculator : TotalsCalculator
Return values
staticgroup()
Defines a line group for the PDF. Lines join it via LineBuilder::group().
public
group(string $id, string $title[, bool $showSubtotal = true ]) : static
Parameters
- $id : string
- $title : string
- $showSubtotal : bool = true
Return values
statichasMacro()
public
static hasMacro(string $name) : bool
Parameters
- $name : string
Return values
boolinvoicedObject()
Identifier of the invoiced object (BT-18), e.g. a meter or subscription number, with its scheme (BT-18-1).
public
invoicedObject(string $value[, string|RawCode|null $scheme = null ]) : static
Parameters
- $value : string
- $scheme : string|RawCode|null = null
Return values
staticinvoicingPeriod()
Invoicing period (BG-14).
public
invoicingPeriod(Date|string|null $start[, Date|string|null $end = null ]) : static
Parameters
Return values
staticissueDate()
Issue date (BT-2); default today. A DateTimeInterface is converted in the time zone of timezone(), so call timezone() first.
public
issueDate(Date|DateTimeInterface|string $date) : static
Parameters
- $date : Date|DateTimeInterface|string
Return values
staticlateFee()
Late payment terms: days, percentage and text. Continues the payment terms.
public
lateFee([int|null $days = null ][, string|null $percent = null ][, string|null $text = null ]) : static
Parameters
- $days : int|null = null
- $percent : string|null = null
- $text : string|null = null
Return values
staticline()
Adds a line (BG-25): a name with the common values (->line('Consulting', netPrice: '120.00', quantity: 4, unit: UnitCode::Hour)), a LineBuilder (Line::make()), an array with the keys of LineBuilder::ARRAY_KEYS, an application model (ProvidesInvoiceLine), a callable that receives a new LineBuilder, or a finished InvoiceLine.
public
line(InvoiceLine|LineBuilder|ProvidesInvoiceLine|array<string|int, mixed>|callable(LineBuilder): mixed|string $line[, BigDecimal|int|float|string|null $netPrice = null ][, BigDecimal|int|float|string|null $quantity = null ][, UnitCode|RawCode|string|null $unit = null ][, TaxPreset|VatCategory|null $vat = null ][, string|null $description = null ][, BigDecimal|int|float|string|null $priceInclVat = null ]) : static
Parameters
- $line : InvoiceLine|LineBuilder|ProvidesInvoiceLine|array<string|int, mixed>|callable(LineBuilder): mixed|string
- $netPrice : BigDecimal|int|float|string|null = null
- $quantity : BigDecimal|int|float|string|null = null
- $unit : UnitCode|RawCode|string|null = null
- $vat : TaxPreset|VatCategory|null = null
- $description : string|null = null
- $priceInclVat : BigDecimal|int|float|string|null = null
Return values
staticlines()
public
lines(iterable<string|int, InvoiceLine|LineBuilder|ProvidesInvoiceLine|array<string|int, mixed>|callable(LineBuilder): mixed|string> $lines) : static
Parameters
- $lines : iterable<string|int, InvoiceLine|LineBuilder|ProvidesInvoiceLine|array<string|int, mixed>|callable(LineBuilder): mixed|string>
Return values
staticlocale()
Language of the invoice: labels, generated texts and the exemption texts of presets.
public
locale(string $locale) : static
The locale of a render call wins; without both, the configured locale or the country default.
Parameters
- $locale : string
Return values
staticmacro()
public
static macro(string $name, callable $macro) : void
Parameters
- $name : string
- $macro : callable
Tags
make()
A new, empty builder; type code 380 and the issue date today unless set.
public
static make() : static
Return values
staticnote()
Adds an invoice note (BG-1): the text (BT-22) and an optional subject code (BT-21, UNTDID 4451, e.g. "REG" for regulatory information). Unknown codes are kept as RawCode.
public
note(string $content[, NoteSubjectCode|RawCode|string|null $subject = null ]) : static
Parameters
- $content : string
- $subject : NoteSubjectCode|RawCode|string|null = null
Return values
staticnumber()
Invoice number (BT-1). Not checked here; the validation requires it.
public
number(string $number) : static
Parameters
- $number : string
Return values
staticpayee()
Payee (BG-10), if different from the seller (e.g. a factoring company): the name with the identifier (BT-60) and the legal registration identifier (BT-61) and their schemes, a PartyBuilder (Party::make('Factoring AG')->identifier(…)), a PayeeParty, or a callable that receives a PartyBuilder and, like seller() and buyer(), continues an earlier payee.
public
payee(PayeeParty|PartyBuilder|string|callable(PartyBuilder): mixed $payee[, string|null $identifier = null ][, string|null $legalRegistration = null ][, IdentifierScheme|RawCode|string|null $identifierScheme = null ][, IdentifierScheme|RawCode|string|null $legalRegistrationScheme = null ]) : static
Parameters
- $payee : PayeeParty|PartyBuilder|string|callable(PartyBuilder): mixed
- $identifier : string|null = null
- $legalRegistration : string|null = null
- $identifierScheme : IdentifierScheme|RawCode|string|null = null
- $legalRegistrationScheme : IdentifierScheme|RawCode|string|null = null
Tags
Return values
staticpayment()
Payment instructions (BG-16) with an optional credit transfer account (BG-17).
public
payment(PaymentMeansCode|RawCode|string $means[, string|null $iban = null ][, string|null $bic = null ][, string|null $accountName = null ][, string|null $remittanceInformation = null ][, string|null $meansText = null ]) : static
A second call replaces the payment instructions: an account given here replaces the accounts, and data of other payment means is dropped (e.g. bank accounts when switching to direct debit). Without an account, existing accounts are kept for credit transfers (e.g. a seller default account); likewise card (BG-18) and direct debit (BG-19) data for card payments and direct debits. The remittance information (BT-83) is kept unless a new one is given. Further accounts are added with creditTransfer().
Parameters
- $means : PaymentMeansCode|RawCode|string
- $iban : string|null = null
- $bic : string|null = null
- $accountName : string|null = null
- $remittanceInformation : string|null = null
- $meansText : string|null = null
Return values
staticpaymentCard()
Payment card (BG-18): the last 4 to 6 digits of the card number (BT-87) and the holder (BT-88). Without payment instructions it starts them with BankCard (48).
public
paymentCard(string $lastDigits[, string|null $holderName = null ]) : static
Parameters
- $lastDigits : string
- $holderName : string|null = null
Tags
Return values
staticpaymentTerms()
Payment terms (BT-20): a PaymentTerms object or a text replace earlier terms; a callable receives a PaymentTermsBuilder that continues the earlier terms, also those of a PaymentTerms object or of from(), like seller() and buyer().
public
paymentTerms(PaymentTerms|string|callable(PaymentTermsBuilder): mixed $terms) : static
Parameters
- $terms : PaymentTerms|string|callable(PaymentTermsBuilder): mixed
Return values
staticprecedingInvoice()
Adds a reference to a preceding invoice (BG-3): its number (BT-25) and issue date (BT-26), e.g. for a corrected invoice or a credit note.
public
precedingInvoice(string $number[, Date|DateTimeInterface|string|null $issueDate = null ]) : static
Parameters
- $number : string
- $issueDate : Date|DateTimeInterface|string|null = null
Return values
staticprepaid()
Amount already paid (BT-113), e.g. received advance payments.
public
prepaid(BigDecimal|int|float|string $amount) : static
Parameters
- $amount : BigDecimal|int|float|string
Return values
staticpresentation()
Design of this invoice in PDF and HTML: a Presentation replaces it, an array changes single values (->presentation(['introText' => 'Thank you for your order.', 'showGrossPrices' => true])), a callable receives the current Presentation and returns the new one.
public
presentation(Presentation|array<string, mixed>|callable(Presentation): Presentation $presentation) : static
Parameters
- $presentation : Presentation|array<string, mixed>|callable(Presentation): Presentation
Return values
staticprojectReference()
Project reference (BT-11) with the project name, which CII requires in addition to the identifier.
public
projectReference(string $id[, string|null $name = null ]) : static
Parameters
- $id : string
- $name : string|null = null
Return values
staticpurchaseOrderReference()
The buyer's purchase order reference (BT-13); null removes it.
public
purchaseOrderReference(string|null $reference) : static
Parameters
- $reference : string|null
Return values
staticreceivingAdviceReference()
Receiving advice reference (BT-15); null removes it.
public
receivingAdviceReference(string|null $reference) : static
Parameters
- $reference : string|null
Return values
staticremoveLine()
Removes an existing line by its identifier (BT-126).
public
removeLine(string $id) : static
Parameters
- $id : string
Return values
staticrounding()
Rounding amount (BT-114), e.g. cash rounding. Never use it to fix wrong totals.
public
rounding(BigDecimal|int|float|string $amount) : static
Parameters
- $amount : BigDecimal|int|float|string
Return values
staticsalesOrderReference()
The seller's sales order reference (BT-14); null removes it.
public
salesOrderReference(string|null $reference) : static
Parameters
- $reference : string|null
Return values
staticseller()
The seller (BG-4).
public
seller(SellerParty|PartyBuilder|ProvidesParty|callable(PartyBuilder): mixed $seller) : static
A SellerParty, a PartyBuilder (Party::make()) or an application model (ProvidesParty) replaces the seller set before. If the builder was started with the defaults of a seller (applyDefaults(), e.g. Quittio::invoice() with the seller of config/quittio.php or the current Managed issuer), another seller gets nothing of them: everything they set is removed again, i.e. the bank account and the small business flag, for a Managed issuer also payment terms, presentation, locale, time zone and currency. Values the caller set on the builder stay, also when they were set before seller().
A callable receives the builder of the seller set before and changes it, e.g. ->seller(fn ($s) => $s->contact('Max Muster')); the seller stays the same, and so do its defaults.
Parameters
- $seller : SellerParty|PartyBuilder|ProvidesParty|callable(PartyBuilder): mixed
Return values
staticsource()
Origin of the data, e.g. "shop" (view model key meta.source).
public
source(string $source) : static
Parameters
- $source : string
Return values
staticstandard()
Version of EN 16931 (BT-24 of the profile): 2017 (default) or 2026, which only the profile EN 16931 supports.
public
standard(StandardVersion $version) : static
Parameters
- $version : StandardVersion
Return values
statictaxCurrency()
VAT accounting currency (BT-6). With an exchange rate, BT-111 is calculated.
public
taxCurrency(string $currency[, BigDecimal|int|float|string|null $exchangeRate = null ][, Date|DateTimeInterface|string|null $rateDate = null ]) : static
Parameters
- $currency : string
- $exchangeRate : BigDecimal|int|float|string|null = null
- $rateDate : Date|DateTimeInterface|string|null = null
Return values
statictaxPointDate()
Date when VAT becomes chargeable (BT-7), if it differs from the issue date. EN 16931 allows BT-7 or BT-8, not both (BR-CO-03).
public
taxPointDate(Date|DateTimeInterface|string $date) : static
Parameters
- $date : Date|DateTimeInterface|string
Return values
statictaxPointDateCode()
Code of the date when VAT becomes chargeable (BT-8): issue, delivery or payment date.
public
taxPointDateCode(TaxPointDateCode $code) : static
EN 16931 allows BT-7 or BT-8, not both (BR-CO-03).
Parameters
- $code : TaxPointDateCode
Return values
statictaxRepresentative()
The seller's tax representative (BG-11): name (BT-62), VAT identifier (BT-63) and postal address (BG-12).
public
taxRepresentative(string $name, string $vatId, Address $address) : static
Parameters
- $name : string
- $vatId : string
- $address : Address
Return values
statictenderReference()
Tender or lot reference (BT-17); null removes it.
public
tenderReference(string|null $reference) : static
Parameters
- $reference : string|null
Return values
statictimezone()
Time zone for DateTimeInterface values and for the default issue date; call it before the date setters.
public
timezone(string $timezone) : static
Parameters
- $timezone : string
Return values
statictype()
Type code (BT-3) from UNTDID 1001, e.g. 381 for a credit note; default 380. Unknown codes are kept as RawCode and reported by the validation.
public
type(InvoiceTypeCode|RawCode|string $type) : static
Parameters
- $type : InvoiceTypeCode|RawCode|string
Return values
staticupdateLine()
Changes an existing line, e.g. of a correction draft started with {@see self::from()}: with the named values ->updateLine('2', netPrice: '80.00', quantity: 3), or with a callable that receives the InvoiceLine and returns the changed one, e.g.
public
updateLine(string $id[, callable(InvoiceLine): InvoiceLine|null $change = null ][, BigDecimal|int|float|string|null $netPrice = null ][, BigDecimal|int|float|string|null $quantity = null ][, BigDecimal|int|float|string|null $priceInclVat = null ][, string|null $name = null ][, string|null $description = null ]) : static
->updateLine('2', fn (InvoiceLine $l) => $l->with(['note' => 'Delivered in two parts'])). The calculated line net amount is reset, and percentage allowances and charges on the line amount are recalculated from the new amount.
Parameters
- $id : string
- $change : callable(InvoiceLine): InvoiceLine|null = null
- $netPrice : BigDecimal|int|float|string|null = null
- $quantity : BigDecimal|int|float|string|null = null
- $priceInclVat : BigDecimal|int|float|string|null = null
- $name : string|null = null
- $description : string|null = null
Return values
staticuseDefaultVat()
Application default VAT of lines that set none, for invoices without defaultVat(): a preset, or a callable that receives the seller's country code and whether the invoice is flagged as small business invoice (Meta::FLAG_SMALL_BUSINESS) and returns a preset or null, e.g. Quittio\Core\Tax\CountryDefaultVat. The Laravel integration sets it from quittio.defaults.vat; null removes it. Lines without VAT and without a default make build() fail (BG-30).
public
static useDefaultVat(callable(Array, bool): Array|TaxPreset|null $default) : void
Parameters
- $default : callable(Array, bool): Array|TaxPreset|null
xrechnungExtension()
Data of the XRechnung extension (e.g. third party payments), written only with the profile xrechnung-extension.
public
xrechnungExtension(XRechnungExtensionData $extension) : static
Parameters
- $extension : XRechnungExtensionData