CRM-19715 (IIDA-96), removed opening_balance and current_period_opening_balance field...
authorPradeep Nayak <pradpnayak@gmail.com>
Mon, 13 Mar 2017 14:22:22 +0000 (19:52 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Wed, 29 Mar 2017 21:46:15 +0000 (03:16 +0530)
----------------------------------------
* 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-19715, removed upgrade code to drop fields from civicrm_financial_account table

----------------------------------------
* CRM-19715: Remove Close Accounting Period code
  https://issues.civicrm.org/jira/browse/CRM-19715

CRM/Financial/BAO/FinancialAccount.php
CRM/Financial/DAO/FinancialAccount.php
CRM/Financial/Form/FinancialAccount.php
sql/civicrm_generated.mysql
templates/CRM/Financial/Form/FinancialAccount.tpl
xml/schema/Financial/FinancialAccount.xml

index 9ba7bf4ecc2b94078b42bfb2508556bb8584f291..6c429f5d4e5147e15c8f3f0204552eb50a27596b 100644 (file)
@@ -126,15 +126,6 @@ class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAcco
     }
 
     $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
index 9fb34a8629950dea80462af8bfdc94029aa471f2..54397beeb1b1f1cf5815d1427a5c2277f78083b4 100644 (file)
@@ -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 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           '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']);
     }
index 9339d59fcb57a134f211ab1cd72c4ee65a6c5512..eff3122f638d895c210e1cae1010c5f2cd137ab8 100644 (file)
@@ -104,21 +104,6 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form {
       $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 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form {
     $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;
   }
index 3382f96432596dc11ecff74ec0aa0b1ea1d4da18..a579009738e1092a0ddfae5aa816b8a1b62157a8 100644 (file)
@@ -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;
 
index 5ff310f8e7b52dc9cdc3d757306a37df3a683c4c..e47c2c693de48b575c1bf5ae6b44f080b01bd433 100644 (file)
         <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}
index 4ec6f94416bae79236360ee6afe0f732917f3cf0..eedf5c621069640207403b413993446f6d62fba4 100644 (file)
     <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>