forked from CiviWare/org.agbu.annualgrantbudgets
support totals on grant budget screen
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user