Zum Inhalt springen

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#

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

static

ParameterTypeDescription
$quantityBrick\Math\BigDecimal
$netPriceBrick\Math\BigDecimal
$baseQuantity?Brick\Math\BigDecimal
Returns
Brick\Math\BigDecimal

calculate()#

public function calculate(InvoiceLine $line, string $currency): InvoiceLine
ParameterTypeDescription
$lineInvoiceLine
$currencystring
Returns
InvoiceLine

exactAmount()#

public static function exactAmount(InvoiceLine $line): ?BigDecimal

static

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).

ParameterTypeDescription
$lineInvoiceLine
Returns
?Brick\Math\BigDecimal

priceFor()#

public static function priceFor(
    BigDecimal $amount,
    BigDecimal $quantity,
    ?BigDecimal $baseQuantity,
): BigDecimal

static

Smallest-precision net price (2 to 10 decimals) for which the line formula yields exactly $amount.

ParameterTypeDescription
$amountBrick\Math\BigDecimal
$quantityBrick\Math\BigDecimal
$baseQuantity?Brick\Math\BigDecimal
Returns
Brick\Math\BigDecimal

Die Open-Core-Pakete stehen unter der MIT-Lizenz. Die rechtlichen Formulierungen der Länderpakete sind mit einer Steuerberatung abzustimmen.