From 7340e501fef04404a3ffd4ed38815b16786f75ec Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Wed, 20 Jul 2016 19:24:59 +0530 Subject: [PATCH] --CRM-16189, added hook to alter deferred revenue items --- CRM/Core/BAO/FinancialTrxn.php | 4 +++- CRM/Utils/Hook.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/FinancialTrxn.php b/CRM/Core/BAO/FinancialTrxn.php index c2f2c5f118..ab589e7844 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Core/BAO/FinancialTrxn.php @@ -669,7 +669,9 @@ WHERE pp.participant_id = {$entityId} AND ft.to_financial_account_id != {$toFina } } $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' ")); - // TODO: Call hook to alter $deferredRevenues + + CRM_Utils_Hook::alterDeferredRevenueItems($deferredRevenues); + foreach ($deferredRevenues as $key => $deferredRevenue) { $results = civicrm_api3('EntityFinancialAccount', 'get', array( 'entity_table' => 'civicrm_financial_type', diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index a60b911bcb..e52af4e30b 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -2094,6 +2094,21 @@ abstract class CRM_Utils_Hook { ); } + /** + * This hook is called to alter Deferred revenue item values just before they are + * inserted in civicrm_financial_trxn table + * + * @param array $deferredRevenues + * + * @return mixed + */ + public static function alterDeferredRevenueItems(&$deferredRevenues) { + return self::singleton()->invoke(1, $deferredRevenues, self::$_nullObject, + self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, + 'civicrm_alterDeferredRevenueItems' + ); + } + /** * This hook is called when the entries of the CSV Batch export are mapped. * -- 2.25.1