Skip to content
Snippets Groups Projects
Commit 2506e932 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #768 from pradpnayak/CRM-12470

Crm 12470
parents b6d7a8cd 7b3622bf
Branches
Tags
No related merge requests found
......@@ -128,11 +128,21 @@ class CRM_Admin_Page_AJAX {
$status = ts('Are you sure you want to disable this relationship type?') . '<br/><br/>' . ts('Users will no longer be able to select this value when adding or editing relationships between contacts.');
break;
case 'CRM_Contribute_BAO_FinancialType':
case 'CRM_Financial_BAO_FinancialType':
$status = ts('Are you sure you want to disable this financial type?');
break;
case 'CRM_Financial_BAO_FinancialAccount':
if (!CRM_Financial_BAO_FinancialAccount::getARAccounts($recordID)) {
$show = 'noButton';
$status = ts('The selected financial account cannot be disabled because least one Accounts Receivable type account is required (to ensure that accounting transactions are in balance).');
}
else {
$status = ts('Are you sure you want to disable this financial account?');
}
break;
case 'CRM_Financial_BAO_PaymentProcessor':
case 'CRM_Financial_BAO_PaymentProcessor':
$status = ts('Are you sure you want to disable this payment processor?') . ' <br/><br/>' . ts('Users will no longer be able to select this value when adding or editing transaction pages.');
break;
......
......@@ -185,9 +185,13 @@ WHERE cft.id = %1
* @return integer count
* @static
*/
static function getARAccounts($financialAccountId, $financialAccountTypeId, $accountTypeCode = 'ar') {
static function getARAccounts($financialAccountId, $financialAccountTypeId = NULL, $accountTypeCode = 'ar') {
if (!$financialAccountTypeId) {
$financialAccountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
$financialAccountTypeId = array_search('Asset', $financialAccountType);
}
$query = "SELECT count(id) FROM civicrm_financial_account WHERE financial_account_type_id = %1 AND LCASE(account_type_code) = %2
AND id != %3;";
AND id != %3 AND is_active = 1;";
$params = array(
1 => array($financialAccountTypeId, 'Integer'),
2 => array(strtolower($accountTypeCode), 'String'),
......
......@@ -101,12 +101,17 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType {
$params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, false);
// action is taken depending upon the mode
$financialType = new CRM_Financial_DAO_FinancialType( );
$financialType->copyValues( $params );;
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->copyValues($params);
if (CRM_Utils_Array::value('financialType', $ids)) {
$financialType->id = CRM_Utils_Array::value('financialType', $ids);
}
$financialType->save( );
$financialType->save();
// CRM-12470
if (!CRM_Utils_Array::value('financialType', $ids)) {
$titles = CRM_Financial_BAO_FinancialTypeAccount::createDefaultFinancialAccounts($financialType);
$financialType->titles = $titles;
}
return $financialType;
}
......
......@@ -210,5 +210,69 @@ WHERE cog.name = 'payment_instrument' ";
return $paymentInstrumentValue ? self::$financialAccount[$paymentInstrumentValue] : self::$financialAccount;
}
/**
* Function to create default entity financial accounts
* for financial type
* CRM-12470
*
* @param int $financialTypeId financial type id
*
* @static
*/
static function createDefaultFinancialAccounts($financialType) {
$titles = array();
$financialAccountTypeID = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
$accountRelationship = CRM_Core_PseudoConstant::accountOptionValues('account_relationship');
$relationships = array (
array_search('Accounts Receivable Account is', $accountRelationship) => array_search('Asset', $financialAccountTypeID),
array_search('Expense Account is', $accountRelationship) => array_search('Expenses', $financialAccountTypeID),
array_search('Cost of Sales Account is', $accountRelationship) => array_search('Cost of Sales', $financialAccountTypeID),
array_search('Income Account is', $accountRelationship) => array_search('Revenue', $financialAccountTypeID),
);
$params = array(
'name' => $financialType->name,
'contact_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', CRM_Core_Config::domainID(), 'contact_id'),
'financial_account_type_id' => array_search('Revenue', $financialAccountTypeID),
'description' => $financialType->description,
'account_type_code' => 'INC',
'is_active' => 1,
);
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, CRM_Core_DAO::$_nullArray);
$params = array (
'entity_table' => 'civicrm_financial_type',
'entity_id' => $financialType->id,
);
foreach ($relationships as $key => $value) {
if ($accountRelationship[$key] == 'Accounts Receivable Account is') {
$params['financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', 'Accounts Receivable', 'id', 'name');
if (!empty($params['financial_account_id'])) {
$titles[] = 'Accounts Receivable';
}
else {
$query = "SELECT financial_account_id, name FROM civicrm_entity_financial_account
LEFT JOIN civicrm_financial_account ON civicrm_financial_account.id = civicrm_entity_financial_account.financial_account_id
WHERE account_relationship = {$key} AND entity_table = 'civicrm_financial_type' LIMIT 1";
$dao = CRM_Core_DAO::executeQuery($query);
$dao->fetch();
$params['financial_account_id'] = $dao->financial_account_id;
$titles[] = $dao->name;
}
}
elseif ($accountRelationship[$key] == 'Income Account is') {
$params['financial_account_id'] = $financialAccount->id;
}
else {
$query = "SELECT id, name FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = {$value}";
$dao = CRM_Core_DAO::executeQuery($query);
$dao->fetch();
$params['financial_account_id'] = $dao->id;
$titles[] = $dao->name;
}
$params['account_relationship'] = $key;
self::add($params);
}
return $titles;
}
}
......@@ -106,10 +106,13 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form {
$this->add('hidden', 'contact_id', '', array('id' => 'contact_id'));
$this->add('text', 'tax_rate', ts('Tax Rate'), $attributes['tax_rate']);
$this->add('checkbox', 'is_deductible', ts('Tax-Deductible?'));
$this->add('checkbox', 'is_active', ts('Enabled?'));
$elementActive = $this->add('checkbox', 'is_active', ts('Enabled?'));
$this->add('checkbox', 'is_tax', ts('Is Tax?'));
$this->add('checkbox', 'is_default', ts('Default?'));
$element = $this->add('checkbox', 'is_default', ts('Default?'));
// CRM-12470 freeze is default if is_default is set
if ($this->_id && CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $this->_id, 'is_default')) {
$element->freeze();
}
$financialAccountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
if (!empty($financialAccountType)) {
$element = $this->add('select', 'financial_account_type_id', ts('Financial Account Type'),
......@@ -117,6 +120,7 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form {
if ($this->_isARFlag) {
$element->freeze();
$elementAccounting->freeze();
$elementActive->freeze();
}
}
......
......@@ -46,29 +46,30 @@ class CRM_Financial_Form_FinancialType extends CRM_Contribute_Form {
* @return None
* @access public
*/
public function buildQuickForm( ) {
parent::buildQuickForm( );
public function buildQuickForm() {
parent::buildQuickForm();
$this->_id = CRM_Utils_Request::retrieve( 'id' , 'Positive', $this );
if ( $this->_id ) {
$this->_title = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_FinancialType', $this->_id, 'name' );
CRM_Utils_System::setTitle( $this->_title .' - '.ts( 'Financial Type' ) );
$this->_id = CRM_Utils_Request::retrieve('id' , 'Positive', $this);
if ($this->_id) {
$this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_id, 'name');
CRM_Utils_System::setTitle($this->_title . ' - ' . ts( 'Financial Type'));
}
if ($this->_action & CRM_Core_Action::DELETE ) {
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute( 'CRM_Financial_DAO_FinancialType', 'name' ),true);
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'name'), TRUE);
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute( 'CRM_Financial_DAO_FinancialType', 'description' ) );
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'description'));
$this->add('checkbox', 'is_deductible', ts('Tax-Deductible?'), CRM_Core_DAO::getAttribute( 'CRM_Financial_DAO_FinancialType', 'is_deductible' ) );
$this->add('checkbox', 'is_active', ts('Enabled?'), CRM_Core_DAO::getAttribute( 'CRM_Financial_DAO_FinancialType', 'is_active' ) );
$this->add('checkbox', 'is_reserved', ts('Reserved?'), CRM_Core_DAO::getAttribute( 'CRM_Financial_DAO_FinancialType', 'is_reserved' ) );
if ( $this->_action == CRM_Core_Action::UPDATE )
$this->assign( 'aid', $this->_id );
if ( $this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_FinancialType', $this->_id, 'is_reserved','vid' )) {
$this->freeze(array( 'is_active' ));
$this->add('checkbox', 'is_deductible', ts('Tax-Deductible?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_deductible'));
$this->add('checkbox', 'is_active', ts('Enabled?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_active'));
$this->add('checkbox', 'is_reserved', ts('Reserved?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_reserved'));
if ($this->_action == CRM_Core_Action::UPDATE) {
$this->assign('aid', $this->_id);
}
if ($this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_id, 'is_reserved','vid')) {
$this->freeze(array('is_active'));
}
//$this->addFormRule( array( 'CRM_Financial_Form_FinancialType', 'formRule'), $this );
......@@ -86,10 +87,11 @@ class CRM_Financial_Form_FinancialType extends CRM_Contribute_Form {
if (!empty($errors)) {
$message = ts('This item cannot be deleted.') . $errors['error_message'];
CRM_Core_Session::setStatus($message);
return CRM_Utils_System::redirect( CRM_Utils_System::url( 'civicrm/admin/financial/financialType', "reset=1&action=browse" ));
return CRM_Utils_System::redirect(CRM_Utils_System::url( 'civicrm/admin/financial/financialType', "reset=1&action=browse"));
}
CRM_Core_Session::setStatus( ts('Selected financial type has been deleted.') );
} else {
CRM_Core_Session::setStatus(ts('Selected financial type has been deleted.'));
}
else {
$params = $ids = array( );
// store the submitted values in an array
$params = $this->exportValues();
......@@ -99,15 +101,23 @@ class CRM_Financial_Form_FinancialType extends CRM_Contribute_Form {
}
$financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
if ( $this->_action & CRM_Core_Action::UPDATE ) {
$url = CRM_Utils_System::url( 'civicrm/admin/financial/financialType', 'reset=1&action=browse');
CRM_Core_Session::setStatus( ts('The financial type \'%1\' has been saved.', array( 1 => $financialType->name )) );
} else {
$url = CRM_Utils_System::url( 'civicrm/admin/financial/financialType/accounts', 'reset=1&action=add&aid=' . $financialType->id);
CRM_Core_Session::setStatus( ts('The financial type \'%1\' has been added. You can add Financial Accounts to this Financial Type now.', array( 1 => $financialType->name )) );
if ($this->_action & CRM_Core_Action::UPDATE) {
$url = CRM_Utils_System::url('civicrm/admin/financial/financialType', 'reset=1&action=browse');
CRM_Core_Session::setStatus(ts('The financial type \'%1\' has been saved.', array( 1 => $financialType->name)));
}
else {
$url = CRM_Utils_System::url('civicrm/admin/financial/financialType/accounts', 'reset=1&action=browse&aid=' . $financialType->id);
$statusArray = array(
1 => $financialType->name,
2 => $financialType->name,
3 => $financialType->titles[0],
4 => $financialType->titles[1],
5 => $financialType->titles[2],
);
CRM_Core_Session::setStatus(ts('Your Financial \'%1\' Type has been created, along with a corresponding income account \'%2\'. That income account, along with standard financial accounts \'%3\', \'%4\' and \'%5\' have been linked to the financial type. You may edit or replace those relationships here.', $statusArray));
}
$session = CRM_Core_Session::singleton( );
$session = CRM_Core_Session::singleton();
$session->replaceUserContext($url);
}
}
......
......@@ -48,7 +48,7 @@ class CRM_Financial_Page_AJAX {
empty($_GET['_value'])) {
CRM_Utils_System::civiExit();
}
$defaultId = NULL;
if ($_GET['_value'] == 'select') {
$result = CRM_Contribute_PseudoConstant::financialAccount();
}
......@@ -65,6 +65,7 @@ class CRM_Financial_Page_AJAX {
$financialAccountType = "{$financialAccountType[$_GET['_value']]}";
$result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
$defaultId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = $financialAccountType");
}
$elements = array(
array(
......@@ -75,10 +76,14 @@ class CRM_Financial_Page_AJAX {
if (!empty($result)){
foreach ($result as $id => $name) {
$selectedArray = array();
if ($id == $defaultId) {
$selectedArray['selected'] = 'Selected';
}
$elements[] = array(
'name' => $name,
'value' => $id,
);
) + $selectedArray;
}
}
echo json_encode($elements);
......
This diff is collapsed.
......@@ -26,142 +26,139 @@
{* this template is used for adding/editing/deleting financial type *}
<h3>{if $action eq 8}{ts}Delete Financial Type Account{/ts}{elseif $action eq 1}{ts}Add New Financial Type Account{/ts}{elseif $action eq 2}{ts}Edit Financial Type Account{/ts}{/if}</h3>
<div class="crm-block crm-form-block crm-financial_type-form-block">
{if $action eq 8}
<div class="messages status">
<div class="icon inform-icon"></div>
{ts}WARNING: You cannot delete a financial type if it is currently used by any Contributions, Contribution Pages or Membership Types. Consider disabling this option instead.{/ts} {ts}Deleting a financial type cannot be undone.{/ts} {ts}Do you want to continue?{/ts}
{if $action eq 8}
<div class="messages status">
<div class="icon inform-icon"></div>
{ts}WARNING: You cannot delete a financial type if it is currently used by any Contributions, Contribution Pages or Membership Types. Consider disabling this option instead.{/ts} {ts}Deleting a financial type cannot be undone.{/ts} {ts}Do you want to continue?{/ts}
</div>
{else}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
{else}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
<table class="form-layout">
<table class="form-layout">
<tr class="crm-contribution-form-block-account_relationship">
<td class="label">{$form.account_relationship.label}</td>
<td class="html-adjust">{$form.account_relationship.html}</td>
</tr>
<tr class="crm-contribution-form-block-account_relationship">
<td class="label">{$form.account_relationship.label}</td>
<td class="html-adjust">{$form.account_relationship.html}</td>
</tr>
<tr class="crm-contribution-form-block-financial_account_id">
<td class="label">{$form.financial_account_id.label}</td>
<td class="html-adjust">{$form.financial_account_id.html}</td>
</tr>
<td class="label">{$form.financial_account_id.label}</td>
<td class="html-adjust">{$form.financial_account_id.html}</td>
</tr>
</table>
</table>
{/if}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="botttom"}</div>
</div>
<script language="JavaScript" type="text/javascript">
{literal}
cj("#financial_account_id").change(function()
{
cj("#financial_account_id").change(function() {
{/literal}
relationID = "#account_relationship"
financialAccountID = "#financial_account_id"
callbackURL = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancialRelation'}"
relationID = "#account_relationship"
financialAccountID = "#financial_account_id"
callbackURL = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancialRelation'}"
{literal}
var financialId = cj("#financial_account_id").val();
var check = cj(relationID).val();
if( check == 'select' || financialId == 'select' ){
callbackURL = callbackURL+"&_value="+financialId;
cj.ajax({
url: callbackURL,
context: document.body,
success: function( data, textStatus ){
cj(relationID).html("");//clear old options
data = eval(data);//get json array
if ( data != null ) {
for (i = 0; i < data.length; i++) {
if( data[i].selected == 'Selected')
var idf = data[i].value;
cj(relationID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
}
}
if( idf != null)
cj(relationID).val(idf);
//cj("option:first", relationID).attr( "selected", "selected" );//select first option
}
});
if( financialId == 'select' ){
var financialId = cj("#financial_account_id").val();
var check = cj(relationID).val();
if (check == 'select' || financialId == 'select') {
callbackURL = callbackURL+"&_value=" + financialId;
cj.ajax({
url: callbackURL,
context: document.body,
success: function(data, textStatus) {
cj(relationID).html("");//clear old options
data = eval(data);//get json array
if (data != null) {
for (i = 0; i < data.length; i++) {
if (data[i].selected == 'Selected') {
var idf = data[i].value;
}
cj(relationID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
}
}
if (idf != null) {
cj(relationID).val(idf);
}
}
});
if (financialId == 'select') {
{/literal}
callbackURLs = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancial'}"
callbackURLs = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancial'}"
{literal}
callbackURLs = callbackURLs+"&_value=select";
cj.ajax({
url: callbackURLs,
context: document.body,
success: function( data, textStatus ){
cj(financialAccountID).html("");//clear old options
data = eval(data);//get json array
if ( data != null ) {
for (i = 0; i < data.length; i++) {
cj(financialAccountID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
}
}
}
});
}
callbackURLs = callbackURLs + "&_value=select";
cj.ajax({
url: callbackURLs,
context: document.body,
success: function(data, textStatus) {
cj(financialAccountID).html("");//clear old options
data = eval(data);//get json array
if (data != null) {
for (i = 0; i < data.length; i++) {
cj(financialAccountID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
}
}
}
});
}
}
});
{/literal}
{literal}
cj("#account_relationship").change(function()
{
{literal}
cj("#account_relationship").change(function() {
{/literal}
relationID = "#account_relationship"
financialAccountID = "#financial_account_id"
callbackURLs = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancial'}"
relationID = "#account_relationship"
financialAccountID = "#financial_account_id"
callbackURLs = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancial'}"
{literal}
var financialId = cj("#account_relationship").val();
var check = cj(financialAccountID).val();
if( check == 'select' || financialId == 'select' ){
callbackURLs = callbackURLs+"&_value="+financialId;
cj.ajax({
url: callbackURLs,
context: document.body,
success: function( data, textStatus ){
cj(financialAccountID).html("");//clear old options
data = eval(data);//get json array
if ( data != null ) {
for (i = 0; i < data.length; i++) {
cj(financialAccountID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
}
}
}
});
if( financialId == 'select' ){
var financialId = cj("#account_relationship").val();
var check = cj(financialAccountID).val();
if (check == 'select' || financialId == 'select') {
callbackURLs = callbackURLs+"&_value="+financialId;
cj.ajax({
url: callbackURLs,
context: document.body,
success: function(data, textStatus) {
cj(financialAccountID).html("");//clear old options
data = eval(data);//get json array
if (data != null) {
for (i = 0; i < data.length; i++) {
if (data[i].selected == 'Selected') {
var idf = data[i].value;
}
cj(financialAccountID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
}
}
if (idf != null) {
cj(financialAccountID).val(idf);
}
}
});
if (financialId == 'select') {
{/literal}
callbackURL = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancialRelation'}"
callbackURL = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancialRelation'}"
{literal}
callbackURL = callbackURL+"&_value=select";
cj.ajax({
url: callbackURL,
context: document.body,
success: function( data, textStatus ){
cj(relationID).html("");//clear old options
data = eval(data);//get json array
if ( data != null ) {
for (i = 0; i < data.length; i++) {
if( data[i].selected == 'Selected')
var idf = data[i].value;
cj(relationID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
}
}
if( idf != null)
cj(relationID).val(idf);
//cj("option:first", relationID).attr( "selected", "selected" );//select first option
}
});
}
callbackURL = callbackURL+"&_value=select";
cj.ajax({
url: callbackURL,
context: document.body,
success: function(data, textStatus) {
cj(relationID).html("");//clear old options
data = eval(data);//get json array
if (data != null) {
for (i = 0; i < data.length; i++) {
if (data[i].selected == 'Selected') {
var idf = data[i].value;
}
cj(relationID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
}
}
if (idf != null) {
cj(relationID).val(idf);
}
}
});
}
}
});
{/literal}
</script>
\ No newline at end of file
......@@ -878,15 +878,15 @@ SELECT @opCost := value FROM civicrm_option_value WHERE name = 'Cost of Sales' a
INSERT 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"}Donation{/ts}' , @contactID, @opval, 'Default account for donations', '4200', 'INC', 0, 1, 1, 0 ),
( '{ts escape="sql"}Donation{/ts}' , @contactID, @opval, 'Default account for donations', '4200', 'INC', 0, 1, 1, 1 ),
( '{ts escape="sql"}Member Dues{/ts}' , @contactID, @opval, 'Default account for membership sales', '4400', 'INC', 0, 1, 1, 0 ),
( '{ts escape="sql"}Campaign Contribution{/ts}', @contactID, @opval, 'Sample account for recording payments to a campaign', '4100', 'INC', 0, 1, 0, 0 ),
( '{ts escape="sql"}Event Fee{/ts}' , @contactID, @opval, 'Default account for event ticket sales', '4300', 'INC', 0, 1, 0, 0 ),
( '{ts escape="sql"}Banking Fees{/ts}' , @contactID, @opexp, 'Payment processor fees and manually recorded banking fees', '5200', 'EXP', 0, 1, 0, 0 ),
( '{ts escape="sql"}Banking Fees{/ts}' , @contactID, @opexp, 'Payment processor fees and manually recorded banking fees', '5200', 'EXP', 0, 1, 0, 1 ),
( '{ts escape="sql"}Deposit Bank Account{/ts}' , @contactID, @opAsset, 'All manually recorded cash and cheques go to this account', '1100', 'BANK', 0, 1, 0, 1 ),
( '{ts escape="sql"}Accounts Receivable{/ts}' , @contactID, @opAsset, 'Amounts to be received later (eg pay later event revenues)', '1200', 'AR', 0, 1, 0, 0 ),
( '{ts escape="sql"}Accounts Payable{/ts}' , @contactID, @opLiability, 'Amounts to be paid out such as grants and refunds', '2200', 'AP', 0, 1, 0, 0 ),
( '{ts escape="sql"}Premiums{/ts}' , @contactID, @opCost, 'Account to record cost of premiums provided to payors', '5100', 'COGS', 0, 1, 0, 0 ),
( '{ts escape="sql"}Accounts Payable{/ts}' , @contactID, @opLiability, 'Amounts to be paid out such as grants and refunds', '2200', 'AP', 0, 1, 0, 1 ),
( '{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
......@@ -1466,6 +1466,7 @@ SELECT @option_value_rel_id := value FROM civicrm_option_value WHERE option_gro
SELECT @option_value_rel_id_exp := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Expense Account is';
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 @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}';
......@@ -1480,6 +1481,7 @@ SELECT @financial_account_id_bf := max(id) FROM civicrm_financial_account
SELECT @financial_account_id_ap := max(id) FROM civicrm_financial_account WHERE name = '{ts escape="sql"}Accounts Receivable{/ts}';
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}';
INSERT INTO `civicrm_entity_financial_account`
( entity_table, entity_id, account_relationship, financial_account_id )
......@@ -1487,15 +1489,19 @@ VALUES
( 'civicrm_financial_type', @financial_type_id_dtn, @option_value_rel_id, @financial_account_id_dtn ),
( 'civicrm_financial_type', @financial_type_id_dtn, @option_value_rel_id_exp, @financial_account_id_bf ),
( 'civicrm_financial_type', @financial_type_id_dtn, @option_value_rel_id_ar, @financial_account_id_ap ),
( 'civicrm_financial_type', @financial_type_id_dtn, @option_value_rel_id_cg, @financial_account_id_pr ),
( 'civicrm_financial_type', @financial_type_id_md, @option_value_rel_id, @financial_account_id_md ),
( '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_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 ),
( 'civicrm_financial_type', @financial_type_id_cc, @option_value_rel_id_cg, @financial_account_id_pr ),
( '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, @financial_account_id_ef ),
( 'civicrm_financial_type', @financial_type_id_ef, @option_value_rel_id_cg, @financial_account_id_pr );
-- CRM-11516
INSERT INTO civicrm_entity_financial_account (entity_table, entity_id, account_relationship, financial_account_id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment