MSP_CashOnDelivery - Version 1.1.0

Version Notes

Enjoy it ;)

Download this release

Release Info

Developer Riccardo Tempesta
Extension MSP_CashOnDelivery
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.0 to 1.1.0

app/code/community/MSP/CashOnDelivery/CHANGELOG.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ 1.0.0
2
+ Initial release
3
+
4
+ 1.1.0
5
+ New features:
6
+ - COD amounts can now include or exclude taxes
7
+ - taxation class could be selected in tax configuration
8
+ - tax amount for COD fee is calculated in tax total
9
+ - new option in backend to display the COD fee including, excluding tax or both
10
+ - added a description field before the COD fee on checkout
app/code/community/MSP/CashOnDelivery/Helper/Data.php CHANGED
@@ -22,15 +22,46 @@ class MSP_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Abstract
22
  {
23
  const XML_PATH_GENERAL_ENABLED = 'msp_cashondelivery/general/enabled';
24
  const XML_PATH_GENERAL_CALC_INC_SHIP = 'payment/msp_cashondelivery/calc_including_shipping';
25
- const XML_PATH_GENERAL_CALC_INC_TAX = 'payment/msp_cashondelivery/calc_including_taxes';
26
  const XML_PATH_STANDARD_FEE_LOCAL = 'payment/msp_cashondelivery/standard_fixed_fee_local';
27
  const XML_PATH_STANDARD_FEE_FOREIGN = 'payment/msp_cashondelivery/standard_fixed_fee_foreign';
 
28
  const XML_PATH_SHIPPING_COUNTRY_ID = 'shipping/origin/country_id';
29
  const XML_PATH_DESCRIPTION = 'payment/msp_cashondelivery/cod_description';
30
-
31
  const MSP_COD_LOCAL = 'local';
32
  const MSP_COD_FOREIGN = 'foreign';
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  /**
36
  * Check if personal catalog is enabled
@@ -44,7 +75,7 @@ class MSP_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Abstract
44
  {
45
  return $this->getIsEnabled();
46
  }
47
-
48
  /**
49
  * Check if must include shipping in subtotal calculation
50
  * @return boolean
@@ -52,18 +83,8 @@ class MSP_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Abstract
52
  public function getCalculateIncludingShipping()
53
  {
54
  return (bool) Mage::getStoreConfig(self::XML_PATH_GENERAL_CALC_INC_SHIP);
55
- }
56
-
57
- /**
58
- * Check if must include taxes in subtotal calculation
59
- * @return boolean
60
- */
61
- public function getCalculateIncludingTaxes()
62
- {
63
- return (bool) Mage::getStoreConfig(self::XML_PATH_GENERAL_CALC_INC_TAX);
64
  }
65
 
66
-
67
  /**
68
  * Get currenct checkout/admin session
69
  *
@@ -71,9 +92,9 @@ class MSP_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Abstract
71
  */
72
  public function getSession()
73
  {
74
- if (Mage::app()->getStore()->isAdmin())
75
  return Mage::getSingleton('adminhtml/session_quote');
76
-
77
  return Mage::getSingleton('checkout/session');
78
  }
79
 
@@ -86,7 +107,7 @@ class MSP_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Abstract
86
  {
87
  return $this->getSession()->getQuote();
88
  }
89
-
90
  public function getCodDescription($storeId = null) {
91
  return Mage::getStoreConfig(self::XML_PATH_DESCRIPTION, $storeId);
92
  }
@@ -116,5 +137,46 @@ class MSP_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Abstract
116
 
117
  return Mage::helper('directory')->currencyConvert($amount, $baseCurrencyCode, $currentCurrencyCode);
118
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  }
22
  {
23
  const XML_PATH_GENERAL_ENABLED = 'msp_cashondelivery/general/enabled';
24
  const XML_PATH_GENERAL_CALC_INC_SHIP = 'payment/msp_cashondelivery/calc_including_shipping';
 
25
  const XML_PATH_STANDARD_FEE_LOCAL = 'payment/msp_cashondelivery/standard_fixed_fee_local';
26
  const XML_PATH_STANDARD_FEE_FOREIGN = 'payment/msp_cashondelivery/standard_fixed_fee_foreign';
27
+ const XML_PATH_PRICE_INCLUDING_TAXES = 'payment/msp_cashondelivery/price_including_taxes';
28
  const XML_PATH_SHIPPING_COUNTRY_ID = 'shipping/origin/country_id';
29
  const XML_PATH_DESCRIPTION = 'payment/msp_cashondelivery/cod_description';
30
+
31
  const MSP_COD_LOCAL = 'local';
32
  const MSP_COD_FOREIGN = 'foreign';
33
 
34
+ const XML_PATH_COD_TAX_CLASS = 'tax/classes/msp_cashondelivery_taxclass';
35
+ const XML_PATH_COD_INCL_TAX = 'tax/calculation/msp_cashondelivery_includes_tax';
36
+ const XML_PATH_COD_DISPLAY_MODE = 'tax/display/msp_cashondelivery';
37
+
38
+ protected $_rate = null;
39
+
40
+ protected function getCodPriceDisplayType($store = null)
41
+ {
42
+ return (int)Mage::getStoreConfig(self::XML_PATH_COD_DISPLAY_MODE, $store);
43
+ }
44
+
45
+ public function getCodPriceInclTax($store = null)
46
+ {
47
+ return (int)Mage::getStoreConfig(self::XML_PATH_COD_INCL_TAX, $store);
48
+ }
49
+
50
+ public function getCodTaxClassId($store = null)
51
+ {
52
+ return (int)Mage::getStoreConfig(self::XML_PATH_COD_TAX_CLASS, $store);
53
+ }
54
+
55
+ public function displayCodBothPrices($store = null)
56
+ {
57
+ return $this->getCodPriceDisplayType($store) == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH;
58
+ }
59
+
60
+ public function displayCodIncludingTax()
61
+ {
62
+ return $this->getCodPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX;
63
+ }
64
+
65
 
66
  /**
67
  * Check if personal catalog is enabled
75
  {
76
  return $this->getIsEnabled();
77
  }
78
+
79
  /**
80
  * Check if must include shipping in subtotal calculation
81
  * @return boolean
83
  public function getCalculateIncludingShipping()
84
  {
85
  return (bool) Mage::getStoreConfig(self::XML_PATH_GENERAL_CALC_INC_SHIP);
 
 
 
 
 
 
 
 
 
86
  }
87
 
 
88
  /**
89
  * Get currenct checkout/admin session
90
  *
92
  */
93
  public function getSession()
94
  {
95
+ if (Mage::app()->getStore()->isAdmin() || !Mage::app()->getStore()->getId() )
96
  return Mage::getSingleton('adminhtml/session_quote');
97
+
98
  return Mage::getSingleton('checkout/session');
99
  }
100
 
107
  {
108
  return $this->getSession()->getQuote();
109
  }
110
+
111
  public function getCodDescription($storeId = null) {
112
  return Mage::getStoreConfig(self::XML_PATH_DESCRIPTION, $storeId);
113
  }
137
 
138
  return Mage::helper('directory')->currencyConvert($amount, $baseCurrencyCode, $currentCurrencyCode);
139
  }
