API reference / Quittio \ Core \ Calculation
LineCalculator
final class in quittio/core
Quittio\Core\Calculation\LineCalculator · Source
Calculates the invoice line net amount (BT-131):
net price BT-146 = BT-148 − BT-147 (if list price and discount are given) base amount B = round2(BT-129 × BT-146 / (BT-149 ?: 1)) allowance A_i = BT-136 or round2((BT-137 ?: B) × BT-138 / 100) charge C_i = BT-141 or round2((BT-142 ?: B) × BT-143 / 100) line amount BT-131 = B − Σ A_i + Σ C_i
Methods#
| Method | Description |
|---|---|
::baseAmount() | |
->calculate() | |
::exactAmount() | Unrounded line amount as PEPPOL-EN16931-R120 checks it: quantity × (net price / base quantity) + line charges − line allowances (BT-129, BT-146, BT-149, BT-141, BT-136). Null without net price (BT-146). |
::priceFor() | Smallest-precision net price (2 to 10 decimals) for which the line formula yields exactly $amount. |
baseAmount()#
public static function baseAmount(
BigDecimal $quantity,
BigDecimal $netPrice,
?BigDecimal $baseQuantity,
): BigDecimal| Parameter | Type | Description |
|---|---|---|
$quantity | Brick\Math\BigDecimal | |
$netPrice | Brick\Math\BigDecimal | |
$baseQuantity | ?Brick\Math\BigDecimal |
- Returns
Brick\Math\BigDecimal
calculate()#
public function calculate(InvoiceLine $line, string $currency): InvoiceLine| Parameter | Type | Description |
|---|---|---|
$line | InvoiceLine | |
$currency | string |
- Returns
InvoiceLine
exactAmount()#
public static function exactAmount(InvoiceLine $line): ?BigDecimalUnrounded line amount as PEPPOL-EN16931-R120 checks it: quantity × (net price / base quantity) + line charges − line allowances (BT-129, BT-146, BT-149, BT-141, BT-136). Null without net price (BT-146).
| Parameter | Type | Description |
|---|---|---|
$line | InvoiceLine |
- Returns
?Brick\Math\BigDecimal
priceFor()#
public static function priceFor(
BigDecimal $amount,
BigDecimal $quantity,
?BigDecimal $baseQuantity,
): BigDecimalSmallest-precision net price (2 to 10 decimals) for which the line formula yields exactly $amount.
| Parameter | Type | Description |
|---|---|---|
$amount | Brick\Math\BigDecimal | |
$quantity | Brick\Math\BigDecimal | |
$baseQuantity | ?Brick\Math\BigDecimal |
- Returns
Brick\Math\BigDecimal