本文整理汇总了PHP中Mage_Sales_Model_Order_Creditmemo类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Creditmemo类的具体用法?PHP Mage_Sales_Model_Order_Creditmemo怎么用?PHP Mage_Sales_Model_Order_Creditmemo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Sales_Model_Order_Creditmemo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$allowedAmount = $order->getShippingAmount() - $order->getShippingRefunded();
$baseAllowedAmount = $order->getBaseShippingAmount() - $order->getBaseShippingRefunded();
/**
* Check if shipping amount was specified (from invoice or another source).
* Using has magic method to allow setting 0 as shipping amount.
*/
if ($creditmemo->hasBaseShippingAmount()) {
$baseShippingAmount = Mage::app()->getStore()->roundPrice($creditmemo->getBaseShippingAmount());
if ($baseShippingAmount < $baseAllowedAmount) {
$shippingAmount = $allowedAmount * $baseShippingAmount / $baseAllowedAmount;
$shippingAmount = Mage::app()->getStore()->roundPrice($shippingAmount);
} elseif ($baseShippingAmount == $baseAllowedAmount) {
$shippingAmount = $allowedAmount;
} else {
$baseAllowedAmount = $order->formatBasePrice($baseAllowedAmount);
Mage::throwException(Mage::helper('sales')->__('Maximum shipping amount allowed to refound is: %s', $baseAllowedAmount));
}
} else {
$baseShippingAmount = $baseAllowedAmount;
$shippingAmount = $allowedAmount;
}
$creditmemo->setShippingAmount($shippingAmount);
$creditmemo->setBaseShippingAmount($baseShippingAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $shippingAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseShippingAmount);
return $this;
}
示例2: setEntity
/**
* 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;
}
示例3: process
/**
* Save order in AvaTax system
*
* @see OnePica_AvaTax_Model_Observer_SalesOrderCreditmemoSaveAfter::execute()
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @param OnePica_AvaTax_Model_Records_Queue $queue
* @return mixed
* @throws OnePica_AvaTax_Exception
* @throws OnePica_AvaTax_Model_Service_Exception_Commitfailure
* @throws OnePica_AvaTax_Model_Service_Exception_Unbalanced
*/
public function process($creditmemo, $queue)
{
$order = $creditmemo->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_Creditmemo $creditmemoResult */
$creditmemoResult = $this->_getService()->creditmemo($creditmemo, $queue);
//if successful
if (!$creditmemoResult->getHasError()) {
$message = $this->_getHelper()->__('Credit memo #%s was saved to AvaTax', $creditmemoResult->getDocumentCode());
$this->_getHelper()->addStatusHistoryComment($order, $message);
$totalTax = $creditmemoResult->getTotalTax();
if ($totalTax != $creditmemo->getBaseTaxAmount() * -1) {
throw new OnePica_AvaTax_Model_Service_Exception_Unbalanced('Collected: ' . $creditmemo->getTaxAmount() . ', Actual: ' . $totalTax);
}
//if not successful
} else {
$messages = $creditmemoResult->getErrors();
throw new OnePica_AvaTax_Model_Service_Exception_Commitfailure(implode(' // ', $messages));
}
return true;
}
示例4: 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;
}
示例5: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order_id = $creditmemo->getOrderId();
$order = Mage::getModel('sales/order')->load($order_id);
$creditmemo->setFeeAmount($order->getFeeAmount());
$creditmemo->setBaseFeeAmount($order->getBaseFeeAmount());
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $creditmemo->getFeeAmount());
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $creditmemo->getBaseFeeAmount());
return $this;
}
示例6: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$baseDiscount = 0;
$discount = 0;
foreach ($creditmemo->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 = $creditmemo->getOrder();
$baseDiscount = $order->getBaseAffiliateplusDiscount();
$discount = $order->getAffiliateplusDiscount();
}
if (floatval($baseDiscount)) {
$baseDiscount = Mage::app()->getStore()->roundPrice($baseDiscount);
$discount = Mage::app()->getStore()->roundPrice($discount);
$creditmemo->setBaseAffiliateplusDiscount($baseDiscount);
$creditmemo->setAffiliateplusDiscount($discount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseDiscount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $discount);
}
return $this;
}
示例7: collect
/**
* Collect total cost of refunded items
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return Mage_Sales_Model_Order_Creditmemo_Total_Cost
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$baseRefundTotalCost = 0;
foreach ($creditmemo->getAllItems() as $item) {
if (!$item->getHasChildren()) {
$baseRefundTotalCost += $item->getBaseCost() * $item->getQty();
}
}
$creditmemo->setBaseCost($baseRefundTotalCost);
return $this;
}
示例8: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
if (!$creditmemo->getInvoice() || !$creditmemo->getInvoice()->getId()) {
return;
}
$order = $creditmemo->getOrder();
if ($order->getWebposChange() < 0.0001) {
return;
}
$creditmemo->setWebposChange($order->getWebposChange())->setWebposBaseChange($order->getWebposBaseChange());
}
示例9: getCurrency
/**
* 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;
}
示例10: refund
*
* @category FCM
* @package FCM_Fulfillment
* @author Pawan Prakash Gupta
* @author_id 51405591
* @company HCL Technologies
* @created Monday, August 13, 2012
* @copyright Four cross media
*/
/**
* Orderpayment model class
*
* @category FCM
* @package FCM_Fulfillment
* @author Pawan Prakash Gupta <51405591>
*/
class FCM_Fulfillment_Model_Salespayment extends Mage_Sales_Model_Order_Payment
{
/**
* Refund payment online or offline, depending on whether there is invoice set in the creditmemo instance
* Updates transactions hierarchy, if required
* Updates payment totals, updates order status and adds proper comments
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return Mage_Sales_Model_Order_Payment
*/
public function refund($creditmemo)
{
$baseAmountToRefund = $this->_formatAmount($creditmemo->getBaseGrandTotal());
$order = $this->getOrder();
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
// call refund from gateway if required
$isOnline = false;
$gateway = $this->getMethodInstance();
$invoice = null;
if ($gateway->canRefund() && $creditmemo->getDoTransaction()) {
$this->setCreditmemo($creditmemo);
$invoice = $creditmemo->getInvoice();
if ($invoice) {
$isOnline = true;
$captureTxn = $this->_lookupTransaction($invoice->getTransactionId());
if ($captureTxn) {
$this->setParentTransactionId($captureTxn->getTxnId());
}
$this->setShouldCloseParentTransaction(true);
// TODO: implement multiple refunds per capture
try {
$gateway->setStore($this->getOrder()->getStoreId())->processBeforeRefund($invoice, $this)->refund($this, $baseAmountToRefund)->processCreditmemo($creditmemo, $this);
} catch (Mage_Core_Exception $e) {
if (!$captureTxn) {
示例11: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$totalDiscountAmount = $order->getMwStorecreditDiscountShow();
$baseTotalDiscountAmount = $order->getMwStorecreditDiscount();
/* $creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $totalDiscountAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseTotalDiscountAmount); */
$creditmemo->setGrandTotal($creditmemo->getGrandTotal());
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal());
$creditmemo->setMwStorecredit($order->getMwStorecredit());
$creditmemo->setMwStorecreditBuyCredit($order->getMwStorecreditBuyCredit());
$creditmemo->setMwStorecreditDiscount($baseTotalDiscountAmount);
$creditmemo->setMwStorecreditDiscountShow($totalDiscountAmount);
return $this;
}
示例12: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setWebposGiftwrapAmount(0);
$orderGiftwrapAmount = $creditmemo->getOrder()->getWebposGiftwrapAmount();
$baseOrderShippingAmount = $creditmemo->getOrder()->getWebposGiftwrapAmount();
if ($orderGiftwrapAmount) {
$creditmemo->setWebposGiftwrapAmount($orderGiftwrapAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $orderGiftwrapAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $orderGiftwrapAmount);
}
return $this;
}
示例13: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setSurchargeAmount(0);
$creditmemo->setBaseSurchargeAmount(0);
$orderSurchargeAmount = Mage::helper('sagepaysurcharges')->getAmount($creditmemo->getOrder()->getId());
if (!$orderSurchargeAmount) {
$orderSurchargeAmount = Mage::getSingleton('core/session')->getData('surchargeamount');
}
if ($orderSurchargeAmount) {
$creditmemo->setSurchargeAmount($orderSurchargeAmount);
$creditmemo->setBaseSurchargeAmount($orderSurchargeAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $orderSurchargeAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $orderSurchargeAmount);
}
return $this;
}
示例14: testSendEmail
/**
* @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('customer@example.com');
$creditmemo = new Mage_Sales_Model_Order_Creditmemo();
$creditmemo->setOrder($order);
$payment = $order->getPayment();
$paymentInfoBlock = Mage::helper('Mage_Payment_Helper_Data')->getInfoBlock($payment);
$paymentInfoBlock->setArea('invalid-area');
$payment->setBlockMock($paymentInfoBlock);
$this->assertEmpty($creditmemo->getEmailSent());
$creditmemo->sendEmail(true);
$this->assertNotEmpty($creditmemo->getEmailSent());
$this->assertEquals('frontend', $paymentInfoBlock->getArea());
}
示例15: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$amount = $order->getServicecostInvoiced() - $order->getServicecostRefunded();
$baseamount = $order->getBaseServicecostInvoiced() - $order->getBaseServicecostRefunded();
$taxamount = $order->getServicecostTaxInvoiced() - $order->getServicecostTaxRefunded();
$basetaxamount = $order->getBaseServicecostTaxInvoiced() - $order->getBaseServicecostTaxRefunded();
if ($baseamount > 0) {
$creditmemo->setServicecost($amount);
$creditmemo->setBaseServicecost($baseamount);
$creditmemo->setServicecostTax($order->getServicecostTaxRefunded());
$creditmemo->setBaseServicecostTax($order->getBaseServicecostTaxRefunded());
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $amount + $taxamount - $order->getServicecostTax());
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseamount + $basetaxamount - $order->getServicecostTax());
}
return $this;
}