예제 #1
0
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $store = $address->getQuote()->getStore();
     $taxConfig = Mage::getSingleton('tax/config');
     $salesHelper = Mage::helper('sales');
     if ($taxConfig->displayCartSubtotalBoth($store) || $taxConfig->displayCartSubtotalInclTax($store)) {
         if ($address->getSubtotalInclTax() > 0) {
             $subtotalInclTax = $address->getSubtotalInclTax();
         } else {
             $subtotalInclTax = $address->getSubtotal() + $address->getTaxAmount() - $address->getShippingTaxAmount() - $address->getPaymentFeeTax();
         }
         $address->addTotal(array('code' => 'subtotal', 'title' => $salesHelper->__('Subtotal'), 'value' => $subtotalInclTax, 'value_incl_tax' => $subtotalInclTax, 'value_excl_tax' => $address->getSubtotal()));
     }
     return $this;
 }
예제 #2
0
 /**
  * Convert quote address model to order
  *
  * @param   Mage_Sales_Model_Quote $quote
  * @return  Mage_Sales_Model_Order
  */
 public function addressToOrder(Mage_Sales_Model_Quote_Address $address, $order = null)
 {
     if (!$order instanceof Mage_Sales_Model_Order) {
         $order = $this->toOrder($address->getQuote());
     }
     $order->setWeight($address->getWeight())->setShippingMethod($address->getShippingMethod())->setShippingDescription($address->getShippingDescription())->setShippingRate($address->getShippingRate())->setSubtotal($address->getSubtotal())->setTaxAmount($address->getTaxAmount())->setDiscountAmount($address->getDiscountAmount())->setShippingAmount($address->getShippingAmount())->setGiftcertAmount($address->getGiftcertAmount())->setCustbalanceAmount($address->getCustbalanceAmount())->setGrandTotal($address->getGrandTotal())->setBaseSubtotal($address->getBaseSubtotal())->setBaseTaxAmount($address->getBaseTaxAmount())->setBaseDiscountAmount($address->getBaseDiscountAmount())->setBaseShippingAmount($address->getBaseShippingAmount())->setBaseGiftcertAmount($address->getBaseGiftcertAmount())->setBaseCustbalanceAmount($address->getBaseCustbalanceAmount())->setBaseGrandTotal($address->getBaseGrandTotal());
     Mage::dispatchEvent('sales_convert_quote_address_to_order', array('address' => $address, 'order' => $order));
     return $order;
 }
예제 #3
0
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     if ($address->getAddressType() == 'billing') {
         return $this;
     }
     if (Mage::helper('customfee')->canApply()) {
         $amount = $this->getFeeAmount($address->getSubtotal());
         $address->addTotal(array('code' => $this->getCode(), 'title' => $this->getLabel(), 'value' => $amount));
     }
     return $this;
 }
예제 #4
0
 protected function resetAddress(Mage_Sales_Model_Quote_Address $address)
 {
     $address->setDiscountAmount(0.0);
     $address->setBaseDiscountAmount(0.0);
     $address->setSubtotalWithDiscount($address->getSubtotal());
     $address->setBaseSubtotalWithDiscount($address->getBaseSubtotal());
     $address->setDiscountDescription('');
     $address->setDiscountDescriptionArray([]);
     if (!$address->getData('__applied_rules_reset__')) {
         $address->setAppliedRuleIds('');
         $address->setData('__applied_rules_reset__', true);
     }
     $address->setShippingDiscountAmount(0);
     $address->setBaseShippingDiscountAmount(0);
     $address->setFreeShipping(false);
 }
예제 #5
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     if (!Mage::getSingleton('checkout/session')->getQuoteId()) {
         return $this;
     }
     $_helper = Mage::helper('msp_cashondelivery');
     $_model = Mage::getModel('msp_cashondelivery/cashondelivery');
     $_subtotal = $address->getSubtotal();
     $quote = $address->getQuote();
     $baseAmount = $_model->getBaseExtraFee($_subtotal);
     $amount = $_model->getExtraFee($_subtotal);
     $codTax = $_helper->getTaxAmount($amount);
     $codBaseTax = $_helper->getTaxAmount($baseAmount);
     if ($quote->getPayment()->getMethod() == $_model->getCode() && $address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING) {
         $address->setTaxAmount($address->getTaxAmount() + $codTax);
         $address->setBaseTaxAmount($address->getBaseTaxAmount() + $codBaseTax);
         $this->_saveAppliedTaxes($address, $_helper->getAppliedRates(), $codTax, $codBaseTax, $_helper->getRate());
         $address->setGrandTotal($address->getGrandTotal() + $codTax);
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $codBaseTax);
     }
     return $this;
 }
예제 #6
0
 /**
  * Assign subtotal amount and label to address object
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Mage_Sales_Model_Quote_Address_Total_Subtotal
  */
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('sales')->__('Subtotal'), 'value' => $address->getSubtotal()));
     return $this;
 }
예제 #7
0
파일: Total.php 프로젝트: Eximagen/pfizer
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $helper = Mage::helper('mageworx_customoptions');
     if (!$helper->isEnabled() || !$helper->isSkuPriceLinkingEnabled()) {
         return $this;
     }
     if ($address->getSubtotal() == 0) {
         return $this;
     }
     $this->_address = $address;
     $this->_store = $address->getQuote()->getStore();
     $this->_config = Mage::getSingleton('tax/config');
     $this->_helper = Mage::helper('tax');
     if (method_exists($this, '_getAddressItems')) {
         $items = $this->_getAddressItems($address);
     } else {
         $items = $address->getAllItems();
     }
     if (!$items) {
         return $this;
     }
     $quote = $address->getQuote();
     $address->setSubtotalInclTax(0);
     $address->setBaseSubtotalInclTax(0);
     $address->setTotalAmount('subtotal', 0);
     $address->setBaseTotalAmount('subtotal', 0);
     $totalDiffTax = 0;
     foreach ($items as $item) {
         $diffTax = 0;
         $product = $item->getProduct();
         // if bad magento))
         if (is_null($product->getHasOptions())) {
             $product->load($product->getId());
         }
         if (($product->getTypeId() == 'simple' || $product->getTypeId() == 'configurable' || $product->getTypeId() == 'virtual' || $product->getTypeId() == 'downloadable') && $product->getHasOptions()) {
             $store = $product->getStore();
             $post = $helper->getInfoBuyRequest($product);
             if (isset($post['options'])) {
                 $options = $post['options'];
             } else {
                 $options = array();
             }
             $qty = $item->getQty();
             if ($options) {
                 $priceIncludesTax = Mage::helper('tax')->priceIncludesTax($store);
                 foreach ($options as $optionId => $option) {
                     $optionModel = $product->getOptionById($optionId);
                     if (!$optionModel) {
                         continue;
                     }
                     $optionModel->setProduct($product);
                     $optionType = $optionModel->getType();
                     if ($optionModel->getGroupByType($optionType) != Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
                         if (!$optionModel->getIsSkuPrice()) {
                             continue;
                         }
                         $taxClassId = $optionModel->getTaxClassId();
                         if (is_null($taxClassId) || $product->getTaxClassId() == $taxClassId || $priceIncludesTax) {
                             continue;
                         }
                         $optionTotalQty = $optionModel->getCustomoptionsIsOnetime() ? 1 : $qty;
                         $price = $helper->getOptionPriceByQty($optionModel, $optionTotalQty);
                         $tax1 = $helper->getTaxPrice($price, $quote, $product->getTaxClassId(), $address);
                         $tax2 = $helper->getTaxPrice($price, $quote, $taxClassId, $address);
                         $diffTax += $tax2 - $tax1;
                     } else {
                         if (!is_array($option)) {
                             $option = array($option);
                         }
                         foreach ($option as $optionTypeId) {
                             if (!$optionTypeId) {
                                 continue;
                             }
                             $valueModel = $optionModel->getValueById($optionTypeId);
                             if (!$valueModel || !$valueModel->getIsSkuPrice()) {
                                 continue;
                             }
                             $taxClassId = $valueModel->getTaxClassId();
                             if (is_null($taxClassId) || $product->getTaxClassId() == $taxClassId || $priceIncludesTax) {
                                 continue;
                             }
                             // get total option qty
                             switch ($optionType) {
                                 case 'checkbox':
                                 case 'multiswatch':
                                 case 'hidden':
                                     if (isset($post['options_' . $optionId . '_' . $optionTypeId . '_qty'])) {
                                         $optionQty = intval($post['options_' . $optionId . '_' . $optionTypeId . '_qty']);
                                     } else {
                                         $optionQty = 1;
                                     }
                                     break;
                                 case 'drop_down':
                                 case 'radio':
                                 case 'swatch':
                                     if (isset($post['options_' . $optionId . '_qty'])) {
                                         $optionQty = intval($post['options_' . $optionId . '_qty']);
                                     } else {
                                         $optionQty = 1;
                                     }
                                     break;
                                 case 'multiple':
                                     $optionQty = 1;
                                     break;
                             }
                             $optionTotalQty = $optionModel->getCustomoptionsIsOnetime() ? $optionQty : $optionQty * $qty;
                             $price = $helper->getOptionPriceByQty($valueModel, $optionTotalQty);
                             $tax1 = $helper->getTaxPrice($price, $quote, $product->getTaxClassId(), $address);
                             $tax2 = $helper->getTaxPrice($price, $quote, $taxClassId, $address);
                             $diffTax += $tax2 - $tax1;
                         }
                     }
                 }
                 if ($diffTax) {
                     // convert basePrice - to price
                     $storeDiffTax = $store->convertPrice($diffTax, false, false);
                     $item->setBasePriceInclTax($item->getBasePriceInclTax() + $diffTax / $qty);
                     // $diffTax/produt qty
                     $item->setPriceInclTax($item->getPriceInclTax() + $storeDiffTax / $qty);
                     // $diffTax/produt qty
                     $item->setBaseRowTotalInclTax($item->getBaseRowTotalInclTax() + $diffTax);
                     $item->setRowTotalInclTax($item->getRowTotalInclTax() + $storeDiffTax);
                     $item->setBaseTaxAmount($item->getBaseTaxAmount() + $diffTax);
                     $item->setTaxAmount($item->getTaxAmount() + $storeDiffTax);
                     $totalDiffTax += $diffTax;
                 }
             }
         }
         if (!$item->getParentItemId()) {
             $this->_addSubtotalAmount($address, $item);
         }
     }
     if ($totalDiffTax) {
         $totalStoreDiffTax = $store->convertPrice($totalDiffTax, false, false);
         $address->setBaseTaxAmount($address->getBaseTaxAmount() + $totalDiffTax);
         $address->setTaxAmount($address->getTaxAmount() + $totalStoreDiffTax);
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $totalDiffTax);
         $address->setGrandTotal($address->getGrandTotal() + $totalStoreDiffTax);
     }
     return $this;
 }
