PHP Classes
elePHPant
Icontem

PHP Price Calculator: Calculate prices using arbitrary precision math

Recommend this page to a friend!
  Info   View files Example   View files View files (19)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2014-05-24 (2 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 246 All time: 7,433 This week: 1,099Up
Version License PHP version Categories
price-calculator 1.0.0BSD License5.3.0PHP 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
PHP Programming Innovation award nominee
June 2014
Number 6


Prize: 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
Picture of Sergii Pryz
  Performance   Level  
Name: Sergii Pryz <contact>
Classes: 6 packages by
Country: Ukraine Ukraine
Innovation award
Innovation award
Nominee: 2x

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 folder image Files  
File Role Description
Files folder imagedocs (1 directory)
Files folder imagesrc (1 file, 1 directory)
Files folder imagetests (2 files, 1 directory)
Accessible without login Plain text file CHANGELOG.md Data Documentation
Accessible without login Plain text file Example.php Example Example script
Accessible without login Plain text file LICENSE.txt Lic. Documentation
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  docs  
File Role Description
Files folder imageuml (1 file)

  Files folder image Files  /  docs  /  uml  
File Role Description
  Accessible without login Image file class.diagram.png Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imagePriceCalculator (4 files, 1 directory)
  Accessible without login Plain text file Autoload.php Aux. Class source

  Files folder image Files  /  src  /  PriceCalculator  
File Role Description
Files folder imageStrategy (2 files, 1 directory)
  Plain text file AbstractPriceCalculator.php Class Class source
  Plain text file Exception.php Class Class source
  Plain text file PriceCalculator.php Class Class source
  Plain text file PriceCalculatorInterface.php Class Class source

  Files folder image Files  /  src  /  PriceCalculator  /  Strategy  
File Role Description
Files folder imagePriceNet (3 files)
  Plain text file AbstractPriceNet.php Class Class source
  Plain text file PriceNetInterface.php Class Class source

  Files folder image Files  /  src  /  PriceCalculator  /  Strategy  /  PriceNet  
File Role Description
  Plain text file Manual.php Class Class source
  Plain text file PercentOver.php Class Class source
  Plain text file PriceOver.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imagesrc (1 directory)
  Accessible without login Plain text file bootstrap.php Aux. Class source
  Accessible without login Plain text file phpunit.xml Data Auxiliary data

  Files folder image Files  /  tests  /  src  
File Role Description
Files folder imagePriceCalculator (2 files)

  Files folder image Files  /  tests  /  src  /  PriceCalculator  
File Role Description
  Accessible without login Plain text file BaseTest.php Test Class source
  Accessible without login Plain text file CalculatorTest.php Test Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:246
This week:0
All time:7,433
This week:1,099Up