140
+
141
+ public function getRate() {
142
+ if (true||!$this->_rate) {
143
+ $address = $this->getQuote()->getShippingAddress();
144
+
145
+ $store = $address->getQuote()->getStore();
146
+ $custTaxClassId = $address->getQuote()->getCustomerTaxClassId();
147
+ $taxCalculationModel = Mage::getSingleton('tax/calculation');
148
+ /* @var $taxCalculationModel Mage_Tax_Model_Calculation */
149
+ $request = $taxCalculationModel->getRateRequest($address, $address->getQuote()->getBillingAddress(), $custTaxClassId, $store);
150
+ $codTaxClass = $this->getCodTaxClassId();
151
+
152
+ $this->_rate = $taxCalculationModel->getRate($request->setProductClassId($codTaxClass));
153
+ }
154
+ return $this->_rate;
155
+ }
156
+
157
+ public function getAppliedRates() {
158
+ $address = $this->getQuote()->getShippingAddress();
159
+ $store = $address->getQuote()->getStore();
160
+ $custTaxClassId = $address->getQuote()->getCustomerTaxClassId();
161
+ $taxCalculationModel = Mage::getSingleton('tax/calculation');
162
+ /* @var $taxCalculationModel Mage_Tax_Model_Calculation */
163
+ $request = $taxCalculationModel->getRateRequest($address, $address->getQuote()->getBillingAddress(), $custTaxClassId, $store);
164
+ return $taxCalculationModel->getAppliedRates($request);
165
+ }
166
 
167
+ public function excludeTax($amount) {
168
+ $rate = $this->getRate();
169
+ return $amount / (1+$rate/100);
170
+ }
171
+
172
+ public function includeTax($amount) {
173
+ $rate = $this->getRate();
174
+ return $amount * (1+$rate/100);
175
+ }
176
+
177
+ public function getTaxAmount($amountExclTax) {
178
+ $rate = $this->getRate();
179
+
180
+ return $amountExclTax * ($rate/100);
181
+ }
182
  }
app/code/community/MSP/CashOnDelivery/Model/Adminhtml/System/Config/Source/Taxclass.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IDEALIAGroup srl
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 info@idealiagroup.com so we can send you a copy immediately.
14
+ *
15
+ * @category MSP
16
+ * @package MSP_CashOnDelivery
17
+ * @copyright Copyright (c) 2013 IDEALIAGroup srl (http://www.idealiagroup.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class MSP_CashOnDelivery_Model_Adminhtml_System_Config_Source_Taxclass
22
+ {
23
+ public function toOptionArray()
24
+ {
25
+ $options = Mage::getModel('tax/class_source_product')->toOptionArray();
26
+ return $options;
27
+ }
28
+ }
app/code/community/MSP/CashOnDelivery/Model/Cashondelivery.php CHANGED
@@ -36,30 +36,51 @@ class MSP_CashOnDelivery_Model_Cashondelivery extends Mage_Payment_Model_Method_
36
 
37
  public function getExtraFee() {
38
  $_helper = Mage::helper('msp_cashondelivery');
39
- $_quote = Mage::getModel('sales/quote')->load($_helper->getQuote()->getId());
 
 
 
 
 
 
 
 
 
40
  // get subtotal depending on options
41
  if ($_helper->getCalculateIncludingShipping())
42
- $_subTotal = $_quote->getBaseGrandTotal();
43
- else
44
- $_subTotal = $_quote->getBaseSubtotal();
45
-
46
-
47
  // get the correct apply rule
48
  $applyRule = $this->getApplyRule($_helper->getZoneType(), $_subTotal);
49
 
50
  $standardFixedFee = $_helper->getStandardFixedFee();
51
  $fixedFee = $applyRule->getFixedFee();
52
  $percentFee = (float)$applyRule->getPercentFee();
53
-
 
 
 
 
 
 
54
  $extraFee = $standardFixedFee + $fixedFee + $percentFee * $_subTotal /100;
55
 
56
  return $extraFee;
57
  }
58
 
 
 
 
 
 
 
 
 
 
 
59
  protected function getApplyRule($zoneType, $subTotal) {
60
  $collection = Mage::getResourceModel('msp_cashondelivery/'.$zoneType.'_collection');
61
- $collection
62
- ->addFieldToFilter('amount_from', array('lteq' => $subTotal));
63
  $collection->getSelect()->order('amount_from DESC')->limit(1);
64
 
65
  return $collection->getFirstItem();
36
 
37
  public function getExtraFee() {
38
  $_helper = Mage::helper('msp_cashondelivery');
39
+ return $_helper->currencyConvert($this->getBaseExtraFee());
40
+ }
41
+
42
+ public function getBaseExtraFee() {
43
+ $_helper = Mage::helper('msp_cashondelivery');
44
+ $_quote = $_helper->getQuote();
45
+
46
+ $_subTotal = $_quote->getShippingAddress()->getSubtotal();
47
+ $_shippingAmount = $_quote->getShippingAddress()->getBaseShippingAmount();
48
+
49
  // get subtotal depending on options
50
  if ($_helper->getCalculateIncludingShipping())
51
+ $_subTotal += $_shippingAmount;
52
+
 
 
 
53
  // get the correct apply rule
54
  $applyRule = $this->getApplyRule($_helper->getZoneType(), $_subTotal);
55
 
56
  $standardFixedFee = $_helper->getStandardFixedFee();
57
  $fixedFee = $applyRule->getFixedFee();
58
  $percentFee = (float)$applyRule->getPercentFee();
59
+ // controlla se il valore inserito � incluso o escluso tasse.
60
+ // Se � incluso deve scorporarle
61
+ if ($_helper->getCodPriceInclTax()){
62
+ $standardFixedFee = $_helper->excludeTax($standardFixedFee);
63
+ $fixedFee = $_helper->excludeTax($fixedFee);
64
+ }
65
+
66
  $extraFee = $standardFixedFee + $fixedFee + $percentFee * $_subTotal /100;
67
 
68
  return $extraFee;
69
  }
70
 
71
+ public function getExtraFeeInclTax() {
72
+ $_helper = Mage::helper('msp_cashondelivery');
73
+ return $_helper->currencyConvert($this->getBaseExtraFeeInclTax());
74
+ }
75
+
76
+ public function getBaseExtraFeeInclTax() {
77
+ $_helper = Mage::helper('msp_cashondelivery');
78
+ return $_helper->includeTax($this->getBaseExtraFee());
79
+ }
80
+
81
  protected function getApplyRule($zoneType, $subTotal) {
82
  $collection = Mage::getResourceModel('msp_cashondelivery/'.$zoneType.'_collection');
83
+ $collection->addFieldToFilter('amount_from', array('lteq' => $subTotal));
 
84
  $collection->getSelect()->order('amount_from DESC')->limit(1);
85
 
86
  return $collection->getFirstItem();
app/code/community/MSP/CashOnDelivery/Model/Creditmemo/Tax.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IDEALIAGroup srl
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 info@idealiagroup.com so we can send you a copy immediately.
14
+ *
15
+ * @category MSP
16
+ * @package MSP_CashOnDelivery
17
+ * @copyright Copyright (c) 2013 IDEALIAGroup srl (http://www.idealiagroup.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class MSP_CashOnDelivery_Model_Creditmemo_Tax extends Mage_Sales_Model_Order_Creditmemo_Total_Tax
22
+ {
23
+ protected $_code = 'msp_cashondelivery_tax';
24
+
25
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
26
+ {
27
+ $_helper = Mage::helper('msp_cashondelivery');
28
+ $_model = Mage::getModel('msp_cashondelivery/cashondelivery');
29
+ $order = $creditmemo->getOrder();
30
+
31
+ $baseAmount = $order->getMspBaseCashondelivery();
32
+ $baseAmountInclTax = $order->getMspBaseCashondeliveryInclTax();
33
+ $amount = $order->getMspCashondelivery();
34
+ $amountInclTax = $order->getMspCashondeliveryInclTax();
35
+
36
+ $codTax = $amountInclTax - $amount;
37
+ $codBaseTax = $baseAmountInclTax - $baseAmount;
38
+
39
+ $creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $codTax);
40
+ $creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $codBaseTax);
41
+ $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $codTax);
42
+ $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $codBaseTax);
43
+
44
+ return $this;
45
+ }
46
+
47
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
48
+ {
49
+ return $this;
50
+ }
51
+ }
app/code/community/MSP/CashOnDelivery/Model/Creditmemo/Total.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IDEALIAGroup srl
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 info@idealiagroup.com so we can send you a copy immediately.
14
+ *
15
+ * @category MSP
16
+ * @package MSP_CashOnDelivery
17
+ * @copyright Copyright (c) 2013 IDEALIAGroup srl (http://www.idealiagroup.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class MSP_CashOnDelivery_Model_Creditmemo_Total extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
22
+ {
23
+ public function collect(Mage_Sales_Model_Order_Creditmemo $invoice)
24
+ {
25
+ $order = $invoice->getOrder();
26
+
27
+ $amount = $order->getMspCashondelivery();
28
+ $baseAmount = $order->getMspBaseCashondelivery();
29
+
30
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
31
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseAmount);
32
+
33
+ $invoice->setMspCashondelivery($amount);
34
+ $invoice->setMspBaseCashondelivery($baseAmount);
35
+
36
+ return $this;
37
+ }
38
+ }
app/code/community/MSP/CashOnDelivery/Model/Invoice/Total.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IDEALIAGroup srl
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 info@idealiagroup.com so we can send you a copy immediately.
14
+ *
15
+ * @category MSP
16
+ * @package MSP_CashOnDelivery
17
+ * @copyright Copyright (c) 2013 IDEALIAGroup srl (http://www.idealiagroup.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class MSP_CashOnDelivery_Model_Order_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
22
+ {
23
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
24
+ {
25
+ $order = $invoice->getOrder();
26
+ $amount = $order->getMspCashondelivery();
27
+ $baseAmount = $order->getMspBaseCashondelivery();
28
+
29
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
30
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseAmount);
31
+
32
+ return $this;
33
+ }
34
+ }
app/code/community/MSP/CashOnDelivery/Model/Order/Tax.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IDEALIAGroup srl
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 info@idealiagroup.com so we can send you a copy immediately.
14
+ *
15
+ * @category MSP
16
+ * @package MSP_CashOnDelivery
17
+ * @copyright Copyright (c) 2013 IDEALIAGroup srl (http://www.idealiagroup.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class MSP_CashOnDelivery_Model_Order_Tax extends Mage_Sales_Model_Order_Invoice_Total_Tax
22
+ {
23
+ protected $_code = 'msp_cashondelivery_tax';
24
+
25
+ public function collect(Mage_Sales_Model_Quote_Address $address)
26
+ {
27
+ $_helper = Mage::helper('msp_cashondelivery');
28
+ $_model = Mage::getModel('msp_cashondelivery/cashondelivery');
29
+ $order = $invoice->getOrder();
30
+
31
+ $baseAmount = $order->getMspBaseCashondelivery();
32
+ $baseAmountInclTax = $order->getMspBaseCashondeliveryInclTax();
33
+ $amount = $order->getMspCashondelivery();
34
+ $amountInclTax = $order->getMspCashondeliveryInclTax();
35
+
36
+ $codTax = $amountInclTax - $amount;
37
+ $codBaseTax = $baseAmountInclTax - $baseAmount;
38
+
39
+ return $this;
40
+ }
41
+
42
+ }
app/code/community/MSP/CashOnDelivery/Model/Order/Total.php CHANGED
@@ -26,14 +26,10 @@ class MSP_CashOnDelivery_Model_Order_Total extends Mage_Sales_Model_Order_Invoic
26
 
27
  $amount = $order->getMspCashondelivery();
28
  $baseAmount = $order->getMspBaseCashondelivery();
29
-
30
  $invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
31
  $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseAmount);
