Ejemplo n.º 1
0
 /**
  * Sets $this->oPrice
  *
  * @param object $oPrice price
  *
  * @return null
  */
 public function setPrice($oPrice)
 {
     $this->_oPrice = oxNew('oxprice');
     $this->_oPrice->setBruttoPriceMode();
     $this->_oPrice->setVat($oPrice->getVAT());
     $this->_oPrice->addPrice($oPrice);
     $this->_oPrice->multiply($this->getAmount());
     $this->_oUnitPrice = oxNew('oxprice');
     $this->_oUnitPrice->setBruttoPriceMode();
     $this->_oUnitPrice->setVat($oPrice->getVAT());
     $this->_oUnitPrice->addPrice($oPrice);
 }
Ejemplo n.º 2
0
 public function testInitWithParams()
 {
     $oPrice = new oxPrice(15);
     $this->assertEquals(15, $oPrice->getBruttoPrice());
 }
Ejemplo n.º 3
0
 /**
  * Template variable getter. Returns formatted min order price value
  *
  * @deprecated in v4.8/5.1 on 2013-10-14; use oxBasket method
  *
  * @return string
  */
 public function getMinOrderPrice()
 {
     if ($this->_sMinOrderPrice === null && $this->isLowOrderPrice()) {
         $dMinOrderPrice = oxPrice::getPriceInActCurrency($this->getConfig()->getConfigParam('iMinOrderPrice'));
         $this->_sMinOrderPrice = oxRegistry::getLang()->formatCurrency($dMinOrderPrice);
     }
     return $this->_sMinOrderPrice;
 }
Ejemplo n.º 4
0
 /**
  * Applies currency factor
  *
  * @param oxPrice $oPrice Price object
  * @param object  $oCur   Currency object
  */
 protected function _applyCurrency(oxPrice $oPrice, $oCur = null)
 {
     if (!$oCur) {
         $oCur = $this->getConfig()->getActShopCurrencyObject();
     }
     $oPrice->multiply($oCur->rate);
 }
 /**
  * Test case for oepaypalexpresscheckoutdispatcher::_setDeliverySetListForCallbackResponse()
  * Applying delivery VAT
  *
  * @return null
  */
 public function testSetDeliverySetListForCallbackResponse_applyingDeliveryVat()
 {
     //disabling delivery VAT check
     $this->setConfigParam("blShowVATForDelivery", true);
     // preparing config
     $oPayPalService = new oePayPalService();
     // preparing delivery set
     $aDeliverySetList = array("oxidstandart" => "DeliverySet Name");
     $oUser = oxNew("oxUser");
     $oUser->oxuser__oxcountryid = new oxField("testCountryId");
     $oBasket = $this->getMock('oxBasket', array('getPriceForPayment', 'getAdditionalServicesVatPercent', 'getPayPalBasketVatValue'));
     $oBasket->expects($this->once())->method('getPriceForPayment')->will($this->returnValue(5));
     $oBasket->expects($this->once())->method('getAdditionalServicesVatPercent')->will($this->returnValue(19));
     $oBasket->expects($this->any())->method('getPayPalBasketVatValue');
     // preparing delivery
     $oPrice = new oxPrice();
     $oPrice->setPrice(27);
     // delivery VAT should be passed to "getDeliveryPrice" method
     $oDelivery = $this->getMock('oxDelivery', array('getDeliveryPrice'));
     $oDelivery->expects($this->once())->method('getDeliveryPrice')->with($this->equalTo(19))->will($this->returnValue($oPrice));
     $aDeliveryList = array($oDelivery);
     $oDeliveryList = $this->getMock('oxDeliveryList', array('hasDeliveries', 'getDeliveryList'));
     $oDeliveryList->expects($this->once())->method("hasDeliveries")->will($this->returnValue(true));
     $oDeliveryList->expects($this->once())->method("getDeliveryList")->will($this->returnValue($aDeliveryList));
     oxTestModules::addModuleObject('oxDeliveryList', $oDeliveryList);
     // preparing
     $oDispatcher = $this->getMock("oepaypalexpresscheckoutdispatcher", array("_isPayPalInDeliverySet"));
     $oDispatcher->expects($this->once())->method("_isPayPalInDeliverySet")->will($this->returnValue(true));
     $this->assertEquals(1, $oDispatcher->UNITsetDeliverySetListForCallbackResponse($oPayPalService, $aDeliverySetList, $oUser, $oBasket));
     $aPayPalParams = $oPayPalService->getCaller()->getParameters();
     $this->assertEquals("DeliverySet Name", $aPayPalParams["L_SHIPPINGOPTIONNAME0"]);
     $this->assertEquals(oxRegistry::getLang()->translateString("OEPAYPAL_PRICE"), $aPayPalParams["L_SHIPPINGOPTIONLABEL0"]);
     $this->assertEquals(27, $aPayPalParams["L_SHIPPINGOPTIONAMOUNT0"]);
     $this->assertEquals('true', $aPayPalParams["L_SHIPPINGOPTIONISDEFAULT0"]);
 }
