public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $totalTax = 0; $baseTotalTax = 0; foreach ($invoice->getAllItems() as $item) { $orderItem = $item->getOrderItem(); $orderItemTax = $orderItem->getTaxAmount(); $baseOrderItemTax = $orderItem->getBaseTaxAmount(); $orderItemQty = $orderItem->getQtyOrdered(); if ($orderItemTax && $orderItemQty) { /** * Resolve rounding problems */ if ($item->isLast()) { $tax = $orderItemTax - $orderItem->getTaxInvoiced(); $baseTax = $baseOrderItemTax - $orderItem->getBaseTaxInvoiced(); } else { $tax = $orderItemTax * $item->getQty() / $orderItemQty; $baseTax = $baseOrderItemTax * $item->getQty() / $orderItemQty; $tax = $invoice->getStore()->roundPrice($tax); $baseTax = $invoice->getStore()->roundPrice($baseTax); } $item->setTaxAmount($tax); $item->setBaseTaxAmount($baseTax); $totalTax += $tax; $baseTotalTax += $baseTax; } } $invoice->setTaxAmount($totalTax); $invoice->setBaseTaxAmount($baseTotalTax); $invoice->setGrandTotal($invoice->getGrandTotal() + $totalTax); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseTotalTax); return $this; }
/** * @param Mage_Sales_Model_Order_Invoice $invoice * * @return $this */ public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order = $invoice->getOrder(); /** * The COD fee is always added to the first invoice, so if this order already has invoices, we don't have to add * anything. */ if ($order->hasInvoices()) { return $this; } /** * Get the COD fee amounts. */ $fee = $order->getBuckarooFee(); $baseFee = $order->getBaseBuckarooFee(); /** * If no COD fee is set, there is nothing to add/ */ if ($fee < 0.01 || $baseFee < 0.01) { return $this; } /** * Add the COD fee amounts to the invoice and update the amounts for the order. */ $grandTotal = $invoice->getGrandTotal(); $baseGrandTotal = $invoice->getBaseGrandTotal(); $invoice->setBuckarooFee($fee)->setBaseBuckarooFee($baseFee)->setGrandTotal($grandTotal + $fee)->setBaseGrandTotal($baseGrandTotal + $baseFee); $order->setBuckarooFeeInvoiced($fee)->setBaseBuckarooFeeInvoiced($baseFee); return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $codTax = 0; $baseCodTax = 0; $includeCodTax = true; /** * Check Cod amount in previus invoices */ foreach ($invoice->getOrder()->getInvoiceCollection() as $previusInvoice) { if ($previusInvoice->getCodFee() && !$previusInvoice->isCanceled()) { $includeCodTax = false; } } if ($includeCodTax) { $codTax += $invoice->getOrder()->getCodTaxAmount(); $baseCodTax += $invoice->getOrder()->getBaseCodTaxAmount(); $invoice->setCodTaxAmount($invoice->getOrder()->getCodTaxAmount()); $invoice->setBaseCodTaxAmount($invoice->getOrder()->getBaseCodTaxAmount()); $invoice->getOrder()->setCodTaxAmountInvoiced($codTax); $invoice->getOrder()->setBaseCodTaxAmountInvoice($baseCodTax); } //$invoice->setTaxAmount($invoice->getTaxAmount() + $codTax); //$invoice->setBaseTaxAmount($invoice->getBaseTaxAmount() + $baseCodTax); //$invoice->setGrandTotal($invoice->getGrandTotal() + $codTax); //$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseCodTax); return $this; }
/** * Set entity * * @param Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object * @return $this */ public function setEntity($object) { $this->setEntityId($object->getId()); $this->setEntityIncrementId($object->getIncrementId()); $this->setStoreId($object->getStoreId()); return $this; }
/** * retrieves used shipping tax rate * * @param Mage_Sales_Model_Order_Invoice $invoice * * @return float */ protected function getShippingTaxRate(Mage_Sales_Model_Order_Invoice $invoice) { $taxRate = 0.0; $order = $invoice->getOrder(); $taxRate = floatval(Mage::helper('ops/payment_request')->getShippingTaxRate($order)); return $taxRate; }
/** * @param Varien_Event_Observer $observer */ public function prepareSequencenumber(Varien_Event_Observer $observer) { $event = $observer->getEvent(); /** @var $request Payone_Api_Request_Capture */ $request = $event->getRequest(); $this->invoice->setPayoneSequencenumber($request->getSequencenumber()); }
/** * Save order in AvaTax system * * @see OnePica_AvaTax_Model_Observer_SalesOrderInvoiceSaveAfter::execute() * @param Mage_Sales_Model_Order_Invoice $invoice * @param OnePica_AvaTax_Model_Records_Queue $queue * @return bool * @throws OnePica_AvaTax_Exception * @throws OnePica_AvaTax_Model_Service_Exception_Commitfailure * @throws OnePica_AvaTax_Model_Service_Exception_Unbalanced */ public function process($invoice, $queue) { $order = $invoice->getOrder(); $storeId = $order->getStoreId(); $this->setStoreId($storeId); $shippingAddress = $order->getShippingAddress() ? $order->getShippingAddress() : $order->getBillingAddress(); if (!$shippingAddress) { throw new OnePica_AvaTax_Exception($this->_getHelper()->__('There is no address attached to this order')); } /** @var OnePica_AvaTax_Model_Service_Result_Invoice $invoiceResult */ $invoiceResult = $this->_getService()->invoice($invoice, $queue); //if successful if (!$invoiceResult->getHasError()) { $message = $this->_getHelper()->__('Invoice #%s was saved to AvaTax', $invoiceResult->getDocumentCode()); $this->_getHelper()->addStatusHistoryComment($order, $message); $totalTax = $invoiceResult->getTotalTax(); if ($totalTax != $invoice->getBaseTaxAmount()) { throw new OnePica_AvaTax_Model_Service_Exception_Unbalanced('Collected: ' . $invoice->getBaseTaxAmount() . ', Actual: ' . $totalTax); } //if not successful } else { $messages = $invoiceResult->getErrors(); throw new OnePica_AvaTax_Model_Service_Exception_Commitfailure(implode(' // ', $messages)); } return true; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order = $invoice->getOrder(); $store = $order->getStore(); $invoiceTaxClass = Mage::getHelper('billmateinvoice')->getInvoiceTaxClass($store); $custTaxClassId = $order->getQuote()->getCustomerTaxClassId(); $address = $order->getBillingAddress(); $taxCalculationModel = Mage::getSingleton('tax/calculation'); /* @var $taxCalculationModel Mage_Tax_Model_Calculation */ $request = $taxCalculationModel->getRateRequest($invoice, $order->getQuote()->getBillingAddress(), $custTaxClassId, $store); if ($invoiceTaxClass) { if ($rate = $taxCalculationModel->getRate($request->setProductClassId($invoiceTaxClass))) { if (!Mage::helper('billmateinvoice')->InvoicePriceIncludesTax()) { $InvoiceTax = $invoice->getFeeAmount() * $rate / 100; $InvoiceBaseTax = $invoice->getBaseFeeAmount() * $rate / 100; } else { $InvoiceTax = $invoice->getPaymentTaxAmount(); $InvoiceBaseTax = $invoice->getBasePaymentTaxAmount(); } $InvoiceTax = $store->roundPrice($InvoiceTax); $InvoiceBaseTax = $store->roundPrice($InvoiceBaseTax); $invoice->setTaxAmount($invoice->getTaxAmount() + $InvoiceTax); $invoice->setBaseTaxAmount($invoice->getBaseTaxAmount() + $InvoiceBaseTax); $this->_saveAppliedTaxes($invoice, $taxCalculationModel->getAppliedRates($request), $InvoiceTax, $InvoiceBaseTax, $rate); } } if (!Mage::helper('billmateinvoice')->InvoicePriceIncludesTax()) { $invoice->setInvoiceTaxAmount($InvoiceTax); $invoice->setBaseInvoiceTaxAmount($InvoiceBaseTax); } $invoice->setGrandTotal($invoice->getGrandTotal() + $invoice->getPaymentTaxAmount()); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $invoice->getBasePaymentTaxAmount()); return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order = $invoice->getOrder(); if ($order->getWebposChange() < 0.0001) { return; } $invoice->setWebposChange($order->getWebposChange())->setWebposBaseChange($order->getWebposBaseChange()); }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { /** * Check order grand total and invoice amounts */ if ($invoice->isLast()) { // } return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order_id = $invoice->getOrderId(); $order = Mage::getModel('sales/order')->load($order_id); $invoice->setFeeAmount($order->getFeeAmount()); $invoice->setBaseFeeAmount($order->getBaseFeeAmount()); $invoice->setGrandTotal($invoice->getGrandTotal() + $invoice->getFeeAmount()); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $invoice->getBaseFeeAmount()); return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order = $invoice->getOrder(); if ($order->getPayment()->getMethodInstance()->getCode() != 'cashondelivery') { return $this; } if (!$order->getCodFee()) { return $this; } foreach ($invoice->getOrder()->getInvoiceCollection() as $previusInvoice) { if ($previusInvoice->getCodAmount() && !$previusInvoice->isCanceled()) { $includeCodTax = false; } } $baseCodFee = $order->getBaseCodFee(); $baseCodFeeInvoiced = $order->getBaseCodFeeInvoiced(); $baseInvoiceTotal = $invoice->getBaseGrandTotal(); $codFee = $order->getCodFee(); $codFeeInvoiced = $order->getCodFeeInvoiced(); $invoiceTotal = $invoice->getGrandTotal(); if (!$baseCodFee || $baseCodFeeInvoiced == $baseCodFee) { return $this; } $baseCodFeeToInvoice = $baseCodFee - $baseCodFeeInvoiced; $codFeeToInvoice = $codFee - $codFeeInvoiced; $baseInvoiceTotal = $baseInvoiceTotal + $baseCodFeeToInvoice; $invoiceTotal = $invoiceTotal + $codFeeToInvoice; $invoice->setBaseGrandTotal($baseInvoiceTotal); $invoice->setGrandTotal($invoiceTotal); $invoice->setBaseCodFee($baseCodFeeToInvoice); $invoice->setCodFee($codFeeToInvoice); $order->setBaseCodFeeInvoiced($baseCodFeeInvoiced + $baseCodFeeToInvoice); $order->setCodFeeInvoiced($codFeeInvoiced + $codFeeToInvoice); return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $baseDiscount = 0; $discount = 0; foreach ($invoice->getAllItems() as $item) { if ($item->getOrderItem()->isDummy()) { continue; } $orderItem = $item->getOrderItem(); $orderItemDiscount = (double) $orderItem->getAffiliateplusAmount(); $baseOrderItemDiscount = (double) $orderItem->getBaseAffiliateplusAmount(); $orderItemQty = $orderItem->getQtyOrdered(); if ($orderItemDiscount && $orderItemQty) { $discount -= $orderItemDiscount * $item->getQty() / $orderItemQty; $baseDiscount -= $baseOrderItemDiscount * $item->getQty() / $orderItemQty; } } if (!floatval($baseDiscount)) { $order = $invoice->getOrder(); $baseDiscount = $order->getBaseAffiliateplusDiscount(); $discount = $order->getAffiliateplusDiscount(); } if (floatval($baseDiscount)) { $baseDiscount = Mage::app()->getStore()->roundPrice($baseDiscount); $discount = Mage::app()->getStore()->roundPrice($discount); $invoice->setBaseAffiliateplusDiscount($baseDiscount); $invoice->setAffiliateplusDiscount($discount); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseDiscount); $invoice->setGrandTotal($invoice->getGrandTotal() + $discount); } return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order = $invoice->getOrder(); if (!preg_match('/^capayable/', $order->getPayment()->getMethodInstance()->getCode())) { return $this; } if (!$order->getCapayableFee()) { return $this; } foreach ($invoice->getOrder()->getInvoiceCollection() as $prevInvoice) { if ($prevInvoice->getCapayableFeeAmount() && !$prevInvoice->isCanceled()) { $includeFeeTax = FALSE; } } $basePaymentFee = $order->getBaseCapayableFee(); $basePaymentFeeInvoiced = $order->getBaseCapayableFeeInvoiced(); $baseInvoiceTotal = $invoice->getBaseGrandTotal(); $paymentFee = $order->getCapayableFee(); $paymentFeeInvoiced = $order->getCapayableFeeInvoiced(); $invoiceTotal = $invoice->getGrandTotal(); if (!$basePaymentFee || $basePaymentFeeInvoiced == $basePaymentFee) { return $this; } $basePaymentFeeToInvoice = $basePaymentFee - $basePaymentFeeInvoiced; $paymentFeeToInvoice = $paymentFee - $paymentFeeInvoiced; $baseInvoiceTotal = $baseInvoiceTotal + $basePaymentFeeToInvoice; $invoiceTotal = $invoiceTotal + $paymentFeeToInvoice; $invoice->setBaseGrandTotal($baseInvoiceTotal); $invoice->setGrandTotal($invoiceTotal); $invoice->setBaseCapayableFee($basePaymentFeeToInvoice); $invoice->setCapayableFee($paymentFeeToInvoice); $order->setBaseCapayableFeeInvoiced($basePaymentFeeInvoiced + $basePaymentFeeToInvoice); $order->setCapayableFeeInvoiced($paymentFeeInvoiced + $paymentFeeToInvoice); return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order = $invoice->getOrder(); $feeAmountLeft = floatval($order->getDamageWaiverAmount() - $order->getDamageWaiverAmountInvoiced()); $baseFeeAmountLeft = floatval($order->getBaseDamageWaiverAmount() - $order->getBaseDamageWaiverAmountInvoiced()); if ($baseFeeAmountLeft > 0) { $invoice->setDamageWaiverAmount($feeAmountLeft); $invoice->setBaseDamageWaiverAmount($baseFeeAmountLeft); } return $this; }
/** * Collect total cost of invoiced items * * @param Mage_Sales_Model_Order_Invoice $invoice * @return Mage_Sales_Model_Order_Invoice_Total_Cost */ public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $baseInvoiceTotalCost = 0; foreach ($invoice->getAllItems() as $item) { if (!$item->getHasChildren()) { $baseInvoiceTotalCost += $item->getBaseCost() * $item->getQty(); } } $invoice->setBaseCost($baseInvoiceTotalCost); return $this; }
/** * Returns the currency compliant to ISO 4217 (3 char code) * @return string 3 Character long currency code * * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order|Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object * @return string */ public function getCurrency($object) { $currency = $object->getBaseCurrencyCode(); if (!Mage::helper('paymill/optionHelper')->isBaseCurrency()) { if ($object instanceof Mage_Sales_Model_Quote) { $currency = $object->getQuoteCurrencyCode(); } else { $currency = $object->getOrderCurrencyCode(); } } return $currency; }
protected function extractFromInvoicedShippingMethod(Mage_Sales_Model_Order_Invoice $invoice) { if ($this->creditmemo['shipping_amount'] > 0) { $this->additionalParams['ITEMID' . $this->itemIdx] = 'SHIPPING'; $this->additionalParams['ITEMNAME' . $this->itemIdx] = substr($invoice->getOrder()->getShippingDescription(), 0, 30); $this->additionalParams['ITEMPRICE' . $this->itemIdx] = $this->getOpsDataHelper()->getAmount($this->creditmemo['shipping_amount']); $this->amount += $this->getOpsDataHelper()->getAmount($this->creditmemo['shipping_amount']); $this->additionalParams['ITEMQUANT' . $this->itemIdx] = 1; $this->additionalParams['ITEMVATCODE' . $this->itemIdx] = $this->getShippingTaxRate($invoice) . '%'; $this->additionalParams['TAXINCLUDED' . $this->itemIdx] = 1; ++$this->itemIdx; } }
/** * Collect shipping amount to be invoiced based on already invoiced amount * * @param Mage_Sales_Model_Order_Invoice $invoice * @return $this */ public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $previousInvoices = $invoice->getOrder()->getInvoiceCollection(); if ($invoice->getShippingAmount() > 0) { return $this; } $order = $invoice->getOrder(); $shippingAmount = $order->getShippingAmount() - $order->getShippingInvoiced() - $order->getShippingRefunded(); $baseShippingAmount = $order->getBaseShippingAmount() - $order->getBaseShippingInvoiced() - $order->getBaseShippingRefunded(); $invoice->setShippingAmount($shippingAmount); $invoice->setBaseShippingAmount($baseShippingAmount); $invoice->setGrandTotal($invoice->getGrandTotal() + $shippingAmount); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseShippingAmount); return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order = $invoice->getOrder(); $totalDiscountAmount = $order->getMwStorecreditDiscountShow(); $baseTotalDiscountAmount = $order->getMwStorecreditDiscount(); /* $invoice->setGrandTotal($invoice->getGrandTotal() - $totalDiscountAmount); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $baseTotalDiscountAmount); */ $invoice->setGrandTotal($invoice->getGrandTotal()); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal()); $invoice->setMwStorecredit($order->getMwStorecredit()); $invoice->setMwStorecreditBuyCredit($order->getMwStorecreditBuyCredit()); $invoice->setMwStorecreditDiscount($baseTotalDiscountAmount); $invoice->setMwStorecreditDiscountShow($totalDiscountAmount); return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $invoice->setWebposGiftwrapAmount(0); $orderGiftwrapAmount = $invoice->getOrder()->getWebposGiftwrapAmount(); $baseOrderShippingAmount = $invoice->getOrder()->getWebposGiftwrapAmount(); if ($orderGiftwrapAmount) { $invoice->setWebposGiftwrapAmount($orderGiftwrapAmount); $invoice->setGrandTotal($invoice->getGrandTotal() + $orderGiftwrapAmount); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $orderGiftwrapAmount); } return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $creditmemo) { $creditmemo->setOnestepcheckoutGiftwrapAmount(0); $orderGiftwrapAmount = $creditmemo->getOrder()->getOnestepcheckoutGiftwrapAmount(); $baseOrderShippingAmount = $creditmemo->getOrder()->getOnestepcheckoutGiftwrapAmount(); if ($orderGiftwrapAmount) { $creditmemo->setOnestepcheckoutGiftwrapAmount($orderGiftwrapAmount); $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $orderGiftwrapAmount); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $orderGiftwrapAmount); } return $this; }
/** * @magentoConfigFixture current_store design/theme/full_name default/default/default * @magentoDataFixture Mage/Sales/_files/order.php */ public function testSendEmail() { $order = new Mage_Sales_Model_Order(); $order->loadByIncrementId('100000001'); $order->setCustomerEmail('*****@*****.**'); $invoice = new Mage_Sales_Model_Order_Invoice(); $invoice->setOrder($order); $payment = $order->getPayment(); $paymentInfoBlock = Mage::helper('Mage_Payment_Helper_Data')->getInfoBlock($payment); $paymentInfoBlock->setArea('invalid-area'); $payment->setBlockMock($paymentInfoBlock); $this->assertEmpty($invoice->getEmailSent()); $invoice->sendEmail(true); $this->assertNotEmpty($invoice->getEmailSent()); $this->assertEquals('frontend', $paymentInfoBlock->getArea()); }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $invoice->setSurchargeAmount(0); $invoice->setBaseSurchargeAmount(0); $orderSurchargeAmount = Mage::helper('sagepaysuite/surcharge')->getAmount($invoice->getOrder()->getId()); if (!$orderSurchargeAmount) { $orderSurchargeAmount = Mage::getSingleton('core/session')->getData('surchargeamount'); } if ($orderSurchargeAmount) { $invoice->setSurchargeAmount($orderSurchargeAmount); $invoice->setBaseSurchargeAmount($orderSurchargeAmount); $invoice->setGrandTotal($invoice->getGrandTotal() + $orderSurchargeAmount); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $orderSurchargeAmount); } return $this; }
public function getData($key = '', $index = null) { switch ($key) { case '0days': return $this->getCurrentTotal(); break; case '30days': return $this->get30DayTotal(); break; case '60days': return $this->get60DayTotal(); break; case '90days': return $this->get90DayTotal(); break; case '120days': return $this->get120DayTotal(); break; case '180days': return $this->get180DayTotal(); break; case '240days': return $this->get240DayTotal(); break; default: return parent::getData($key, $index); } }
/** * Collect invoice subtotal * * @param Mage_Sales_Model_Order_Invoice $invoice * @return Mage_Sales_Model_Order_Invoice_Total_Subtotal */ public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $subtotal = 0; $baseSubtotal = 0; $subtotalInclTax = 0; $baseSubtotalInclTax = 0; $order = $invoice->getOrder(); foreach ($invoice->getAllItems() as $item) { if ($item->getOrderItem()->isDummy()) { continue; } $item->calcRowTotal(); $subtotal += $item->getRowTotal(); $baseSubtotal += $item->getBaseRowTotal(); $subtotalInclTax += $item->getRowTotalInclTax(); $baseSubtotalInclTax += $item->getBaseRowTotalInclTax(); } $allowedSubtotal = $order->getSubtotal() - $order->getSubtotalInvoiced(); $baseAllowedSubtotal = $order->getBaseSubtotal() - $order->getBaseSubtotalInvoiced(); $allowedSubtotalInclTax = $allowedSubtotal + $order->getHiddenTaxAmount() + $order->getTaxAmount() - $order->getTaxInvoiced() - $order->getHiddenTaxInvoiced(); $baseAllowedSubtotalInclTax = $baseAllowedSubtotal + $order->getBaseHiddenTaxAmount() + $order->getBaseTaxAmount() - $order->getBaseTaxInvoiced() - $order->getBaseHiddenTaxInvoiced(); /** * Check if shipping tax calculation is included to current invoice. */ $includeShippingTax = true; foreach ($invoice->getOrder()->getInvoiceCollection() as $previousInvoice) { if ($previousInvoice->getShippingAmount() && !$previousInvoice->isCanceled()) { $includeShippingTax = false; break; } } if ($includeShippingTax) { $allowedSubtotalInclTax -= $order->getShippingTaxAmount(); $baseAllowedSubtotalInclTax -= $order->getBaseShippingTaxAmount(); } else { $allowedSubtotalInclTax += $order->getShippingHiddenTaxAmount(); $baseAllowedSubtotalInclTax += $order->getBaseShippingHiddenTaxAmount(); } if ($invoice->isLast()) { $subtotal = $allowedSubtotal; $baseSubtotal = $baseAllowedSubtotal; $subtotalInclTax = $allowedSubtotalInclTax; $baseSubtotalInclTax = $baseAllowedSubtotalInclTax; } else { $subtotal = min($allowedSubtotal, $subtotal); $baseSubtotal = min($baseAllowedSubtotal, $baseSubtotal); $subtotalInclTax = min($allowedSubtotalInclTax, $subtotalInclTax); $baseSubtotalInclTax = min($baseAllowedSubtotalInclTax, $baseSubtotalInclTax); } $invoice->setSubtotal($subtotal); $invoice->setBaseSubtotal($baseSubtotal); $invoice->setSubtotalInclTax($subtotalInclTax); $invoice->setBaseSubtotalInclTax($baseSubtotalInclTax); $invoice->setGrandTotal($invoice->getGrandTotal() + $subtotal); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseSubtotal); return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order = $invoice->getOrder(); if ($order->getWebposCash() < 0.0001 || $order->getGrandTotal() < 0.0001) { return; } if ($invoice->isLast()) { $cash = $order->getWebposCash(); $baseCash = $order->getWebposBaseCash(); foreach ($order->getInvoiceCollection() as $existedInvoice) { if ($cash > 0.0001) { $cash -= $existedInvoice->getWebposCash(); $baseCash -= $existedInvoice->getWebposBaseCash(); } } } else { $ratio = $invoice->getGrandTotal() / $order->getGrandTotal(); $cash = $order->getWebposCash() * $ratio; $baseCash = $order->getWebposBaseCash() * $ratio; $maxcash = $order->getWebposCash(); $maxbaseCash = $order->getWebposBaseCash(); foreach ($order->getInvoiceCollection() as $existedInvoice) { if ($maxcash > 0.0001) { $maxcash -= $existedInvoice->getWebposCash(); $maxbaseCash -= $existedInvoice->getWebposBaseCash(); } } if ($cash > $maxcash) { $cash = $maxcash; $baseCash = $maxbaseCash; } } if ($cash > 0.0001) { $invoice->setWebposCash($cash)->setWebposBaseCash($baseCash); /* if ($invoice->getGrandTotal() <= $cash) { $invoice->setBaseGrandTotal(0.0) ->setGrandTotal(0.0); } else { $invoice->setGrandTotal($invoice->getGrandTotal() - $cash) ->setBaseGrandTotal($invoice->getBaseGrandTotal() - $baseCash); } */ } }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order = $invoice->getOrder(); $paymentMethod = $order->getPayment()->getMethod(); if ($this->getHelper()->isBillpayPayment($paymentMethod)) { $net = $order->getBillpayChargedFeeNet(); $gross = $order->getBillpayChargedFee(); $baseNet = $order->getBaseBillpayChargedFeeNet(); $baseGross = $order->getBaseBillpayChargedFee(); if ($this->getHelper()->getConfigData('fee/display_incl_tax_admin', $order->getStoreId())) { $invoice->setBillpayChargedFeeAmount($gross); $invoice->setBaseBillpayChargedFeeAmount($baseGross); } else { $invoice->setBillpayChargedFeeAmount($net); $invoice->setBaseBillpayChargedFeeAmount($baseNet); } if (isset($gross) && $gross > 0) { $feeTaxAmount = $gross - $net; $baseFeeTaxAmount = $baseGross - $baseNet; Mage::helper('billpay')->setFeeOnInvoice($invoice, $baseNet, $baseGross, $net, $gross); // We have to set the value for subtotal incl. tax here when a fee tax is present // Otherwise the value will be calculated wrongly in Mage_Tax_Block_Sales_Order_Tax::_initSubtotal if (!$invoice->getSubtotalInclTax() && $feeTaxAmount > 0) { $subtotalInclTax = $invoice->getSubtotal() + $invoice->getTaxAmount() - $invoice->getShippingTaxAmount() - $feeTaxAmount; $invoice->setSubtotalInclTax($subtotalInclTax); } // hack start (only valid for complete activation!) //$this->adjustFeeAmount($invoice, $feeTaxAmount, $baseFeeTaxAmount); } } return $this; }
/** * @param Mage_Sales_Model_Order_Invoice $invoice * * @return $this */ public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $order = $invoice->getOrder(); /** * The COD fee tax is always added to the first invoice, so if this order already has invoices, we don't have to * add anything. */ if ($order->hasInvoices()) { return $this; } /** * Get the COD fee tax amounts. */ $feeTax = $order->getBuckarooFeeTax(); $baseFeeTax = $order->getBaseBuckarooFeeTax(); /** * If no COD fee tax is set, there is nothing to add/ */ if ($feeTax < 0.01 || $baseFeeTax < 0.01) { return $this; } /** * Add the COD fee tax amounts to the invoice. */ $invoice->setBuckarooFeeTax($feeTax)->setBaseBuckarooFeeTax($baseFeeTax)->setTaxAmount($invoice->getTaxAmount() + $feeTax)->setBaseTaxAmount($invoice->getBaseTaxAmount() + $baseFeeTax); /** * For all versions except 1.13.0.X and 1.8.0.X we need to add the Payment fee tax to the grand total amounts. */ $helper = Mage::helper('buckaroo3extended'); //fix for Magento 1.6.2.0 for showing correctly taxes in the order totals if (!$helper->isEnterprise() && version_compare(Mage::getVersion(), '1.6.2.0', '==')) { $grandTotal = $invoice->getGrandTotal(); $baseGrandTotal = $invoice->getBaseGrandTotal(); } else { $grandTotal = $invoice->getGrandTotal() + $feeTax; $baseGrandTotal = $invoice->getBaseGrandTotal() + $baseFeeTax; } $invoice->setGrandTotal($grandTotal)->setBaseGrandTotal($baseGrandTotal); /** * Update the order's COD fee tax amounts. */ $order->setBuckarooFeeTaxInvoiced($feeTax)->setBaseBuckarooFeeTaxInvoiced($baseFeeTax); return $this; }
public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $invoice->setWebposDiscountAmount(0); $orderWebposDiscount = $invoice->getOrder()->getWebposDiscountAmount(); if ($orderWebposDiscount) { $invoice->setWebposDiscountAmount($orderWebposDiscount); $invoice->setGrandTotal($invoice->getGrandTotal() - $orderWebposDiscount); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $orderWebposDiscount); } return $this; }