Пример #1
0
 /**
  * Implementing (faking) performance friendly method from oxArticle
  *
  * @return oxPrice
  */
 public function getPrice()
 {
     $myConfig = $this->getConfig();
     // 0002030 No need to return price if it disabled for better performance.
     if (!$myConfig->getConfigParam('bl_perfLoadPrice')) {
         return;
     }
     if ($this->_oPrice === null) {
         $this->_oPrice = oxNew("oxPrice");
         if ($dPrice = $this->_getGroupPrice()) {
             $this->_oPrice->setPrice($dPrice, $this->_dVat);
             $this->_applyParentVat($this->_oPrice);
             $this->_applyCurrency($this->_oPrice);
             // apply discounts
             $this->_applyParentDiscounts($this->_oPrice);
         } elseif ($oParent = $this->getParent()) {
             $this->_oPrice = $oParent->getPrice();
         }
     }
     return $this->_oPrice;
 }
Пример #2
0
 /**
  * Performs final sum calculations and roundings.
  *
  * @return null
  *
  */
 protected function _calcTotalPrice()
 {
     // 1. add products price
     $dprice = $this->_oProductsPriceList->getBruttoSum();
     $this->_oPrice->setPrice($dprice);
     // 2. substract discounts
     if ($dprice) {
         // 2.1 applying basket item discounts
         foreach ($this->_aItemDiscounts as $oDiscount) {
             // skipping bundle discounts
             if ($oDiscount->sType == 'itm') {
                 continue;
             }
             $this->_oPrice->subtract($oDiscount->dDiscount);
         }
         // 2.2 applying basket discounts
         $this->_oPrice->subtract($this->_oTotalDiscount->getBruttoPrice());
         // 2.3 applying voucher discounts
         if ($oVoucherDisc = $this->getVoucherDiscount()) {
             $this->_oPrice->subtract($oVoucherDisc->getBruttoPrice());
         }
     }
     // 2.3 add delivery cost
     if (isset($this->_aCosts['oxdelivery'])) {
         $this->_oPrice->add($this->_aCosts['oxdelivery']->getBruttoPrice());
     }
     // 2.4 add wrapping price
     if (isset($this->_aCosts['oxwrapping'])) {
         $this->_oPrice->add($this->_aCosts['oxwrapping']->getBruttoPrice());
     }
     // 2.5 add payment price
     if (isset($this->_aCosts['oxpayment'])) {
         $this->_oPrice->add($this->_aCosts['oxpayment']->getBruttoPrice());
     }
     // 2.6 add TS protection price
     if (isset($this->_aCosts['oxtsprotection'])) {
         $this->_oPrice->add($this->_aCosts['oxtsprotection']->getBruttoPrice());
     }
 }
 /**
  * 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"]);
 }
Пример #4
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));
 }