There are two ways to refund from an accounting perspective:
- Just reverse out the payment (credit the revenue and debit the asset account like a bank account that received the deposit and is used to pay the refund), or
- Create a Pending Refund, then Process the Refund. From an accounting perspective, this means 1) Move the monies to be refunded into accounts payable (ie credit accounts payable and debit the original revenue account or a related contra revenue account), then 2) at some later point when the refund is paid (via check, etc) clear the funds from the accounts payable account using the account used to pay (debit accounts payable and credit bank account). See eg http://accounting-simplified.com/accounting-for-sales-return.html
1 was implemented first in core. 2 is being implemented as an extension.
- Only a single Accounts Payable account is needed.
- Add 'Refunded' option value in Financial Item Status option group on upgrade and in tarball. Check if this causes issues anywhere, eg reports.
$result = civicrm_api3('refund', 'create', array(
'contribution_id' => 1, /* required */
'total_amount' => 50, /* optional, if not present, will default to amount outstanding;
if present and line_items present, must equal sum of amounts for specified line_items */
'line_items' => array ( /* optional, if not present, will default to all line items for contribution;
if present, must be non-null, ie have at least one line_item array */
'line_item_id' => 1, /* required */
'amount' => 20, /* optional, if not present, will default to amount outstanding;
if present, must be for same amount as outstanding in initial implementation */
'line_item_id' => 2,
'amount' => 30,
The Refund API uses the financial_type for line items to determine the appropriate financial account to debit by finding the 'Is Contra Revenue Account' 'Is Revenue Account' entity_financial_account relationship for the FT, same as for a contribution.
For each line item fully refunded,
More to come re: how to specify item to be partially refunded when a line item is for qty>1 (eg multiple tickets), how to specify the refund instrument, how to determine whether to record accounts payable, storage of refund.