# PHP Price Calculator: Calculate prices using arbitrary precision math

 Recommend this page to a friend!
 Download .zip
 Info Example View files (19) Download .zip Reputation Support forum Blog Links
 Ratings Unique User Downloads Download Rankings 82% Total: 281 This week: 1 All time: 7,603 This week: 59
 Version License PHP version Categories price-calculator 1.0.0 BSD License 5.3.0 PHP 5, E-Commerce
Description

Author

This package can calculate prices using arbitrary precision math.

It can calculate the prices of goods using different strategies to compute the final price.

Currently it implements strategies to calculate the sales prices based on a value set manually, adding percentage or a fixed value over the original price.

The calculations of the prices are done using arbitrary precision math to avoid losing precision over multiple operations.

Innovation Award
 June 2014 Number 6Prize: One subscription to the PDF edition of the PHP Architect magazine When dealing with money operations it is important to preserve the precision of the operation results as much as possible, so rounding errors do not result in serious financial losses. This class uses arbitrary precision math to avoid rounding errors when performing operations on prices. Manuel Lemos
 Performance Level
Name: Classes: Sergii Pryz 10 packages by Sergii Pryz Ukraine 39 1341 21 in Ukraine 74 1 in Ukraine
Innovation award

Nominee: 4x

## Example

 3)); // vat is 23% \$vat_percent = 23; // calculate price \$calculator = new PriceCalculator(\$strategy, \$vat_percent); \$price = \$calculator->setPricePurchase(\$price_purchase)                     ->getPrice(); var_dump(\$price); // output: array(3) {                     // ["price_net"]=>                     // string(5) "10.30"                     // ["price_gross"]=>                     // string(7) "12.6690"                     // ["vat_value"]=>                     // string(6) "2.3690"                     //}

## Details

 PriceCalculator ============== Introduction ------------ Library helps calculate products sales price components such as net, gross, vat with using BCMath (http://www.php.net/manual/en/book.bc.php) for all arithmetics operations. Moreover PriceCalculator offers several algorithms to build price net: * Fixed price over purchase price * Fixed percent over purchase price * Manually set net without any margin Additionally it is possible extend library by adding own net price strategy. ### The areas of usage * Calculation product sales price * Form price that's includes several fees like delivery, insurance etc. * Build price that vary from region * Simply calculate VAT, gross, net ### Examples Example can be found here: `/Example.php`

 Files
File Role Description
docs (1 directory)
src (1 file, 1 directory)
tests (2 files, 1 directory)
CHANGELOG.md Data Documentation
Example.php Example Example script
LICENSE.txt Lic. Documentation
README.md Doc. Documentation

 Files / docs
File Role Description
uml (1 file)

 Files / docs / uml
File Role Description
class.diagram.png Data Auxiliary data

 Files / src
File Role Description
PriceCalculator (4 files, 1 directory)
Autoload.php Aux. Class source

 Files / src / PriceCalculator
File Role Description
Strategy (2 files, 1 directory)
AbstractPriceCalculator.php Class Class source
Exception.php Class Class source
PriceCalculator.php Class Class source
PriceCalculatorInterface.php Class Class source

 Files / src / PriceCalculator / Strategy
File Role Description
PriceNet (3 files)
AbstractPriceNet.php Class Class source
PriceNetInterface.php Class Class source

 Files / src / PriceCalculator / Strategy / PriceNet
File Role Description
Manual.php Class Class source
PercentOver.php Class Class source
PriceOver.php Class Class source

 Files / tests
File Role Description
src (1 directory)
bootstrap.php Aux. Class source
phpunit.xml Data Auxiliary data

 Files / tests / src
File Role Description
PriceCalculator (2 files)

 Files / tests / src / PriceCalculator
File Role Description
BaseTest.php Test Class source
CalculatorTest.php Test Class source

Version Control Unique User Downloads Download Rankings
100%
 Total: 281 This week: 1
 All time: 7,603 This week: 59
User Ratings

All time 91% 91% 100% 91% 83% - 82% 7

 About us Advertise on this site Site map Newsletter Statistics Site tips Privacy policy Contact
For more information send a message to info at phpclasses dot org.