Componette

Componette

sunfoxcz

sunfoxcz / price-calculator v1.1.0

Library for easier price calculation using VAT and discount.

download-cloud-line composer require sunfoxcz/price-calculator

Price calculator library

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
  • v1.1.0 Released version 1.1.0

    • Allow PHP 8
  • v1.0.1 Released version 1.0.1

    Fixed PriceCalculator and IPriceCalculator return types in method getDiscount() and getDecimalPoints().

  • v1.0.0 Released version 1.0.0

    After long use in production, version 1.0.0 is here with few updates:

    • Updated minimal nette/bootstrap version to 2.4.5
    • Allow installing with nette/utils and nette/bootstrap version 3.0
    • Added scalar typehints for property and return types
    • Updated code to use new PHP features
    • Add declare(strict_types=1) to all PHP files
    • Fixed compatibility with PHP 7.2 and 7.3
    • Fixed return type declaration
    • Fixed coding style, added EasyCodingStandard for automated checks
  • v0.4.0 Released version 0.4.0

    • Dropped HHVM, PHP 5.6 and 7.0 support
    • Deprecated Nette\Object switched to Nette\SmartObject trait
    • Upgraded nette/utils to version 2.5
    • Added PHP 7.2 support
  • v0.3.0 Released version 0.3.0

    • Fixed compatibility with Nette 2.4
    • Dropped php 5.4 and 5.5 support
  • v0.2.0 Released version 0.2.0

    • Added Extension for Nette framework
    • Improved coding style
    • Renamed reduction to discount [BC Break]
    • Added separated discount class implementations [BC Break]
  • v0.1.0 Released version 0.1.0

    First release.

Componette Componette felix@nette.org