From 1f3954326fd2194918331123338c5ca9919e9e83 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 4 Feb 2016 18:44:39 +1300 Subject: [PATCH] CRM-17951 add Chargeback & refund account relationships and Chargeback status --- CRM/Upgrade/Incremental/php/FourSeven.php | 33 +++++++++++++++++++++++ xml/templates/civicrm_data.tpl | 4 ++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index a2e49c35cd..40dfe2bca5 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -161,6 +161,7 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base */ public function upgrade_4_7_2($rev) { $this->addTask('Fix Index on civicrm_financial_item combined entity_id + entity_table', 'addCombinedIndexFinancialItemEntityIDEntityType'); + $this->addTask('enable financial account relationships for chargeback & refund', 'addRefundAndChargeBackAccountsIfNotExist'); } /** @@ -454,4 +455,36 @@ FROM `civicrm_dashboard_contact` WHERE 1 GROUP BY contact_id"; return TRUE; } + /** + * CRM-17951 Add accounts option values for refund and chargeback. + * + * Add Chargeback contribution status and Chargeback and Contra account relationships, + * checking first if one exists. + */ + public function addRefundAndChargeBackAccountsIfNotExist() { + // First we enable and edit the record for Credit contra - this exists but is disabled for most sites. + // Using the ensure function (below) will not enabled a disabled option (by design). + CRM_Core_DAO::executeQuery("UPDATE civicrm_option_value v + INNER JOIN civicrm_option_group g on v.option_group_id=g.id and g.name='account_relationship' + SET v.is_active=1, v.label='Credit/Contra Revenue Account is', v.name='Credit/Contra Revenue Account is', v.description='Credit/Contra Revenue Account is' + WHERE v.name = 'Credit/Contra Account is';"); + + CRM_Core_BAO_OptionValue::ensureOptionValueExists(array( + 'option_group_id' => 'account_relationship', + 'name' => 'Chargeback Account Is', + 'label' => ts('Chargeback Account Is'), + 'is_active' => TRUE, + 'component_id' => 'CiviContribute', + )); + + CRM_Core_BAO_OptionValue::ensureOptionValueExists(array( + 'option_group_id' => 'contribution_status', + 'name' => 'Chargeback', + 'label' => ts('Chargeback'), + 'is_active' => TRUE, + 'component_id' => 'CiviContribute', + )); + return TRUE; + } + } diff --git a/xml/templates/civicrm_data.tpl b/xml/templates/civicrm_data.tpl index 3e287673b0..7d5247d6f6 100644 --- a/xml/templates/civicrm_data.tpl +++ b/xml/templates/civicrm_data.tpl @@ -437,6 +437,7 @@ VALUES (@option_group_id_cs, '{ts escape="sql"}Refunded{/ts}' , 7, 'Refunded' , NULL, 0, NULL, 7, NULL, 0, 1, 1, NULL, NULL), (@option_group_id_cs, '{ts escape="sql"}Partially paid{/ts}', 8, 'Partially paid', NULL, 0, NULL, 8, NULL, 0, 1, 1, NULL, NULL), (@option_group_id_cs, '{ts escape="sql"}Pending refund{/ts}', 9, 'Pending refund', NULL, 0, NULL, 9, NULL, 0, 1, 1, NULL, NULL), + (@option_group_id_cs, '{ts escape="sql"}Chargeback{/ts}', 10, 'Chargeback', NULL, 0, NULL, 10, NULL, 0, 1, 1, NULL, NULL), (@option_group_id_pcp, '{ts escape="sql"}Waiting Review{/ts}', 1, 'Waiting Review', NULL, 0, NULL, 1, NULL, 0, 1, 1, NULL, NULL), (@option_group_id_pcp, '{ts escape="sql"}Approved{/ts}' , 2, 'Approved' , NULL, 0, NULL, 2, NULL, 0, 1, 1, NULL, NULL), @@ -870,7 +871,7 @@ VALUES -- account_relationship (@option_group_id_arel, '{ts escape="sql"}Income Account is{/ts}', 1, 'Income Account is', NULL, 0, 1, 1, 'Income Account is', 0, 1, 1, 2, NULL), - (@option_group_id_arel, '{ts escape="sql"}Credit/Contra Account is{/ts}', 2, 'Credit/Contra Account is', NULL, 0, 0, 2, 'Credit/Contra Account is', 0, 1, 0, 2, NULL), + (@option_group_id_arel, '{ts escape="sql"}Credit/Contra Revenue Account is{/ts}', 2, 'Credit/Contra Revenue Account is', NULL, 0, 0, 2, 'Credit/Contra Revenue Account is', 0, 1, 1, 2, NULL), (@option_group_id_arel, '{ts escape="sql"}Accounts Receivable Account is{/ts}', 3, 'Accounts Receivable Account is', NULL, 0, 0, 3, 'Accounts Receivable Account is', 0, 1, 1, 2, NULL), (@option_group_id_arel, '{ts escape="sql"}Credit Liability Account is{/ts}', 4, 'Credit Liability Account is', NULL, 0, 0, 4, 'Credit Liability Account is', 0, 1, 0, 2, NULL), (@option_group_id_arel, '{ts escape="sql"}Expense Account is{/ts}', 5, 'Expense Account is', NULL, 0, 0, 5, 'Expense Account is', 0, 1, 1, 2, NULL), @@ -879,6 +880,7 @@ VALUES (@option_group_id_arel, '{ts escape="sql"}Premiums Inventory Account is{/ts}', 8, 'Premiums Inventory Account is', NULL, 0, 0, 8, 'Premiums Inventory Account is', 0, 1, 1, 2, NULL), (@option_group_id_arel, '{ts escape="sql"}Discounts Account is{/ts}', 9, 'Discounts Account is', NULL, 0, 0, 9, 'Discounts Account is', 0, 1, 1, 2, NULL), (@option_group_id_arel, '{ts escape="sql"}Sales Tax Account is{/ts}', 10, 'Sales Tax Account is', NULL, 0, 0, 10, 'Sales Tax Account is', 0, 1, 1, 2, NULL), + (@option_group_id_arel, '{ts escape="sql"}Chargeback Account is{/ts}', 11, 'Chargeback Account is', NULL, 0, 0, 11, 'Chargeback Account is', 0, 1, 1, 2, NULL) -- event_contacts (@option_group_id_ere, '{ts escape="sql"}Participant Role{/ts}', 1, 'participant_role', NULL, 0, NULL, 1, NULL, 0, 0, 1, NULL, NULL), -- 2.25.1