Skip to content

krzysztofzylka/Price

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Install

composer require krzysztofzylka/price

Methods

Price

Global default currency

\Krzysztofzylka\Price\Price::$currency = NULL;

Initialize

Initialize with 50.00

$price = \Krzysztofzylka\Price\Price::of(50)

Add tax rate

Add 23% tax rate

$price->plusTaxRate(23);

Add price

Add 150.00 price

$price->plus(150);

Subtract price

Subtract 100 price

$price->minus(100);

Get amount

echo $price->getAmount();
//173

Get format amount

echo $price->getFormatAmount('EUR');
//173,00 EUR

Calculate

Format amount

\Krzysztofzylka\Price\Calculate::formatAmount(100, 'PLN');
// 100,00 PLN

Calculate vat amount

\Krzysztofzylka\Price\Calculate::calculateVatAmount($amount, $vat)

Calculate net amount

\Krzysztofzylka\Price\Calculate::calculateNetAmount($grossAmount, $vatRate)

Calculate gross amount

\Krzysztofzylka\Price\Calculate::calculateGrossAmount($netAmount, $vatRate)