Esempio n. 1
0
 /**
  * Prepare valid cart data
  *
  * @return array
  */
 protected function _prepareValidModelData()
 {
     $totals = ['discount' => 0.1, 'shipping' => 0.2, 'subtotal' => 0.3, 'tax' => 0.4];
     $taxContainer = new \Magento\Framework\DataObject(['base_discount_tax_compensation_amount' => 0, 'base_shipping_discount_tax_compensation_amnt' => 0]);
     $this->_salesModel->expects($this->once())->method('getTaxContainer')->will($this->returnValue($taxContainer));
     $this->_salesModel->expects($this->once())->method('getAllItems')->will($this->returnValue([$this->_validItem]));
     $this->_salesModel->expects($this->once())->method('getBaseSubtotal')->will($this->returnValue($totals['subtotal']));
     $this->_salesModel->expects($this->once())->method('getBaseTaxAmount')->will($this->returnValue($totals['tax']));
     $this->_salesModel->expects($this->once())->method('getBaseShippingAmount')->will($this->returnValue($totals['shipping']));
     $this->_salesModel->expects($this->once())->method('getBaseDiscountAmount')->will($this->returnValue($totals['discount']));
     $this->_salesModel->expects($this->once())->method('getDataUsingMethod')->with('base_grand_total')->will($this->returnValue(6.0 + $totals['tax'] + $totals['shipping'] - $totals['discount']));
     return $totals;
 }
Esempio n. 2
0
 /**
  * Import items from sales model
  *
  * @return void
  */
 protected function _importItemsFromSalesModel()
 {
     $this->_salesModelItems = [];
     foreach ($this->_salesModel->getAllItems() as $item) {
         if ($item->getParentItem()) {
             continue;
         }
         $this->_salesModelItems[] = $this->_createItemFromData($item->getName(), $item->getQty(), $item->getPrice(), $item->getOriginalItem()->getId());
     }
     $this->addSubtotal($this->_salesModel->getBaseSubtotal());
     $this->addTax($this->_salesModel->getBaseTaxAmount());
     $this->addShipping($this->_salesModel->getBaseShippingAmount());
     $this->addDiscount(abs($this->_salesModel->getBaseDiscountAmount()));
 }
Esempio n. 3
0
 /**
  * Add "hidden" discount and shipping tax
  *
  * Go ahead, try to understand ]:->
  *
  * Tax settings for getting "discount tax":
  * - Catalog Prices = Including Tax
  * - Apply Customer Tax = After Discount
  * - Apply Discount on Prices = Including Tax
  *
  * Test case for getting "hidden shipping tax":
  * - Make sure shipping is taxable (set shipping tax class)
  * - Catalog Prices = Including Tax
  * - Shipping Prices = Including Tax
  * - Apply Customer Tax = After Discount
  * - Create a shopping cart price rule with % discount applied to the Shipping Amount
  * - run shopping cart and estimate shipping
  * - go to PayPal
  *
  * @param \Magento\Payment\Model\Cart\SalesModel\SalesModelInterface $salesEntity
  * @return void
  */
 protected function _applyHiddenTaxWorkaround(\Magento\Payment\Model\Cart\SalesModel\SalesModelInterface $salesEntity)
 {
     $dataContainer = $salesEntity->getTaxContainer();
     $this->addTax((double) $dataContainer->getBaseHiddenTaxAmount());
     $this->addTax((double) $dataContainer->getBaseShippingHiddenTaxAmnt());
 }