Skip to content

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#

MethodDescription
->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): static

Defines a line group for the PDF. Lines join it via LineBuilder::group().

ParameterTypeDescription
$idstring
$titlestring
$showSubtotalbool = 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,
): 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.

ParameterTypeDescription
$lineInvoiceLine|LineBuilder|ProvidesInvoiceLine|array|callable|string
$netPriceBrick\Math\BigDecimal|int|float|string|null = null
$quantityBrick\Math\BigDecimal|int|float|string|null = null
$unitUnitCode|RawCode|string|null = null
$vatTaxPreset|VatCategory|null = null
$description?string = null
$priceInclVatBrick\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
ParameterTypeDescription
$linesiterable<InvoiceLine|LineBuilder|ProvidesInvoiceLine|array<array-key, mixed>|callable(LineBuilder): mixed|string>
Returns
static

removeLine()#

public function removeLine(string $id): static

Removes an existing line by its identifier (BT-126).

ParameterTypeDescription
$idstring
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,
): 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. ->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.

ParameterTypeDescription
$idstring
$change(callable(InvoiceLine): InvoiceLine)|null = null
$netPriceBrick\Math\BigDecimal|int|float|string|null = null
$quantityBrick\Math\BigDecimal|int|float|string|null = null
$priceInclVatBrick\Math\BigDecimal|int|float|string|null = null
$name?string = null
$description?string = null
Returns
static

The open core packages are MIT licensed. The legal wording of the country packs must be confirmed by a tax adviser.