예제 #8
0
 /**
  * Add tax totals information to address object
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Mage_Tax_Model_Sales_Total_Quote
  */
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $applied = $address->getAppliedTaxes();
     $store = $address->getQuote()->getStore();
     $amount = $address->getTaxAmount();
     $area = null;
     if ($this->_config->displayCartTaxWithGrandTotal($store) && $address->getGrandTotal()) {
         $area = 'taxes';
     }
     if ($amount != 0 || $this->_config->displayCartZeroTax($store)) {
         $address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('tax')->__('Tax'), 'full_info' => $applied ? $applied : array(), 'value' => $amount, 'area' => $area));
     }
     $store = $address->getQuote()->getStore();
     /**
      * Modify subtotal
      */
     if ($this->_config->displayCartSubtotalBoth($store) || $this->_config->displayCartSubtotalInclTax($store)) {
         if ($address->getSubtotalInclTax() > 0) {
             $subtotalInclTax = $address->getSubtotalInclTax();
         } else {
             $subtotalInclTax = $address->getSubtotal() + $address->getTaxAmount() - $address->getShippingTaxAmount();
         }
         $address->addTotal(array('code' => 'subtotal', 'title' => Mage::helper('sales')->__('Subtotal'), 'value' => $subtotalInclTax, 'value_incl_tax' => $subtotalInclTax, 'value_excl_tax' => $address->getSubtotal()));
     }
     return $this;
 }
예제 #9
0
 /**
  * Add total
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @return Mage_Sales_Model_Resource_Quote_Address_Attribute_Frontend_Subtotal
  */
 public function fetchTotals(Mage_Sales_Model_Quote_Address $address)
 {
     $address->addTotal(array('code' => 'subtotal', 'title' => Mage::helper('Mage_Sales_Helper_Data')->__('Subtotal'), 'value' => $address->getSubtotal()));
     return $this;
 }
예제 #10
0
 /**
  * @param Mage_Sales_Model_Quote_Address $address
  * @return $this|Mage_Sales_Model_Quote_Address_Total_Abstract
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $helper = Mage::helper('mageworx_multifees');
     if ($address->getSubtotal() == 0 && floatval($address->getCustomerCreditAmount()) == 0) {
         return $this;
     }
     if ($this->_collected) {
         return $this;
     }
     ////////////////////////////////////////////////////////////////////
     $subtotalRowTOTAL = 0;
     $CompanyTotal = 0;
     $PersonTotal = 0;
     $quote = Mage::getSingleton('checkout/cart')->getQuote();
     $cartItems = $quote->getAllVisibleItems();
     $userGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
     foreach ($cartItems as $item) {
         $subtotalRow = 0;
         $_product = Mage::getModel('catalog/product')->load($item->getProductId());
         $ids = $_product->getCategoryIds();
         $productId = $item->getProductId();
         $qty = $item->getQty();
         $price = $item->getProduct()->getPrice();
         $subtotalRow = $subtotalRow + $price * $qty;
         //If the product has perception tax for persons
         if (array_search("372", $ids) != false && $subtotalRow >= 100) {
             $PersonTotal = $PersonTotal + $subtotalRow;
         }
         //If the product has perception tax for persons
         if (array_search("373", $ids) != false) {
             $CompanyTotal = $CompanyTotal + $subtotalRow;
         }
     }
     //If the user is Not log in
     if ($userGroupId == 0 || $userGroupId == 8) {
         $subtotalRowTOTAL = $PersonTotal;
         $subtotalRowTOTAL = $subtotalRowTOTAL / 1.18;
     } elseif ($userGroupId == 8) {
         $subtotalRowTOTAL = $CompanyTotal;
         $subtotalRowTOTAL = $subtotalRowTOTAL / 1.18;
     } else {
         $subtotalRowTOTAL = 0;
     }
     //////////////////////////////////////////////////////////////////////////////////////////////////////
     $baseSubtotalRow = floatval($subtotalRowTOTAL);
     $baseSubtotal = floatval($address->getBaseSubtotalWithDiscount());
     $baseShipping = floatval($address->getBaseShippingAmount());
     // - $address->getBaseShippingTaxAmount()
     $baseTax = floatval($address->getBaseTaxAmount());
     //amount
     $address->setMultifeesAmount(0);
     $address->setBaseMultifeesAmount(0);
     $address->setDetailsMultifees(null);
     $quote = $address->getQuote();
     $feeMessages = new Varien_Data_Collection();
     // add payment fee (front and admin)
     if (Mage::app()->getRequest()->getPost('is_payment_fee', false)) {
         $feesPost = Mage::app()->getRequest()->getPost('fee', array());
         foreach ($feesPost as $feeId => $data) {
             if (isset($data['message'])) {
                 $obj = new Varien_Object();
                 $obj->setFeeId($feeId);
                 $obj->setMessage($data['message']);
                 $feeMessages->addItem($obj);
             }
         }
         $helper->addFeesToCart($feesPost, $quote->getStoreId(), false, 2, 0);
     }
     // add shipping fee (front and admin)
     if (Mage::app()->getRequest()->getPost('is_shipping_fee', false)) {
         $feesPost = Mage::app()->getRequest()->getPost('fee', array());
         foreach ($feesPost as $feeId => $data) {
             if (isset($data['message'])) {
                 $obj = new Varien_Object();
                 $obj->setFeeId($feeId);
                 $obj->setMessage($data['message']);
                 $feeMessages->addItem($obj);
             }
         }
         $helper->addFeesToCart($feesPost, $quote->getStoreId(), false, 3, 0);
     }
     $feesData = $helper->getQuoteDetailsMultifees($address->getId());
     // autoadd default cart fees, no hidden
     if (is_null($feesData) && $helper->isEnableCartFees()) {
         $this->autoAddFeesByParams(1, 0, 2, 1, '', $quote, $address, $helper, null);
     }
     // autoadd hidden cart fees
     if ($helper->isEnableCartFees()) {
         $this->autoAddFeesByParams(1, 0, 1, 1, '', $quote, $address, $helper, null);
     }
     // autoadd hidden shipping fees
     if ($helper->isEnableShippingFees() && $address->getShippingMethod()) {
         $this->autoAddFeesByParams(3, 0, 1, 1, strval($address->getShippingMethod()), $quote, $address, $helper, $feeMessages);
     }
     // autoadd hidden fees
     if ($helper->isEnablePaymentFees() && $quote->getPayment()->getMethod()) {
         // autoadd default payment fees, no hidden
         if (is_null($feesData) && Mage::app()->getRequest()->getControllerName() == 'express') {
             $this->autoAddFeesByParams(2, 0, 3, 1, $quote->getPayment()->getMethod(), $quote, $address, $helper, null);
         }
         // autoadd hidden payment fees
         $this->autoAddFeesByParams(2, 0, 1, 1, $quote->getPayment()->getMethod(), $quote, $address, $helper, $feeMessages);
     }
     $feesData = $helper->getQuoteDetailsMultifees($address->getId());
     if (!is_array($feesData) || count($feesData) == 0) {
         return $this;
     }
     // check conditions added fees
     // get all possible fees
     $possibleFeesCollection = $helper->getMultifees(0, 0, 0, 0, '', $quote, $address);
     $possibleFees = array();
     foreach ($possibleFeesCollection as $fee) {
         $possibleFees[$fee->getId()] = $fee;
     }
     $store = $quote->getStore();
     $baseMultifeesAmount = 0;
     $baseMultifeesTaxAmount = 0;
     foreach ($feesData as $feeId => $data) {
         if (!isset($data['options']) || !isset($possibleFees[$feeId])) {
             unset($feesData[$feeId]);
             continue;
         }
         $baseMultifeesLeft = 0;
         $appliedTotals = $data['applied_totals'];
         foreach ($appliedTotals as $field) {
             switch ($field) {
                 case 'subtotal':
                     $baseMultifeesLeft += $baseSubtotal;
                     break;
                 case 'shipping':
                     $baseMultifeesLeft += $baseShipping;
                     break;
                 case 'tax':
                     $baseMultifeesLeft += $baseTax;
                     break;
                 case 'rowsubtotal':
                     $baseMultifeesLeft += $baseSubtotalRow;
                     break;
             }
         }
         $taxClassId = $data['tax_class_id'];
         // Caluclation the subtotal/discount with/without tax
         $baseSubtotal = floatval($address->getBaseSubtotal());
         $discountAmount = $address->getBaseDiscountAmount();
         if (Mage::helper('tax')->discountTax()) {
             // check discount with tax
             $discountAmount = floatval($helper->getPriceExcludeTax($discountAmount, $quote, $data['tax_class_id']));
         }
         $baseSubtotal = floatval($baseSubtotal + $discountAmount);
         /////////////////////
         //Custom
         //////////////////////
         $baseSubtotalRow = floatval($baseSubtotalRow + $discountAmount);
         $feePrice = 0;
         $feeTax = 0;
         foreach ($data['options'] as $optionId => $value) {
             if (isset($value['percent'])) {
                 $opBasePrice = $baseMultifeesLeft * $value['percent'] / 100;
             } else {
                 $opBasePrice = $value['base_price'] * $possibleFees[$feeId]->getFoundQty($address->getId());
             }
             $opPrice = $store->convertPrice($opBasePrice);
             if ($helper->isTaxСalculationIncludesTax()) {
                 $opBaseTax = $opBasePrice - $helper->getPriceExcludeTax($opBasePrice, $quote, $taxClassId, $address);
                 $opTax = $opPrice - $helper->getPriceExcludeTax($opPrice, $quote, $taxClassId, $address);
             } else {
                 // add tax
                 $opBasePrice += $opBaseTax = $helper->getTaxPrice($opBasePrice, $quote, $taxClassId, $address);
                 $opPrice += $opTax = $helper->getTaxPrice($opPrice, $quote, $taxClassId, $address);
             }
             // round price
             $opBasePrice = $store->roundPrice($opBasePrice);
             $opPrice = $store->roundPrice($opPrice);
             $opBaseTax = $store->roundPrice($opBaseTax);
             $opTax = $store->roundPrice($opTax);
             //$opPrice, $opBasePrice = inclTax
             $feesData[$feeId]['options'][$optionId]['base_price'] = $opBasePrice;
             $feesData[$feeId]['options'][$optionId]['price'] = $opPrice;
             $feesData[$feeId]['options'][$optionId]['base_tax'] = $opBaseTax;
             $feesData[$feeId]['options'][$optionId]['tax'] = $opTax;
             $feeTax += $opBaseTax;
             $feePrice += $opBasePrice;
         }
         $feesData[$feeId]['base_price'] = $feePrice;
         $feesData[$feeId]['price'] = $store->convertPrice($feePrice);
         $feesData[$feeId]['base_tax'] = $feeTax;
         $feesData[$feeId]['tax'] = $store->convertPrice($feeTax);
         $baseMultifeesAmount += $feePrice;
         $baseMultifeesTaxAmount += $feeTax;
     }
     $multifeesAmount = $store->roundPrice($store->convertPrice($baseMultifeesAmount));
     $baseMultifeesAmount = $store->roundPrice($baseMultifeesAmount);
     $multifeesTaxAmount = $store->roundPrice($store->convertPrice($baseMultifeesTaxAmount));
     $baseMultifeesTaxAmount = $store->roundPrice($baseMultifeesTaxAmount);
     if ($helper->isIncludeFeeInShippingPrice()) {
         $address->setBaseShippingAmount($baseMultifeesAmount - $baseMultifeesTaxAmount + $address->getBaseShippingAmount());
         $address->setShippingAmount($multifeesAmount - $multifeesTaxAmount + $address->getShippingAmount());
         $address->setBaseShippingTaxAmount($baseMultifeesTaxAmount + $address->getBaseShippingTaxAmount());
         $address->setShippingTaxAmount($multifeesTaxAmount + $address->getShippingTaxAmount());
         $address->setBaseShippingInclTax($baseMultifeesAmount + $address->getBaseShippingInclTax());
         $address->setShippingInclTax($multifeesAmount + $address->getShippingInclTax());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $baseMultifeesAmount - $baseMultifeesTaxAmount);
         $address->setGrandTotal($address->getGrandTotal() + $multifeesAmount - $multifeesTaxAmount);
     } else {
         $address->setBaseMultifeesAmount($baseMultifeesAmount);
         $address->setMultifeesAmount($multifeesAmount);
         $address->setBaseMultifeesTaxAmount($baseMultifeesTaxAmount);
         $address->setMultifeesTaxAmount($multifeesTaxAmount);
         $address->setDetailsMultifees(serialize($feesData));
         $address->setBaseTotalAmount('multifees', $baseMultifeesAmount);
         $address->setTotalAmount('multifees', $multifeesAmount);
     }
     $address->setBaseTaxAmount($address->getBaseTaxAmount() + $baseMultifeesTaxAmount);
     $address->setTaxAmount($address->getTaxAmount() + $multifeesTaxAmount);
     // emulation $this->_saveAppliedTaxes($address, $applied, $tax, $baseTax, $rate);
     $appliedTaxes = $address->getAppliedTaxes();
     if (is_array($appliedTaxes)) {
         foreach ($appliedTaxes as $row) {
             if (isset($appliedTaxes[$row['id']]['amount'])) {
                 $appliedTaxes[$row['id']]['amount'] += $multifeesTaxAmount;
                 $appliedTaxes[$row['id']]['base_amount'] += $baseMultifeesTaxAmount;
                 break;
             }
         }
         $address->setAppliedTaxes($appliedTaxes);
     }
     $this->_collected = true;
     return $this;
 }
예제 #11
0
파일: Tax.php 프로젝트: shabirm/avatax
 /**
  * Add tax totals information to address object
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Mage_Tax_Model_Sales_Total_Quote
  */
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $config = Mage::getSingleton('tax/config');
     $quote = $address->getQuote();
     $store = $quote->getStore();
     $amount = $address->getTaxAmount();
     $fullInfo = array();
     $summary = Mage::getModel('avatax/avatax_estimate')->getSummary($address->getId());
     foreach ($summary as $key => $row) {
         $id = 'avatax-' . $key;
         $fullInfo[$id] = array('rates' => array(array('code' => $row['name'], 'title' => $row['name'], 'percent' => $row['rate'], 'position' => $key, 'priority' => $key, 'rule_id' => 0)), 'percent' => $row['rate'], 'id' => $id, 'process' => 0, 'amount' => $row['amt'], 'base_amount' => $row['amt']);
     }
     if ($amount != 0 || Mage::helper('tax')->displayZeroTax($store)) {
         $address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('tax')->__('Tax'), 'full_info' => $fullInfo, 'value' => $amount, 'area' => null));
     }
     /**
      * Modify subtotal
      */
     if (method_exists($config, "displayCartSubtotalBoth") && method_exists($config, "displayCartSubtotalInclTax") && ($config->displayCartSubtotalBoth($store) || $config->displayCartSubtotalInclTax($store))) {
         $subtotalInclTax = $address->getSubtotal() + $address->getTaxAmount() - $address->getShippingTaxAmount();
         $address->setSubtotalInclTax($subtotalInclTax);
         $address->addTotal(array('code' => 'subtotal', 'title' => Mage::helper('sales')->__('Subtotal'), 'value' => $subtotalInclTax, 'value_incl_tax' => $subtotalInclTax, 'value_excl_tax' => $address->getSubtotal()));
     }
     return $this;
 }
