Contribution api - get paid, balance
@colemanw just wanted to put this on your radar - being able to get
contribution.paid_amount and contribution.balance
would be hugely use at the api level , search kit AND the template / token level.
We currently have a php function & what it does to get paid_amount is this...
I suspect there are some challenges in that it would have to be a subquery which would have performance limits but it would have a lot of application
$sql = "SELECT SUM(ft.total_amount) FROM civicrm_financial_trxn ft INNER JOIN civicrm_entity_financial_trxn eft ON (eft.financial_trxn_id = ft.id AND eft.entity_table = 'civicrm_contribution') WHERE eft.entity_id = %1 AND ft.is_payment = 1 AND ft.status_id IN (%2) "; return (float) CRM_Core_DAO::singleValueQuery($sql, [ 1 => [$contributionID, 'Integer'], // status IDs are 'completed' & 'refunded' 2 => [implode(',', $statusIDs), 'CommaSeparatedIntegers'], ]);