Bug 11644: fix occasional failure to update fund amount due to floating-point math

When attempting to update a fund, if the amount unalloccated for the
fund is equal to the total, you can be prevented from saving. This is
due to imprecise floating point number comparison in
check_parent_total.pl

Test Plan:
1) Create a fund where the amount unallocated is equal to the amount
   unallocated for the budget period
2) Edit the fund, attempt to change the name of the fund
3) Note you recieve an error and cannot save
4) Apply this patch
5) Repeat step 2
6) Note you can now update the fund

Signed-off-by: Sean McGarvey <smcgarvey@pascocountyfl.net>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit ba689152e4)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 984758cd3c)
This commit is contained in:
Kyle M Hall 2014-01-30 12:39:19 -05:00
parent e2f4b2e01f
commit 254bd580ac
1 changed files with 4 additions and 0 deletions

View File

@ -96,6 +96,10 @@ else {
$budget_period_unalloc = $period->{'budget_period_total'} - $period_sum->{'sum'} if $period->{'budget_period_total'};
}
$total = sprintf( "%.2f", $total );
$sub_unalloc = sprintf( "%.2f", $sub_unalloc );
$budget_period_unalloc = sprintf( "%.2f", $budget_period_unalloc );
if ( $parent_id) {
if ( ($total > $sub_unalloc ) && $sub_unalloc ) {
$returncode = 1;