From: Pradeep Nayak Date: Wed, 15 Jun 2016 10:13:27 +0000 (+0530) Subject: CRM-16189, added 2 default Financial Account on install and upgrade X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9845bedbc14fdafe89ad4e1ff8b57d193979fa08;p=civicrm-core.git CRM-16189, added 2 default Financial Account on install and upgrade ---------------------------------------- * CRM-16189: Improve support for Accrual Method bookkeeping https://issues.civicrm.org/jira/browse/CRM-16189 --- diff --git a/CRM/Upgrade/Incremental/sql/4.7.9.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.9.mysql.tpl index 30ff4d2e43..77275ffb71 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.9.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.9.mysql.tpl @@ -32,3 +32,24 @@ INSERT INTO `civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`) VALUES (@option_group_id_arel, {localize}'{ts escape="sql"}Deferred Revenue Account is{/ts}'{/localize}, @option_group_id_arel_val+1, 'Deferred Revenue Account is', NULL, 0, 0, @option_group_id_arel_wt+1, {localize}'Deferred Revenue Account is'{/localize}, 0, 1, 1, 2, NULL); + +SELECT @option_group_id_fat := max(id) from civicrm_option_group where name = 'financial_account_type'; +SELECT @opLiability := value FROM civicrm_option_value WHERE name = 'Liability' and option_group_id = @option_group_id_fat; +SELECT @domainContactId := contact_id from civicrm_domain where id = {$domainID}; +INSERT IGNORE INTO + `civicrm_financial_account` (`name`, `contact_id`, `financial_account_type_id`, `description`, `accounting_code`, `account_type_code`, `is_reserved`, `is_active`, `is_deductible`, `is_default`) +VALUES + ('{ts escape="sql"}Deferred Revenue - Event Fee{/ts}', @domainContactId, @opLiability, 'Event revenue to be recognized in future months when the events occur', '2730', 'OCLIAB', 0, 1, 0, 0), + ('{ts escape="sql"}Deferred Revenue - Member Dues{/ts}', @domainContactId, @opLiability, 'Membership revenue to be recognized in future months', '2740', 'OCLIAB', 0, 1, 0, 0); + +SELECT @financial_account_id_dref := max(id) FROM civicrm_financial_account WHERE name = '{ts escape="sql"}Deferred Revenue - Event Fee{/ts}'; +SELECT @financial_account_id_drmd := max(id) FROM civicrm_financial_account WHERE name = '{ts escape="sql"}Deferred Revenue - Member Dues{/ts}'; +SELECT @option_value_rel_id_dr := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Deferred Revenue Account is'; +SELECT @financial_type_id_md := max(id) FROM civicrm_financial_type WHERE name = '{ts escape="sql"}Member Dues{/ts}'; +SELECT @financial_type_id_ef := max(id) FROM civicrm_financial_type WHERE name = '{ts escape="sql"}Event Fee{/ts}'; + +INSERT INTO `civicrm_entity_financial_account` + (entity_table, entity_id, account_relationship, financial_account_id) +VALUES + ('civicrm_financial_type', @financial_type_id_ef, @option_value_rel_id_dr, @financial_account_id_dref), + ('civicrm_financial_type', @financial_type_id_md, @option_value_rel_id_dr, @financial_account_id_drmd); diff --git a/xml/templates/civicrm_data.tpl b/xml/templates/civicrm_data.tpl index 2e3474b86c..7eafdfaf58 100644 --- a/xml/templates/civicrm_data.tpl +++ b/xml/templates/civicrm_data.tpl @@ -1042,7 +1042,9 @@ VALUES ( '{ts escape="sql"}Premiums{/ts}' , @contactID, @opCost, 'Account to record cost of premiums provided to payors', '5100', 'COGS', 0, 1, 0, 1 ), ( '{ts escape="sql"}Premiums inventory{/ts}' , @contactID, @opAsset, 'Account representing value of premiums inventory', '1375', 'OCASSET', 0, 1, 0, 0 ), ( '{ts escape="sql"}Discounts{/ts}' , @contactID, @opval, 'Contra-revenue account for amounts discounted from sales', '4900', 'INC', 0, 1, 0, 0 ), - ( '{ts escape="sql"}Payment Processor Account{/ts}', @contactID, @opAsset, 'Account to record payments into a payment processor merchant account', '1150', 'BANK', 0, 1, 0, 0 + ( '{ts escape="sql"}Payment Processor Account{/ts}', @contactID, @opAsset, 'Account to record payments into a payment processor merchant account', '1150', 'BANK', 0, 1, 0, 0), + ( '{ts escape="sql"}Deferred Revenue - Event Fee{/ts}', @contactID, @opLiability, 'Event revenue to be recognized in future months when the events occur', '2730', 'OCLIAB', 0, 1, 0, 0), + ( '{ts escape="sql"}Deferred Revenue - Member Dues{/ts}', @contactID, @opLiability, 'Membership revenue to be recognized in future months', '2740', 'OCLIAB', 0, 1, 0, 0 ); -- Now insert option values which require domainID @@ -1653,6 +1655,7 @@ SELECT @option_value_rel_id_exp := value FROM civicrm_option_value WHERE option SELECT @option_value_rel_id_ar := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Accounts Receivable Account is'; SELECT @option_value_rel_id_as := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Asset Account is'; SELECT @option_value_rel_id_cg := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Cost of Sales Account is'; +SELECT @option_value_rel_id_dr := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Deferred Revenue Account is'; SELECT @financial_type_id_dtn := max(id) FROM civicrm_financial_type WHERE name = '{ts escape="sql"}Donation{/ts}'; SELECT @financial_type_id_md := max(id) FROM civicrm_financial_type WHERE name = '{ts escape="sql"}Member Dues{/ts}'; @@ -1668,6 +1671,8 @@ SELECT @financial_account_id_ap := max(id) FROM civicrm_financial_account SELECT @financial_account_id_ar := max(id) FROM civicrm_financial_account WHERE name = '{ts escape="sql"}Deposit Bank Account{/ts}'; SELECT @financial_account_id_pp := max(id) FROM civicrm_financial_account WHERE name = '{ts escape="sql"}Payment Processor Account{/ts}'; SELECT @financial_account_id_pr := max(id) FROM civicrm_financial_account WHERE name = '{ts escape="sql"}Premiums{/ts}'; +SELECT @financial_account_id_dref := max(id) FROM civicrm_financial_account WHERE name = '{ts escape="sql"}Deferred Revenue - Event Fee{/ts}'; +SELECT @financial_account_id_drmd := max(id) FROM civicrm_financial_account WHERE name = '{ts escape="sql"}Deferred Revenue - Member Dues{/ts}'; INSERT INTO `civicrm_entity_financial_account` ( entity_table, entity_id, account_relationship, financial_account_id ) @@ -1680,6 +1685,7 @@ VALUES ( 'civicrm_financial_type', @financial_type_id_md, @option_value_rel_id_exp, @financial_account_id_bf ), ( 'civicrm_financial_type', @financial_type_id_md, @option_value_rel_id_ar, @financial_account_id_ap ), ( 'civicrm_financial_type', @financial_type_id_md, @option_value_rel_id_cg, @financial_account_id_pr ), + ( 'civicrm_financial_type', @financial_type_id_md, @option_value_rel_id_dr, @financial_account_id_drmd ), ( 'civicrm_financial_type', @financial_type_id_cc, @option_value_rel_id, @financial_account_id_cc ), ( 'civicrm_financial_type', @financial_type_id_cc, @option_value_rel_id_exp, @financial_account_id_bf ), ( 'civicrm_financial_type', @financial_type_id_cc, @option_value_rel_id_ar, @financial_account_id_ap ), @@ -1687,6 +1693,7 @@ VALUES ( 'civicrm_financial_type', @financial_type_id_ef, @option_value_rel_id_exp, @financial_account_id_bf ), ( 'civicrm_financial_type', @financial_type_id_ef, @option_value_rel_id_ar, @financial_account_id_ap ), ( 'civicrm_financial_type', @financial_type_id_ef, @option_value_rel_id, @financial_account_id_ef ), + ( 'civicrm_financial_type', @financial_type_id_ef, @option_value_rel_id_dr, @financial_account_id_dref ), ( 'civicrm_financial_type', @financial_type_id_ef, @option_value_rel_id_cg, @financial_account_id_pr ); -- CRM-11516