Exemplo n.º 1
0
 private function getProductTaxRate()
 {
     /** @var $taxCalculator Mage_Tax_Model_Calculation */
     $taxCalculator = Mage::getSingleton('tax/calculation');
     $request = $taxCalculator->getRateRequest($this->quote->getShippingAddress(), $this->quote->getBillingAddress(), $this->quote->getCustomerTaxClassId(), $this->quote->getStore());
     $request->setProductClassId($this->getProduct()->getTaxClassId());
     return $taxCalculator->getRate($request);
 }
Exemplo n.º 2
0
 public function getCustomerTaxClassId()
 {
     /** @var $customer Mage_Customer_Model_Customer */
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     if ($taxClassId = $customer->getTaxClassId()) {
         $this->setCustomerTaxClassId($taxClassId);
         return $this->getData('customer_tax_class_id');
     }
     return parent::getCustomerTaxClassId();
 }
Exemplo n.º 3
0
 /**
  * Convert quote model to order model
  *
  * @param   Mage_Sales_Model_Quote $quote
  * @return  Mage_Sales_Model_Order
  */
 public function toOrder(Mage_Sales_Model_Quote $quote, $order = null)
 {
     if (!$order instanceof Mage_Sales_Model_Order) {
         $order = Mage::getModel('sales/order');
     }
     /* @var $order Mage_Sales_Model_Order */
     $order->setStoreId($quote->getStoreId())->setQuoteId($quote->getId())->setRemoteIp($quote->getRemoteIp())->setCustomerId($quote->getCustomerId())->setCustomerEmail($quote->getCustomerEmail())->setCustomerFirstname($quote->getCustomerFirstname())->setCustomerLastname($quote->getCustomerLastname())->setCustomerGroupId($quote->getCustomerGroupId())->setCustomerTaxClassId($quote->getCustomerTaxClassId())->setCustomerNote($quote->getCustomerNote())->setCustomerNoteNotify($quote->getCustomerNoteNotify())->setCustomerIsGuest($quote->getCustomerIsGuest())->setBaseCurrencyCode($quote->getBaseCurrencyCode())->setStoreCurrencyCode($quote->getStoreCurrencyCode())->setOrderCurrencyCode($quote->getQuoteCurrencyCode())->setStoreToBaseRate($quote->getStoreToBaseRate())->setStoreToOrderRate($quote->getStoreToQuoteRate())->setCouponCode($quote->getCouponCode())->setGiftcertCode($quote->getGiftcertCode())->setIsVirtual($quote->getIsVirtual())->setIsMultiPayment($quote->getIsMultiPayment())->setAppliedRuleIds($quote->getAppliedRuleIds());
     Mage::dispatchEvent('sales_convert_quote_to_order', array('order' => $order, 'quote' => $quote));
     return $order;
 }
Exemplo n.º 4
0
 protected function _getProductTaxClassId()
 {
     if (is_null($this->_productTaxClassId)) {
         // Init product tax class
         // -------------------------
         $productTaxClass = Mage::getModel('tax/class')->getCollection()->addFieldToFilter('class_name', 'eBay Product Tax Class')->addFieldToFilter('class_type', Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT)->getFirstItem();
         if (is_null($productTaxClass->getId())) {
             $productTaxClass->setClassName('eBay Product Tax Class')->setClassType(Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT);
             $productTaxClass->save();
         }
         // -------------------------
         // Init customer tax class
         // -------------------------
         if (is_null($customerTaxClassId = $this->_quote->getCustomerTaxClassId())) {
             $customerTaxClass = Mage::getModel('tax/class')->getCollection()->addFieldToFilter('class_name', 'eBay Customer Tax Class')->addFieldToFilter('class_type', Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER)->getFirstItem();
             if (is_null($customerTaxClass->getId())) {
                 $customerTaxClass->setClassName('eBay Customer Tax Class')->setClassType(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER);
                 $customerTaxClass->save();
             }
             $customerTaxClassId = $customerTaxClass->getId();
         }
         // -------------------------
         // Init tax rate
         // -------------------------
         $taxRate = Mage::getModel('tax/calculation_rate')->load('eBay Tax Rate', 'code');
         $taxRate->setRate((double) $this->_taxPercent)->setCode('eBay Tax Rate')->setTaxCountryId('US');
         $taxRate->save();
         // -------------------------
         // Combine tax classes and tax rate in tax rule
         // -------------------------
         $taxRule = Mage::getModel('tax/calculation_rule')->load('eBay Tax Rule', 'code');
         $taxRule->setCode('eBay Tax Rule')->setTaxCustomerClass(array($customerTaxClassId))->setTaxProductClass(array($productTaxClass->getId()))->setTaxRate(array($taxRate->getId()));
         $taxRule->save();
         // -------------------------
         $this->_productTaxClassId = $productTaxClass->getId();
     }
     return $this->_productTaxClassId;
 }
Exemplo n.º 5
0
 /**
  * Get the tax request object for the current quote.
  *
  * @param Mage_Sales_Model_Quote $quote
  *
  * @return bool|Varien_Object
  */
 protected function _getBuckarooFeeTaxRequest(Mage_Sales_Model_Quote $quote)
 {
     $store = $quote->getStore();
     $codTaxClass = Mage::getStoreConfig(self::XPATH_BUCKAROO_TAX_CLASS, $store);
     /**
      * If no tax class is configured for the Buckaroo fee, there is no tax to be calculated.
      */
     if (!$codTaxClass) {
         return false;
     }
     $taxCalculation = $this->getTaxCalculation();
     $customerTaxClass = $quote->getCustomerTaxClassId();
     $shippingAddress = $quote->getShippingAddress();
     $billingAddress = $quote->getBillingAddress();
     $request = $taxCalculation->getRateRequest($shippingAddress, $billingAddress, $customerTaxClass, $store);
     $request->setProductClassId($codTaxClass);
     return $request;
 }