本文整理汇总了PHP中Mage_Sales_Model_Order_Creditmemo::getStore方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Creditmemo::getStore方法的具体用法?PHP Mage_Sales_Model_Order_Creditmemo::getStore怎么用?PHP Mage_Sales_Model_Order_Creditmemo::getStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Creditmemo
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Creditmemo::getStore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$totalTax = 0;
$baseTotalTax = 0;
foreach ($creditmemo->getAllItems() as $item) {
$orderItemTax = $item->getOrderItem()->getTaxAmount();
$baseOrderItemTax = $item->getOrderItem()->getBaseTaxAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemTax && $orderItemQty) {
$tax = $orderItemTax * $item->getQty() / $orderItemQty;
$baseTax = $baseOrderItemTax * $item->getQty() / $orderItemQty;
$tax = $creditmemo->getStore()->roundPrice($tax);
$baseTax = $creditmemo->getStore()->roundPrice($baseTax);
$item->setTaxAmount($tax);
$item->setBaseTaxAmount($baseTax);
$totalTax += $tax;
$baseTotalTax += $baseTax;
}
}
$creditmemo->setTaxAmount($totalTax);
$creditmemo->setBaseTaxAmount($baseTotalTax);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
return $this;
}
示例2: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setDiscountAmount(0);
$creditmemo->setBaseDiscountAmount(0);
$totalDiscountAmount = 0;
$baseTotalDiscountAmount = 0;
foreach ($creditmemo->getAllItems() as $item) {
$orderItemDiscount = (double) $item->getOrderItem()->getDiscountAmount();
$baseOrderItemDiscount = (double) $item->getOrderItem()->getBaseDiscountAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemDiscount && $orderItemQty) {
$discount = $orderItemDiscount * $item->getQty() / $orderItemQty;
$baseDiscount = $baseOrderItemDiscount * $item->getQty() / $orderItemQty;
$discount = $creditmemo->getStore()->roundPrice($discount);
$baseDiscount = $creditmemo->getStore()->roundPrice($baseDiscount);
$item->setDiscountAmount($discount);
$item->setBaseDiscountAmount($baseDiscount);
$totalDiscountAmount += $discount;
$baseTotalDiscountAmount += $baseDiscount;
}
}
$creditmemo->setDiscountAmount($totalDiscountAmount);
$creditmemo->setBaseDiscountAmount($baseTotalDiscountAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $totalDiscountAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseTotalDiscountAmount);
return $this;
}
示例3: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setGomageGiftWrapAmount(0);
$creditmemo->setBaseGomageGiftWrapAmount(0);
$order = $creditmemo->getOrder();
$totalGomageGiftWrapAmount = 0;
$baseTotalGomageGiftWrapAmount = 0;
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$orderItemGomageGiftWrap = (double) $item->getOrderItem()->getGomageGiftWrapAmount();
$baseOrderItemGomageGiftWrap = (double) $item->getOrderItem()->getBaseGomageGiftWrapAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemGomageGiftWrap && $orderItemQty) {
$GomageGiftWrap = $orderItemGomageGiftWrap * $item->getQty() / $orderItemQty;
$baseGomageGiftWrap = $baseOrderItemGomageGiftWrap * $item->getQty() / $orderItemQty;
$GomageGiftWrap = $creditmemo->getStore()->roundPrice($GomageGiftWrap);
$baseGomageGiftWrap = $creditmemo->getStore()->roundPrice($baseGomageGiftWrap);
$item->setGomageGiftWrapAmount($GomageGiftWrap);
$item->setBaseGomageGiftWrapAmount($baseGomageGiftWrap);
$totalGomageGiftWrapAmount += $GomageGiftWrap;
$baseTotalGomageGiftWrapAmount += $baseGomageGiftWrap;
}
}
$creditmemo->setGomageGiftWrapAmount($totalGomageGiftWrapAmount);
$creditmemo->setBaseGomageGiftWrapAmount($baseTotalGomageGiftWrapAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalGomageGiftWrapAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalGomageGiftWrapAmount);
return $this;
}
示例4: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$shippingTaxAmount = 0;
$baseShippingTaxAmount = 0;
$totalTax = 0;
$baseTotalTax = 0;
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$orderItemTax = $item->getOrderItem()->getTaxAmount();
$baseOrderItemTax = $item->getOrderItem()->getBaseTaxAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemTax && $orderItemQty) {
$tax = $orderItemTax * $item->getQty() / $orderItemQty;
$baseTax = $baseOrderItemTax * $item->getQty() / $orderItemQty;
$tax = $creditmemo->getStore()->roundPrice($tax);
$baseTax = $creditmemo->getStore()->roundPrice($baseTax);
$item->setTaxAmount($tax);
$item->setBaseTaxAmount($baseTax);
$totalTax += $tax;
$baseTotalTax += $baseTax;
}
}
if ($invoice = $creditmemo->getInvoice()) {
$totalTax += $invoice->getShippingTaxAmount();
$baseTotalTax += $invoice->getBaseShippingTaxAmount();
$creditmemo->setShippingTaxAmount($invoice->getShippingTaxAmount());
$creditmemo->setBaseShippingTaxAmount($invoice->getBaseShippingTaxAmount());
} else {
$shippingAmount = $creditmemo->getOrder()->getBaseShippingAmount();
$shippingRefundedAmount = $creditmemo->getOrder()->getBaseShippingRefunded();
$shippingTaxAmount = 0;
$baseShippingTaxAmount = 0;
if ($shippingAmount - $shippingRefundedAmount > $creditmemo->getShippingAmount()) {
$shippingTaxAmount = $creditmemo->getShippingAmount() * ($creditmemo->getOrder()->getShippingTaxAmount() / $shippingAmount);
$baseShippingTaxAmount = $creditmemo->getBaseShippingAmount() * ($creditmemo->getOrder()->getBaseShippingTaxAmount() / $shippingAmount);
$shippingTaxAmount = $creditmemo->getStore()->roundPrice($shippingTaxAmount);
$baseShippingTaxAmount = $creditmemo->getStore()->roundPrice($baseShippingTaxAmount);
} elseif ($shippingAmount - $shippingRefundedAmount == $creditmemo->getShippingAmount()) {
$shippingTaxAmount = $creditmemo->getOrder()->getShippingTaxAmount() - $creditmemo->getOrder()->getShippingTaxRefunded();
$baseShippingTaxAmount = $creditmemo->getOrder()->getBaseShippingTaxAmount() - $creditmemo->getOrder()->getBaseShippingTaxRefunded();
}
$totalTax += $shippingTaxAmount;
$baseTotalTax += $baseShippingTaxAmount;
}
$tmpBaseTotalTax = $baseTotalTax - ($creditmemo->getOrder()->getBaseTaxRefunded() - $creditmemo->getOrder()->getBaseShippingTaxRefunded());
if ($tmpBaseTotalTax < 0) {
$baseTotalTax = 0;
$totalTax = 0;
}
$creditmemo->setTaxAmount($totalTax);
$creditmemo->setBaseTaxAmount($baseTotalTax);
$creditmemo->setShippingTaxAmount($shippingTaxAmount);
$creditmemo->setBaseShippingTaxAmount($baseShippingTaxAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
return $this;
}
示例5: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$store = $creditmemo->getStore();
$totalTax = 0;
$baseTotalTax = 0;
$weeeTaxAmount = 0;
$baseWeeeTaxAmount = 0;
foreach ($creditmemo->getAllItems() as $item) {
$orderItem = $item->getOrderItem();
if ($orderItem->isDummy()) {
continue;
}
$orderItemQty = $orderItem->getQtyOrdered();
$weeeRowDiscountAmount = $orderItem->getDiscountAppliedForWeeeTax();
$weeeDiscountAmount = $creditmemo->roundPrice($weeeRowDiscountAmount / $orderItemQty * $item->getQty(), 'regular', true);
$baseWeeeRowDiscountAmount = $orderItem->getBaseDiscountAppliedForWeeeTax();
$baseWeeeDiscountAmount = $creditmemo->roundPrice($baseWeeeRowDiscountAmount / $orderItemQty * $item->getQty(), 'base', true);
$weeeAmountExclTax = (Mage::helper('weee')->getWeeeTaxInclTax($item) - Mage::helper('weee')->getTotalTaxAppliedForWeeeTax($item)) * $item->getQty();
$totalTax += $weeeAmountExclTax - $weeeDiscountAmount;
$baseWeeeAmountExclTax = (Mage::helper('weee')->getBaseWeeeTaxInclTax($item) - Mage::helper('weee')->getBaseTotalTaxAppliedForWeeeTax($item)) * $item->getQty();
$baseTotalTax += $baseWeeeAmountExclTax - $baseWeeeDiscountAmount;
$item->setWeeeTaxAppliedRowAmount($weeeAmountExclTax);
$item->setBaseWeeeTaxAppliedRowAmount($baseWeeeAmountExclTax);
$weeeTaxAmount += Mage::helper('weee')->getWeeeTaxInclTax($item) * $item->getQty();
$baseWeeeTaxAmount += Mage::helper('weee')->getBaseWeeeTaxInclTax($item) * $item->getQty();
$newApplied = array();
$applied = Mage::helper('weee')->getApplied($item);
foreach ($applied as $one) {
$one['base_row_amount'] = $one['base_amount'] * $item->getQty();
$one['row_amount'] = $one['amount'] * $item->getQty();
$one['base_row_amount_incl_tax'] = $one['base_amount_incl_tax'] * $item->getQty();
$one['row_amount_incl_tax'] = $one['amount_incl_tax'] * $item->getQty();
$one['weee_discount'] = $weeeDiscountAmount;
$one['base_weee_discount'] = $baseWeeeDiscountAmount;
$newApplied[] = $one;
}
Mage::helper('weee')->setApplied($item, $newApplied);
$item->setWeeeTaxRowDisposition($item->getWeeeTaxDisposition() * $item->getQty());
$item->setBaseWeeeTaxRowDisposition($item->getBaseWeeeTaxDisposition() * $item->getQty());
}
/*
* please refer the description in weee - invoice section for reasoning
*/
if (Mage::helper('weee')->includeInSubtotal($store)) {
$creditmemo->setSubtotal($creditmemo->getSubtotal() + $totalTax);
$creditmemo->setBaseSubtotal($creditmemo->getBaseSubtotal() + $baseTotalTax);
} else {
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $totalTax);
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $baseTotalTax);
}
//Increment the subtotal
$creditmemo->setSubtotalInclTax($creditmemo->getSubtotalInclTax() + $weeeTaxAmount);
$creditmemo->setBaseSubtotalInclTax($creditmemo->getBaseSubtotalInclTax() + $baseWeeeTaxAmount);
//Increment the grand total
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
return $this;
}
示例6: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setDiscountAmount(0);
$creditmemo->setBaseDiscountAmount(0);
$order = $creditmemo->getOrder();
$totalDiscountAmount = 0;
$baseTotalDiscountAmount = 0;
/**
* Calculate how much shipping discount should be applied
* basing on how much shipping should be refunded.
*/
$baseShippingAmount = $creditmemo->getBaseShippingAmount();
if ($baseShippingAmount) {
$baseShippingDiscount = $baseShippingAmount * $order->getBaseShippingDiscountAmount() / $order->getBaseShippingAmount();
$shippingDiscount = $order->getShippingAmount() * $baseShippingDiscount / $order->getBaseShippingAmount();
$totalDiscountAmount = $totalDiscountAmount + $shippingDiscount;
$baseTotalDiscountAmount = $baseTotalDiscountAmount + $baseShippingDiscount;
}
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$orderItemDiscount = (double) $item->getOrderItem()->getDiscountAmount();
$baseOrderItemDiscount = (double) $item->getOrderItem()->getBaseDiscountAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemDiscount && $orderItemQty) {
$discount = $orderItemDiscount * $item->getQty() / $orderItemQty;
$baseDiscount = $baseOrderItemDiscount * $item->getQty() / $orderItemQty;
$discount = $creditmemo->getStore()->roundPrice($discount);
$baseDiscount = $creditmemo->getStore()->roundPrice($baseDiscount);
$item->setDiscountAmount($discount);
$item->setBaseDiscountAmount($baseDiscount);
$totalDiscountAmount += $discount;
$baseTotalDiscountAmount += $baseDiscount;
}
}
$creditmemo->setDiscountAmount($totalDiscountAmount);
$creditmemo->setBaseDiscountAmount($baseTotalDiscountAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $totalDiscountAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseTotalDiscountAmount);
return $this;
}
示例7: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$store = $creditmemo->getStore();
$totalTax = 0;
$baseTotalTax = 0;
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
$totalTax += $item->getWeeeTaxAppliedAmount() * $item->getQty();
$baseTotalTax += $item->getBaseWeeeTaxAppliedAmount() * $item->getQty();
$newApplied = array();
$applied = Mage::helper('weee')->getApplied($item);
foreach ($applied as $one) {
$one['base_row_amount'] = $one['base_amount'] * $item->getQty();
$one['row_amount'] = $one['amount'] * $item->getQty();
$one['base_row_amount_incl_tax'] = $one['base_amount_incl_tax'] * $item->getQty();
$one['row_amount_incl_tax'] = $one['amount_incl_tax'] * $item->getQty();
$newApplied[] = $one;
}
Mage::helper('weee')->setApplied($item, $newApplied);
$item->setWeeeTaxRowDisposition($item->getWeeeTaxDisposition() * $item->getQty());
$item->setBaseWeeeTaxRowDisposition($item->getBaseWeeeTaxDisposition() * $item->getQty());
}
if (Mage::helper('weee')->includeInSubtotal($store)) {
$creditmemo->setSubtotal($creditmemo->getSubtotal() + $totalTax);
$creditmemo->setBaseSubtotal($creditmemo->getBaseSubtotal() + $baseTotalTax);
} else {
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $totalTax);
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $baseTotalTax);
}
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
return $this;
}
示例8: isObjectActionable
/**
* Determines if the object (quote, invoice, or credit memo) should use AvaTax services
*
* @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
* @param Mage_Sales_Model_Quote_Address $shippingAddress
* @return bool
*/
public function isObjectActionable($object, $shippingAddress = null)
{
$storeId = $object->getStore()->getId();
//is action enabled?
$action = $object->getOrder() ? OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT : OnePica_AvaTax_Model_Config::ACTION_CALC;
if (Mage::getStoreConfig('tax/avatax/action', $storeId) < $action) {
return false;
}
if (!$shippingAddress) {
$shippingAddress = $object->getShippingAddress();
}
if (!$shippingAddress) {
$shippingAddress = $object->getBillingAddress();
}
//is the region filtered?
if (!$this->isAddressActionable($shippingAddress, $storeId, OnePica_AvaTax_Model_Config::REGIONFILTER_TAX)) {
return false;
}
return true;
}
示例9: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$shippingTaxAmount = 0;
$baseShippingTaxAmount = 0;
$totalTax = 0;
$baseTotalTax = 0;
$totalHiddenTax = 0;
$baseTotalHiddenTax = 0;
$order = $creditmemo->getOrder();
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$orderItem = $item->getOrderItem();
$orderItemTax = $item->getOrderItem()->getTaxAmount();
$baseOrderItemTax = $item->getOrderItem()->getBaseTaxAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemTax && $orderItemQty) {
/**
* Check item tax amount
*/
if ($item->isLast()) {
$tax = $orderItemTax - $item->getOrderItem()->getTaxRefunded() - $item->getOrderItem()->getTaxCanceled();
$baseTax = $baseOrderItemTax - $item->getOrderItem()->getTaxRefunded() - $item->getOrderItem()->getTaxCanceled();
$hiddenTax = $orderItem->getHiddenTaxAmount() - $orderItem->getHiddenTaxRefunded() - $item->getOrderItem()->getHiddenTaxCanceled();
$baseHiddenTax = $orderItem->getBaseHiddenTaxAmount() - $orderItem->getBaseHiddenTaxRefunded() - $item->getOrderItem()->getHiddenTaxCanceled();
} else {
$tax = $orderItemTax * $item->getQty() / $orderItemQty;
$baseTax = $baseOrderItemTax * $item->getQty() / $orderItemQty;
$hiddenTax = $orderItem->getHiddenTaxAmount() * $item->getQty() / $orderItemQty;
$baseHiddenTax = $orderItem->getBaseHiddenTaxAmount() * $item->getQty() / $orderItemQty;
$tax = $creditmemo->getStore()->roundPrice($tax);
$baseTax = $creditmemo->getStore()->roundPrice($baseTax);
$hiddenTax = $creditmemo->getStore()->roundPrice($hiddenTax);
$baseHiddenTax = $creditmemo->getStore()->roundPrice($baseHiddenTax);
}
$item->setTaxAmount($tax);
$item->setBaseTaxAmount($baseTax);
$item->setHiddenTaxAmount($hiddenTax);
$item->setBaseHiddenTaxAmount($baseHiddenTax);
$totalTax += $tax;
$baseTotalTax += $baseTax;
$totalHiddenTax += $hiddenTax;
$baseTotalHiddenTax += $baseHiddenTax;
}
}
if ($invoice = $creditmemo->getInvoice()) {
//recalculate tax amounts in case if refund shipping value was changed
if ($order->getBaseShippingAmount() && $creditmemo->getBaseShippingAmount()) {
$taxFactor = $creditmemo->getBaseShippingAmount() / $order->getBaseShippingAmount();
$shippingTaxAmount = $invoice->getShippingTaxAmount() * $taxFactor;
$baseShippingTaxAmount = $invoice->getBaseShippingTaxAmount() * $taxFactor;
$totalHiddenTax += $invoice->getShippingHiddenTaxAmount() * $taxFactor;
$baseTotalHiddenTax += $invoice->getBaseShippingHiddenTaxAmount() * $taxFactor;
$shippingHiddenTaxAmount = $invoice->getShippingHiddenTaxAmount() * $taxFactor;
$baseShippingHiddenTaxAmount = $invoice->getBaseShippingHiddenTaxAmount() * $taxFactor;
$shippingTaxAmount = $creditmemo->getStore()->roundPrice($shippingTaxAmount);
$baseShippingTaxAmount = $creditmemo->getStore()->roundPrice($baseShippingTaxAmount);
$totalHiddenTax = $creditmemo->getStore()->roundPrice($totalHiddenTax);
$baseTotalHiddenTax = $creditmemo->getStore()->roundPrice($baseTotalHiddenTax);
$shippingHiddenTaxAmount = $creditmemo->getStore()->roundPrice($shippingHiddenTaxAmount);
$baseShippingHiddenTaxAmount = $creditmemo->getStore()->roundPrice($baseShippingHiddenTaxAmount);
$totalTax += $shippingTaxAmount;
$baseTotalTax += $baseShippingTaxAmount;
}
} else {
$orderShippingAmount = $order->getShippingAmount();
$baseOrderShippingAmount = $order->getBaseShippingAmount();
$orderShippingHiddenTaxAmount = $order->getShippingHiddenTaxAmount();
$baseOrderShippingHiddenTaxAmount = $order->getBaseShippingHiddenTaxAmount();
$baseOrderShippingRefundedAmount = $order->getBaseShippingRefunded();
$baseOrderShippingHiddenTaxRefunded = $order->getBaseShippingHiddenTaxRefunded();
$shippingTaxAmount = 0;
$baseShippingTaxAmount = 0;
$shippingHiddenTaxAmount = 0;
$baseShippingHiddenTaxAmount = 0;
$shippingDelta = $baseOrderShippingAmount - $baseOrderShippingRefundedAmount;
if ($shippingDelta > $creditmemo->getBaseShippingAmount()) {
$part = $creditmemo->getShippingAmount() / $orderShippingAmount;
$basePart = $creditmemo->getBaseShippingAmount() / $baseOrderShippingAmount;
$shippingTaxAmount = $order->getShippingTaxAmount() * $part;
$baseShippingTaxAmount = $order->getBaseShippingTaxAmount() * $basePart;
$shippingHiddenTaxAmount = $order->getShippingHiddenTaxAmount() * $part;
$baseShippingHiddenTaxAmount = $order->getBaseShippingHiddenTaxAmount() * $basePart;
$shippingTaxAmount = $creditmemo->getStore()->roundPrice($shippingTaxAmount);
$baseShippingTaxAmount = $creditmemo->getStore()->roundPrice($baseShippingTaxAmount);
$shippingHiddenTaxAmount = $creditmemo->getStore()->roundPrice($shippingHiddenTaxAmount);
$baseShippingHiddenTaxAmount = $creditmemo->getStore()->roundPrice($baseShippingHiddenTaxAmount);
} elseif ($shippingDelta == $creditmemo->getBaseShippingAmount()) {
$shippingTaxAmount = $order->getShippingTaxAmount() - $order->getShippingTaxRefunded();
$baseShippingTaxAmount = $order->getBaseShippingTaxAmount() - $order->getBaseShippingTaxRefunded();
$shippingHiddenTaxAmount = $order->getShippingHiddenTaxAmount() - $order->getShippingHiddenTaxRefunded();
$baseShippingHiddenTaxAmount = $order->getBaseShippingHiddenTaxAmount() - $order->getBaseShippingHiddenTaxRefunded();
}
$totalTax += $shippingTaxAmount;
$baseTotalTax += $baseShippingTaxAmount;
$totalHiddenTax += $shippingHiddenTaxAmount;
$baseTotalHiddenTax += $baseShippingHiddenTaxAmount;
}
$allowedTax = $order->getTaxAmount() - $order->getTaxRefunded();
//.........这里部分代码省略.........
示例10: _addGwPrintedCardAmount
/**
* Adds giftwrap printed card cost to request as item
*
* @param Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
* @param bool $credit
* @return int|bool
*/
protected function _addGwPrintedCardAmount($object, $credit = false)
{
if (!$object->getGwPrintedCardBasePrice()) {
return false;
}
$lineNumber = $this->_getNewLineCode();
$storeId = $object->getStore()->getId();
$amount = $object->getGwPrintedCardBasePrice();
$line = $this->_getNewDocumentRequestLineObject();
if ($this->_getTaxDataHelper()->priceIncludesTax($storeId)) {
$amount += $object->getGwCardBaseTaxAmount();
$line->setTaxIncluded('true');
}
//@startSkipCommitHooks
$amount = $credit ? -1 * $amount : $amount;
//@finishSkipCommitHooks
$line->setLineCode($lineNumber);
$gwPrintedCardSku = $this->_getConfigHelper()->getGwPrintedCardSku($storeId);
$line->setItemCode($gwPrintedCardSku ? $gwPrintedCardSku : self::DEFAULT_GW_PRINTED_CARD_SKU);
$line->setItemDescription(self::DEFAULT_GW_PRINTED_CARD_DESCRIPTION);
$line->setAvalaraGoodsAndServicesType($this->_getGiftTaxClassCode($storeId));
$line->setNumberOfItems(1);
$line->setlineAmount($amount);
$line->setDiscounted('false');
$this->_lineToItemId[$lineNumber] = $gwPrintedCardSku;
$this->_lines[$lineNumber] = $line;
$this->_setLinesToRequest();
return $lineNumber;
}
示例11: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditMemo)
{
$currencyFrom = Mage::getModel('directory/currency')->load($creditMemo->getOrderCurrencyCode());
$currencyTo = $creditMemo->getStore()->getBaseCurrency();
/* @var $helper Dutycalculator_Charge_Helper_Data */
$helper = Mage::helper('dccharge');
$creditMemo->setImportDutyTax(0);
$creditMemo->setBaseImportDutyTax(0);
$creditMemo->setImportDuty(0);
$creditMemo->setBaseImportDuty(0);
$creditMemo->setSalesTax(0);
$creditMemo->setBaseSalesTax(0);
$creditMemo->setDeliveryDutyType($creditMemo->getOrder()->getDeliveryDutyType());
$creditMemo->setFailedCalculation($creditMemo->getOrder()->getFailedCalculation());
$creditMemo->setDcOrderId(0);
foreach ($creditMemo->getAllItems() as $creditMemoItem) {
$creditMemoItem->setImportDutyTax(0);
$creditMemoItem->setBaseImportDutyTax(0);
$creditMemoItem->setImportDuty(0);
$creditMemoItem->setBaseImportDuty(0);
$creditMemoItem->setSalesTax(0);
$creditMemoItem->setBaseSalesTax(0);
}
if ($creditMemo->getOrder()->getDcOrderId()) {
$result = Dutycalculator_Charge_Model_Importdutytaxes::creditMemoCalculation($creditMemo);
if ($result) {
$amountToRefund = $result['total'];
$baseAmountToRefund = $helper->convertPrice($currencyFrom, $currencyTo, $result['total']);
$creditMemo->setDeliveryDutyType($creditMemo->getOrder()->getDeliveryDutyType());
$creditMemo->setFailedCalculation($creditMemo->getOrder()->getFailedCalculation());
$creditMemo->setImportDutyTax($result['total']);
$creditMemo->setBaseImportDutyTax($helper->convertPrice($currencyFrom, $currencyTo, $result['total']));
$creditMemo->setImportDuty($result['duty']);
$creditMemo->setBaseImportDuty($helper->convertPrice($currencyFrom, $currencyTo, $result['duty']));
$creditMemo->setSalesTax($result['sales_tax']);
$creditMemo->setBaseSalesTax($helper->convertPrice($currencyFrom, $currencyTo, $result['sales_tax']));
$creditMemo->setDcOrderId($result['dc_order_id']);
if ($creditMemo->getOrder()->getDeliveryDutyType() == Dutycalculator_Charge_Helper_Data::DC_DELIVERY_TYPE_DDP) {
$creditMemo->setGrandTotal($creditMemo->getGrandTotal() + $amountToRefund);
$creditMemo->setBaseGrandTotal($creditMemo->getBaseGrandTotal() + $baseAmountToRefund);
$aggregatedItemsValues = array();
foreach ($creditMemo->getAllItems() as $creditMemoItem) {
if ($creditMemoItem->getOrderItem()->getParentItemId()) {
continue;
}
$id = $creditMemoItem->getOrderItem()->getQuoteItemId();
if (isset($result['items'][$id])) {
$creditMemoItem->setImportDutyTax($result['items'][$id]['total']);
$creditMemoItem->setBaseImportDutyTax($helper->convertPrice($currencyFrom, $currencyTo, $result['items'][$id]['total']));
$creditMemoItem->setImportDuty($result['items'][$id]['duty']);
$creditMemoItem->setBaseImportDuty($helper->convertPrice($currencyFrom, $currencyTo, $result['items'][$id]['duty']));
$creditMemoItem->setSalesTax($result['items'][$id]['sales_tax']);
$creditMemoItem->setBaseSalesTax($helper->convertPrice($currencyFrom, $currencyTo, $result['items'][$id]['sales_tax']));
} else {
foreach ($result['aggregated_items'] as $key => $_items) {
if (in_array($id, $_items['items'])) {
$aggregatedItemsValues[$key][$id] = $creditMemoItem->getRowTotal();
}
}
}
}
$totals = array();
$totalDuty = array();
$totalSalesTaxes = array();
foreach ($aggregatedItemsValues as $key => $aggregatedItemsValue) {
$aggregatedTotal = $result['aggregated_items'][$key]['aggregated_total'];
$aggregatedDuty = $result['aggregated_items'][$key]['aggregated_duty'];
$aggregatedSalesTax = $result['aggregated_items'][$key]['aggregated_sales_tax'];
$totalAggregatedItemsValue = array_sum($aggregatedItemsValue);
foreach ($aggregatedItemsValue as $itemId => $value) {
$totals[$itemId] = round($value / $totalAggregatedItemsValue * $aggregatedTotal, 2);
$totalDuty[$itemId] = round($value / $totalAggregatedItemsValue * $aggregatedDuty, 2);
$totalSalesTaxes[$itemId] = round($value / $totalAggregatedItemsValue * $aggregatedSalesTax, 2);
}
}
foreach ($creditMemo->getAllItems() as $creditMemoItem) {
if ($creditMemoItem->getOrderItem()->getParentItemId()) {
continue;
}
$id = $creditMemoItem->getOrderItem()->getQuoteItemId();
if (isset($taxes[$id])) {
$creditMemoItem->setImportDutyTax($totals[$id]);
$creditMemoItem->setBaseImportDutyTax($helper->convertPrice($currencyFrom, $currencyTo, $totals[$id]));
$creditMemoItem->setImportDuty($totalDuty[$id]);
$creditMemoItem->setBaseImportDuty($helper->convertPrice($currencyFrom, $currencyTo, $totalDuty[$id]));
$creditMemoItem->setSalesTax($totalSalesTaxes[$id]);
$creditMemoItem->setBaseSalesTax($helper->convertPrice($currencyFrom, $currencyTo, $totalSalesTaxes[$id]));
}
if ($creditMemoItem->getQty() == 0) {
$creditMemoItem->setImportDutyTax(0);
$creditMemoItem->setBaseImportDutyTax(0);
$creditMemoItem->setImportDuty(0);
$creditMemoItem->setBaseImportDuty(0);
$creditMemoItem->setSalesTax(0);
$creditMemoItem->setBaseSalesTax(0);
}
}
}
}
}
//.........这里部分代码省略.........
示例12: getCreditmemoDocCode
public function getCreditmemoDocCode(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$prefix = trim($this->getConfig('creditmemo_prefix', $creditmemo->getStore()), self::DOC_CODE_SEPARATOR);
$prefix = (empty($prefix) ? 'R' : $prefix) . self::DOC_CODE_SEPARATOR;
if ($creditmemo->getAvataxDocument()) {
return $creditmemo->getAvataxDocument();
} elseif ($creditmemo->getIncrementId()) {
return $prefix . $creditmemo->getIncrementId();
} else {
return null;
}
}
示例13: collect
/**
* Collects the total tax for the credit memo
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
*
* @return $this
*
* @throws Aoe_AvaTax_Exception
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$store = $creditmemo->getStore();
if (!$this->getHelper()->isActive($store)) {
return parent::collect($creditmemo);
}
$creditmemo->setTaxAmount(0.0);
$creditmemo->setBaseTaxAmount(0.0);
$creditmemo->setHiddenTaxAmount(0.0);
$creditmemo->setBaseHiddenTaxAmount(0.0);
$items = $this->getHelper()->getActionableCreditmemoItems($creditmemo);
// Get taxes via API call
$api = $this->getHelper()->getApi($store);
$result = $api->callGetTaxForCreditmemo($creditmemo, false);
if ($result['ResultCode'] !== 'Success') {
throw new Aoe_AvaTax_Exception($result['ResultCode'], $result['Messages']);
}
$totalTax = 0;
$baseTotalTax = 0;
/** @var Mage_Tax_Model_Config $taxConfig */
$taxConfig = Mage::getSingleton('tax/config');
$hasDisplayCurrency = $creditmemo->getBaseCurrencyCode() !== $creditmemo->getOrderCurrencyCode();
$exchangeRate = $hasDisplayCurrency ? $creditmemo->getBaseToOrderRate() : 1.0;
$shippingPriceIncludesTax = $taxConfig->shippingPriceIncludesTax($store);
$itemPriceIncludesTax = $taxConfig->priceIncludesTax($store);
foreach ($result['TaxLines'] as $line) {
$itemId = $line['LineNo'];
$chargeTax = $store->roundPrice(floatval($line['Tax']));
switch ($itemId) {
case 'SHIPPING':
// Store the tax amount
$creditmemo->setBaseShippingTaxAmount(-$chargeTax);
$creditmemo->setShippingTaxAmount($store->roundPrice(-$chargeTax * $exchangeRate));
// Update shipping totals
if ($shippingPriceIncludesTax) {
$creditmemo->setBaseShippingAmount($creditmemo->getBaseShippingInclTax() - $creditmemo->getBaseShippingTaxAmount());
$creditmemo->setShippingAmount($creditmemo->getShippingInclTax() - $creditmemo->getShippingTaxAmount());
} else {
$creditmemo->setBaseShippingInclTax($creditmemo->getBaseShippingAmount() + $creditmemo->getBaseShippingTaxAmount());
$creditmemo->setShippingInclTax($creditmemo->getShippingAmount() + $creditmemo->getShippingTaxAmount());
}
// Add shipping tax to total
$baseTotalTax += $creditmemo->getBaseShippingTaxAmount();
$totalTax += $creditmemo->getShippingTaxAmount();
break;
default:
/** @var Mage_Sales_Model_Order_Creditmemo_Item $item */
$item = isset($items[$itemId]) ? $items[$itemId] : false;
if (!$item) {
continue;
}
// Store the tax amount
$item->setBaseTaxAmount(-$chargeTax);
$item->setTaxAmount($store->roundPrice(-$chargeTax * $exchangeRate));
if ($itemPriceIncludesTax) {
$item->setBaseRowTotal($item->getBaseRowTotalInclTax() - $item->getBaseTaxAmount());
$item->setRowTotal($item->getRowTotalInclTax() - $item->getTaxAmount());
} else {
$item->setBaseRowTotalInclTax($item->getBaseRowTotal() + $item->getBaseTaxAmount());
$item->setRowTotalInclTax($item->getRowTotal() + $item->getTaxAmount());
}
// Add item tax to tax total
$baseTotalTax += $item->getBaseTaxAmount();
$totalTax += $item->getTaxAmount();
}
}
$creditmemo->setTaxAmount($totalTax);
$creditmemo->setBaseTaxAmount($baseTotalTax);
$creditmemo->setHiddenTaxAmount(0.0);
$creditmemo->setBaseHiddenTaxAmount(0.0);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
if ($creditmemo->getCommitTaxDocuments()) {
$creditmemo->setAvataxDocument($result['DocCode']);
}
}
示例14: callDeleteTaxForCreditmemo
public function callDeleteTaxForCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$request = new AvaTax\CancelTaxRequest();
$request->setCompanyCode($this->limit($this->getHelper()->getConfig('company_code', $creditmemo->getStore()), 25));
$request->setDocType(AvaTax\DocumentType::$ReturnInvoice);
$request->setDocCode($this->limit($this->getHelper()->getCreditmemoDocCode($creditmemo), 50));
$request->setCancelCode(AvaTax\CancelCode::$DocDeleted);
Mage::dispatchEvent('aoe_avatax_soapapi_delete_tax_for_creditmemo_before', array('request' => $request, 'creditmemo' => $creditmemo));
return $this->callCancelTax($creditmemo->getStore(), $request);
}
示例15: createTaxRequestFromCreditmemo
protected function createTaxRequestFromCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo, $commit = false)
{
$order = $creditmemo->getOrder();
$store = $creditmemo->getStore();
$invoice = $creditmemo->getInvoice();
/** @var Mage_Customer_Model_Customer $customer */
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
$hideDiscountAmount = Mage::getStoreConfigFlag(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT, $store);
$request = array('Client' => 'Aoe_AvaTax', 'CompanyCode' => $this->limit($this->getHelper()->getConfig('company_code', $store), 25), 'DocType' => $commit ? 'ReturnInvoice' : 'ReturnOrder', 'DocCode' => $this->limit($this->getHelper()->getCreditmemoDocCode($creditmemo), 50), 'ReferenceCode' => $invoice ? $this->getHelper()->getInvoiceDocCode($invoice) : $this->getHelper()->getOrderDocCode($order), 'Commit' => $commit, 'DetailLevel' => 'Tax', 'DocDate' => $creditmemo->getCreatedAtDate()->toString('yyyy-MM-dd'), 'CustomerCode' => $this->getHelper()->getCustomerDocCode($customer) ?: $this->getHelper()->getOrderDocCode($order), 'CurrencyCode' => $this->limit($creditmemo->getBaseCurrencyCode(), 3), 'Discount' => $hideDiscountAmount ? 0.0 : -$store->roundPrice($creditmemo->getBaseDiscountAmount()), 'Addresses' => array(), 'Lines' => array());
if ($order->getCustomerTaxvat()) {
$request['BusinessIdentificationNo'] = $this->limit($order->getCustomerTaxvat(), 25);
}
$request['Addresses'][] = $this->getOriginAddress('ORIGIN', $store);
$request['Addresses'][] = $this->getAddress('DESTINATION', $order->getShippingAddress());
$itemPriceIncludesTax = Mage::getStoreConfigFlag(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $store);
foreach ($this->getHelper()->getActionableCreditmemoItems($creditmemo) as $k => $item) {
/** @var Mage_Sales_Model_Order_Creditmemo_Item $item */
$request['Lines'][] = array("LineNo" => $this->limit($k, 50), "ItemCode" => $this->limit($item->getSku(), 50), "Qty" => round(floatval($item->getQty()), 4), "Amount" => -($store->roundPrice($itemPriceIncludesTax ? $item->getBaseRowTotalInclTax() : $item->getBaseRowTotal()) - $store->roundPrice($item->getBaseDiscountAmount())), "OriginCode" => "ORIGIN", "DestinationCode" => "DESTINATION", "Description" => $this->limit($item->getDescription(), 255), "TaxCode" => $this->limit($this->getHelper()->getProductTaxCode($item->getOrderItem()->getProduct()), 25), "Discounted" => $item->getBaseDiscountAmount() > 0.0, "TaxIncluded" => $itemPriceIncludesTax, "Ref1" => $this->limit($this->getHelper()->getCreditmemoItemRef1($item, $store), 250), "Ref2" => $this->limit($this->getHelper()->getCreditmemoItemRef2($item, $store), 250));
}
$shippingPriceIncludesTax = Mage::getStoreConfigFlag(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_INCLUDES_TAX, $store);
$request['Lines'][] = array("LineNo" => "SHIPPING", "ItemCode" => "SHIPPING", "Qty" => "1", "Amount" => -($store->roundPrice($shippingPriceIncludesTax ? $creditmemo->getBaseShippingInclTax() : $creditmemo->getBaseShippingAmount()) - $store->roundPrice($creditmemo->getBaseShippingDiscountAmount())), "OriginCode" => "ORIGIN", "DestinationCode" => "DESTINATION", "Description" => $this->limit("Shipping: " . $order->getShippingMethod(), 255), "TaxCode" => $this->limit($this->getHelper()->getShippingTaxCode($store), 25), "Discounted" => $creditmemo->getBaseShippingDiscountAmount() > 0.0, "TaxIncluded" => $shippingPriceIncludesTax, "Ref1" => $this->limit($order->getShippingMethod(), 250));
// TODO: Handle giftwrapping
return $request;
}