public function testInitWithParams() { $oPrice = new oxPrice(15); $this->assertEquals(15, $oPrice->getBruttoPrice()); }
/** * Get cost line item summary data as array. * * @param integer $iLineItem * @param string $sCostName * @param oxPrice $oPrice * * @return array */ protected function _getCostSummary($iLineItem, $sCostName, oxPrice $oPrice) { $sPmPrefix = OxpsPaymorrowOxBasketItem::getPaymorrowBasketSummaryLineItemPrefix($iLineItem); list($sId, $sName, $sType) = $this->_getCostMetadata($sCostName); if (empty($sId)) { return array(); } return array($sPmPrefix . 'quantity' => 1, $sPmPrefix . 'articleId' => $sId, $sPmPrefix . 'name' => $sName, $sPmPrefix . 'type' => $sType, $sPmPrefix . 'unitPriceGross' => (double) $oPrice->getBruttoPrice(), $sPmPrefix . 'grossAmount' => (double) $oPrice->getBruttoPrice(), $sPmPrefix . 'vatAmount' => (double) $oPrice->getVatValue(), $sPmPrefix . 'vatRate' => (double) $oPrice->getVat()); }
/** * Depending on view mode prepare price for viewing * * @param oxPrice $oPrice price object * * @return double */ protected function _getPriceForView($oPrice) { if ($this->_isPriceViewModeNetto()) { $dPrice = $oPrice->getNettoPrice(); } else { $dPrice = $oPrice->getBruttoPrice(); } return $dPrice; }
/** * 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. * * @param oxPrice $oPrice price object * * @return null */ public function compare(oxPrice $oPrice) { $dBruttoPrice1 = $this->getBruttoPrice(); $dBruttoPrice2 = $oPrice->getBruttoPrice(); if ($dBruttoPrice1 == $dBruttoPrice2) { $iRes = 0; } elseif ($dBruttoPrice1 > $dBruttoPrice2) { $iRes = 1; } else { $iRes = -1; } return $iRes; }
/** * Applies discounts which are supposed to be applied on amounts greater than zero. * Returns applied discounts. * * @param oxPrice $oPrice Old article price * @param array $aDiscounts Discount array * @param amount $dAmount Amount in basket * * @return array */ public function applyBasketDiscounts(oxPrice $oPrice, $aDiscounts, $dAmount = 1) { $aDiscLog = array(); reset($aDiscounts); // price object to correctly perform calculations $dOldPrice = $oPrice->getBruttoPrice(); while (list(, $oDiscount) = each($aDiscounts)) { $oDiscount->applyDiscount($oPrice); $dNewPrice = $oPrice->getBruttoPrice(); if (!isset($aDiscLog[$oDiscount->getId()])) { $aDiscLog[$oDiscount->getId()] = $oDiscount->getSimpleDiscount(); } $aDiscLog[$oDiscount->getId()]->dDiscount += $dOldPrice - $dNewPrice; $aDiscLog[$oDiscount->getId()]->dDiscount *= $dAmount; $dOldPrice = $dNewPrice; } return $aDiscLog; }