support totals on grant budget screen

This commit is contained in:
2019-08-19 17:06:17 -04:00
parent 956c1e90c6
commit 3534930f22
3 changed files with 32 additions and 0 deletions

View File

@ -20,6 +20,8 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
* @return array
*/
public static function getGrantBudget($params) {
$returnTotals = $params['return_totals'];
$totals = [];
$fiscalYear = $params['fiscal_year'];
if (empty($fiscalYear)) {
$fiscalYear = date('Y');
@ -86,6 +88,18 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
'balance_amount' => CRM_Utils_Money::format(($result->budget - $result->total_amount_granted)),
'financial_type_id' => $result->financial_type_id,
];
if ($returnTotals) {
$totals['budget'] += $result->budget;
$totals['total_amount_granted'] += $result->total_amount_granted;
$totals['balance_amount'] += $result->budget - $result->total_amount_granted;
}
}
if ($returnTotals) {
// Format as money.
foreach ($totals as $k => $v) {
$totals[$k] = CRM_Utils_Money::format($v);
}
return $totals;
}
return $grantBudget;
}