예제 #12
0
파일: Tax.php 프로젝트: onepica/avatax
 /**
  * Add tax totals information to address object
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  $this
  */
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $config = Mage::getSingleton('tax/config');
     $quote = $address->getQuote();
     $store = $quote->getStore();
     $amount = $address->getTaxAmount();
     if ($amount != 0 || Mage::helper('tax')->displayZeroTax($store)) {
         $address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('tax')->__('Tax'), 'full_info' => $address->getAppliedTaxes(), 'value' => $amount, 'area' => null));
     }
     /**
      * Modify subtotal
      */
     if (method_exists($config, "displayCartSubtotalBoth") && method_exists($config, "displayCartSubtotalInclTax") && ($config->displayCartSubtotalBoth($store) || $config->displayCartSubtotalInclTax($store))) {
         if ($address->getSubtotalInclTax() > 0) {
             $subtotalInclTax = $address->getSubtotalInclTax();
         } else {
             $subtotalInclTax = $address->getSubtotal() + $address->getTaxAmount() - $address->getShippingTaxAmount();
         }
         $address->addTotal(array('code' => 'subtotal', 'title' => Mage::helper('sales')->__('Subtotal'), 'value' => $subtotalInclTax, 'value_incl_tax' => $subtotalInclTax, 'value_excl_tax' => $address->getSubtotal()));
     }
     return $this;
 }
예제 #13
0
 /**
  * Calculate cart total net
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @return int
  */
 private function calculateCartTotal($address)
 {
     if ($address->getTaxAmount() > 0) {
         $value = $address->getGrandTotal() - $address->getTaxAmount();
         return $this->currencyToSmallerUnit($value);
     } else {
         $discount = $address->getDiscountAmount() < 0 ? -$address->getDiscountAmount() : $address->getDiscountAmount();
         $value = $address->getSubtotal() + $address->getShippingAmount() + $this->getQuote()->getBillpayChargedFeeNet() - $discount;
         // TODO: for rate payment add fee tax amount
         return $this->currencyToSmallerUnit($value);
     }
 }