Example #1
0
 /**
  * Retrieve subtotal price include tax html formated content
  *
  * @param Varien_Object $item
  * @return string
  */
 public function displaySubtotalInclTax($item)
 {
     $baseTax = $item->getTaxBeforeDiscount() ? $item->getTaxBeforeDiscount() : ($item->getTaxAmount() ? $item->getTaxAmount() : 0);
     $tax = $item->getBaseTaxBeforeDiscount() ? $item->getBaseTaxBeforeDiscount() : ($item->getBaseTaxAmount() ? $item->getBaseTaxAmount() : 0);
     return $this->displayPrices($item->getBaseRowTotal() + $baseTax, $item->getRowTotal() + $tax);
 }
Example #2
0
 /**
  * If tax value differs tax which is setted on magento,
  * apply Google tax and recollect quote
  *
  * @param Varien_Object $qAddress
  * @return string | false
  */
 protected function _applyCustomTax($qAddress)
 {
     $quote = $qAddress->getQuote();
     $qTaxAmount = $qAddress->getBaseTaxAmount();
     $newTaxAmount = $this->getData('root/order-adjustment/total-tax/VALUE');
     if ($qTaxAmount != $newTaxAmount) {
         $taxQuotient = (int) $qTaxAmount ? $newTaxAmount / $qTaxAmount : $newTaxAmount;
         $qAddress->setTaxAmount($this->_reCalculateToStoreCurrency($newTaxAmount, $quote));
         $qAddress->setBaseTaxAmount($newTaxAmount);
         $grandTotal = $qAddress->getBaseGrandTotal() - $qTaxAmount + $newTaxAmount;
         $qAddress->setGrandTotal($this->_reCalculateToStoreCurrency($grandTotal, $quote));
         $qAddress->setBaseGrandTotal($grandTotal);
         $subtotalInclTax = $qAddress->getSubtotalInclTax() - $qTaxAmount + $newTaxAmount;
         $qAddress->setSubtotalInclTax($subtotalInclTax);
         foreach ($quote->getAllVisibleItems() as $item) {
             if ($item->getParentItem()) {
                 continue;
             }
             if ($item->getTaxAmount()) {
                 $item->setTaxAmount($item->getTaxAmount() * $taxQuotient);
                 $item->setBaseTaxAmount($item->getBaseTaxAmount() * $taxQuotient);
                 $taxPercent = round($item->getTaxAmount() / $item->getRowTotal() * 100);
                 $item->setTaxPercent($taxPercent);
             }
         }
         $grandTotal = $quote->getBaseGrandTotal() - $qTaxAmount + $newTaxAmount;
         $quote->setGrandTotal($this->_reCalculateToStoreCurrency($grandTotal, $quote));
         $quote->setBaseGrandTotal($grandTotal);
         $message = $this->__('The tax amount has been applied based on the information received from Google Checkout, because tax amount received from Google Checkout is different from the calculated tax amount');
         return $message;
     }
     return false;
 }
 /**
  * charge money for recurring item
  */
 protected function _checkoutRecurring()
 {
     /** @var Mage_Sales_Model_Order $order */
     $order = Mage::getModel('sales/order');
     $item = new Varien_Object($this->_recurringProfile->getOrderItemInfo());
     $this->_price = $item->getBasePrice() * $item->getQty();
     $additionalInfo = $this->_recurringProfile->getAdditionalInfo();
     // check isset TrialBilling
     // Trial Billing Frequency <= 0 or isn't numeric => failure
     if ($this->_recurringProfile->getTrialBillingAmount() && $this->_recurringProfile->getTrialPeriodFrequency() && $this->_recurringProfile->getTrialPeriodMaxCycles() && $this->_recurringProfile->getTrialPeriodUnit() && (string) (int) $this->_recurringProfile->getTrialPeriodFrequency() === ltrim($this->_recurringProfile->getTrialPeriodFrequency(), '0') && (int) $this->_recurringProfile->getTrialPeriodFrequency() > 0) {
         $trialPeriodMaxCycles = (int) $this->_recurringProfile->getTrialPeriodMaxCycles();
         if (!isset($additionalInfo['trialPeriodMaxCycles'])) {
             $additionalInfo['trialPeriodMaxCycles'] = $trialPeriodMaxCycles;
             $this->_recurringProfile->setAdditionalInfo($additionalInfo);
             $this->_price = $this->_recurringProfile->getTrialBillingAmount();
             $this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
         } elseif (isset($additionalInfo['trialPeriodMaxCycles']) && $additionalInfo['trialPeriodMaxCycles'] > 0) {
             $this->_price = $this->_recurringProfile->getTrialBillingAmount();
             $this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
         }
     }
     // calculate total amount
     $this->_shippingAmount = $item->getBaseShippingAmount();
     $this->_taxAmount = $item->getBaseTaxAmount();
     $this->_amount = $this->_price + $this->_shippingAmount + $this->_taxAmount;
     // init order
     /** @var Mage_Sales_Model_Order_Item $orderItem */
     $orderItem = Mage::getModel('sales/order_item')->setName($item->getName())->setSku($item->getSku())->setDescription($item->getDescription())->setQtyOrdered($item->getQty())->setBasePrice($item->getBasePrice())->setBaseTaxAmount($item->getBaseTaxAmount())->setBaseRowTotalInclTax($item->getBaseRowTotalInclTax());
     $order->addItem($orderItem);
     $shippingInfo = $this->_recurringProfile->getShippingAddressInfo();
     $shippingAddress = Mage::getModel('sales/order_address')->setData($shippingInfo)->setId(null);
     // get base currency code
     $orderInfo = new Varien_Object($this->_recurringProfile->getOrderInfo());
     $currencyCode = $orderInfo->getBaseCurrencyCode();
     $order->setShippingAddress($shippingAddress);
     $order->setBaseCurrencyCode($currencyCode);
     /** @var Mage_Sales_Model_Order_Payment $payment */
     $payment = Mage::getModel('sales/order_payment');
     $payment->setOrder($order);
     $payment->setIsRecurring(true);
     $payment->setIsInitialFee(true);
     $customerId = $this->_recurringProfile->getCustomerId();
     $payment->setCustomerId($customerId);
     $tokenId = $additionalInfo['token']['saved_token'];
     $payment->setTokenId($tokenId);
     /** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
     $ewaySave = Mage::getModel('ewayrapid/method_saved');
     $paymentAction = Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
     if ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
         $ewaySave->authorize($payment, $this->_amount);
     } elseif ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
         $ewaySave->capture($payment, $this->_amount);
     }
     if (!$payment->getTransactionId()) {
         throw new Exception('Transaction is not available');
     } else {
         $this->_txdId = $payment->getTransactionId();
     }
     /** @todo: change status of order = "eWAY Authorised"
      *         now status order = "processing"
      */
 }
Example #4
0
 /**
  * Get sales item (quote item, order item etc) row total price including tax excluding wee
  *
  * @param Varien_Object $item
  * @return float
  */
 public function getBaseSubtotalInclTax($item)
 {
     $tax = $item->getBaseTaxAmount() + $item->getBaseDiscountTaxCompensation() - $this->_getWeeeHelper()->getBaseTotalRowTaxAppliedForWeeeTax($item);
     return $item->getBaseRowTotal() + $tax;
 }
 public function renderExport(Varien_Object $_item)
 {
     return Mage::helper('mageworx_customerplus')->displayPrices($_item->getBaseRowTotal() - $_item->getBaseDiscountAmount() + $_item->getBaseTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmount(), $_item->getRowTotal() - $_item->getDiscountAmount() + $_item->getTaxAmount() + $_item->getWeeeTaxAppliedRowAmount(), $_item->getOrderId());
 }