32
-
33
- $invoice->setMspCashondelivery($premium);
34
- $invoice->setMspBaseCashondelivery($basePremium);
35
-
36
  return $this;
37
-
38
  }
39
  }
26
 
27
  $amount = $order->getMspCashondelivery();
28
  $baseAmount = $order->getMspBaseCashondelivery();
29
+
30
  $invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
31
  $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseAmount);
32
+
 
 
 
33
  return $this;
 
34
  }
35
  }
app/code/community/MSP/CashOnDelivery/Model/Quote/Tax.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IDEALIAGroup srl
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 info@idealiagroup.com so we can send you a copy immediately.
14
+ *
15
+ * @category MSP
16
+ * @package MSP_CashOnDelivery
17
+ * @copyright Copyright (c) 2013 IDEALIAGroup srl (http://www.idealiagroup.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class MSP_CashOnDelivery_Model_Quote_Tax extends Mage_Sales_Model_Quote_Address_Total_Tax
22
+ {
23
+ protected $_code = 'msp_cashondelivery_tax';
24
+
25
+ public function collect(Mage_Sales_Model_Quote_Address $address)
26
+ {
27
+ $_helper = Mage::helper('msp_cashondelivery');
28
+ $_model = Mage::getModel('msp_cashondelivery/cashondelivery');
29
+ $_subtotal = $address->getSubtotal();
30
+ $quote = $address->getQuote();
31
+ $baseAmount = $_model->getBaseExtraFee($_subtotal);
32
+ $amount = $_model->getExtraFee($_subtotal);
33
+
34
+ $codTax = $_helper->getTaxAmount($amount);
35
+ $codBaseTax = $_helper->getTaxAmount($baseAmount);
36
+
37
+ if (
38
+ ($_helper->getQuote()->getPayment()->getMethod() == $_model->getCode()) &&
39
+ ($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING)
40
+ ) {
41
+ $address->setTaxAmount($address->getTaxAmount() + $codTax);
42
+ $address->setBaseTaxAmount($address->getBaseTaxAmount() + $codBaseTax);
43
+
44
+ $this->_saveAppliedTaxes(
45
+ $address,
46
+ $_helper->getAppliedRates(),
47
+ $codTax,
48
+ $codBaseTax,
49
+ $_helper->getRate()
50
+ );
51
+ $address->setGrandTotal($address->getGrandTotal() + $codTax);
52
+ $address->setBaseGrandTotal($address->getBaseGrandTotal() + $codBaseTax);
53
+ }
54
+
55
+ return $this;
56
+ }
57
+
58
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
59
+ {
60
+ return $this;
61
+ }
62
+ }
app/code/community/MSP/CashOnDelivery/Model/Quote/Total.php CHANGED
@@ -28,31 +28,38 @@ class MSP_CashOnDelivery_Model_Quote_Total extends Mage_Sales_Model_Quote_Addres
28
  $_helper = Mage::helper('msp_cashondelivery');
29
  $_model = Mage::getModel('msp_cashondelivery/cashondelivery');
30
  $quote = $address->getQuote();
31
- $baseAmount = $_model->getExtraFee();
32
- $amount = $_helper->currencyConvert($baseAmount);
 
 
33
 
34
  if (
35
- ($_helper->getQuote()->getPayment()->getMethod() == $_model->getCode()) &&
36
- ($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING)
37
  ) {
38
- $this->_addAmount($amount);
39
- $this->_addBaseAmount($baseAmount);
 
40
  $address->setMspCashondelivery($amount);
41
  $address->setMspBaseCashondelivery($baseAmount);
 
 
42
  $quote->setMspCashondelivery($amount);
43
  $quote->setMspBaseCashondelivery($baseAmount);
 
 
44
  }
45
 
46
- return $this;
47
  }
48
-
49
  public function fetch(Mage_Sales_Model_Quote_Address $address)
50
  {
51
  parent::fetch($address);
52
  $_helper = Mage::helper('msp_cashondelivery');
53
  $_model = Mage::getModel('msp_cashondelivery/cashondelivery');
54
 
55
- $amount = $_model->getExtraFee();
56
 
57
  if ($amount > 0 &&
58
  ($_helper->getQuote()->getPayment()->getMethod() == $_model->getCode()) &&
@@ -67,14 +74,14 @@ class MSP_CashOnDelivery_Model_Quote_Total extends Mage_Sales_Model_Quote_Addres
67
 
68
  return $this;
69
  }
70
-
71
  /**
72
- * Get Subtotal label
73
- *
74
- * @return string
75
- */
76
- public function getLabel()
77
- {
78
- return Mage::helper('msp_cashondelivery')->__('Cash On Delivery');
79
- }
80
  }
28
  $_helper = Mage::helper('msp_cashondelivery');
29
  $_model = Mage::getModel('msp_cashondelivery/cashondelivery');
30
  $quote = $address->getQuote();
31
+ $baseAmount = $_model->getBaseExtraFee();
32
+ $amount = $_model->getExtraFee();
33
+ $baseAmountInclTax = $_model->getBaseExtraFeeInclTax();
34
+ $amountInclTax = $_model->getExtraFeeInclTax();
35
 
36
  if (
37
+ ($_helper->getQuote()->getPayment()->getMethod() == $_model->getCode()) &&
38
+ ($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING)
39
  ) {
40
+ $address->setGrandTotal($address->getGrandTotal() + $amount);
41
+ $address->setBaseGrandTotal($address->getBaseGrandTotal() + $baseAmount);
42
+
43
  $address->setMspCashondelivery($amount);
44
  $address->setMspBaseCashondelivery($baseAmount);
45
+ $address->setMspCashondeliveryInclTax($amountInclTax);
46
+ $address->setMspBaseCashondeliveryInclTax($baseAmountInclTax);
47
  $quote->setMspCashondelivery($amount);
48
  $quote->setMspBaseCashondelivery($baseAmount);
49
+ $quote->setMspCashondeliveryInclTax($amountInclTax);
50
+ $quote->setMspBaseCashondeliveryInclTax($baseAmountInclTax);
51
  }
52
 
53
+ return $this;
54
  }
55
+
56
  public function fetch(Mage_Sales_Model_Quote_Address $address)
57
  {
58
  parent::fetch($address);
59
  $_helper = Mage::helper('msp_cashondelivery');
60
  $_model = Mage::getModel('msp_cashondelivery/cashondelivery');
61
 
62
+ $amount = $_model->getExtraFee();
63
 
64
  if ($amount > 0 &&
65
  ($_helper->getQuote()->getPayment()->getMethod() == $_model->getCode()) &&
74
 
75
  return $this;
76
  }
77
+
78
  /**
79
+ * Get Subtotal label
80
+ *
81
+ * @return string
82
+ */
83
+ public function getLabel()
84
+ {
85
+ return Mage::helper('msp_cashondelivery')->__('Cash On Delivery');
86
+ }
87
  }
app/code/community/MSP/CashOnDelivery/etc/config.xml CHANGED
@@ -22,7 +22,7 @@
22
  <config>
23
  <modules>
24
  <MSP_CashOnDelivery>
25
- <version>1.0.0</version>
26
  </MSP_CashOnDelivery>
27
  </modules>
28
 
@@ -86,42 +86,82 @@
86
  <totals>
87
  <msp_cashondelivery>
88
  <class>msp_cashondelivery/quote_total</class>
89
- <after>grand_total</after>
 
90
  </msp_cashondelivery>
 
 
 
 
 
91
  </totals>
92
  </quote>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  <order_invoice>
94
                 <totals>
95
                     <msp_cashondelivery>
96
                        <class>msp_cashondelivery/order_total</class>
 
 
97
                     </msp_cashondelivery>
98
                 </totals>
99
             </order_invoice>           
100
             <order_creditmemo>
101
                 <totals>
102
                     <msp_cashondelivery>
103
-                       <class>msp_cashondelivery/order_total</class>
 
 
104
                     </msp_cashondelivery>
105
-                </totals>
 
 
 
 
 
106
             </order_creditmemo>
 
 
 
107
  </sales>
108
 
109
  <fieldsets>
110
  <sales_convert_quote>
111
- <msp_cashondelivery><to_quote>*</to_quote></msp_cashondelivery>
112
- <msp_base_cashondelivery><to_quote>*</to_quote></msp_base_cashondelivery>
 
 
113
  </sales_convert_quote>
114
  <sales_convert_order>
115
  <msp_cashondelivery><to_quote>*</to_quote></msp_cashondelivery>
116
  <msp_base_cashondelivery><to_quote>*</to_quote></msp_base_cashondelivery>
 
 
117
  </sales_convert_order>
118
  <sales_convert_order_address>
119
  <msp_cashondelivery><to_quote_address>*</to_quote_address></msp_cashondelivery>
120
  <msp_base_cashondelivery><to_quote_address>*</to_quote_address></msp_base_cashondelivery>
 
 
121
  </sales_convert_order_address>
122
  <sales_convert_quote_address>
123
  <msp_cashondelivery><to_quote>*</to_quote><to_order>*</to_order></msp_cashondelivery>
124
  <msp_base_cashondelivery><to_quote>*</to_quote><to_order>*</to_order></msp_base_cashondelivery>
 
 
125
  </sales_convert_quote_address>
126
  </fieldsets>
127
 
@@ -239,6 +279,17 @@
239
  <calc_including_taxes>1</calc_including_taxes>
240
  </msp_cashondelivery>
241
  </payment>
 
 
 
 
 
 
 
 
 
 
 
242
  <sales>
243
  <totals_sort>
244
  <msp_cashondelivery>1000</msp_cashondelivery>
22
  <config>
23
  <modules>
24
  <MSP_CashOnDelivery>
25
+ <version>1.1.0</version>
26
  </MSP_CashOnDelivery>
27
  </modules>
28
 
86
  <totals>
87
  <msp_cashondelivery>
88
  <class>msp_cashondelivery/quote_total</class>
89
+ <after>tax</after>
90
+ <before>grand_total</before>
91
  </msp_cashondelivery>
92
+ <msp_cashondelivery_tax>
93
+ <class>msp_cashondelivery/quote_tax</class>
94
+ <after>tax</after>
95
+ <before>grand_total</before>
96
+ </msp_cashondelivery_tax>
97
  </totals>
98
  </quote>
