Zum Inhalt springen

API reference / Quittio \ Core \ Testing

InvoiceFactory

final class in quittio/core

Quittio\Core\Testing\InvoiceFactory · Source

Test data factory: InvoiceData::factory()->reverseCharge()->withLines(5)->make().

Deterministic (no random values), so that snapshots stay stable.

Methods#

MethodDescription
->b2c()Makes the buyer a German consumer without a buyer reference (BT-10). Takes precedence over the buyer of reverseCharge(), intraCommunity() and export(). Returns a copy.
->builder()Returns a new InvoiceBuilder with all chosen states applied, the state() callbacks last, for further changes before build().
->calculated()Invoice data with totals and VAT breakdown, calculated with $calculator (default: En16931Calculator).
->creditNote()Makes a credit note (type 381) that refers to the preceding invoice RE-2026-0001 of 2026-09-01 (BG-3). Returns a copy.
->currency()Sets the invoice currency (BT-5). For any currency other than EUR the invoice also gets EUR as VAT accounting currency (BT-6) at rate 0.9 and a plain credit transfer as payment means. Returns a copy.
->export()Makes an export invoice (category G, VATEX-EU-G) to a US company without a VAT ID. Returns a copy.
->intraCommunity()Makes an intra-community supply (category K, VATEX-EU-IC) to an Italian company with a VAT ID. Returns a copy.
->make()Uncalculated invoice data.
::new()Starts a factory for an invoice on the Scenarios::base() data: German seller and buyer, EUR, one line at 19 % standard rate. Same as InvoiceData::factory().
->number()Sets the invoice number (BT-1) instead of the base number "RE-2026-0042". Returns a copy.
->reverseCharge()Makes a reverse charge invoice (category AE, VATEX-EU-AE) to a French company with a VAT ID. Returns a copy.
->state()Free modification of the builder.
->withLines()Uses $count lines (at least 1): line n is "Item n", n pieces at n × 10.00 net. Returns a copy.

b2c()#

public function b2c(): self

Makes the buyer a German consumer without a buyer reference (BT-10). Takes precedence over the buyer of reverseCharge(), intraCommunity() and export(). Returns a copy.

Returns
self

builder()#

public function builder(): InvoiceBuilder

Returns a new InvoiceBuilder with all chosen states applied, the state() callbacks last, for further changes before build().

Returns
InvoiceBuilder

calculated()#

public function calculated(?TotalsCalculator $calculator = null): InvoiceData

Invoice data with totals and VAT breakdown, calculated with $calculator (default: En16931Calculator).

ParameterTypeDescription
$calculator?TotalsCalculator = null
Returns
InvoiceData

creditNote()#

public function creditNote(): self

Makes a credit note (type 381) that refers to the preceding invoice RE-2026-0001 of 2026-09-01 (BG-3). Returns a copy.

Returns
self

currency()#

public function currency(string $currency): self

Sets the invoice currency (BT-5). For any currency other than EUR the invoice also gets EUR as VAT accounting currency (BT-6) at rate 0.9 and a plain credit transfer as payment means. Returns a copy.

ParameterTypeDescription
$currencystring
Returns
self

export()#

public function export(): self

Makes an export invoice (category G, VATEX-EU-G) to a US company without a VAT ID. Returns a copy.

Returns
self

intraCommunity()#

public function intraCommunity(): self

Makes an intra-community supply (category K, VATEX-EU-IC) to an Italian company with a VAT ID. Returns a copy.

Returns
self

make()#

public function make(): InvoiceData

Uncalculated invoice data.

Returns
InvoiceData

new()#

public static function new(): self

static

Starts a factory for an invoice on the Scenarios::base() data: German seller and buyer, EUR, one line at 19 % standard rate. Same as InvoiceData::factory().

Returns
self

number()#

public function number(string $number): self

Sets the invoice number (BT-1) instead of the base number "RE-2026-0042". Returns a copy.

ParameterTypeDescription
$numberstring
Returns
self

reverseCharge()#

public function reverseCharge(): self

Makes a reverse charge invoice (category AE, VATEX-EU-AE) to a French company with a VAT ID. Returns a copy.

Returns
self

state()#

public function state(callable $state): self

Free modification of the builder.

ParameterTypeDescription
$statecallable
Returns
self

withLines()#

public function withLines(int $count): self

Uses $count lines (at least 1): line n is "Item n", n pieces at n × 10.00 net. Returns a copy.

ParameterTypeDescription
$countint
Returns
self

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