本文整理汇总了PHP中CRM_Core_PseudoConstant::accountOptionValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::accountOptionValues方法的具体用法?PHP CRM_Core_PseudoConstant::accountOptionValues怎么用?PHP CRM_Core_PseudoConstant::accountOptionValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::accountOptionValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
static function create($params)
{
// FIXME Reconcile with CRM_Admin_Form_PaymentProcessor::updatePaymentProcessor
$processor = new CRM_Financial_DAO_PaymentProcessor();
$processor->copyValues($params);
$ppTypeDAO = new CRM_Financial_DAO_PaymentProcessorType();
$ppTypeDAO->id = $params['payment_processor_type_id'];
if (!$ppTypeDAO->find(TRUE)) {
CRM_Core_Error::fatal(ts('Could not find payment processor meta information'));
}
// also copy meta fields from the info DAO
$processor->is_recur = $ppTypeDAO->is_recur;
$processor->billing_mode = $ppTypeDAO->billing_mode;
$processor->class_name = $ppTypeDAO->class_name;
$processor->payment_type = $ppTypeDAO->payment_type;
$processor->save();
// CRM-11826, add entry in civicrm_entity_financial_account
// if financial_account_id is not NULL
if (CRM_Utils_Array::value('financial_account_id', $params)) {
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
$values = array('entity_table' => 'civicrm_payment_processor', 'entity_id' => $processor->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $params['financial_account_id']);
CRM_Financial_BAO_FinancialTypeAccount::add($values);
}
return $processor;
}
示例2: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
parent::preProcess();
if ($this->_id) {
$params = array('id' => $this->_id);
$financialAccount = CRM_Financial_BAO_FinancialAccount::retrieve($params, CRM_Core_DAO::$_nullArray);
$financialAccountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
if ($financialAccount->financial_account_type_id == array_search('Asset', $financialAccountType) && strtolower($financialAccount->account_type_code) == 'ar' && !CRM_Financial_BAO_FinancialAccount::getARAccounts($this->_id, array_search('Asset', $financialAccountType))) {
$this->_isARFlag = TRUE;
if ($this->_action & CRM_Core_Action::DELETE) {
$msg = ts("The selected financial account cannot be deleted because at least one Accounts Receivable type account is required (to ensure that accounting transactions are in balance).");
CRM_Core_Error::statusBounce($msg);
}
}
}
}
示例3: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
parent::preProcess();
if ($this->_id) {
$params = array('id' => $this->_id);
$financialAccount = CRM_Financial_BAO_FinancialAccount::retrieve($params, CRM_Core_DAO::$_nullArray);
$financialAccountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
if ($financialAccount->financial_account_type_id == array_search('Asset', $financialAccountType) && strtolower($financialAccount->account_type_code) == 'ar' && !CRM_Financial_BAO_FinancialAccount::getARAccounts($this->_id, array_search('Asset', $financialAccountType))) {
$this->_isARFlag = TRUE;
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Core_Session::setStatus(ts("The selected financial account cannot be deleted because at least one Accounts Receivable type account is required (to ensure that accounting transactions are in balance)."), '', 'error');
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/financial/financialAccount', "reset=1&action=browse"));
}
}
}
}
示例4: recordFees
/**
* create financial trxn and items when fee is charged
*
* @params params to create trxn entries
*
* @access public
* @static
*/
static function recordFees($params)
{
$expenseTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Expense Account is' "));
$domainId = CRM_Core_Config::domainID();
$amount = 0;
if (CRM_Utils_Array::value('prevContribution', $params)) {
$amount = $params['prevContribution']->fee_amount;
}
$amount = $params['fee_amount'] - $amount;
if (!$amount) {
return FALSE;
}
$financialAccount = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id'], $expenseTypeId);
$params['trxnParams']['from_financial_account_id'] = $params['to_financial_account_id'];
$params['trxnParams']['to_financial_account_id'] = $financialAccount;
$params['trxnParams']['total_amount'] = $amount;
$params['trxnParams']['fee_amount'] = $params['trxnParams']['net_amount'] = 0;
$params['trxnParams']['status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
$params['trxnParams']['contribution_id'] = isset($params['contribution']->id) ? $params['contribution']->id : $params['contribution_id'];
$trxn = self::create($params['trxnParams']);
if (!CRM_Utils_Array::value('entity_id', $params)) {
$financialTrxnID = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['trxnParams']['contribution_id'], 'DESC');
$params['entity_id'] = $financialTrxnID['financialTrxnId'];
}
$fItemParams = array('financial_account_id' => $financialAccount, 'contact_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', $domainId, 'contact_id'), 'created_date' => date('YmdHis'), 'transaction_date' => date('YmdHis'), 'amount' => $amount, 'description' => 'Fee', 'status_id' => CRM_Core_OptionGroup::getValue('financial_item_status', 'Paid', 'name'), 'entity_table' => 'civicrm_financial_trxn', 'entity_id' => $params['entity_id'], 'currency' => $params['trxnParams']['currency']);
$trxnIDS['id'] = $trxn->id;
$financialItem = CRM_Financial_BAO_FinancialItem::create($fItemParams, NULL, $trxnIDS);
}
示例5: recordAdjustedAmt
/**
* Record adjusted amount.
*
* @param int $updatedAmount
* @param int $paidAmount
* @param int $contributionId
*
* @param int $taxAmount
* @param bool $updateAmountLevel
*
* @return bool|\CRM_Core_BAO_FinancialTrxn
*/
public static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount = NULL, $updateAmountLevel = NULL)
{
$pendingAmount = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
$pendingAmount = CRM_Utils_Array::value('total_amount', $pendingAmount, 0);
$balanceAmt = $updatedAmount - $paidAmount;
if ($paidAmount != $pendingAmount) {
$balanceAmt -= $pendingAmount;
}
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
$pendingRefundStatusId = array_search('Pending refund', $contributionStatuses);
$completedStatusId = array_search('Completed', $contributionStatuses);
$updatedContributionDAO = new CRM_Contribute_BAO_Contribution();
$adjustedTrxn = $skip = FALSE;
if ($balanceAmt) {
if ($balanceAmt > 0 && $paidAmount != 0) {
$contributionStatusVal = $partiallyPaidStatusId;
} elseif ($balanceAmt < 0 && $paidAmount != 0) {
$contributionStatusVal = $pendingRefundStatusId;
} elseif ($paidAmount == 0) {
//skip updating the contribution status if no payment is made
$skip = TRUE;
$updatedContributionDAO->cancel_date = 'null';
$updatedContributionDAO->cancel_reason = NULL;
}
// update contribution status and total amount without trigger financial code
// as this is handled in current BAO function used for change selection
$updatedContributionDAO->id = $contributionId;
if (!$skip) {
$updatedContributionDAO->contribution_status_id = $contributionStatusVal;
}
$updatedContributionDAO->total_amount = $updatedContributionDAO->net_amount = $updatedAmount;
$updatedContributionDAO->fee_amount = 0;
$updatedContributionDAO->tax_amount = $taxAmount;
if (!empty($updateAmountLevel)) {
$updatedContributionDAO->amount_level = $updateAmountLevel;
}
$updatedContributionDAO->save();
// adjusted amount financial_trxn creation
$updatedContribution = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contributionId), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($updatedContribution->financial_type_id, $relationTypeId);
$adjustedTrxnValues = array('from_financial_account_id' => NULL, 'to_financial_account_id' => $toFinancialAccount, 'total_amount' => $balanceAmt, 'status_id' => $completedStatusId, 'payment_instrument_id' => $updatedContribution->payment_instrument_id, 'contribution_id' => $updatedContribution->id, 'trxn_date' => date('YmdHis'), 'currency' => $updatedContribution->currency);
$adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues);
}
return $adjustedTrxn;
}
示例6: getFinancialAccountId
/**
* Get financial account id has 'Sales Tax Account is'
* account relationship with financial type
*
* @param int $financialTypeId
*
* @return FinancialAccountId
*/
public static function getFinancialAccountId($financialTypeId)
{
$accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
$searchParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $financialTypeId, 'account_relationship' => $accountRel);
$result = array();
CRM_Financial_BAO_FinancialTypeAccount::retrieve($searchParams, $result);
return CRM_Utils_Array::value('financial_account_id', $result);
}
示例7: formRule
/**
* Global validation rules for the form.
*
* @param array $values
* posted values of the form
* @param $files
* @param $self
*
* @return array
* list of errors to be posted back to the form
*/
public static function formRule($values, $files, $self)
{
$errorMsg = array();
$financialAccountTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Liability' "));
if (isset($values['is_tax'])) {
if ($values['financial_account_type_id'] != $financialAccountTypeId) {
$errorMsg['financial_account_type_id'] = ts('Taxable accounts should have Financial Account Type set to Liability.');
}
if (CRM_Utils_Array::value('tax_rate', $values) == NULL) {
$errorMsg['tax_rate'] = ts('Please enter value for tax rate');
}
}
if (CRM_Utils_Array::value('tax_rate', $values) != NULL) {
if ($values['tax_rate'] < 0 || $values['tax_rate'] >= 100) {
$errorMsg['tax_rate'] = ts('Tax Rate Should be between 0 - 100');
}
}
if ($self->_action & CRM_Core_Action::UPDATE) {
if (!isset($values['is_tax'])) {
$relationshipId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
$params = array('financial_account_id' => $self->_id, 'account_relationship' => $relationshipId);
$result = CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, $defaults);
if ($result) {
$errorMsg['is_tax'] = ts('Is Tax? must be set for this financial account');
}
}
}
return CRM_Utils_Array::crmIsEmptyArray($errorMsg) ? TRUE : $errorMsg;
}
示例8: updatePaymentProcessor
/**
* Save a payment processor.
*
* @param $values
* @param int $domainID
* @param $test
*
* @return void
*/
public function updatePaymentProcessor(&$values, $domainID, $test)
{
$dao = new CRM_Financial_DAO_PaymentProcessor();
$dao->id = $test ? $this->_testID : $this->_id;
$dao->domain_id = $domainID;
$dao->is_test = $test;
$dao->is_default = CRM_Utils_Array::value('is_default', $values, 0);
$dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
$dao->name = $values['name'];
$dao->description = $values['description'];
$dao->payment_processor_type_id = $values['payment_processor_type_id'];
foreach ($this->_fields as $field) {
$fieldName = $test ? "test_{$field['name']}" : $field['name'];
$dao->{$field['name']} = trim(CRM_Utils_Array::value($fieldName, $values));
if (empty($dao->{$field['name']})) {
$dao->{$field['name']} = 'null';
}
}
// also copy meta fields from the info DAO
$dao->is_recur = $this->_ppDAO->is_recur;
$dao->billing_mode = $this->_ppDAO->billing_mode;
$dao->class_name = $this->_ppDAO->class_name;
$dao->payment_type = $this->_ppDAO->payment_type;
$dao->save();
//CRM-11515
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
$params = array('entity_table' => 'civicrm_payment_processor', 'entity_id' => $dao->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $values['financial_account_id']);
CRM_Financial_BAO_FinancialTypeAccount::add($params);
}
示例9: select
/**
* Build select for Pledge.
*
* @param $query
*
* @return void
*/
public static function select(&$query)
{
$statusId = implode(',', array_keys(CRM_Core_PseudoConstant::accountOptionValues("contribution_status", NULL, " AND v.name IN ('Pending', 'Overdue')")));
if ($query->_mode & CRM_Contact_BAO_Query::MODE_PLEDGE || !empty($query->_returnProperties['pledge_id'])) {
$query->_select['pledge_id'] = 'civicrm_pledge.id as pledge_id';
$query->_element['pledge_id'] = 1;
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
}
//add pledge select
if (!empty($query->_returnProperties['pledge_amount'])) {
$query->_select['pledge_amount'] = 'civicrm_pledge.amount as pledge_amount';
$query->_element['pledge_amount'] = 1;
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
}
if (!empty($query->_returnProperties['pledge_create_date'])) {
$query->_select['pledge_create_date'] = 'civicrm_pledge.create_date as pledge_create_date';
$query->_element['pledge_create_date'] = 1;
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
}
if (!empty($query->_returnProperties['pledge_start_date'])) {
$query->_select['pledge_start_date'] = 'civicrm_pledge.start_date as pledge_start_date';
$query->_element['pledge_start_date'] = 1;
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
}
if (!empty($query->_returnProperties['pledge_status_id'])) {
$query->_select['pledge_status_id'] = 'pledge_status.value as pledge_status_id';
$query->_element['pledge_status'] = 1;
$query->_tables['pledge_status'] = $query->_whereTables['pledge_status'] = 1;
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
}
if (!empty($query->_returnProperties['pledge_status'])) {
$query->_select['pledge_status'] = 'pledge_status.label as pledge_status';
$query->_element['pledge_status'] = 1;
$query->_tables['pledge_status'] = $query->_whereTables['pledge_status'] = 1;
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
}
if (!empty($query->_returnProperties['pledge_total_paid'])) {
$query->_select['pledge_total_paid'] = ' (SELECT sum(civicrm_pledge_payment.actual_amount) FROM civicrm_pledge_payment WHERE civicrm_pledge_payment.pledge_id = civicrm_pledge.id AND civicrm_pledge_payment.status_id = 1 ) as pledge_total_paid';
$query->_element['pledge_total_paid'] = 1;
}
if (!empty($query->_returnProperties['pledge_next_pay_date'])) {
$query->_select['pledge_next_pay_date'] = " (SELECT civicrm_pledge_payment.scheduled_date FROM civicrm_pledge_payment WHERE civicrm_pledge_payment.pledge_id = civicrm_pledge.id AND civicrm_pledge_payment.status_id IN ({$statusId}) ORDER BY civicrm_pledge_payment.scheduled_date ASC LIMIT 0, 1) as pledge_next_pay_date";
$query->_element['pledge_next_pay_date'] = 1;
}
if (!empty($query->_returnProperties['pledge_next_pay_amount'])) {
$query->_select['pledge_next_pay_amount'] = " (SELECT civicrm_pledge_payment.scheduled_amount FROM civicrm_pledge_payment WHERE civicrm_pledge_payment.pledge_id = civicrm_pledge.id AND civicrm_pledge_payment.status_id IN ({$statusId}) ORDER BY civicrm_pledge_payment.scheduled_date ASC LIMIT 0, 1) as pledge_next_pay_amount";
$query->_element['pledge_next_pay_amount'] = 1;
$query->_select['pledge_outstanding_amount'] = " (SELECT sum(civicrm_pledge_payment.scheduled_amount) FROM civicrm_pledge_payment WHERE civicrm_pledge_payment.pledge_id = civicrm_pledge.id AND civicrm_pledge_payment.status_id = 6 ) as pledge_outstanding_amount";
$query->_element['pledge_outstanding_amount'] = 1;
}
if (!empty($query->_returnProperties['pledge_financial_type'])) {
$query->_select['pledge_financial_type'] = "(SELECT civicrm_financial_type.name FROM civicrm_financial_type WHERE civicrm_financial_type.id = civicrm_pledge.financial_type_id) as pledge_financial_type";
$query->_element['pledge_financial_type'] = 1;
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
}
if (!empty($query->_returnProperties['pledge_contribution_page_id'])) {
$query->_select['pledge_contribution_page_id'] = 'civicrm_pledge.contribution_page_id as pledge_contribution_page_id';
$query->_element['pledge_contribution_page_id'] = 1;
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
}
if (!empty($query->_returnProperties['pledge_payment_id'])) {
$query->_select['pledge_payment_id'] = 'civicrm_pledge_payment.id as pledge_payment_id';
$query->_element['pledge_payment_id'] = 1;
$query->_tables['civicrm_pledge_payment'] = $query->_whereTables['civicrm_pledge_payment'] = 1;
}
if (!empty($query->_returnProperties['pledge_payment_scheduled_amount'])) {
$query->_select['pledge_payment_scheduled_amount'] = 'civicrm_pledge_payment.scheduled_amount as pledge_payment_scheduled_amount';
$query->_element['pledge_payment_scheduled_amount'] = 1;
$query->_tables['civicrm_pledge_payment'] = $query->_whereTables['civicrm_pledge_payment'] = 1;
}
if (!empty($query->_returnProperties['pledge_payment_scheduled_date'])) {
$query->_select['pledge_payment_scheduled_date'] = 'civicrm_pledge_payment.scheduled_date as pledge_payment_scheduled_date';
$query->_element['pledge_payment_scheduled_date'] = 1;
$query->_tables['civicrm_pledge_payment'] = $query->_whereTables['civicrm_pledge_payment'] = 1;
}
if (!empty($query->_returnProperties['pledge_payment_paid_amount'])) {
$query->_select['pledge_payment_paid_amount'] = 'civicrm_pledge_payment.actual_amount as pledge_payment_paid_amount';
$query->_element['pledge_payment_paid_amount'] = 1;
$query->_tables['civicrm_pledge_payment'] = $query->_whereTables['civicrm_pledge_payment'] = 1;
}
if (!empty($query->_returnProperties['pledge_payment_paid_date'])) {
$query->_select['pledge_payment_paid_date'] = 'payment_contribution.receive_date as pledge_payment_paid_date';
$query->_element['pledge_payment_paid_date'] = 1;
$query->_tables['civicrm_pledge_payment'] = $query->_whereTables['civicrm_pledge_payment'] = 1;
$query->_tables['payment_contribution'] = $query->_whereTables['payment_contribution'] = 1;
}
if (!empty($query->_returnProperties['pledge_payment_reminder_date'])) {
$query->_select['pledge_payment_reminder_date'] = 'civicrm_pledge_payment.reminder_date as pledge_payment_reminder_date';
$query->_element['pledge_payment_reminder_date'] = 1;
$query->_tables['civicrm_pledge_payment'] = $query->_whereTables['civicrm_pledge_payment'] = 1;
}
if (!empty($query->_returnProperties['pledge_payment_reminder_count'])) {
$query->_select['pledge_payment_reminder_count'] = 'civicrm_pledge_payment.reminder_count as pledge_payment_reminder_count';
//.........这里部分代码省略.........
示例10: buildQuickForm
/**
* Build the form object.
*
* @param bool $check
*/
public function buildQuickForm($check = FALSE)
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_PaymentProcessor');
$this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Financial_DAO_PaymentProcessor', $this->_id, 'name', CRM_Core_Config::domainID()));
$this->add('text', 'description', ts('Description'), $attributes['description']);
$types = CRM_Core_PseudoConstant::paymentProcessorType();
$this->add('select', 'payment_processor_type_id', ts('Payment Processor Type'), $types, TRUE, array('onchange' => "reload(true)"));
// Financial Account of account type asset CRM-11515
$accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' ");
$financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType));
if ($fcount = count($financialAccount)) {
$this->assign('financialAccount', $fcount);
}
$this->add('select', 'financial_account_id', ts('Financial Account'), array('' => ts('- select -')) + $financialAccount, TRUE);
$this->addSelect('payment_instrument_id', array('entity' => 'contribution', 'label' => ts('Payment Method'), 'placeholder' => NULL));
// is this processor active ?
$this->add('checkbox', 'is_active', ts('Is this Payment Processor active?'));
$this->add('checkbox', 'is_default', ts('Is this Payment Processor the default?'));
$creditCardTypes = CRM_Contribute_PseudoConstant::creditCard();
$this->addCheckBox('accept_credit_cards', ts('Accepted Credit Card Type(s)'), $creditCardTypes, NULL, NULL, NULL, NULL, ' ');
foreach ($this->_fields as $field) {
if (empty($field['label'])) {
continue;
}
$this->add('text', $field['name'], $field['label'], $attributes[$field['name']]);
$this->add('text', "test_{$field['name']}", $field['label'], $attributes[$field['name']]);
if (!empty($field['rule'])) {
$this->addRule($field['name'], $field['msg'], $field['rule']);
$this->addRule("test_{$field['name']}", $field['msg'], $field['rule']);
}
}
$this->addFormRule(array('CRM_Admin_Form_PaymentProcessor', 'formRule'));
}
示例11: browse
/**
* Browse all Financial Type Account data
*
* @return void
* @access public
* @static
*/
function browse()
{
// get all Financial Type Account data sorted by weight
$financialType = array();
$params = array();
$dao = new CRM_Financial_DAO_EntityFinancialAccount();
$params['entity_id'] = $this->_aid;
$params['entity_table'] = 'civicrm_financial_type';
if ($this->_aid) {
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_aid, 'name');
CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Assigned Financial Accounts'));
$financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id');
$accountRelationship = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
$dao->copyValues($params);
$dao->find();
while ($dao->fetch()) {
$financialType[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $financialType[$dao->id]);
$params = array('id' => $dao->financial_account_id);
$defaults = array();
$financialAccount = CRM_Financial_BAO_FinancialAccount::retrieve($params, $defaults);
if (!empty($financialAccount)) {
$financialType[$dao->id]['financial_account'] = $financialAccount->name;
$financialType[$dao->id]['accounting_code'] = $financialAccount->accounting_code;
$financialType[$dao->id]['account_type_code'] = $financialAccount->account_type_code;
$financialType[$dao->id]['is_active'] = $financialAccount->is_active;
if (!empty($financialAccount->contact_id)) {
$financialType[$dao->id]['owned_by'] = CRM_Contact_BAO_Contact::displayName($financialAccount->contact_id);
}
if (!empty($financialAccount->financial_account_type_id)) {
$optionGroupName = 'financial_account_type';
$financialType[$dao->id]['financial_account_type'] = CRM_Utils_Array::value($financialAccount->financial_account_type_id, $financialAccountType);
}
if (!empty($dao->account_relationship)) {
$optionGroupName = 'account_relationship';
$financialType[$dao->id]['account_relationship'] = CRM_Utils_Array::value($dao->account_relationship, $accountRelationship);
}
}
// form all action links
$action = array_sum(array_keys($this->links()));
$links = self::links();
//CRM-12492
if ($dao->account_relationship == $relationTypeId) {
unset($links[CRM_Core_Action::DELETE]);
}
$financialType[$dao->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $dao->id, 'aid' => $dao->entity_id), ts('more'), FALSE, 'financialTypeAccount.manage.action', 'FinancialTypeAccount', $dao->id);
}
$this->assign('rows', $financialType);
$this->assign('aid', $this->_aid);
$this->assign('financialTypeTitle', $this->_title);
} else {
CRM_Core_Error::fatal();
return null;
}
}
示例12: getIncomeFinancialType
/**
* fetch financial type having relationship as Income Account is.
*
*
* @return array
* all financial type with income account is relationship
*/
public static function getIncomeFinancialType()
{
// Financial Type
$financialType = CRM_Contribute_PseudoConstant::financialType();
$revenueFinancialType = array();
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
CRM_Core_PseudoConstant::populate($revenueFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'entity_id', $filter = NULL, "account_relationship = {$relationTypeId} AND entity_table = 'civicrm_financial_type' ");
foreach ($financialType as $key => $financialTypeName) {
if (!in_array($key, $revenueFinancialType) || CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('add contributions of type ' . $financialTypeName)) {
unset($financialType[$key]);
}
}
return $financialType;
}
示例13: _createDeferredFinancialAccount
/**
* Helper function to create deferred financial account.
*/
public function _createDeferredFinancialAccount()
{
$params = array('name' => 'TestFinancialAccount_1', 'accounting_code' => 4800, 'contact_id' => 1, 'is_deductible' => 0, 'is_active' => 1, 'is_reserved' => 0);
$financialAccount = $this->callAPISuccess('FinancialAccount', 'create', $params);
$params['name'] = 'test_financialType1';
$financialType = $this->callAPISuccess('FinancialType', 'create', $params);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Deferred Revenue Account is' "));
$financialParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $financialType['id'], 'account_relationship' => $relationTypeId, 'financial_account_id' => $financialAccount['id']);
$this->callAPISuccess('EntityFinancialAccount', 'create', $financialParams);
$result = $this->assertDBNotNull('CRM_Financial_DAO_EntityFinancialAccount', $financialAccount['id'], 'entity_id', 'financial_account_id', 'Database check on added financial type record.');
$this->assertEquals($result, $financialType['id'], 'Verify Account Type');
return $result;
}
示例14: recordAdjustedAmt
/**
* @param $updatedAmount
* @param $paidAmount
* @param $contributionId
*/
static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId)
{
$balanceAmt = $updatedAmount - $paidAmount;
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
$pendngRefundStatusId = array_search('Pending refund', $contributionStatuses);
$completedStatusId = array_search('Completed', $contributionStatuses);
$updatedContributionDAO = new CRM_Contribute_BAO_Contribution();
if ($balanceAmt) {
if ($balanceAmt > 0 && $paidAmount != 0) {
$contributionStatusVal = $partiallyPaidStatusId;
} elseif ($balanceAmt < 0 && $paidAmount != 0) {
$contributionStatusVal = $pendngRefundStatusId;
} elseif ($paidAmount == 0) {
$contributionStatusVal = $completedStatusId;
$updatedContributionDAO->cancel_date = 'null';
$updatedContributionDAO->cancel_reason = NULL;
}
// update contribution status and total amount without trigger financial code
// as this is handled in current BAO function used for change selection
$updatedContributionDAO->id = $contributionId;
$updatedContributionDAO->contribution_status_id = $contributionStatusVal;
$updatedContributionDAO->total_amount = $updatedAmount;
$updatedContributionDAO->save();
$ftDetail = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
// adjusted amount financial_trxn creation
if (empty($ftDetail['trxn_id'])) {
$updatedContribution = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contributionId), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($updatedContribution->financial_type_id, $relationTypeId);
$adjustedTrxnValues = array('from_financial_account_id' => NULL, 'to_financial_account_id' => $toFinancialAccount, 'total_amount' => $balanceAmt, 'status_id' => CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name'), 'payment_instrument_id' => $updatedContribution->payment_instrument_id, 'contribution_id' => $updatedContribution->id, 'trxn_date' => date('YmdHis'), 'currency' => $updatedContribution->currency);
$adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues);
} else {
// update the financial trxn amount as well, as the fee selections has been updated
if ($balanceAmt != $ftDetail['total_amount']) {
CRM_Core_DAO::setFieldValue('CRM_Core_BAO_FinancialTrxn', $ftDetail['trxn_id'], 'total_amount', $balanceAmt);
}
}
}
}
示例15: getARAccounts
/**
* Get AR account.
*
* @param $financialAccountId
* Financial account id.
*
* @param $financialAccountTypeId
* Financial account type id.
*
* @param string $accountTypeCode
* account type code
*
* @return int
* count
*/
public 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\n AND id != %3 AND is_active = 1;";
$params = array(1 => array($financialAccountTypeId, 'Integer'), 2 => array(strtolower($accountTypeCode), 'String'), 3 => array($financialAccountId, 'Integer'));
return CRM_Core_DAO::singleValueQuery($query, $params);
}