Xonu_RoundingErrorFix - Version 1.0.2

Version Notes

Fixes rounding error in Magento 1.7.x.x and PayPal.

Download this release

Release Info

Developer Pawel Kazakow
Extension Xonu_RoundingErrorFix
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

app/code/community/Xonu/RoundingErrorFix/Model/Api/Standard.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
 
3
  class Xonu_RoundingErrorFix_Model_Api_Standard extends Mage_Paypal_Model_Api_Standard {
4
  /**
1
  <?php
2
+ /**
3
+ * @copyright (c) 2013, Pawel Kazakow <support@xonu.de>
4
+ * @license http://xonu.de/license/ xonu.de EULA
5
+ */
6
 
7
  class Xonu_RoundingErrorFix_Model_Api_Standard extends Mage_Paypal_Model_Api_Standard {
8
  /**
app/code/community/Xonu/RoundingErrorFix/Model/Store.php CHANGED
@@ -7,6 +7,17 @@
7
 
8
  class Xonu_RoundingErrorFix_Model_Store extends Mage_Core_Model_Store {
9
 
 
 
 
 
 
 
 
 
 
 
 
10
  /**
11
  * Round price
12
  *
@@ -15,7 +26,14 @@ class Xonu_RoundingErrorFix_Model_Store extends Mage_Core_Model_Store {
15
  */
16
  public function roundPrice($price)
17
  {
18
- // return round($price, 2); // original code
19
- return round($price, 4);
 
 
 
 
 
 
 
20
  }
21
  }
7
 
8
  class Xonu_RoundingErrorFix_Model_Store extends Mage_Core_Model_Store {
9
 
10
+ private $classList = array();
11
+
12
+ /**
13
+ * Initialize object
14
+ */
15
+ protected function _construct()
16
+ {
17
+ $this->classList[] = get_class(Mage::getSingleton('tax/sales_total_quote_subtotal'));
18
+ parent::_construct();
19
+ }
20
+
21
  /**
22
  * Round price
23
  *
26
  */
27
  public function roundPrice($price)
28
  {
29
+ $trace = debug_backtrace(); $depth = 2;
30
+
31
+ // if(in_array($trace[$depth]['class'], $this->classList))
32
+ if($trace[$depth]['class'] == $this->classList[0])
33
+ $precision = 2;
34
+ else
35
+ $precision = 4;
36
+
37
+ return round($price, $precision);
38
  }
39
  }
app/code/community/Xonu/RoundingErrorFix/etc/config.xml CHANGED
@@ -6,7 +6,7 @@
6
  <config>
7
  <modules>
8
  <Xonu_RoundingErrorFix>
9
- <version>1.0.1</version>
10
  </Xonu_RoundingErrorFix>
11
  </modules>
12
  <global>
6
  <config>
7
  <modules>
8
  <Xonu_RoundingErrorFix>
9
+ <version>1.0.2</version>
10
  </Xonu_RoundingErrorFix>
11
  </modules>
12
  <global>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Xonu_RoundingErrorFix</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
- <license uri="http://xonu.de/license">xonu.de EULA</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Fixes rounding error in Magento 1.7.x.x and PayPal.</summary>
10
  <description>There is a rounding error in Magento 1.7. Example: If a product costs 9.99 incl. tax. 19% and shipping is 5.00 these values add up to 15.00 in the cart. The correct value would be 14.99.</description>
11
  <notes>Fixes rounding error in Magento 1.7.x.x and PayPal.</notes>
12
  <authors><author><name>Pawel Kazakow</name><user>xonu</user><email>support@xonu.de</email></author></authors>
13
- <date>2013-10-08</date>
14
- <time>19:04:10</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Xonu_RoundingErrorFix.xml" hash="fc60ed34d31316a139635137222c8442"/></dir></target><target name="magecommunity"><dir name="Xonu"><dir name="RoundingErrorFix"><dir name="Model"><dir name="Api"><file name="Standard.php" hash="530661d1c7de367456acab1efe3df0b0"/></dir><dir name="Sales"><dir name="Order"><file name="Payment.php" hash="d5ec636bc978992d177977d52d9d17eb"/></dir></dir><file name="Store.php" hash="8a16dddbefeedc7a8e24b466d4ce5246"/></dir><dir name="etc"><file name="config.xml" hash="beceed94efe87af4d2f2ee6ca2d3de16"/></dir></dir></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>Xonu_RoundingErrorFix</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
+ <license uri="https://xonu.de/license">xonu.de EULA</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Fixes rounding error in Magento 1.7.x.x and PayPal.</summary>
10
  <description>There is a rounding error in Magento 1.7. Example: If a product costs 9.99 incl. tax. 19% and shipping is 5.00 these values add up to 15.00 in the cart. The correct value would be 14.99.</description>
11
  <notes>Fixes rounding error in Magento 1.7.x.x and PayPal.</notes>
12
  <authors><author><name>Pawel Kazakow</name><user>xonu</user><email>support@xonu.de</email></author></authors>
13
+ <date>2013-10-20</date>
14
+ <time>11:45:29</time>
15
+ <contents><target name="magecommunity"><dir name="Xonu"><dir name="RoundingErrorFix"><dir name="Model"><dir name="Api"><file name="Standard.php" hash="7b20a014c8b9444796535e899287799f"/></dir><dir name="Sales"><dir name="Order"><file name="Payment.php" hash="d5ec636bc978992d177977d52d9d17eb"/></dir></dir><file name="Store.php" hash="49d8a77771e445ef100860cb65a7cd54"/></dir><dir name="etc"><file name="config.xml" hash="2fca1499d83c2c24db94bd591dc11aaa"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Xonu_RoundingErrorFix.xml" hash="fc60ed34d31316a139635137222c8442"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>