From 38b48eefe98c2d9d22dae9e41c1d5c81004a1200 Mon Sep 17 00:00:00 2001 From: Jon Goldberg Date: Tue, 19 May 2020 11:57:56 -0400 Subject: [PATCH] fix grantbudget to handle different currency formats --- CRM/AnnualGrantBudgets/BAO/GrantBudget.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/CRM/AnnualGrantBudgets/BAO/GrantBudget.php b/CRM/AnnualGrantBudgets/BAO/GrantBudget.php index d389a7f..644ab18 100644 --- a/CRM/AnnualGrantBudgets/BAO/GrantBudget.php +++ b/CRM/AnnualGrantBudgets/BAO/GrantBudget.php @@ -81,9 +81,9 @@ class CRM_AnnualGrantBudgets_BAO_GrantBudget extends CRM_AnnualGrantBudgets_DAO_ $grantBudget[] = [ 'id' => $result->id, 'name' => $result->name, - 'budget' => CRM_Utils_Money::format($result->budget), - 'total_amount_granted' => CRM_Utils_Money::format($result->total_amount_granted), - 'balance_amount' => CRM_Utils_Money::format(($result->budget - $result->total_amount_granted)), + 'budget' => $result->budget, + 'total_amount_granted' => $result->total_amount_granted, + 'balance_amount' => $result->budget - $result->total_amount_granted, 'financial_type_id' => $result->financial_type_id, 'note' => $result->note, 'is_reserved' => $result->is_reserved, @@ -125,8 +125,8 @@ class CRM_AnnualGrantBudgets_BAO_GrantBudget extends CRM_AnnualGrantBudgets_DAO_ ])['values'][0]; if ($grantBudget) { - $balanceAmount = CRM_Utils_Rule::cleanMoney($grantBudget['balance_amount']); - $amountGranted = CRM_Utils_Rule::cleanMoney($params['multifund_amount'][$k]); + $balanceAmount = $grantBudget['balance_amount']; + $amountGranted = $params['multifund_amount'][$k]; // If there's a $grantId, we're updating an existing grant. Make sure we don't // double-count this money on validation. if ($grantId) { @@ -142,7 +142,10 @@ class CRM_AnnualGrantBudgets_BAO_GrantBudget extends CRM_AnnualGrantBudgets_DAO_ } } if ($balanceAmount < $amountGranted) { - $errors["multifund_amount[$k]"] = ts("The annual budget for this grant is {$grantBudget['budget']}. Grants totaling {$grantBudget['total_amount_granted']} have been made. {$grantBudget['balance_amount']} remains."); + $budgetDisplay = CRM_Utils_Money::format($grantBudget['budget']); + $totalGrantedDisplay = CRM_Utils_Money::format($grantBudget['total_amount_granted']); + $balanceDisplay = CRM_Utils_Money::format($grantBudget['balance_amount']); + $errors["multifund_amount[$k]"] = ts("The annual budget for this grant is $budgetDisplay. Grants totaling $totalGrantedDisplay have been made. $balanceDisplay remains."); } } }