OXID eShop CE  4.10.8
 All Classes Namespaces Files Functions Variables Pages
oxPrice Class Reference

Public Member Functions

 __construct ($dPrice=null)
 setNettoMode ($blNetto=true)
 isNettoMode ()
 setNettoPriceMode ()
 setBruttoPriceMode ()
 setVat ($dVat)
 setUserVat ($newVat)
 getVat ()
 setPrice ($dPrice, $dVat=null)
 getPrice ()
 getBruttoPrice ()
 getNettoPrice ()
 getVatValue ()
 subtractPercent ($dValue)
 addPercent ($dValue)
 addPrice (oxPrice $oPrice)
 add ($dValue)
 subtract ($dValue)
 multiply ($dValue)
 divide ($dValue)
 compare (oxPrice $oPrice)
 setDiscount ($dValue, $sType)
 getDiscounts ()
 calculateDiscount ()

Static Public Member Functions

static percent ($dValue, $dPercent)
static brutto2Netto ($dBrutto, $dVat)
static netto2Brutto ($dNetto, $dVat)
static getPriceInActCurrency ($dPrice)

Protected Member Functions

 _flushDiscounts ()

Protected Attributes

 $_dBrutto = 0.0
 $_dNetto = 0.0
 $_dVat = 0.0
 $_aDiscounts = null
 $_blNetPriceMode

Detailed Description

Price calculation class. Responsible for simple price calculations. Basically contains Brutto, Netto prices and VAT values.

Definition at line 6 of file oxprice.php.

Constructor & Destructor Documentation

oxPrice::__construct (   $dPrice = null)

Class constructor. Gets price entering mode.

Parameters
double$dPricegiven price
Returns
oxPrice

Definition at line 56 of file oxprice.php.

Member Function Documentation

oxPrice::_flushDiscounts ( )
protected

Flush assigned discounts

Definition at line 418 of file oxprice.php.

oxPrice::add (   $dValue)

Adds given value to price depending on price entering mode, and recalculates price

Parameters
double$dValuevalue to add to price

Definition at line 260 of file oxprice.php.

oxPrice::addPercent (   $dValue)

Adds given percent to price depending on price entering mode, and recalculates price

Parameters
double$dValuepercent to add to price

Definition at line 235 of file oxprice.php.

oxPrice::addPrice ( oxPrice  $oPrice)

Adds another oxPrice object and recalculates current method.

Parameters
oxPrice$oPriceobject

Definition at line 245 of file oxprice.php.

static oxPrice::brutto2Netto (   $dBrutto,
  $dVat 
)
static

Converts Brutto price to Netto using formula: X + $dVat% = $dBrutto X/100 = $dBrutto/(100+$dVAT) X= ($dBrutto/(100+$dVAT))/100 returns X

Parameters
double$dBruttobrutto price
double$dVatvat
Returns
double

Definition at line 353 of file oxprice.php.

oxPrice::calculateDiscount ( )

Calculates price: affects discounts

Definition at line 426 of file oxprice.php.

oxPrice::compare ( oxPrice  $oPrice)

Compares this object to another oxPrice objects. Comparison is performed on brutto price. Result is equal to: 0 - when prices are equal. 1 - when this price is larger than $oPrice. -1 - when this price is smaller than $oPrice.

Parameters
oxPrice$oPriceprice object
Returns
null

Definition at line 312 of file oxprice.php.

oxPrice::divide (   $dValue)

Divides price by given value depending on price entering mode, and recalculates price

Parameters
double$dValuevalue for dividing price

Definition at line 295 of file oxprice.php.

oxPrice::getBruttoPrice ( )

Returns brutto price

Returns
double

Definition at line 178 of file oxprice.php.

oxPrice::getDiscounts ( )

Returns assigned discounts

Returns
array

Definition at line 410 of file oxprice.php.

oxPrice::getNettoPrice ( )

Returns netto price

Returns
double

Definition at line 192 of file oxprice.php.