Ejemplo n.º 6
0
 /**
  * Returns TRUE if ( current basket products sum - total discount - voucher discount ) > 0
  *
  * @return bool
  */
 public function isBelowMinOrderPrice()
 {
     $blIsBelowMinOrderPrice = false;
     $sConfValue = $this->getConfig()->getConfigParam('iMinOrderPrice');
     if (is_numeric($sConfValue) && $this->getProductsCount()) {
         $dMinOrderPrice = oxPrice::getPriceInActCurrency((int) $sConfValue);
         $dNotDiscountedProductPrice = 0;
         if ($oPrice = $this->getNotDiscountProductsPrice()) {
             $dNotDiscountedProductPrice = $oPrice->getBruttoSum();
         }
         $blIsBelowMinOrderPrice = $dMinOrderPrice > $this->getDiscountedProductsBruttoPrice() + $dNotDiscountedProductPrice;
     }
     return $blIsBelowMinOrderPrice;
 }
Ejemplo n.º 7
0
 /**
  * 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());
 }
Ejemplo n.º 8
0
 /**
  * Sets $this->_oPrice
  *
  * @param object $oPrice price
  */
 public function setPrice($oPrice)
 {
     $this->_oUnitPrice = clone $oPrice;
     $this->_oPrice = clone $oPrice;
     $this->_oPrice->multiply($this->getAmount());
 }
Ejemplo n.º 9
0
 /**
  * Returns price of TS protection product
  *
  * @return float
  */
 public function getPrice()
 {
     if ($this->_oPrice == null) {
         if ($sTsId = $this->getTsId()) {
             $aTsProducts = $this->getAllTsProducts();
             if ($aTsProducts[$sTsId] && is_array($aTsProducts[$sTsId])) {
                 $oConfig = $this->getConfig();
                 $dVat = $oConfig->getConfigParam('dDefaultVAT');
                 $dPrice = oxPrice::netto2Brutto($aTsProducts[$sTsId]['netto'], $dVat);
                 $oPrice = oxNew('oxPrice');
                 $oPrice->setPrice($dPrice);
                 if ($oConfig->getConfigParam('blCalcVATForPayCharge')) {
                     $oPrice->setVat($dVat);
                 }
                 $this->_oPrice = $oPrice;
             }
         }
     }
     return $this->_oPrice;
 }
Ejemplo n.º 10
0
 /**
  * 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;
 }
Ejemplo n.º 11
0
 /**
  * testing calculation of discount of brutto price
  *
  * @return null
  */
 public function testGetDiscountedProductsBruttoPrice()
 {
     $oProdPrice = new oxPrice(1199);
     $oProdPrice->setBruttoPriceMode();
     $oProdPriceList = oxNew('oxPriceList');
     $oProdPriceList->addToPriceList($oProdPrice);
     $oTotalDiscount = new oxPrice(100);
     $oTotalDiscount->setBruttoPriceMode();
     $oVoucherDiscount = new oxPrice(100);
     $oVoucherDiscount->setBruttoPriceMode();
     $oBasket = $this->getMock("oxbasket", array("getDiscountProductsPrice", "getTotalDiscount", "getVoucherDiscount"));
     $oBasket->expects($this->once())->method('getDiscountProductsPrice')->will($this->returnValue($oProdPriceList));
     $oBasket->expects($this->once())->method('getTotalDiscount')->will($this->returnValue($oTotalDiscount));
     $oBasket->expects($this->once())->method('getVoucherDiscount')->will($this->returnValue($oVoucherDiscount));
     $this->assertEquals(999, $oBasket->getDiscountedProductsBruttoPrice());
 }
