sunfoxcz/price-calculator

Library for easier price calculation using VAT and discount.

v1.1.1 2023-02-03 14:40 UTC

This package is auto-updated.

Last update: 2024-03-01 00:12:12 UTC


README

68747470733a2f2f62616467656e2e6e65742f6769746875622f636865636b732f73756e666f78637a2f70726963652d63616c63756c61746f722f6d61737465723f63616368653d333030 68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73756e666f78637a2f70726963652d63616c63756c61746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572 68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73756e666f78637a2f70726963652d63616c63756c61746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572

68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f73756e666f78637a2f70726963652d63616c63756c61746f72 68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f73756e666f78637a2f70726963652d63616c63756c61746f72 68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6963656e73652f73756e666f78637a2f70726963652d63616c63756c61746f72

Library for easier price calculation using VAT and discount.

Installation

composer require sunfoxcz/price-calculator

Usage

<?php declare(strict_types=1);

use Sunfox\PriceCalculator\Discount\PercentDiscount;
use Sunfox\PriceCalculator\PriceCalculator;

/* @var Sunfox\PriceCalculator\PriceCalculatorResult $calc */
$calc = (new PriceCalculator)
	->setBasePrice(1983.48)
	->setDiscount(new PercentDiscount(10.0))
	->setVatRate(21.0)
	->calculate();

$calc->getBasePrice(); // price without VAT and discount
$calc->getDiscount();  // discount in percent without VAT
$calc->getPrice();     // price after discount without VAT
$calc->getVatRate();   // VAT rate in percent
$calc->getVat();       // VAT value
$calc->getPriceVat();  // price after discount with VAT
$calc->toArray();      // Ger results as array

$calc->getCalculator(); // Sunfox\PriceCalculator\PriceCalculator