fix grantbudget to handle different currency formats

This commit is contained in:
Jon Goldberg 2020-05-19 11:57:56 -04:00
parent ed86787d20
commit 38b48eefe9
No known key found for this signature in database
GPG Key ID: C2D2247364F9DB13

View File

@ -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.");
}
}
}