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#
| Method | Description |
|---|---|
->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(): selfMakes 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(): InvoiceBuilderReturns 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): InvoiceDataInvoice data with totals and VAT breakdown, calculated with $calculator (default: En16931Calculator).
| Parameter | Type | Description |
|---|---|---|
$calculator | ?TotalsCalculator = null |
- Returns
InvoiceData
creditNote()#
public function creditNote(): selfMakes 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): selfSets 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.
| Parameter | Type | Description |
|---|---|---|
$currency | string |
- Returns
self
export()#
public function export(): selfMakes 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(): selfMakes 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(): InvoiceDataUncalculated invoice data.
- Returns
InvoiceData
new()#
public static function new(): selfStarts 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): selfSets the invoice number (BT-1) instead of the base number "RE-2026-0042". Returns a copy.
| Parameter | Type | Description |
|---|---|---|
$number | string |
- Returns
self
reverseCharge()#
public function reverseCharge(): selfMakes 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): selfFree modification of the builder.
| Parameter | Type | Description |
|---|---|---|
$state | callable |
- Returns
self
withLines()#
public function withLines(int $count): selfUses $count lines (at least 1): line n is "Item n", n pieces at n × 10.00 net. Returns a copy.
| Parameter | Type | Description |
|---|---|---|
$count | int |
- Returns
self