oxPrice::getPrice ( )

Returns price depending on mode brutto or netto

Returns
double

Definition at line 164 of file oxprice.php.

static oxPrice::getPriceInActCurrency (   $dPrice)
static

Returns price multiplied by current currency

Parameters
string$dPriceprice value
Returns
double

Definition at line 386 of file oxprice.php.

oxPrice::getVat ( )

Returns VAT percent

Returns
double

Definition at line 134 of file oxprice.php.

oxPrice::getVatValue ( )

Returns absolute VAT value

Returns
double

Definition at line 206 of file oxprice.php.

oxPrice::isNettoMode ( )

return true if mode is netto

Returns
bool

Definition at line 80 of file oxprice.php.

oxPrice::multiply (   $dValue)

Multiplies price by given value depending on price entering mode, and recalculates price

Parameters
double$dValuevalue for multiplying price

Definition at line 283 of file oxprice.php.

static oxPrice::netto2Brutto (   $dNetto,
  $dVat 
)
static

Converts Netto price to Brutto using formula: X = $dNetto + $dVat% returns X

Parameters
double$dNettonetto price
double$dVatvat
Returns
double

Definition at line 374 of file oxprice.php.

static oxPrice::percent (   $dValue,
  $dPercent 
)
static

Private function for percent value calculations

Parameters
double$dValuevalue
double$dPercentpercent
Returns
double

Definition at line 336 of file oxprice.php.

oxPrice::setBruttoPriceMode ( )

Brutto price mode setter

Definition at line 96 of file oxprice.php.

oxPrice::setDiscount (   $dValue,
  $sType 
)

Sets discount to price

Parameters
double$dValuediscount value
string$sTypediscount type: abs or %

Definition at line 400 of file oxprice.php.

oxPrice::setNettoMode (   $blNetto = true)

Netto price mode setter

Parameters
bool$blNettoState to set price to net mode (default true).

Definition at line 70 of file oxprice.php.

oxPrice::setNettoPriceMode ( )

Netto price mode setter

Definition at line 88 of file oxprice.php.

oxPrice::setPrice (   $dPrice,
  $dVat = null 
)

Sets new price and VAT percent(optional). Recalculates price by price entering mode

Parameters
double$dPricenew price
double$dVatVAT

Definition at line 146 of file oxprice.php.

oxPrice::setUserVat (   $newVat)

Sets new base VAT percent, recalculates brutto, and then netto price (in brutto mode). if bruttoMode then BruttoPrice =(BruttoPrice - oldVAT% ) + newVat; oldVAT = newVat; finally recalculate; USE ONLY TO CHANGE BASE VAT (in case when local VAT differs from user VAT), USE setVat() in usual case !!!

Parameters
double$newVatvat percent

Definition at line 121 of file oxprice.php.

oxPrice::setVat (   $dVat)

Sets new VAT percent, and recalculates price.

Parameters
double$dVatvat percent

Definition at line 106 of file oxprice.php.

oxPrice::subtract (   $dValue)

Subtracts given value from price depending on price entering mode, and recalculates price

Parameters
double$dValuevalue to subtracts from price

Definition at line 272 of file oxprice.php.

oxPrice::subtractPercent (   $dValue)

Subtracts given percent from price depending on price entering mode, and recalculates price

Parameters
double$dValuepercent to subtract from price

Definition at line 223 of file oxprice.php.

Member Data Documentation

oxPrice::$_aDiscounts = null
protected

Definition at line 36 of file oxprice.php.

oxPrice::$_blNetPriceMode
protected

Definition at line 47 of file oxprice.php.

oxPrice::$_dBrutto = 0.0
protected

Definition at line 14 of file oxprice.php.

oxPrice::$_dNetto = 0.0
protected

Definition at line 21 of file oxprice.php.

oxPrice::$_dVat = 0.0
protected

Definition at line 28 of file oxprice.php.


The documentation for this class was generated from the following file: