1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26: class Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Adjustments extends Mage_Adminhtml_Block_Template
27: {
28: protected $_source;
29: /**
30: * Initialize creditmemo agjustment totals
31: *
32: * @return Mage_Tax_Block_Sales_Order_Tax
33: */
34: public function initTotals()
35: {
36: $parent = $this->getParentBlock();
37: $this->_source = $parent->getSource();
38: $total = new Varien_Object(array(
39: 'code' => 'agjustments',
40: 'block_name'=> $this->getNameInLayout()
41: ));
42: $parent->removeTotal('shipping');
43: $parent->removeTotal('adjustment_positive');
44: $parent->removeTotal('adjustment_negative');
45: $parent->addTotal($total);
46: return $this;
47: }
48:
49: public function getSource()
50: {
51: return $this->_source;
52: }
53:
54: /**
55: * Get credit memo shipping amount depend on configuration settings
56: * @return float
57: */
58: public function getShippingAmount()
59: {
60: $config = Mage::getSingleton('tax/config');
61: $source = $this->getSource();
62: if ($config->displaySalesShippingInclTax($source->getOrder()->getStoreId())) {
63: $shipping = $source->getBaseShippingInclTax();
64: } else {
65: $shipping = $source->getBaseShippingAmount();
66: }
67: return Mage::app()->getStore()->roundPrice($shipping) * 1;
68: }
69:
70: /**
71: * Get label for shipping total based on configuration settings
72: * @return string
73: */
74: public function getShippingLabel()
75: {
76: $config = Mage::getSingleton('tax/config');
77: $source = $this->getSource();
78: if ($config->displaySalesShippingInclTax($source->getOrder()->getStoreId())) {
79: $label = $this->helper('sales')->__('Refund Shipping (Incl. Tax)');
80: } elseif ($config->displaySalesShippingBoth($source->getOrder()->getStoreId())) {
81: $label = $this->helper('sales')->__('Refund Shipping (Excl. Tax)');
82: } else {
83: $label = $this->helper('sales')->__('Refund Shipping');
84: }
85: return $label;
86: }
87: }
88: