diff --git a/civicrm/CRM/Price/BAO/LineItem.php b/civicrm/CRM/Price/BAO/LineItem.php index c00e3fda01808a41788d61a0da02c200c238007c..61a8f0b0883c943ea86fca7b57870c4353f8d10c 100644 --- a/civicrm/CRM/Price/BAO/LineItem.php +++ b/civicrm/CRM/Price/BAO/LineItem.php @@ -769,7 +769,10 @@ WHERE li.contribution_id = %1"; )); unset($updateFinancialItemInfoValues['financialTrxn']); } - elseif (!empty($updateFinancialItemInfoValues['link-financial-trxn']) && $newFinancialItem->amount != 0) { + elseif ($newFinancialItem->amount != 0 && (// bug in EntityFinancialTrxn.create API which doesn't recognize 0 amount + !empty($updateFinancialItemInfoValues['link-financial-trxn']) || + in_array($contributionStatus, ['Pending refund', 'Partially paid']) + )) { civicrm_api3('EntityFinancialTrxn', 'create', array( 'entity_id' => $newFinancialItem->id, 'entity_table' => 'civicrm_financial_item',