sunfoxcz / price-calculator
使用增值税和折扣更轻松地进行价格计算的库。
v2.0.0
2024-05-31 17:51 UTC
Requires
- php: >=8.1
- nette/utils: ^4.0
Requires (Dev)
- nette/bootstrap: ^3.2
- nette/tester: ^2.5
- phpstan/phpstan: ^1.11
Suggests
- nette/bootstrap: ^3.2
README
使用增值税和折扣更轻松地进行价格计算的库。
安装
composer require sunfoxcz/price-calculator
使用
<?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