Skip to content

Commit

Permalink
CRM-19715 (IIDA-96), removed opening_balance and current_period_openi…
Browse files Browse the repository at this point in the history
…ng_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
  • Loading branch information
pradpnayak committed Mar 13, 2017
1 parent fecc7f4 commit 658aaf2
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 117 deletions.
9 changes: 0 additions & 9 deletions CRM/Financial/BAO/FinancialAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 1 addition & 39 deletions CRM/Financial/DAO/FinancialAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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']);
}
Expand Down
16 changes: 0 additions & 16 deletions CRM/Financial/Form/FinancialAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions CRM/Upgrade/Incremental/sql/4.7.18.mysql.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
2 changes: 1 addition & 1 deletion sql/civicrm_generated.mysql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
34 changes: 0 additions & 34 deletions templates/CRM/Financial/Form/FinancialAccount.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,41 +91,7 @@
<span class="description">{ts}Is this account to be used as the default account for its financial account type when associating financial accounts with financial types?{/ts}</span>
</td>
</tr>
{if $form.opening_balance}
<tr class="crm-contribution-form-block-opening_balance">
<td class="label">{$form.opening_balance.label}</td>
<td class="html-adjust">{$form.opening_balance.html}
</td>
</tr>
<tr class="crm-contribution-form-block-current_period_opening_balance">
<td class="label">{$form.current_period_opening_balance.label}</td>
<td class="html-adjust">{$form.current_period_opening_balance.html}
</td>
</tr>
{/if}
</table>
{/if}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="botttom"}</div>
</div>
{if $form.opening_balance}
{literal}
<script type="text/javascript">
CRM.$(function($) {
$('#financial_account_type_id').on('change', showHideElement);
showHideElement();
function showHideElement() {
var financialAccountType = $('#financial_account_type_id').val();
var financialAccountTypes = '{/literal}{$limitedAccount}{literal}';
if ($.inArray(financialAccountType, financialAccountTypes) > -1) {
$('tr.crm-contribution-form-block-current_period_opening_balance').show();
$('tr.crm-contribution-form-block-opening_balance').show();
}
else {
$('tr.crm-contribution-form-block-current_period_opening_balance').hide();
$('tr.crm-contribution-form-block-opening_balance').hide();
}
}
});
</script>
{/literal}
{/if}
18 changes: 0 additions & 18 deletions xml/schema/Financial/FinancialAccount.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,4 @@
<unique>true</unique>
<add>4.3</add>
</index>
<field>
<name>opening_balance</name>
<type>decimal</type>
<title>Opening Balance</title>
<comment>Contains the opening balance for this financial account</comment>
<default>0</default>
<length>20,2</length>
<add>4.7</add>
</field>
<field>
<name>current_period_opening_balance</name>
<type>decimal</type>
<length>20,2</length>
<title>Current period opening Balance</title>
<comment>Contains the opening balance for the current period for this financial account</comment>
<default>0</default>
<add>4.7</add>
</field>
</table>

0 comments on commit 658aaf2

Please sign in to comment.