99
+ <order>
100
+ <totals>
101
+ <msp_cashondelivery>
102
+ <class>msp_cashondelivery/quote_total</class>
103
+ <after>tax</after>
104
+ <before>grand_total</before>
105
+ </msp_cashondelivery>
106
+ <msp_cashondelivery_tax>
107
+ <class>msp_cashondelivery/quote_tax</class>
108
+ <after>tax</after>
109
+ <before>grand_total</before>
110
+ </msp_cashondelivery_tax>
111
+ </totals>
112
+ </order>
113
  <order_invoice>
114
                 <totals>
115
                     <msp_cashondelivery>
116
                        <class>msp_cashondelivery/order_total</class>
117
+ <after>tax</after>
118
+ <before>grand_total</before>
119
                     </msp_cashondelivery>
120
                 </totals>
121
             </order_invoice>           
122
             <order_creditmemo>
123
                 <totals>
124
                     <msp_cashondelivery>
125
+                       <class>msp_cashondelivery/creditmemo_total</class>
126
+ <after>tax</after>
127
+ <before>grand_total</before>
128
                     </msp_cashondelivery>
129
+ <msp_cashondelivery_tax>
130
+ <class>msp_cashondelivery/creditmemo_tax</class>
131
+ <after>tax</after>
132
+ <before>grand_total</before>
133
+ </msp_cashondelivery_tax>
134
+                </totals>
135
             </order_creditmemo>
136
+ <totals_sort>
137
+ <msp_cashondelivery>15</msp_cashondelivery>
138
+ </totals_sort>
139
  </sales>
140
 
141
  <fieldsets>
142
  <sales_convert_quote>
143
+ <msp_cashondelivery><to_order>*</to_order></msp_cashondelivery>
144
+ <msp_base_cashondelivery><to_order>*</to_order></msp_base_cashondelivery>
145
+ <msp_base_cashondelivery_incl_tax><to_order>*</to_order></msp_base_cashondelivery_incl_tax>
146
+ <msp_cashondelivery_incl_tax><to_order>*</to_order></msp_cashondelivery_incl_tax>
147
  </sales_convert_quote>
148
  <sales_convert_order>
149
  <msp_cashondelivery><to_quote>*</to_quote></msp_cashondelivery>
150
  <msp_base_cashondelivery><to_quote>*</to_quote></msp_base_cashondelivery>
151
+ <msp_base_cashondelivery_incl_tax><to_quote>*</to_quote></msp_base_cashondelivery_incl_tax>
152
+ <msp_cashondelivery_incl_tax><to_quote>*</to_quote></msp_cashondelivery_incl_tax>
153
  </sales_convert_order>
154
  <sales_convert_order_address>
155
  <msp_cashondelivery><to_quote_address>*</to_quote_address></msp_cashondelivery>
156
  <msp_base_cashondelivery><to_quote_address>*</to_quote_address></msp_base_cashondelivery>
157
+ <msp_base_cashondelivery_incl_tax><to_quote>*</to_quote></msp_base_cashondelivery_incl_tax>
158
+ <msp_cashondelivery_incl_tax><to_quote>*</to_quote></msp_cashondelivery_incl_tax>
159
  </sales_convert_order_address>
160
  <sales_convert_quote_address>
161
  <msp_cashondelivery><to_quote>*</to_quote><to_order>*</to_order></msp_cashondelivery>
162
  <msp_base_cashondelivery><to_quote>*</to_quote><to_order>*</to_order></msp_base_cashondelivery>
163
+ <msp_base_cashondelivery_incl_tax><to_quote>*</to_quote></msp_base_cashondelivery_incl_tax>
164
+ <msp_cashondelivery_incl_tax><to_quote>*</to_quote></msp_cashondelivery_incl_tax>
165
  </sales_convert_quote_address>
166
  </fieldsets>
167
 
279
  <calc_including_taxes>1</calc_including_taxes>
280
  </msp_cashondelivery>
281
  </payment>
282
+ <tax>
283
+ <classes>
284
+ <msp_cashondelivery_taxclass></msp_cashondelivery_taxclass>
285
+ </classes>
286
+ <calculation>
287
+ <msp_cashondelivery_includes_tax>1</msp_cashondelivery_includes_tax>
288
+ </calculation>
289
+ <display>
290
+ <msp_cashondelivery>2</msp_cashondelivery>
291
+ </display>
292
+ </tax>
293
  <sales>
294
  <totals_sort>
295
  <msp_cashondelivery>1000</msp_cashondelivery>
app/code/community/MSP/CashOnDelivery/etc/system.xml CHANGED
@@ -34,23 +34,62 @@
34
  <msp_cashondelivery translate="label">
35
  <label>Cash On Delivery</label>
36
  <frontend_type>text</frontend_type>
37
- <sort_order>1000</sort_order>
38
  <show_in_default>1</show_in_default>
39
  <show_in_website>1</show_in_website>
40
  <show_in_store>0</show_in_store>
41
  </msp_cashondelivery>
42
- <msp_cashondelivery_tax translate="label">
43
- <label>Cash On Delivery Taxes</label>
44
- <frontend_type>text</frontend_type>
45
- <sort_order>1001</sort_order>
46
- <show_in_default>1</show_in_default>
47
- <show_in_website>1</show_in_website>
48
- <show_in_store>0</show_in_store>
49
- </msp_cashondelivery_tax>
50
  </fields>
51
  </totals_sort>
52
  </groups>
53
  </sales>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  <payment>
55
  <groups>
56
  <msp_cashondelivery translate="label">
@@ -112,15 +151,6 @@
112
  <show_in_website>1</show_in_website>
113
  <show_in_store>0</show_in_store>
114
  </calc_including_shipping>
115
- <calc_including_taxes translate="label">
116
- <label>Calculate subtotal including taxes</label>
117
- <frontend_type>select</frontend_type>
118
- <sort_order>100</sort_order>
119
- <source_model>adminhtml/system_config_source_yesno</source_model>
120
- <show_in_default>1</show_in_default>
121
- <show_in_website>1</show_in_website>
122
- <show_in_store>0</show_in_store>
123
- </calc_including_taxes>
124
  <allowspecific translate="label">
125
  <label>Payment from applicable countries</label>
126
  <frontend_type>allowspecific</frontend_type>
34
  <msp_cashondelivery translate="label">
35
  <label>Cash On Delivery</label>
36
  <frontend_type>text</frontend_type>
37
+ <sort_order>35</sort_order>
38
  <show_in_default>1</show_in_default>
39
  <show_in_website>1</show_in_website>
40
  <show_in_store>0</show_in_store>
41
  </msp_cashondelivery>
 
 
 
 
 
 
 
 
42
  </fields>
43
  </totals_sort>
44
  </groups>
45
  </sales>
