API reference / Quittio \ Core \ Builder \ Concerns
BuildsLines
trait in quittio/core
Quittio\Core\Builder\Concerns\BuildsLines · Source
Invoice lines (BG-25) and their groups.
Part of InvoiceBuilder, which holds the state; use the builder, not the trait.
Methods#
| Method | Description |
|---|---|
->group() | Defines a line group for the PDF. Lines join it via LineBuilder::group(). |
->line() | 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() | |
->removeLine() | Removes an existing line by its identifier (BT-126). |
->updateLine() | 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. ->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. |
group()#
public function group(string $id, string $title, bool $showSubtotal = true): staticDefines a line group for the PDF. Lines join it via LineBuilder::group().
| Parameter | Type | Description |
|---|---|---|
$id | string | |
$title | string | |
$showSubtotal | bool = true |
- Returns
static
line()#
public function line(
InvoiceLine|LineBuilder|ProvidesInvoiceLine|array|callable|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 $description = null,
BigDecimal|int|float|string|null $priceInclVat = null,
): staticAdds 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.
| Parameter | Type | Description |
|---|---|---|
$line | InvoiceLine|LineBuilder|ProvidesInvoiceLine|array|callable|string | |
$netPrice | Brick\Math\BigDecimal|int|float|string|null = null | |
$quantity | Brick\Math\BigDecimal|int|float|string|null = null | |
$unit | UnitCode|RawCode|string|null = null | |
$vat | TaxPreset|VatCategory|null = null | |
$description | ?string = null | |
$priceInclVat | Brick\Math\BigDecimal|int|float|string|null = null |
- Returns
static
lines()#
public function lines(
iterable<InvoiceLine|LineBuilder|ProvidesInvoiceLine|array<array-key, mixed>|callable(LineBuilder): mixed|string> $lines,
): static| Parameter | Type | Description |
|---|---|---|
$lines | iterable<InvoiceLine|LineBuilder|ProvidesInvoiceLine|array<array-key, mixed>|callable(LineBuilder): mixed|string> |
- Returns
static
removeLine()#
public function removeLine(string $id): staticRemoves an existing line by its identifier (BT-126).
| Parameter | Type | Description |
|---|---|---|
$id | string |
- Returns
static
updateLine()#
public function 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 $name = null,
?string $description = null,
): staticChanges 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. ->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.
| Parameter | Type | Description |
|---|---|---|
$id | string | |
$change | (callable(InvoiceLine): InvoiceLine)|null = null | |
$netPrice | Brick\Math\BigDecimal|int|float|string|null = null | |
$quantity | Brick\Math\BigDecimal|int|float|string|null = null | |
$priceInclVat | Brick\Math\BigDecimal|int|float|string|null = null | |
$name | ?string = null | |
$description | ?string = null |
- Returns
static