贷项通知单-默认退回0产品


13

贷项通知单的典型用例是价格调整(调整运输,礼节性折扣等)。我很少用它来获得总回报。

奇怪的是,Magento的默认行为是CreditMemo退还所有产品并退还所有运费。即使有退货,也很少退款。

如果CreditMemo默认为$ 0(不退还任何产品,不退还任何运费),这样会更好(更安全),因此管理员可以明确知道要退款的内容(默认情况下为零)。否则,例如创建贷项凭证以退还运费但退还整个订单太容易了!

是否有任何配置或自定义支持将CreditMemo缺省设置为$ 0?


无答案:配置解决方案。可以通过扩展来实现吗?也就是说,在贷项凭单上设置初始设置?
MarkE

Answers:


2

不知道是否可以在不扩展magento基本功能的情况下实现所需的功能。我必须做类似的事情,这就是我所做的: 首先,我将sales_order_creditmemo_totals改写为自动的贷项通知单(也许您不需要,所以可以转到第二部分):

在我的模块config.xml中:

    <blocks>
        <adminhtml>
            <rewrite>
                ...
                <sales_order_creditmemo_totals>Bla_Customercredit_Block_Adminhtml_Sales_Creditmemo</sales_order_creditmemo_totals>
            </rewrite>
        </adminhtml>

        <sales>
            <rewrite>
                ...
                <order_creditmemo_totals>Bla_Customercredit_Block_Sales_Creditmemo</order_creditmemo_totals>
            </rewrite>
        </sales>
    </blocks>

然后在Block / Adminhtml / Sales / Creditmemo.php中

class Bla_Customercredit_Block_Adminhtml_Sales_Creditmemo extends Mage_Sales_Block_Order_Creditmemo_Totals 
{
    protected $_code = 'credit';

    protected function _initTotals() 
    {
        $helper = $this->getCreditsHelper();
        parent::_initTotals();
        $baseAmount = $this->getOrder()->getBaseCustomerCredit();

        $this->addTotal(
            new Varien_Object(
                array(
                    'code' => $this->_code,
                    'value' => -$creditAmount,
                    'base_value' => -$baseAmount,
                    'label' => $helper->__('Bla Credit'),
                )
            ), 
            'discount'
        );

        return $this;
    }
}

如您所见,我这样做是为了为具有客户信用的订单创建贷项通知单,因此我也重写了sales_order_totals和sales_order_invoice_totals,但我认为您不需要这样做。

第二: 我还添加了自己的模板,以在手动creditmemo创建期间添加一些功能,因此管理员可以决定如何生成它。为此,我在app / design / adminhtml / default / default / template / MODULE_NAME / order / creditmemo / create / items.phtml下创建了items.phtml,在此phtml中,我添加了一些输入字段以更改默认值。我还在Company_CustomerCredit_Adminhtml_CustomerController下的管理控制器中的模块中添加了我

require_once 'Mage/Adminhtml/controllers/CustomerController.php';
class Bla_Customercredit_Adminhtml_CustomerController extends Mage_Adminhtml_CustomerController
{
    /**
     * Overload to save customer credits, then call 
     * parent::saveAction() 
     */
    public function saveAction()
    {
        $data = $this->getRequest()->getPost();
        if($data && $data['bla_credits'])
        {
            if(!empty($data['bla_credits']['id']))
            {
                $model = Mage::getModel('credits/credits')->load($data['bla_credits']['id']);
            }
            else
            {
                unset($data['bla_credits']['id']);
                $model = Mage::getModel('credits/credits');
            }

            try
            {
                $model->setData($data['bla_credits']);
                $model->save();
            }
            catch(Exception $e)
            {
            }
        }

        parent::saveAction();
    }
}

谢谢,感谢您的答复,我们将看看是否可以将您的解决方案应用于我的要求。
MarkE
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.