46
+
47
+ <tax>
48
+ <groups>
49
+ <classes>
50
+ <fields>
51
+ <msp_cashondelivery_taxclass translate="label">
52
+ <label>Tax Class for Cash On Delivery</label>
53
+ <frontend_type>select</frontend_type>
54
+ <source_model>msp_cashondelivery/adminhtml_system_config_source_taxclass</source_model>
55
+ <sort_order>20</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>0</show_in_store>
59
+ </msp_cashondelivery_taxclass>
60
+ </fields>
61
+ </classes>
62
+ <calculation>
63
+ <fields>
64
+ <msp_cashondelivery_includes_tax translate="label">
65
+ <label>Cash On Delivery</label>
66
+ <comment>Whether Cash On delivery amounts entered by admin include tax.</comment>
67
+ <frontend_type>select</frontend_type>
68
+ <backend_model>tax/config_price_include</backend_model>
69
+ <source_model>tax/system_config_source_priceType</source_model>
70
+ <sort_order>1000</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </msp_cashondelivery_includes_tax>
75
+ </fields>
76
+ </calculation>
77
+ <display>
78
+ <fields>
79
+ <msp_cashondelivery translate="label">
80
+ <label>Display Cash On Delivery Amount</label>
81
+ <frontend_type>select</frontend_type>
82
+ <source_model>tax/system_config_source_tax_display_type</source_model>
83
+ <sort_order>1000</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ </msp_cashondelivery>
88
+ </fields>
89
+ </display>
90
+ </groups>
91
+ </tax>
92
+
93
  <payment>
94
  <groups>
95
  <msp_cashondelivery translate="label">
151
  <show_in_website>1</show_in_website>
152
  <show_in_store>0</show_in_store>
153
  </calc_including_shipping>
 
 
 
 
 
 
 
 
 
154
  <allowspecific translate="label">
155
  <label>Payment from applicable countries</label>
156
  <frontend_type>allowspecific</frontend_type>
