Quittio 0.3 API

LineBuilder
in package
uses Macroable

FinalYes

Fluent builder for an invoice line (BG-25).

Table of Contents

Constants

ARRAY_KEYS  : array<string|int, mixed> = ['id', 'name', 'description', 'note', 'quantity...
Keys of a line given as array (InvoiceBuilder::line(), Line::fromArray()): the methods of this builder that can be called with the value.

Properties

$macros  : array<string, callable>

Methods

__call()  : mixed
allowance()  : self
Adds a line allowance (BG-27): an amount (BT-136), or a percentage (BT-138) of the base amount (BT-137, default quantity × net price), with reason (BT-139) and reason code (BT-140).
attribute()  : self
Adds an item attribute (BG-32): name (BT-160) and value (BT-161).
build()  : InvoiceLine
Builds the line; called by InvoiceBuilder. $vatDefault is a builder whose VAT treatment applies to this line and its sub lines when they have none (InvoiceBuilder::defaultVat()).
buyerAccountingReference()  : self
The buyer's accounting reference of the line (BT-133); null removes it.
buyerId()  : self
The buyer's item number (BT-156); null removes it.
charge()  : self
Adds a line charge (BG-28): an amount (BT-141), or a percentage (BT-143) of the base amount (BT-142, default quantity × net price), with reason (BT-144) and reason code (BT-145).
classification()  : self
Adds an item classification (BT-158) with list identifier (BT-158-1) and version (BT-158-2).
description()  : self
Item description (BT-154); null removes it.
explicitId()  : string|null
Identifier set with id(); null when the invoice builder assigns one.
extended()  : self
Line data of the profile EXTENDED; other profiles do not write it.
fill()  : self
Calls the method of every key with its value: ['name' => 'Consulting', 'quantity' => 4, 'netPrice' => '120.00']. An array value holds the arguments, as list or by name (['quantity' => [4, UnitCode::Hour]], ['allowance' => ['percent' => '10', 'reason' => 'Early bird']]); null values are skipped.
flushMacros()  : void
fromModel()  : self
Lets an application model fill this line (ProvidesInvoiceLine::fillLine()).
group()  : self
Assigns the line to a presentation group of the PDF (see InvoiceBuilder::group()).
hasMacro()  : bool
hasPrice()  : bool
Whether a net price, list price or price including VAT was set.
hasVat()  : bool
Whether vat() was called.
highlight()  : self
Highlights the line in the PDF and HTML (the default templates shade it and mark it in the secondary colour).
id()  : self
Line identifier (BT-126); default the position, "1", "2", …
lacksVat()  : bool
Whether the line or one of its sub lines has no VAT treatment yet.
listPrice()  : self
List price before price discount (BT-148) and the discount per unit (BT-147).
macro()  : void
name()  : self
Item name (BT-153). Required.
netPrice()  : self
Net price per base quantity (BT-146, BT-149, BT-150).
note()  : self
Line note (BT-127); null removes it.
objectId()  : self
Invoiced object identifier of the line (BT-128) with its scheme.
orderLineReference()  : self
Line of the purchase order (BT-132); null removes it.
originCountry()  : self
Country of origin of the item (BT-159), ISO 3166-1 alpha-2, uppercased; null removes it.
period()  : self
Line period (BG-26): start (BT-134) and end (BT-135); one of them may be null.
priceInclVat()  : self
Price including VAT (gross price mode for B2C and shops).
quantity()  : self
Invoiced quantity (BT-129), optionally with the unit (BT-130); default 1. Negative quantities for returns and discounts.
reference()  : self
Adds a reference to an order, contract, despatch or receiving advice or another document (profile EXTENDED only).
sellerId()  : self
The seller's item number (BT-155); null removes it.
showGrossPrice()  : self
Prints the price including VAT below the net unit price of this line (true) or not (false), whatever Presentation::$showGrossPrices says for the invoice; null follows the presentation again. It is printed only for lines with a price including VAT (priceInclVat()).
standardId()  : self
Standard item identifier (BT-157) with its scheme (BT-157-1); default scheme GTIN (0160).
subLine()  : self
Adds a sub line (profile EXTENDED or XRechnung extension), in the forms of InvoiceBuilder::line(): a name with the common values, Line::make(), an array, a model or a callable.
unit()  : self
Unit of the quantity (BT-130), UN/ECE Recommendation 20/21; default C62 (one). Unknown codes are kept as RawCode.
vat()  : self
Sets the VAT treatment, either via a preset of a country pack or as category and rate.

Constants

ARRAY_KEYS

Keys of a line given as array (InvoiceBuilder::line(), Line::fromArray()): the methods of this builder that can be called with the value.

public array<string|int, mixed> ARRAY_KEYS = ['id', 'name', 'description', 'note', 'quantity', 'unit', 'netPrice', 'listPrice', 'priceInclVat', 'vat', 'period', 'allowance', 'charge', 'sellerId', 'buyerId', 'standardId', 'classification', 'originCountry', 'attribute', 'orderLineReference', 'buyerAccountingReference', 'objectId', 'group', 'highlight', 'showGrossPrice']

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>

allowance()

Adds a line allowance (BG-27): an amount (BT-136), or a percentage (BT-138) of the base amount (BT-137, default quantity × net price), with reason (BT-139) and reason code (BT-140).

public allowance([string|null $amount = null ][, string|null $percent = null ][, string|null $reason = null ][, AllowanceReasonCode|RawCode|string|null $reasonCode = null ][, string|null $baseAmount = null ]) : self
Parameters
$amount : string|null = null
$percent : string|null = null
$reason : string|null = null
$reasonCode : AllowanceReasonCode|RawCode|string|null = null
$baseAmount : string|null = null
Return values
self

attribute()

Adds an item attribute (BG-32): name (BT-160) and value (BT-161).

public attribute(string $name, string $value) : self
Parameters
$name : string
$value : string
Return values
self

build()

Builds the line; called by InvoiceBuilder. $vatDefault is a builder whose VAT treatment applies to this line and its sub lines when they have none (InvoiceBuilder::defaultVat()).

public build(string $currency, string $defaultId[, string|null $locale = null ][, self|null $vatDefault = null ][, Date|null $supplyDate = null ]) : InvoiceLine

$supplyDate is the supply date of the document (SupplyDate); a line period wins. It resolves presets whose rate depends on the date (DatedTaxPreset).

Parameters
$currency : string
$defaultId : string
$locale : string|null = null
$vatDefault : self|null = null
$supplyDate : Date|null = null
Return values
InvoiceLine

buyerAccountingReference()

The buyer's accounting reference of the line (BT-133); null removes it.

public buyerAccountingReference(string|null $reference) : self
Parameters
$reference : string|null
Return values
self

buyerId()

The buyer's item number (BT-156); null removes it.

public buyerId(string|null $id) : self
Parameters
$id : string|null
Return values
self

charge()

Adds a line charge (BG-28): an amount (BT-141), or a percentage (BT-143) of the base amount (BT-142, default quantity × net price), with reason (BT-144) and reason code (BT-145).

public charge([string|null $amount = null ][, string|null $percent = null ][, string|null $reason = null ][, ChargeReasonCode|RawCode|string|null $reasonCode = null ][, string|null $baseAmount = null ]) : self
Parameters
$amount : string|null = null
$percent : string|null = null
$reason : string|null = null
$reasonCode : ChargeReasonCode|RawCode|string|null = null
$baseAmount : string|null = null
Return values
self

classification()

Adds an item classification (BT-158) with list identifier (BT-158-1) and version (BT-158-2).

public classification(string $code, ItemClassificationScheme|RawCode|string $scheme[, string|null $version = null ]) : self
Parameters
$code : string
$scheme : ItemClassificationScheme|RawCode|string
$version : string|null = null
Return values
self

description()

Item description (BT-154); null removes it.

public description(string|null $description) : self
Parameters
$description : string|null
Return values
self

explicitId()

Identifier set with id(); null when the invoice builder assigns one.

public explicitId() : string|null
Return values
string|null

fill()

Calls the method of every key with its value: ['name' => 'Consulting', 'quantity' => 4, 'netPrice' => '120.00']. An array value holds the arguments, as list or by name (['quantity' => [4, UnitCode::Hour]], ['allowance' => ['percent' => '10', 'reason' => 'Early bird']]); null values are skipped.

public fill(array<string|int, mixed> $values) : self
Parameters
$values : array<string|int, mixed>
Return values
self

flushMacros()

public static flushMacros() : void

group()

Assigns the line to a presentation group of the PDF (see InvoiceBuilder::group()).

public group(string $groupId) : self
Parameters
$groupId : string
Return values
self

hasMacro()

public static hasMacro(string $name) : bool
Parameters
$name : string
Return values
bool

hasPrice()

Whether a net price, list price or price including VAT was set.

public hasPrice() : bool
Return values
bool

hasVat()

Whether vat() was called.

public hasVat() : bool
Return values
bool

highlight()

Highlights the line in the PDF and HTML (the default templates shade it and mark it in the secondary colour).

public highlight([bool $highlight = true ]) : self
Parameters
$highlight : bool = true
Return values
self

id()

Line identifier (BT-126); default the position, "1", "2", …

public id(string $id) : self
Parameters
$id : string
Return values
self

lacksVat()

Whether the line or one of its sub lines has no VAT treatment yet.

public lacksVat() : bool
Return values
bool

listPrice()

List price before price discount (BT-148) and the discount per unit (BT-147).

public listPrice(BigDecimal|int|float|string $grossPrice[, BigDecimal|int|float|string|null $discount = null ]) : self

The net price is derived as list price minus discount unless set explicitly.

Parameters
$grossPrice : BigDecimal|int|float|string
$discount : BigDecimal|int|float|string|null = null
Return values
self

macro()

public static macro(string $name, callable $macro) : void
Parameters
$name : string
$macro : callable
Tags
param-closure-this

static $macro

name()

Item name (BT-153). Required.

public name(string $name) : self
Parameters
$name : string
Return values
self

netPrice()

Net price per base quantity (BT-146, BT-149, BT-150).

public netPrice(BigDecimal|int|float|string $price[, BigDecimal|int|float|string|null $baseQuantity = null ][, UnitCode|RawCode|string|null $baseQuantityUnit = null ]) : self
Parameters
$price : BigDecimal|int|float|string
$baseQuantity : BigDecimal|int|float|string|null = null
$baseQuantityUnit : UnitCode|RawCode|string|null = null
Return values
self

note()

Line note (BT-127); null removes it.

public note(string|null $note) : self
Parameters
$note : string|null
Return values
self

objectId()

Invoiced object identifier of the line (BT-128) with its scheme.

public objectId(string $value[, string|RawCode|null $scheme = null ]) : self
Parameters
$value : string
$scheme : string|RawCode|null = null
Return values
self

orderLineReference()

Line of the purchase order (BT-132); null removes it.

public orderLineReference(string|null $reference) : self
Parameters
$reference : string|null
Return values
self

originCountry()

Country of origin of the item (BT-159), ISO 3166-1 alpha-2, uppercased; null removes it.

public originCountry(string|null $country) : self
Parameters
$country : string|null
Return values
self

period()

Line period (BG-26): start (BT-134) and end (BT-135); one of them may be null.

public period(Date|string|null $start[, Date|string|null $end = null ]) : self
Parameters
$start : Date|string|null
$end : Date|string|null = null
Return values
self

priceInclVat()

Price including VAT (gross price mode for B2C and shops).

public priceInclVat(BigDecimal|int|float|string $price) : self

The calculator derives the net price so that the customer pays exactly the gross amount.

Parameters
$price : BigDecimal|int|float|string
Return values
self

quantity()

Invoiced quantity (BT-129), optionally with the unit (BT-130); default 1. Negative quantities for returns and discounts.

public quantity(BigDecimal|int|float|string $quantity[, UnitCode|RawCode|string|null $unit = null ]) : self
Parameters
$quantity : BigDecimal|int|float|string
$unit : UnitCode|RawCode|string|null = null
Tags
throws
InvalidArgumentException

for a float

Return values
self

reference()

Adds a reference to an order, contract, despatch or receiving advice or another document (profile EXTENDED only).

public reference(DocumentReference $reference) : self
Parameters
$reference : DocumentReference
Return values
self

sellerId()

The seller's item number (BT-155); null removes it.

public sellerId(string|null $id) : self
Parameters
$id : string|null
Return values
self

showGrossPrice()

Prints the price including VAT below the net unit price of this line (true) or not (false), whatever Presentation::$showGrossPrices says for the invoice; null follows the presentation again. It is printed only for lines with a price including VAT (priceInclVat()).

public showGrossPrice([bool|null $show = true ]) : self
Parameters
$show : bool|null = true
Return values
self

subLine()

Adds a sub line (profile EXTENDED or XRechnung extension), in the forms of InvoiceBuilder::line(): a name with the common values, Line::make(), an array, a model or a callable.

public subLine(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 ]) : self
Parameters
$line : 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
self

unit()

Unit of the quantity (BT-130), UN/ECE Recommendation 20/21; default C62 (one). Unknown codes are kept as RawCode.

public unit(UnitCode|RawCode|string $unit) : self
Parameters
$unit : UnitCode|RawCode|string
Return values
self

vat()

Sets the VAT treatment, either via a preset of a country pack or as category and rate.

public vat(TaxPreset|VatCategory $presetOrCategory[, BigDecimal|int|float|string|null $rate = null ][, string|null $exemptionReason = null ][, VatExemptionReasonCode|RawCode|string|null $exemptionReasonCode = null ]) : self
Parameters
$presetOrCategory : TaxPreset|VatCategory
$rate : BigDecimal|int|float|string|null = null
$exemptionReason : string|null = null
$exemptionReasonCode : VatExemptionReasonCode|RawCode|string|null = null
Return values
self
On this page

Search results