3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class for handling processing of financial records.
15 * This is a place to extract the financial record processing code to
16 * in order to clean it up.
18 * @internal core use only.
21 * @copyright CiviCRM LLC https://civicrm.org/licensing
23 class CRM_Contribute_BAO_FinancialProcessor
{
26 * Get the financial account for the item associated with the new transaction.
28 * @param array $params
33 public static function getFinancialAccountForStatusChangeTrxn($params, $default) {
34 if (!empty($params['financial_account_id'])) {
35 return $params['financial_account_id'];
38 $contributionStatus = CRM_Contribute_PseudoConstant
::contributionStatus($params['contribution_status_id'], 'name');
39 $preferredAccountsRelationships = [
40 'Refunded' => 'Credit/Contra Revenue Account is',
41 'Chargeback' => 'Chargeback Account is',
44 if (array_key_exists($contributionStatus, $preferredAccountsRelationships)) {
45 $financialTypeID = !empty($params['financial_type_id']) ?
$params['financial_type_id'] : $params['prevContribution']->financial_type_id
;
46 return CRM_Financial_BAO_FinancialAccount
::getFinancialAccountForFinancialTypeByRelationship(
48 $preferredAccountsRelationships[$contributionStatus]