CRM-188: Fix Floating Point Precision Comparison Exception
authorCamilo Rodriguez <camilo@compucorp.co.uk>
Mon, 18 Jun 2018 18:48:44 +0000 (18:48 +0000)
committerCamilo Rodriguez <camilo@compucorp.co.uk>
Fri, 13 Jul 2018 13:32:21 +0000 (13:32 +0000)
commitc16c6ad8329246c1375e2ec99630a07504a2f224
tree0cd06002902a41e81ac31b2f323654955e652303
parent92cc04486f6bba56b845dbe48406152d7c638ac1
CRM-188: Fix Floating Point Precision Comparison Exception

Under certain circumstances, floating point comparison between set and
calculated values may fail, even if they should be equal. This is due to the
way floating point values are represented internally in binary form. To avoid
this problem, comparison needs to be made using an expected precision below
which compared values may be treated as equal. Implemented  precision of 0.001
and used it to check the difference between both values is less.
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/Exception/CheckLineItemsException.php [new file with mode: 0644]
CRM/Utils/Money.php
tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
tests/phpunit/CRM/Utils/MoneyTest.php