app/code/community/MSP/CashOnDelivery/sql/msp_cashondelivery_setup/mysql4-install-1.1.0.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IDEALIAGroup srl
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 info@idealiagroup.com so we can send you a copy immediately.
14
+ *
15
+ * @category MSP
16
+ * @package MSP_PersonalCatalog
17
+ * @copyright Copyright (c) 2013 IDEALIAGroup srl (http://www.idealiagroup.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ $installer = $this;
22
+ $installer->startSetup();
23
+ $installer->run("
24
+ DROP TABLE IF EXISTS {$this->getTable('msp_cashondelivery_local')};
25
+ CREATE TABLE {$this->getTable('msp_cashondelivery_local')} (
26
+ `msp_cashondelivery_local_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
27
+ `amount_from` float NOT NULL,
28
+ `fixed_fee` float NOT NULL,
29
+ `percent_fee` float NOT NULL,
30
+ PRIMARY KEY (`msp_cashondelivery_local_id`)
31
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
32
+ ");
33
+ $installer->run("
34
+ DROP TABLE IF EXISTS {$this->getTable('msp_cashondelivery_foreign')};
35
+ CREATE TABLE {$this->getTable('msp_cashondelivery_foreign')} (
36
+ `msp_cashondelivery_foreign_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
37
+ `amount_from` float NOT NULL,
38
+ `fixed_fee` float NOT NULL,
39
+ `percent_fee` float NOT NULL,
40
+ PRIMARY KEY (`msp_cashondelivery_foreign_id`)
41
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
42
+ ");
43
+
44
+ $setup = new Mage_Sales_Model_Mysql4_Setup('core_setup');
45
+ $setup->startSetup();
46
+ $setup->addAttribute('invoice', 'msp_base_cashondelivery', array('type' => 'decimal', 'visible' => false, 'required' => true));
47
+ $setup->addAttribute('invoice', 'msp_cashondelivery', array('type' => 'decimal', 'visible' => false, 'required' => true));
48
+ $setup->addAttribute('invoice', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
49
+ $setup->addAttribute('invoice', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
50
+ $setup->addAttribute('order', 'msp_base_cashondelivery', array('type' => 'decimal', 'visible' => false, 'required' => true));
51
+ $setup->addAttribute('order', 'msp_cashondelivery', array('type' => 'decimal', 'visible' => false, 'required' => true));
52
+ $setup->addAttribute('order', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
53
+ $setup->addAttribute('order', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
54
+ $setup->addAttribute('quote', 'msp_base_cashondelivery', array('type' => 'decimal', 'visible' => false, 'required' => true));
55
+ $setup->addAttribute('quote', 'msp_cashondelivery', array('type' => 'decimal', 'visible' => false, 'required' => true));
56
+ $setup->addAttribute('quote', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
57
+ $setup->addAttribute('quote', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
58
+ $setup->addAttribute('order_address', 'msp_base_cashondelivery', array('type' => 'decimal', 'visible' => false, 'required' => true));
59
+ $setup->addAttribute('order_address', 'msp_cashondelivery', array('type' => 'decimal', 'visible' => false, 'required' => true));
60
+ $setup->addAttribute('order_address', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
61
+ $setup->addAttribute('order_address', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
62
+ $setup->addAttribute('quote_address', 'msp_base_cashondelivery', array('type' => 'decimal', 'visible' => false, 'required' => true));
63
+ $setup->addAttribute('quote_address', 'msp_cashondelivery', array('type' => 'decimal', 'visible' => false, 'required' => true));
64
+ $setup->addAttribute('quote_address', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
65
+ $setup->addAttribute('quote_address', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
66
+ $setup->endSetup();
67
+
68
+ $installer->endSetup();
app/code/community/MSP/CashOnDelivery/sql/msp_cashondelivery_setup/mysql4-upgrade-1.0.0-1.1.0.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IDEALIAGroup srl
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 info@idealiagroup.com so we can send you a copy immediately.
14
+ *
15
+ * @category MSP
16
+ * @package MSP_PersonalCatalog
17
+ * @copyright Copyright (c) 2013 IDEALIAGroup srl (http://www.idealiagroup.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ $installer = $this;
22
+ $installer->startSetup();
23
+
24
+ $setup = new Mage_Sales_Model_Mysql4_Setup('core_setup');
25
+ $setup->startSetup();
26
+ $setup->addAttribute('invoice', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
27
+ $setup->addAttribute('invoice', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
28
+ $setup->addAttribute('order', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
29
+ $setup->addAttribute('order', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
30
+ $setup->addAttribute('quote', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
31
+ $setup->addAttribute('quote', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
32
+ $setup->addAttribute('order_address', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
33
+ $setup->addAttribute('order_address', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
34
+ $setup->addAttribute('quote_address', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
35
+ $setup->addAttribute('quote_address', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
36
+ $setup->endSetup();
37
+
38
+ $installer->endSetup();
app/design/adminhtml/default/default/template/msp_cashondelivery/form.phtml CHANGED
@@ -20,11 +20,23 @@
20
 
21
  $_code = $this->getMethodCode();
22
  $quote = Mage::getSingleton('checkout/session')->getQuote();
 
23
 
24
  $_extraFee = Mage::helper('core')->currency($this->getMethod()->getExtraFee());
 
 
 
 
25
  ?>
26
- <ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none">
27
- <li>
28
- <?php echo $this->__('You will be charged an extra fee of %s', $_extraFee) ?>
29
- </li>
 
 
 
 
 
 
 
30
  </ul>
20
 
21
  $_code = $this->getMethodCode();
22
  $quote = Mage::getSingleton('checkout/session')->getQuote();
23
+ $_helper = Mage::helper('msp_cashondelivery');
24
 
25
  $_extraFee = Mage::helper('core')->currency($this->getMethod()->getExtraFee());
26
+ $_extraFeeInclTaxes = Mage::helper('core')->currency($this->getMethod()->getExtraFeeInclTax());
27
+ $_description = $_helper->getCodDescription();
28
+ $_displayBothPrices = $_helper->displayCodBothPrices();
29
+ $_displayInclTax = $_helper->displayCodIncludingTax();
30
  ?>
31
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
32
+ <li>
33
+ <?php echo $_description ?><br/>
34
+ <?php if ($_displayBothPrices) :?>
35
+ <?php echo $this->__('You will be charged an extra fee of %s (Incl. Taxes %s)', $_extraFee, $_extraFeeInclTaxes) ?>
36
+ <?php elseif ($_displayInclTax) : ?>
37
+ <?php echo $this->__('You will be charged an extra fee of %s Incl. Taxes', $_extraFeeInclTaxes) ?>
38
+ <?php else : ?>
39
+ <?php echo $this->__('You will be charged an extra fee of %s', $_extraFee) ?>
40
+ <?php endif;?>
41
+ </li>
42
  </ul>
app/design/frontend/base/default/template/msp_cashondelivery/form.phtml CHANGED
@@ -20,15 +20,25 @@
20
 
21
  $_code = $this->getMethodCode();
22
  $quote = Mage::getSingleton('checkout/session')->getQuote();
 
23
 
24
  $_extraFee = Mage::helper('core')->currency($this->getMethod()->getExtraFee());
25
- $_description = $this->getMethod()->getCodDescription();
 
 
 
26
  ?>
27
  <fieldset class="form-list">
28
  <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
29
  <li>
30
- <?php echo $_description ?>
 
 
 
 
 
31
  <?php echo $this->__('You will be charged an extra fee of %s', $_extraFee) ?>
32
- </li>
 
33
  </ul>
34
  </fieldset>
20
 
21
  $_code = $this->getMethodCode();
22
  $quote = Mage::getSingleton('checkout/session')->getQuote();
23
+ $_helper = Mage::helper('msp_cashondelivery');
24
 
25
  $_extraFee = Mage::helper('core')->currency($this->getMethod()->getExtraFee());
26
+ $_extraFeeInclTaxes = Mage::helper('core')->currency($this->getMethod()->getExtraFeeInclTax());
27
+ $_description = $_helper->getCodDescription();
28
+ $_displayBothPrices = $_helper->displayCodBothPrices();
29
+ $_displayInclTax = $_helper->displayCodIncludingTax();
30
  ?>
31
  <fieldset class="form-list">
32
  <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
33
  <li>
34
+ <?php echo $_description ?><br/>
35
+ <?php if ($_displayBothPrices) :?>
36
+ <?php echo $this->__('You will be charged an extra fee of %s (Incl. Taxes %s)', $_extraFee, $_extraFeeInclTaxes) ?>
37
+ <?php elseif ($_displayInclTax) : ?>
38
+ <?php echo $this->__('You will be charged an extra fee of %s Incl. Taxes', $_extraFeeInclTaxes) ?>
39
+ <?php else : ?>
40
  <?php echo $this->__('You will be charged an extra fee of %s', $_extraFee) ?>
41
+ <?php endif;?>
42
+ </li>
43
  </ul>
44
  </fieldset>
app/locale/it_IT/MSP_CashOnDelivery.csv CHANGED
@@ -11,6 +11,8 @@
11
  "Apply from amount","Applica a partire dall'importo"
12
  "Cash on delivery fee","Prezzo contrassegno"
13
  "You will be charged an extra fee of %s","Il servizio prevede un costo addizionale di %s"
 
 
14
  "Fee Amount","Prezzo aggiuntivo"
15
  "Apply","Applica"
16
  "Cash On Delivery", "Contrassegno"
@@ -30,4 +32,5 @@
30
  "Standard foreign fixed fee", "Importo estero fisso standard"
31
  "Calculate subtotal including shipping","Calcola il subtotale includendo la spedizione"
32
  "Calculate subtotal including taxes","Calcola il subtotale includendo le tasse"
33
- "Additional text displayed on the payment method selection","Testo aggiuntivo da mostrare nella selezione del pagamento"
 
11
  "Apply from amount","Applica a partire dall'importo"
12
  "Cash on delivery fee","Prezzo contrassegno"
13
  "You will be charged an extra fee of %s","Il servizio prevede un costo addizionale di %s"
14
+ "You will be charged an extra fee of %s (Incl. Taxes %s)","Il servizio prevede un costo addizionale di %s (%s Incl. Tasse)"
15
+ "You will be charged an extra fee of %s Incl. Taxes","Il servizio prevede un costo addizionale di %s Incl. Tasse"
16
  "Fee Amount","Prezzo aggiuntivo"
17
  "Apply","Applica"
18
  "Cash On Delivery", "Contrassegno"
32
  "Standard foreign fixed fee", "Importo estero fisso standard"
33
  "Calculate subtotal including shipping","Calcola il subtotale includendo la spedizione"
34
  "Calculate subtotal including taxes","Calcola il subtotale includendo le tasse"
35
+ "Additional text displayed on the payment method selection","Testo aggiuntivo da mostrare nella selezione del pagamento"
36
+ "Cash on delivery price including taxes","Prezzo del contrassegno comprensivo di tasse"
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MSP_CashOnDelivery</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>MagenoSpecialist CashOnDelivery module</summary>
10
  <description>An easy to use module to add a fully configurable Cash On Delivery payment mode in your Magento store.</description>
11
  <notes>Enjoy it ;)</notes>
12
  <authors><author><name>Riccardo Tempesta</name><user>idealiagroup</user><email>tempesta@idealiagroup.com</email></author><author><name>Paolo Vecchiocattivi</name><user>idealiagroup</user><email>vecchiocattivi@idealiagroup.com</email></author></authors>
13
- <date>2013-05-29</date>
14
- <time>10:01:02</time>
15
- <contents><target name="magecommunity"><dir name="MSP"><dir name="CashOnDelivery"><dir name="Block"><dir name="Admin"><dir name="Rule"><dir name="Edit"><file name="Form.php" hash="3ef514b316321a601b1414df18986c68"/></dir><file name="Edit.php" hash="16d02cedb6204fd7b831b5564f072d08"/><file name="Grid.php" hash="3588123b02fa04214defcfb7b09e1c51"/></dir><file name="Rule.php" hash="b933ae1daa5a7160d5bd27c75b20f3a6"/></dir><file name="Form.php" hash="1ed8f181beb6736ac9d481e6e622978f"/><dir name="Sales"><dir name="Order"><file name="Total.php" hash="c399bf6a6d9fed0b72bae2a253cc534f"/></dir></dir></dir><file name="COMPATIBILITY.txt" hash="b120e5821ccb687741d038f63cbd76c7"/><dir name="Helper"><file name="Data.php" hash="77d9d5093c34cff4bbbbcb22b0cd3ff5"/></dir><file name="LICENSE.txt" hash="43d8581f57722664f478fccb6e71f99b"/><dir name="Model"><file name="Cashondelivery.php" hash="41b74ad334f9f6b0f4f5f4effc38ba43"/><file name="Foreign.php" hash="a1582c07f33304b476d589349ab97a0e"/><file name="Local.php" hash="724831a475386d67793b41b3cf7ac302"/><dir name="Mysql4"><dir name="Foreign"><file name="Collection.php" hash="0a8c362e781a435a840f3a27bdb62e8b"/></dir><file name="Foreign.php" hash="186027f699b82cb3a84ff28ea00ae614"/><dir name="Local"><file name="Collection.php" hash="dcb52df5861f1e47c06580673da60b57"/></dir><file name="Local.php" hash="f364150b5cfc416601261f912e5af995"/></dir><dir name="Order"><dir name="Pdf"><dir name="Total"><file name="Default.php" hash="a5b1971b0d96ea083a8e3d27c0ab4666"/></dir></dir><file name="Total.php" hash="b8620df3c1bac6a89c3dc6ddc590656f"/></dir><dir name="Quote"><file name="Total.php" hash="d7856c70d7f07beae559ec200fd2b63a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Cashondelivery"><file name="ForeignController.php" hash="d8ef1364e94f5c2ea492fee2ec2da84f"/><file name="LocalController.php" hash="c6e615ac1332e7d155d72f300b7c6fc6"/></dir><file name="CashondeliveryController.php" hash="b2d29ca215099171f926c15fcdd39e90"/></dir></dir><dir name="etc"><file name="config.xml" hash="d6e3c9032cf3abb19c0dbd5ae7f78d97"/><file name="system.xml" hash="39b7c98519671d69b794b538d36dc835"/></dir><dir name="sql"><dir name="msp_cashondelivery_setup"><file name="mysql4-install-1.0.0.php" hash="4f1f491964a4702bac27a00c6b634de1"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="msp_cashondelivery"><file name="form.phtml" hash="1534c81cc7d9478e221b6431770c6740"/></dir></dir><dir name="layout"><file name="msp_cashondelivery.xml" hash="1639e2df536b6fbb8066d9b59bc0c058"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="msp_cashondelivery"><file name="form.phtml" hash="be6ebdb094a5eaacbc565c17793af877"/></dir></dir><dir name="layout"><file name="msp_cashondelivery.xml" hash="9e0c45c81a9ccd35d1b12aa897eacfcf"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MSP_CashOnDelivery.xml" hash="d64644f02358bdbb7715c0bfab466582"/></dir></target><target name="magelocale"><dir name="it_IT"><file name="MSP_CashOnDelivery.csv" hash="7302d705c7c0101f0f657c8979924a5e"/></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MSP_CashOnDelivery</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>MagentoSpecialist CashOnDelivery module</summary>
10
  <description>An easy to use module to add a fully configurable Cash On Delivery payment mode in your Magento store.</description>
11
  <notes>Enjoy it ;)</notes>
12
  <authors><author><name>Riccardo Tempesta</name><user>idealiagroup</user><email>tempesta@idealiagroup.com</email></author><author><name>Paolo Vecchiocattivi</name><user>idealiagroup</user><email>vecchiocattivi@idealiagroup.com</email></author></authors>
13
+ <date>2013-06-05</date>
14
+ <time>15:02:48</time>
15
+ <contents><target name="magecommunity"><dir name="MSP"><dir name="CashOnDelivery"><dir name="Block"><dir name="Admin"><dir name="Rule"><dir name="Edit"><file name="Form.php" hash="3ef514b316321a601b1414df18986c68"/></dir><file name="Edit.php" hash="16d02cedb6204fd7b831b5564f072d08"/><file name="Grid.php" hash="3588123b02fa04214defcfb7b09e1c51"/></dir><file name="Rule.php" hash="b933ae1daa5a7160d5bd27c75b20f3a6"/></dir><file name="Form.php" hash="1ed8f181beb6736ac9d481e6e622978f"/><dir name="Sales"><dir name="Order"><file name="Total.php" hash="c399bf6a6d9fed0b72bae2a253cc534f"/></dir></dir></dir><file name="CHANGELOG.txt" hash="87899c225d07216f3737032680acd098"/><file name="COMPATIBILITY.txt" hash="b120e5821ccb687741d038f63cbd76c7"/><dir name="Helper"><file name="Data.php" hash="04e5b819282e301b863f553346df22eb"/></dir><file name="LICENSE.txt" hash="43d8581f57722664f478fccb6e71f99b"/><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Taxclass.php" hash="8e321361f0814b8c21aa2cb7662fd2ee"/></dir></dir></dir></dir><file name="Cashondelivery.php" hash="0d4776b99bb9beb613fd9ec43c62e8e4"/><dir name="Creditmemo"><file name="Tax.php" hash="52e02c6cb7ca5b8c9651685d1a77f8ab"/><file name="Total.php" hash="1b73140986a7ba42634c375c39e0c118"/></dir><file name="Foreign.php" hash="a1582c07f33304b476d589349ab97a0e"/><dir name="Invoice"><file name="Total.php" hash="b6cd1dbc7522bd6294b19573f993eea0"/></dir><file name="Local.php" hash="724831a475386d67793b41b3cf7ac302"/><dir name="Mysql4"><dir name="Foreign"><file name="Collection.php" hash="0a8c362e781a435a840f3a27bdb62e8b"/></dir><file name="Foreign.php" hash="186027f699b82cb3a84ff28ea00ae614"/><dir name="Local"><file name="Collection.php" hash="dcb52df5861f1e47c06580673da60b57"/></dir><file name="Local.php" hash="f364150b5cfc416601261f912e5af995"/></dir><dir name="Order"><dir name="Pdf"><dir name="Total"><file name="Default.php" hash="a5b1971b0d96ea083a8e3d27c0ab4666"/></dir></dir><file name="Tax.php" hash="6a86adbd4bde7a78a1ef43560cd4be60"/><file name="Total.php" hash="045a6a6f5b57cc5f38665e8d6aafd797"/></dir><dir name="Quote"><file name="Tax.php" hash="045783c15f162191325732d5255edb68"/><file name="Total.php" hash="6cf29ebe76ac7c4bfd5e96b594a802a2"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Cashondelivery"><file name="ForeignController.php" hash="d8ef1364e94f5c2ea492fee2ec2da84f"/><file name="LocalController.php" hash="c6e615ac1332e7d155d72f300b7c6fc6"/></dir><file name="CashondeliveryController.php" hash="b2d29ca215099171f926c15fcdd39e90"/></dir></dir><dir name="etc"><file name="config.xml" hash="52d940ce5750e9dd3e189be2aef3e4e2"/><file name="system.xml" hash="ff57f1a52ac2b037b54856ff97a7f1f6"/></dir><dir name="sql"><dir name="msp_cashondelivery_setup"><file name="mysql4-install-1.0.0.php" hash="4f1f491964a4702bac27a00c6b634de1"/><file name="mysql4-install-1.1.0.php" hash="fc5dfa28fc97afaeb4175428cad75042"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="5e7f0f25cb83bcd2e7c8d2ec8c7b3bd1"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="msp_cashondelivery"><file name="form.phtml" hash="7085ccee4d932846fcc7aa99faf7319f"/></dir></dir><dir name="layout"><file name="msp_cashondelivery.xml" hash="1639e2df536b6fbb8066d9b59bc0c058"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="msp_cashondelivery"><file name="form.phtml" hash="bf2572fa6aa4e190f90c6e8205920b39"/></dir></dir><dir name="layout"><file name="msp_cashondelivery.xml" hash="9e0c45c81a9ccd35d1b12aa897eacfcf"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MSP_CashOnDelivery.xml" hash="d64644f02358bdbb7715c0bfab466582"/></dir></target><target name="magelocale"><dir name="it_IT"><file name="MSP_CashOnDelivery.csv" hash="9437f81dfd1425fc1b9f43f4e23ab040"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>MSP_Common</name><channel>community</channel><min>1.0.0</min><max/></package></required></dependencies>
18
  </package>