Ejemplo n.º 12
0
 /**
  * Test data provider
  *
  * @return array
  */
 public function getDiscountSumPayPalBasketDataProvider()
 {
     $oBasketDiscount1 = new oxPrice();
     $oBasketDiscount1->setPrice(2);
     $oBasketDiscount2 = new oxPrice();
     $oBasketDiscount2->setPrice(4);
     // vouchers
     $oVoucher = new oxVoucher();
     $VoucherDiscount1 = $oVoucher->getSimpleVoucher();
     $VoucherDiscount1->dVoucherdiscount = 6;
     $VoucherDiscount2 = $oVoucher->getSimpleVoucher();
     $VoucherDiscount2->dVoucherdiscount = 8;
     $dPaymentCost1 = 7;
     $dPaymentCost2 = -7;
     return array(array(0, array(), 0, 0), array(0, array(), $dPaymentCost1, 0), array($oBasketDiscount1, array($VoucherDiscount1, $VoucherDiscount2), $dPaymentCost1, 16), array($oBasketDiscount2, array($VoucherDiscount1, $VoucherDiscount2), $dPaymentCost2, 25));
 }
Ejemplo n.º 13
0
 /**
  * Depending on view mode prepare price before calculation
  *
  * @param double $dPrice                 - price
  * @param double $dVat                   - VAT
  * @param bool   $blCalculationModeNetto - if calculation mode netto - true
  *
  * @return double
  */
 protected function _preparePrice($dPrice, $dVat, $blCalculationModeNetto = null)
 {
     if ($blCalculationModeNetto === null) {
         $blCalculationModeNetto = $this->_isPriceViewModeNetto();
     }
     $oCurrency = $this->getConfig()->getActShopCurrencyObject();
     $blEnterNetPrice = $this->getConfig()->getConfigParam('blEnterNetPrice');
     if ($blCalculationModeNetto && !$blEnterNetPrice) {
         $dPrice = round(oxPrice::brutto2Netto($dPrice, $dVat), $oCurrency->decimal);
     } elseif (!$blCalculationModeNetto && $blEnterNetPrice) {
         $dPrice = round(oxPrice::netto2Brutto($dPrice, $dVat), $oCurrency->decimal);
     }
     return $dPrice;
 }
Ejemplo n.º 14
0
 /**
  * Returns min order price value
  *
  * @return decimal
  */
 public function getMinOrderPrice()
 {
     return oxPrice::getPriceInActCurrency($this->getConfig()->getConfigParam('iMinOrderPrice'));
 }
 /**
  * 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;
 }
Ejemplo n.º 16
0
 /**
  * Collecting assigned to article amount-price list
  *
  * @return oxList
  */
 protected function _getAmountPriceList()
 {
     if ($this->_oAmountPriceList === null) {
         $this->_oAmountPriceList = array();
         if (!$this->skipDiscounts()) {
             $myConfig = $this->getConfig();
             $sArtId = $this->getId();
             // #1690C - Scale prices and variants
             if (!$this->isAdmin() && $myConfig->getConfigParam('blVariantInheritAmountPrice') && $this->oxarticles__oxparentid->value) {
                 $sArtId = $this->oxarticles__oxparentid->value;
             }
             //collecting assigned to article amount-price list
             $oAmPriceList = oxNew('oxlist');
             $oAmPriceList->init('oxbase', 'oxprice2article');
             $sShopID = $myConfig->getShopID();
             if ($myConfig->getConfigParam('blMallInterchangeArticles')) {
                 $sShopSelect = '1';
             } else {
                 $sShopSelect = " oxshopid =  '{$sShopID}' ";
             }
             $oAmPriceList->selectString("select * from oxprice2article where oxartid = " . oxDb::getDb()->quote($sArtId) . " and {$sShopSelect} order by oxamount ");
             // prepare abs prices if currently having percentages
             $oBasePrice = $this->_getGroupPrice();
             foreach ($oAmPriceList as $oAmPrice) {
                 if ($oAmPrice->oxprice2article__oxaddperc->value) {
                     $oAmPrice->oxprice2article__oxaddabs = new oxField(oxPrice::percent($oBasePrice, 100 - $oAmPrice->oxprice2article__oxaddperc->value), oxField::T_RAW);
                 }
             }
             $this->_oAmountPriceList = $oAmPriceList;
         }
     }
     return $this->_oAmountPriceList;
 }