*/
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');
}
/**
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;
+ }
+
}
(@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),
-- 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),
(@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),