CRM-17281 Pledge payments : fix bug with miscalculation when assigning pledge payments.
authorMathieu Lutfy <mathieu@symbiotic.coop>
Tue, 15 Aug 2017 18:54:18 +0000 (14:54 -0400)
committereileen <emcnaughton@wikimedia.org>
Tue, 15 Aug 2017 20:28:22 +0000 (16:28 -0400)
commit31f5f5e4e28a3800dbac35a601d70ed3880ef13c
tree22617da2caa0cde0d2348c3b96fa180fe22ed2e0
parent51a4603b3c033d39d209fe9530b0ae0ffe1f09ad
CRM-17281 Pledge payments : fix bug with miscalculation when assigning pledge payments.

This PR fixes a bug where payments are miscalculated with weird results. If a payment
changes the amount of future payments in such a way as to make an irregular amount
e.g 10 is split over 3 payments, the payment amount needs to be recorded as .33 not
.333333, assuming a currency with 2 decimal places. This commit
ensures the rounding takes place & is locked in by the accompanying unit test.

Note that we discussed this & agreed to use a function as a placeholder for the number
of decimal places.
CRM/Pledge/BAO/PledgePayment.php
CRM/Utils/Money.php