From 658aaf245031934d0f2d3e2f7dd198a2c329e4ec Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Mon, 13 Mar 2017 19:52:22 +0530 Subject: [PATCH] CRM-19715 (IIDA-96), removed opening_balance and current_period_opening_balance field from civicrm_financial_account table and code ---------------------------------------- * CRM-19715: https://issues.civicrm.org/jira/browse/CRM-19715 CRM-19715, added DAO changes ---------------------------------------- * CRM-19715: Remove Close Accounting Period code https://issues.civicrm.org/jira/browse/CRM-19715 --- CRM/Financial/BAO/FinancialAccount.php | 9 ----- CRM/Financial/DAO/FinancialAccount.php | 40 +------------------ CRM/Financial/Form/FinancialAccount.php | 16 -------- CRM/Upgrade/Incremental/sql/4.7.18.mysql.tpl | 5 +++ sql/civicrm_generated.mysql | 2 +- .../CRM/Financial/Form/FinancialAccount.tpl | 34 ---------------- xml/schema/Financial/FinancialAccount.xml | 18 --------- 7 files changed, 7 insertions(+), 117 deletions(-) diff --git a/CRM/Financial/BAO/FinancialAccount.php b/CRM/Financial/BAO/FinancialAccount.php index 9ba7bf4ecc2b..6c429f5d4e51 100644 --- a/CRM/Financial/BAO/FinancialAccount.php +++ b/CRM/Financial/BAO/FinancialAccount.php @@ -126,15 +126,6 @@ public static function add(&$params) { } $financialAccount->copyValues($params); - //CRM-16189 - $accountType = CRM_Core_PseudoConstant::accountOptionValues( - 'financial_account_type', - NULL, - " AND v.name IN ('Liability', 'Asset') " - ); - if (empty($params['id']) && !CRM_Utils_Array::value($financialAccount->financial_account_type_id, $accountType)) { - $financialAccount->opening_balance = $financialAccount->current_period_opening_balance = '0.00'; - } $financialAccount->save(); // invoke post hook diff --git a/CRM/Financial/DAO/FinancialAccount.php b/CRM/Financial/DAO/FinancialAccount.php index 1e63f7f04249..ac2c79c00ac4 100644 --- a/CRM/Financial/DAO/FinancialAccount.php +++ b/CRM/Financial/DAO/FinancialAccount.php @@ -30,7 +30,7 @@ * * Generated from xml/schema/CRM/Financial/FinancialAccount.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:e2138251a2433069b991db111a5f55d2) + * (GenCodeChecksum:cc26d75452b2f2a5423d6e5a59b6a3a3) */ require_once 'CRM/Core/DAO.php'; require_once 'CRM/Utils/Type.php'; @@ -140,18 +140,6 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO { * @var boolean */ public $is_default; - /** - * Contains the opening balance for this financial account - * - * @var float - */ - public $opening_balance; - /** - * Contains the opening balance for the current period for this financial account - * - * @var float - */ - public $current_period_opening_balance; /** * Class constructor. */ @@ -351,32 +339,6 @@ static function &fields() { 'entity' => 'FinancialAccount', 'bao' => 'CRM_Financial_BAO_FinancialAccount', ) , - 'opening_balance' => array( - 'name' => 'opening_balance', - 'type' => CRM_Utils_Type::T_MONEY, - 'title' => ts('Opening Balance') , - 'description' => 'Contains the opening balance for this financial account', - 'precision' => array( - 20, - 2 - ) , - 'table_name' => 'civicrm_financial_account', - 'entity' => 'FinancialAccount', - 'bao' => 'CRM_Financial_BAO_FinancialAccount', - ) , - 'current_period_opening_balance' => array( - 'name' => 'current_period_opening_balance', - 'type' => CRM_Utils_Type::T_MONEY, - 'title' => ts('Current period opening Balance') , - 'description' => 'Contains the opening balance for the current period for this financial account', - 'precision' => array( - 20, - 2 - ) , - 'table_name' => 'civicrm_financial_account', - 'entity' => 'FinancialAccount', - 'bao' => 'CRM_Financial_BAO_FinancialAccount', - ) , ); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); } diff --git a/CRM/Financial/Form/FinancialAccount.php b/CRM/Financial/Form/FinancialAccount.php index 9339d59fcb57..eff3122f638d 100644 --- a/CRM/Financial/Form/FinancialAccount.php +++ b/CRM/Financial/Form/FinancialAccount.php @@ -104,21 +104,6 @@ public function buildQuickForm() { $element->freeze(); } - //CRM-16189 - if (CRM_Contribute_BAO_Contribution::checkContributeSettings('financial_account_bal_enable')) { - $this->add('text', 'opening_balance', ts('Opening Balance'), $attributes['opening_balance']); - $this->add('text', 'current_period_opening_balance', ts('Current Period Opening Balance'), $attributes['current_period_opening_balance']); - $financialAccountType = CRM_Core_PseudoConstant::get( - 'CRM_Financial_DAO_FinancialAccount', - 'financial_account_type_id', - array('labelColumn' => 'name') - ); - $limitedAccount = array( - array_search('Asset', $financialAccountType), - array_search('Liability', $financialAccountType), - ); - $this->assign('limitedAccount', json_encode($limitedAccount)); - } $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id'); if (!empty($financialAccountType)) { $element = $this->add('select', 'financial_account_type_id', ts('Financial Account Type'), @@ -192,7 +177,6 @@ public function setDefaultValues() { $defaults = parent::setDefaultValues(); if ($this->_action & CRM_Core_Action::ADD) { $defaults['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', CRM_Core_Config::domainID(), 'contact_id'); - $defaults['opening_balance'] = $defaults['current_period_opening_balance'] = '0.00'; } return $defaults; } diff --git a/CRM/Upgrade/Incremental/sql/4.7.18.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.18.mysql.tpl index a5cf38f85d78..b63fcdfa2262 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.18.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.18.mysql.tpl @@ -72,3 +72,8 @@ UPDATE `civicrm_country` SET `name`='Virgin Islands, British' WHERE `name` = 'Vi --- CRM-19715 Remove Close Accounting Period code - now in an extension. DELETE FROM civicrm_navigation WHERE url = 'civicrm/admin/contribute/closeaccperiod?reset=1' AND name = 'Close Accounting Period'; + +-- Drop field opening_balance and current_period_opening_balance +ALTER TABLE `civicrm_financial_account` + DROP `opening_balance`, + DROP `current_period_opening_balance`; diff --git a/sql/civicrm_generated.mysql b/sql/civicrm_generated.mysql index ccc977d49b41..4347448b4932 100644 --- a/sql/civicrm_generated.mysql +++ b/sql/civicrm_generated.mysql @@ -513,7 +513,7 @@ UNLOCK TABLES; LOCK TABLES `civicrm_financial_account` WRITE; /*!40000 ALTER TABLE `civicrm_financial_account` DISABLE KEYS */; -INSERT INTO `civicrm_financial_account` (`id`, `name`, `contact_id`, `financial_account_type_id`, `accounting_code`, `account_type_code`, `description`, `parent_id`, `is_header_account`, `is_deductible`, `is_tax`, `tax_rate`, `is_reserved`, `is_active`, `is_default`, `opening_balance`, `current_period_opening_balance`) VALUES (1,'Donation',1,3,'4200','INC','Default account for donations',NULL,0,1,0,NULL,0,1,1,0.00,0.00),(2,'Member Dues',1,3,'4400','INC','Default account for membership sales',NULL,0,1,0,NULL,0,1,0,0.00,0.00),(3,'Campaign Contribution',1,3,'4100','INC','Sample account for recording payments to a campaign',NULL,0,0,0,NULL,0,1,0,0.00,0.00),(4,'Event Fee',1,3,'4300','INC','Default account for event ticket sales',NULL,0,0,0,NULL,0,1,0,0.00,0.00),(5,'Banking Fees',1,5,'5200','EXP','Payment processor fees and manually recorded banking fees',NULL,0,0,0,NULL,0,1,1,0.00,0.00),(6,'Deposit Bank Account',1,1,'1100','BANK','All manually recorded cash and cheques go to this account',NULL,0,0,0,NULL,0,1,1,0.00,0.00),(7,'Accounts Receivable',1,1,'1200','AR','Amounts to be received later (eg pay later event revenues)',NULL,0,0,0,NULL,0,1,0,0.00,0.00),(8,'Accounts Payable',1,2,'2200','AP','Amounts to be paid out such as grants and refunds',NULL,0,0,0,NULL,0,1,1,0.00,0.00),(9,'Premiums',1,4,'5100','COGS','Account to record cost of premiums provided to payors',NULL,0,0,0,NULL,0,1,1,0.00,0.00),(10,'Premiums inventory',1,1,'1375','OCASSET','Account representing value of premiums inventory',NULL,0,0,0,NULL,0,1,0,0.00,0.00),(11,'Discounts',1,3,'4900','INC','Contra-revenue account for amounts discounted from sales',NULL,0,0,0,NULL,0,1,0,0.00,0.00),(12,'Payment Processor Account',1,1,'1150','BANK','Account to record payments into a payment processor merchant account',NULL,0,0,0,NULL,0,1,0,0.00,0.00),(13,'Deferred Revenue - Event Fee',1,2,'2730','OCLIAB','Event revenue to be recognized in future months when the events occur',NULL,0,0,0,NULL,0,1,0,0.00,0.00),(14,'Deferred Revenue - Member Dues',1,2,'2740','OCLIAB','Membership revenue to be recognized in future months',NULL,0,0,0,NULL,0,1,0,0.00,0.00); +INSERT INTO `civicrm_financial_account` (`id`, `name`, `contact_id`, `financial_account_type_id`, `accounting_code`, `account_type_code`, `description`, `parent_id`, `is_header_account`, `is_deductible`, `is_tax`, `tax_rate`, `is_reserved`, `is_active`, `is_default`) VALUES (1,'Donation',1,3,'4200','INC','Default account for donations',NULL,0,1,0,NULL,0,1,1),(2,'Member Dues',1,3,'4400','INC','Default account for membership sales',NULL,0,1,0,NULL,0,1,0),(3,'Campaign Contribution',1,3,'4100','INC','Sample account for recording payments to a campaign',NULL,0,0,0,NULL,0,1,0),(4,'Event Fee',1,3,'4300','INC','Default account for event ticket sales',NULL,0,0,0,NULL,0,1,0),(5,'Banking Fees',1,5,'5200','EXP','Payment processor fees and manually recorded banking fees',NULL,0,0,0,NULL,0,1,1),(6,'Deposit Bank Account',1,1,'1100','BANK','All manually recorded cash and cheques go to this account',NULL,0,0,0,NULL,0,1,1),(7,'Accounts Receivable',1,1,'1200','AR','Amounts to be received later (eg pay later event revenues)',NULL,0,0,0,NULL,0,1,0),(8,'Accounts Payable',1,2,'2200','AP','Amounts to be paid out such as grants and refunds',NULL,0,0,0,NULL,0,1,1),(9,'Premiums',1,4,'5100','COGS','Account to record cost of premiums provided to payors',NULL,0,0,0,NULL,0,1,1),(10,'Premiums inventory',1,1,'1375','OCASSET','Account representing value of premiums inventory',NULL,0,0,0,NULL,0,1,0),(11,'Discounts',1,3,'4900','INC','Contra-revenue account for amounts discounted from sales',NULL,0,0,0,NULL,0,1,0),(12,'Payment Processor Account',1,1,'1150','BANK','Account to record payments into a payment processor merchant account',NULL,0,0,0,NULL,0,1,0),(13,'Deferred Revenue - Event Fee',1,2,'2730','OCLIAB','Event revenue to be recognized in future months when the events occur',NULL,0,0,0,NULL,0,1,0),(14,'Deferred Revenue - Member Dues',1,2,'2740','OCLIAB','Membership revenue to be recognized in future months',NULL,0,0,0,NULL,0,1,0); /*!40000 ALTER TABLE `civicrm_financial_account` ENABLE KEYS */; UNLOCK TABLES; diff --git a/templates/CRM/Financial/Form/FinancialAccount.tpl b/templates/CRM/Financial/Form/FinancialAccount.tpl index 5ff310f8e7b5..e47c2c693de4 100644 --- a/templates/CRM/Financial/Form/FinancialAccount.tpl +++ b/templates/CRM/Financial/Form/FinancialAccount.tpl @@ -91,41 +91,7 @@ {ts}Is this account to be used as the default account for its financial account type when associating financial accounts with financial types?{/ts} - {if $form.opening_balance} - - {$form.opening_balance.label} - {$form.opening_balance.html} - - - - {$form.current_period_opening_balance.label} - {$form.current_period_opening_balance.html} - - - {/if} {/if}
{include file="CRM/common/formButtons.tpl" location="botttom"}
-{if $form.opening_balance} -{literal} - -{/literal} -{/if} diff --git a/xml/schema/Financial/FinancialAccount.xml b/xml/schema/Financial/FinancialAccount.xml index 4ec6f94416ba..eedf5c621069 100644 --- a/xml/schema/Financial/FinancialAccount.xml +++ b/xml/schema/Financial/FinancialAccount.xml @@ -162,22 +162,4 @@ true 4.3 - - opening_balance - decimal - Opening Balance - Contains the opening balance for this financial account - 0 - 20,2 - 4.7 - - - current_period_opening_balance - decimal - 20,2 - Current period opening Balance - Contains the opening balance for the current period for this financial account - 0 - 4.7 -