InvoiceComposerLine
in package
One billed line of the input of {@see \App\UI\Api\Invoicer\Models\Generators\InvoiceComposer}.
Carries only the primary calculator inputs (name, quantity, unit price, rate, discount).
Derived fields (priceWithVat, totalPrice, vatInMoney, ...) are deliberately absent: the
only authority for them is InvoiceCalculator running
in InvoiceManager::beforeSave(), which overwrites anything precomputed. Carrying them would
let a caller believe its number is binding.
IMPORTANT: the constructor is private on purpose. DI search scans all of app/UI and the
*DTO* mask does not cover the Dto/ folder; a class that cannot be instantiated is dropped
from the search, so this DTO needs no config entry and autowiring cannot fail on it. Build it
with create().
Table of Contents
Properties
- $code : string|null
- $description : string|null
- $discountPercents : int|float|string|null
- $name : string
- $price : int|float|string
- $quantity : int|float|string
- $supplyKindId : int|null
- $unit : string|null
- $useVat : bool|null
- $vat : int|float|string|null
Methods
- create() : self
- The only way to create a line; call it with named arguments.
- __construct() : mixed
Properties
$code read-only
public
string|null
$code
= null
$description read-only
public
string|null
$description
= null
$discountPercents read-only
public
int|float|string|null
$discountPercents
= null
$name read-only
public
string
$name
= ''
$price read-only
public
int|float|string
$price
= 0
$quantity read-only
public
int|float|string
$quantity
= 1
$supplyKindId read-only
public
int|null
$supplyKindId
= null
$unit read-only
public
string|null
$unit
= null
$useVat read-only
public
bool|null
$useVat
= null
$vat read-only
public
int|float|string|null
$vat
= null
Methods
create()
The only way to create a line; call it with named arguments.
public
static create([string $name = '' ][, int|float|string $quantity = 1 ][, int|float|string $price = 0 ][, int|float|string|null $vat = null ][, string|null $unit = null ][, string|null $code = null ][, string|null $description = null ][, bool|null $useVat = null ][, int|float|string|null $discountPercents = null ][, int|null $supplyKindId = null ]) : self
Parameters
- $name : string = ''
- $quantity : int|float|string = 1
- $price : int|float|string = 0
- $vat : int|float|string|null = null
- $unit : string|null = null
- $code : string|null = null
- $description : string|null = null
- $useVat : bool|null = null
- $discountPercents : int|float|string|null = null
- $supplyKindId : int|null = null
Return values
self__construct()
private
__construct([string $name = '' ][, int|float|string $quantity = 1 ][, int|float|string $price = 0 ][, int|float|string|null $vat = null ][, string|null $unit = null ][, string|null $code = null ][, string|null $description = null ][, bool|null $useVat = null ][, int|float|string|null $discountPercents = null ][, int|null $supplyKindId = null ]) : mixed
Parameters
- $name : string = ''
-
line name on the invoice (required; an empty line makes the invoice unreadable)
- $quantity : int|float|string = 1
-
quantity;
decimal(8,2), so "2", "2.5" and "2,5" all pass (normalized by DecimalQuantityTrait) - $price : int|float|string = 0
-
unit price without VAT (decimal(10,3) column). IMPORTANT: never the price of the whole line, the calculator multiplies it by the quantity.
- $vat : int|float|string|null = null
-
VAT rate in percent (may be decimal: 5.5 or "5,5";
decimal(5,2)in the DB). Fallback input for a line without a supply kind ($supplyKindId === null);nulltakes the default from the request. When the line has a supply kind, the tax engine decides the rate as of the tax point and this value is discarded. - $unit : string|null = null
-
unit ("hod", "ks", "km");
nulltakes the default from the request - $code : string|null = null
-
line code (SKU, work number); informational only
- $description : string|null = null
-
longer description under the name
- $useVat : bool|null = null
-
per-line VAT opt-out;
nullfollows the header. The header wins: for a VAT non-payer no line carries VAT, whatever it asks for. - $discountPercents : int|float|string|null = null
-
line discount in percent;
nullor 0 means no discount - $supplyKindId : int|null = null
-
supply kind of the line (
cms_system_supply_kinds), an engine input.nulltakes the default kind from the request (InvoiceComposerRequest::$supplyKindId); when the request has none either, the line stays without a kind, the engine is not called for it and the line behaves according to$vat.