Commit e2f98db4 authored by mattwire's avatar mattwire

Add Contribution.Getbalance API

parent ab85b222
<?php
/**
* Action payment.
*
* @param array $params
*
* @return array
* API result array.
* @throws CiviCRM_API3_Exception
*/
function civicrm_api3_contribution_getbalance($params) {
$result['id'] = $params['id'];
$result['total'] = (float) CRM_Price_BAO_LineItem::getLineTotal($params['id']);
$result['balance'] = CRM_Contribute_BAO_Contribution::getContributionBalance($params['id']);
$result['paid'] = $result['total'] - $result['balance'];
$result['currency'] = civicrm_api3('Contribution', 'getvalue', [
'return' => 'currency',
'id' => $params['id'],
]);
return civicrm_api3_create_success($result, $params);
}
/**
* Action payment.
*
* @param array $params
*
* @return array
*/
function _civicrm_api3_contribution_getbalance_spec(&$params) {
$idField = civicrm_api3('Contribution', 'getfield', [
'name' => "id",
'action' => "get",
]);
$params['id'] = $idField['values'];
$params['id']['api.required'] = 1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment