本文整理汇总了PHP中CRM_Financial_BAO_FinancialAccount类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Financial_BAO_FinancialAccount类的具体用法?PHP CRM_Financial_BAO_FinancialAccount怎么用?PHP CRM_Financial_BAO_FinancialAccount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Financial_BAO_FinancialAccount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Takes an associative array and creates a price set object.
*
* @param array $params
* (reference) an assoc array of name/value pairs.
*
* @return CRM_Price_DAO_PriceSet
*/
public static function create(&$params)
{
if (empty($params['id']) && empty($params['name'])) {
$params['name'] = CRM_Utils_String::munge($params['title'], '_', 242);
}
$priceSetID = NULL;
$validatePriceSet = TRUE;
if (!empty($params['extends']) && is_array($params['extends'])) {
if (!array_key_exists(CRM_Core_Component::getComponentID('CiviEvent'), $params['extends']) || !array_key_exists(CRM_Core_Component::getComponentID('CiviMember'), $params['extends'])) {
$validatePriceSet = FALSE;
}
$params['extends'] = CRM_Utils_Array::implodePadded($params['extends']);
} else {
$priceSetID = CRM_Utils_Array::value('id', $params);
}
// CRM-16189
if ($validatePriceSet && !empty($params['financial_type_id'])) {
CRM_Financial_BAO_FinancialAccount::validateFinancialType($params['financial_type_id'], $priceSetID);
}
$priceSetBAO = new CRM_Price_BAO_PriceSet();
$priceSetBAO->copyValues($params);
if (self::eventPriceSetDomainID()) {
$priceSetBAO->domain_id = CRM_Core_Config::domainID();
}
return $priceSetBAO->save();
}
示例2: jqFinancialRelation
/**
* @param $config
*/
public static function jqFinancialRelation($config)
{
if (!isset($_GET['_value']) || empty($_GET['_value'])) {
CRM_Utils_System::civiExit();
}
if ($_GET['_value'] != 'select') {
$financialAccountType = CRM_Financial_BAO_FinancialAccount::getfinancialAccountRelations(TRUE);
$financialAccountId = CRM_Utils_Request::retrieve('_value', 'Positive', CRM_Core_DAO::$_nullObject);
$financialAccountTypeId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $financialAccountId, 'financial_account_type_id');
}
$params['orderColumn'] = 'label';
$result = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', $params);
$elements = array(array('name' => ts('- Select Financial Account Relationship -'), 'value' => 'select'));
$countResult = count($financialAccountType[$financialAccountTypeId]);
if (!empty($result)) {
foreach ($result as $id => $name) {
if (in_array($id, $financialAccountType[$financialAccountTypeId]) && $_GET['_value'] != 'select') {
if ($countResult != 1) {
$elements[] = array('name' => $name, 'value' => $id);
} else {
$elements[] = array('name' => $name, 'value' => $id, 'selected' => 'Selected');
}
} elseif ($_GET['_value'] == 'select') {
$elements[] = array('name' => $name, 'value' => $id);
}
}
}
CRM_Utils_JSON::output($elements);
}
示例3: __construct
/**
*/
public function __construct()
{
$this->_autoIncludeIndexedFieldsAsOrderBys = 1;
$this->_deferredFinancialAccount = CRM_Financial_BAO_FinancialAccount::getAllDeferredFinancialAccount();
$this->_columns = array('civicrm_financial_account' => array('dao' => 'CRM_Financial_DAO_FinancialAccount', 'alias' => 'financial_account_deferred', 'filters' => array('id' => array('title' => ts('Deferred Financial Account'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_deferredFinancialAccount, 'type' => CRM_Utils_Type::T_INT))));
parent::__construct();
}
示例4: setUp
public function setUp()
{
parent::setUp();
$this->_individualId = $this->individualCreate();
$this->_orgId = $this->organizationCreate(NULL);
$this->params = array('title' => "Test Contribution Page" . substr(sha1(rand()), 0, 7), 'financial_type_id' => 1, 'payment_processor' => 1, 'currency' => 'NZD', 'goal_amount' => 350, 'is_pay_later' => 1, 'pay_later_text' => 'I will pay later', 'pay_later_receipt' => "I will pay later", 'is_monetary' => TRUE, 'is_billing_required' => TRUE);
$this->_priceSetParams = array('name' => 'tax_contribution' . substr(sha1(rand()), 0, 7), 'title' => 'contributiontax' . substr(sha1(rand()), 0, 7), 'is_active' => 1, 'help_pre' => "Where does your goat sleep", 'help_post' => "thank you for your time", 'extends' => 2, 'financial_type_id' => 3, 'is_quick_config' => 0, 'is_reserved' => 0);
// Financial Account with 20% tax rate
$financialAccountSetparams = array('name' => 'vat full taxrate account' . substr(sha1(rand()), 0, 7), 'contact_id' => $this->_orgId, 'financial_account_type_id' => 2, 'is_tax' => 1, 'tax_rate' => 20.0, 'is_reserved' => 0, 'is_active' => 1, 'is_default' => 0);
$financialAccount = $this->callAPISuccess('financial_account', 'create', $financialAccountSetparams);
$this->financialAccountId = $financialAccount['id'];
// Financial type having 'Sales Tax Account is' with liability financail account
$financialType = array('name' => 'grassvariety1' . substr(sha1(rand()), 0, 7), 'is_reserved' => 0, 'is_active' => 1);
$priceField = $this->callAPISuccess('financial_type', 'create', $financialType);
$this->financialtypeID = $priceField['id'];
$financialRelationParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $this->financialtypeID, 'account_relationship' => 10, 'financial_account_id' => $this->financialAccountId);
$financialRelation = CRM_Financial_BAO_FinancialTypeAccount::add($financialRelationParams);
// Financial type with 5% tax rate
$financialAccHalftax = array('name' => 'vat half taxrate account' . substr(sha1(rand()), 0, 7), 'contact_id' => $this->_orgId, 'financial_account_type_id' => 2, 'is_tax' => 1, 'tax_rate' => 5.0, 'is_reserved' => 0, 'is_active' => 1, 'is_default' => 0);
$halfFinancialAccount = CRM_Financial_BAO_FinancialAccount::add($financialAccHalftax);
$this->halfFinancialAccId = $halfFinancialAccount->id;
$halfFinancialtypeHalftax = array('name' => 'grassvariety2' . substr(sha1(rand()), 0, 7), 'is_reserved' => 0, 'is_active' => 1);
$halfFinancialType = CRM_Financial_BAO_FinancialType::add($halfFinancialtypeHalftax);
$this->halfFinancialTypeId = $halfFinancialType->id;
$financialRelationHalftax = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $this->halfFinancialTypeId, 'account_relationship' => 10, 'financial_account_id' => $this->halfFinancialAccId);
$halfFinancialRelation = CRM_Financial_BAO_FinancialTypeAccount::add($financialRelationHalftax);
// Enable component contribute setting
$contributeSetting = array('invoicing' => 1, 'invoice_prefix' => 'INV_', 'credit_notes_prefix' => 'CN_', 'due_date' => 10, 'due_date_period' => 'days', 'notes' => '', 'is_email_pdf' => 1, 'tax_term' => 'Sales Tax', 'tax_display_settings' => 'Inclusive');
$setInvoiceSettings = CRM_Core_BAO_Setting::setItem($contributeSetting, CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
// Payment Processor
$paymentProceParams = array('domain_id' => 1, 'name' => 'dummy' . substr(sha1(rand()), 0, 7), 'payment_processor_type_id' => 10, 'financial_account_id' => 12, 'is_active' => 1, 'is_default' => 1, 'user_name' => 'dummy', 'url_site' => 'http://dummy.com', 'url_recur' => 'http://dummyrecur.com', 'class_name' => 'Payment_Dummy', 'billing_mode' => 1, 'is_recur' => 1, 'payment_type' => 1);
$result = $this->callAPISuccess('payment_processor', 'create', $paymentProceParams);
$this->_ids['paymentProcessID'] = $result['id'];
require_once 'api/v3/examples/PaymentProcessor/Create.php';
$this->assertAPISuccess($result);
}
示例5: getAccountCode
/**
* Get the accounting code from the financial type id.
*
* @param int $financialTypeID *
*
* @return string
*/
public static function getAccountCode($financialTypeID)
{
static $codes = array();
if (!in_array($financialTypeID, $codes)) {
$codes[$financialTypeID] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($financialTypeID);
}
return $codes[$financialTypeID];
}
示例6: createDefaultFinancialAccounts
/**
* Create default entity financial accounts
* for financial type
* CRM-12470
*
* @param $financialType
*
* @return array
*/
public static function createDefaultFinancialAccounts($financialType)
{
$titles = array();
$financialAccountTypeID = CRM_Core_OptionGroup::values('financial_account_type', FALSE, FALSE, FALSE, NULL, 'name');
$accountRelationship = CRM_Core_OptionGroup::values('account_relationship', FALSE, FALSE, FALSE, NULL, 'name');
$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));
$dao = CRM_Core_DAO::executeQuery('SELECT id, financial_account_type_id FROM civicrm_financial_account WHERE name LIKE %1', array(1 => array($financialType->name, 'String')));
$dao->fetch();
$existingFinancialAccount = array();
if (!$dao->N) {
$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);
} else {
$existingFinancialAccount[$dao->financial_account_type_id] = $dao->id;
}
$params = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $financialType->id);
foreach ($relationships as $key => $value) {
if (!array_key_exists($value, $existingFinancialAccount)) {
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\n LEFT JOIN civicrm_financial_account ON civicrm_financial_account.id = civicrm_entity_financial_account.financial_account_id\n 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' && empty($existingFinancialAccount)) {
$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;
}
} else {
$params['financial_account_id'] = $existingFinancialAccount[$value];
$titles[] = $financialType->name;
}
$params['account_relationship'] = $key;
self::add($params);
}
if (!empty($existingFinancialAccount)) {
$titles = array();
}
return $titles;
}
示例7: validateRelationship
/**
* Validate account relationship with financial account type
*
* @param obj $financialTypeAccount of CRM_Financial_DAO_EntityFinancialAccount
*
*/
public static function validateRelationship($financialTypeAccount)
{
$financialAccountLinks = CRM_Financial_BAO_FinancialAccount::getfinancialAccountRelations();
$financialAccountType = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $financialTypeAccount->financial_account_id, 'financial_account_type_id');
if (CRM_Utils_Array::value($financialTypeAccount->account_relationship, $financialAccountLinks) != $financialAccountType) {
$accountRelationships = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
$params = array(1 => $accountRelationships[$financialTypeAccount->account_relationship]);
throw new Exception(ts("This financial account cannot have '%1' relationship.", $params));
}
}
示例8: testGetInstrumentFinancialAccount
/**
* check method getInstrumentFinancialAccount()
*/
function testGetInstrumentFinancialAccount()
{
$paymentInstrumentValue = 1;
$params = array('name' => 'Donations', 'is_deductible' => 0, 'is_active' => 1);
$ids = array();
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
$optionParams = array('name' => 'Credit Card', 'value' => $paymentInstrumentValue);
$optionValue = CRM_Core_BAO_OptionValue::retrieve($optionParams, $defaults);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
$financialParams = array('entity_table' => 'civicrm_option_value', 'entity_id' => $optionValue->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $financialAccount->id);
CRM_Financial_BAO_FinancialTypeAccount::add($financialParams, $ids);
$financialAccountId = CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($paymentInstrumentValue);
$this->assertEquals($financialAccountId, $financialAccount->id, 'Verify Payment Instrument');
}
示例9: getFinancialAccountForStatusChangeTrxn
/**
* Get the financial account for the item associated with the new transaction.
*
* @param array $params
* @param CRM_Financial_BAO_FinancialItem $prevFinancialItem
*
* @return int
*/
public static function getFinancialAccountForStatusChangeTrxn($params, $prevFinancialItem)
{
if (!empty($params['financial_account_id'])) {
return $params['financial_account_id'];
}
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus($params['contribution_status_id'], 'name');
$preferredAccountsRelationships = array('Refunded' => 'Credit/Contra Revenue Account is', 'Chargeback' => 'Chargeback Account is');
if (in_array($contributionStatus, array_keys($preferredAccountsRelationships))) {
$financialTypeID = !empty($params['financial_type_id']) ? $params['financial_type_id'] : $params['prevContribution']->financial_type_id;
return CRM_Financial_BAO_FinancialAccount::getFinancialAccountForFinancialTypeByRelationship($financialTypeID, $preferredAccountsRelationships[$contributionStatus]);
}
return $prevFinancialItem->financial_account_id;
}
示例10: createFinancialAccount
/**
* Function to create Financial Account.
*
* @param string $financialAccountType
*
* @param string $relationType
*
* @return array
* obj CRM_Financial_DAO_FinancialAccount, obj CRM_Financial_DAO_FinancialType, obj CRM_Financial_DAO_EntityFinancialAccount
*/
public function createFinancialAccount($financialAccountType, $relationType = NULL)
{
$params = array('labelColumn' => 'name');
$relationTypes = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', $params);
$financialAccountTypes = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id', $params);
$params = array('name' => 'TestFinancialAccount_' . rand(), 'contact_id' => 1, 'is_deductible' => 0, 'is_active' => 1, 'is_reserved' => 0, 'financial_account_type_id' => array_search($financialAccountType, $financialAccountTypes));
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params);
$financialType = $financialAccountType = NULL;
if ($relationType) {
$params['name'] = 'test_financialType1';
$financialType = CRM_Financial_BAO_FinancialType::add($params);
$financialParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $financialType->id, 'account_relationship' => array_search($relationType, $relationTypes), 'financial_account_id' => $financialAccount->id);
$financialAccountType = CRM_Financial_BAO_FinancialTypeAccount::add($financialParams);
}
return array($financialAccount, $financialType, $financialAccountType);
}
示例11: processConfirm
/**
* Function to process payment after confirmation
*
* @param object $form form object
* @param array $paymentParams array with payment related key
* value pairs
* @param array $premiumParams array with premium related key
* value pairs
* @param int $contactID contact id
* @param int $contributionTypeId financial type id
* @param int $component component id
*
* @return array associated array
*
* @static
* @access public
*/
static function processConfirm(&$form, &$paymentParams, &$premiumParams, $contactID, $contributionTypeId, $component = 'contribution', $fieldTypes = NULL)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$contributionType = new CRM_Financial_DAO_FinancialType();
if (isset($paymentParams['financial_type'])) {
$contributionType->id = $paymentParams['financial_type'];
} elseif (!empty($form->_values['pledge_id'])) {
$contributionType->id = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $form->_values['pledge_id'], 'financial_type_id');
} else {
$contributionType->id = $contributionTypeId;
}
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal('Could not find a system table');
}
// add some financial type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $contributionType->name;
//CRM-11456
$paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionType->id);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$payment = NULL;
$paymentObjError = ts('The system did not record payment details for this payment and so could not process the transaction. Please report this error to the site administrator.');
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && is_array($form->_paymentProcessor)) {
$payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
}
//fix for CRM-2062
$now = date('YmdHis');
$result = NULL;
if ($form->_contributeMode == 'notify' || $form->_params['is_pay_later']) {
// this is not going to come back, i.e. we fill in the other details
// when we get a callback from the payment processor
// also add the contact ID and contribution ID to the params list
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, NULL, $contactID, $contributionType, TRUE, TRUE, TRUE);
if ($contribution) {
$form->_params['contributionID'] = $contribution->id;
}
$form->_params['contributionTypeID'] = $contributionType->id;
$form->_params['item_name'] = $form->_params['description'];
$form->_params['receive_date'] = $now;
if ($contribution && $form->_values['is_recur'] && $contribution->contribution_recur_id) {
$form->_params['contributionRecurID'] = $contribution->contribution_recur_id;
}
$form->set('params', $form->_params);
$form->postProcessPremium($premiumParams, $contribution);
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// add qfKey so we can send to paypal
$form->_params['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
$membershipResult = array(1 => $contribution);
return $membershipResult;
} else {
if (!$form->_params['is_pay_later']) {
if (is_object($payment)) {
// call postprocess hook before leaving
$form->postProcessHook();
// this does not return
$result =& $payment->doTransferCheckout($form->_params, 'contribute');
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
// follow similar flow as IPN
// send the receipt mail
$form->set('params', $form->_params);
if ($contributionType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
return;
}
}
//.........这里部分代码省略.........
示例12: add
/**
* Add the financial types.
*
* @param array $params
* Reference array contains the values submitted by the form.
*
* @return CRM_Financial_DAO_FinancialAccount
*/
public static function add(&$params)
{
if (empty($params['id'])) {
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
$params['is_deductible'] = CRM_Utils_Array::value('is_deductible', $params, FALSE);
$params['is_tax'] = CRM_Utils_Array::value('is_tax', $params, FALSE);
$params['is_header_account'] = CRM_Utils_Array::value('is_header_account', $params, FALSE);
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
}
if (!empty($params['id']) && !empty($params['financial_account_type_id']) && CRM_Financial_BAO_FinancialAccount::validateFinancialAccount($params['id'], $params['financial_account_type_id'])) {
throw new CRM_Core_Exception(ts('You cannot change the account type since this financial account refers to a financial item having an account type of Revenue/Liability.'));
}
if (!empty($params['is_default'])) {
$query = 'UPDATE civicrm_financial_account SET is_default = 0 WHERE financial_account_type_id = %1';
$queryParams = array(1 => array($params['financial_account_type_id'], 'Integer'));
CRM_Core_DAO::executeQuery($query, $queryParams);
}
// action is taken depending upon the mode
$financialAccount = new CRM_Financial_DAO_FinancialAccount();
if (!empty($params['id'])) {
$financialAccount->id = $params['id'];
$financialAccount->find(TRUE);
}
$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();
return $financialAccount;
}
示例13: processConfirm
/**
* Process payment after confirmation.
*
* @param CRM_Core_Form $form
* Form object.
* @param array $paymentParams
* Array with payment related key.
* value pairs
* @param int $contactID
* Contact id.
* @param int $contributionTypeId
* Financial type id.
* @param int|string $component component id
* @param bool $isTest
* @param bool $isRecur
*
* @throws CRM_Core_Exception
* @throws Exception
* @return array
* associated array
*
*/
public static function processConfirm(&$form, &$paymentParams, $contactID, $contributionTypeId, $component = 'contribution', $isTest, $isRecur)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$lineItems = $form->_lineItem;
$isPaymentTransaction = self::isPaymentTransaction($form);
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $contributionTypeId;
$financialType->find(TRUE);
if ($financialType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
// add some financial type details to the params list
// if folks need to use it
//CRM-15297 - contributionType is obsolete - pass financial type as well so people can deprecate it
$paymentParams['financialType_name'] = $paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $financialType->name;
//CRM-11456
$paymentParams['financialType_accounting_code'] = $paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionTypeId);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
//fix for CRM-16317
$form->_params['receive_date'] = date('YmdHis');
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
if ($isPaymentTransaction) {
$contributionParams = array('id' => CRM_Utils_Array::value('contribution_id', $paymentParams), 'contact_id' => $contactID, 'line_item' => $lineItems, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams, CRM_Utils_Array::value('campaign_id', $form->_values)), 'contribution_page_id' => $form->_id, 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)));
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
if (empty($paymentParams['is_pay_later'])) {
// @todo look up payment_instrument_id on payment processor table.
$contributionParams['payment_instrument_id'] = 1;
}
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form, $paymentParams, NULL, $contributionParams, $financialType, TRUE, $form->_bltID, $isRecur);
$paymentParams['contributionTypeID'] = $contributionTypeId;
$paymentParams['item_name'] = $form->_params['description'];
$paymentParams['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
return array('contribution' => $contribution);
}
$paymentParams['contributionID'] = $contribution->id;
//CRM-15297 deprecate contributionTypeID
$paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if (isset($paymentParams['contribution_source'])) {
$paymentParams['source'] = $paymentParams['contribution_source'];
}
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
if (!empty($form->_paymentProcessor)) {
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
if ($form->_contributeMode == 'notify') {
// We want to get rid of this & make it generic - eg. by making payment processing the last thing
// and always calling it first.
$form->postProcessHook();
}
$result = $payment->doPayment($paymentParams);
$form->_params = array_merge($form->_params, $result);
$form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
if (!empty($result['trxn_id'])) {
$contribution->trxn_id = $result['trxn_id'];
}
if (!empty($result['payment_status_id'])) {
$contribution->payment_status_id = $result['payment_status_id'];
}
$result['contribution'] = $contribution;
if ($result['payment_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'status_id', 'Pending') && $payment->isSendReceiptForPending()) {
//.........这里部分代码省略.........
示例14: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
parent::buildQuickForm();
$this->setPageTitle(ts('Financial Type Account'));
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, $defaults);
$this->setDefaults($defaults);
$financialAccountTitle = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $defaults['financial_account_id'], 'name');
}
$this->applyFilter('__ALL__', 'trim');
if ($this->_action == CRM_Core_Action::UPDATE) {
$this->assign('aid', $this->_id);
// hidden field to catch the group id in profile
$this->add('hidden', 'financial_type_id', $this->_aid);
// hidden field to catch the field id in profile
$this->add('hidden', 'account_type_id', $this->_id);
}
$params['orderColumn'] = 'label';
$AccountTypeRelationship = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', $params);
if (!empty($AccountTypeRelationship)) {
$element = $this->add('select', 'account_relationship', ts('Financial Account Relationship'), array('select' => ts('- Select Financial Account Relationship -')) + $AccountTypeRelationship, TRUE);
}
if ($this->_isARFlag) {
$element->freeze();
}
if ($this->_action == CRM_Core_Action::ADD) {
if (!empty($this->_submitValues['account_relationship']) || !empty($this->_submitValues['financial_account_id'])) {
$financialAccountType = CRM_Financial_BAO_FinancialAccount::getfinancialAccountRelations();
$financialAccountType = CRM_Utils_Array::value($this->_submitValues['account_relationship'], $financialAccountType);
$result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
$financialAccountSelect = array('' => ts('- select -')) + $result;
} else {
$financialAccountSelect = array('select' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialAccount();
}
}
if ($this->_action == CRM_Core_Action::UPDATE) {
$financialAccountType = CRM_Financial_BAO_FinancialAccount::getfinancialAccountRelations();
$financialAccountType = $financialAccountType[$this->_defaultValues['account_relationship']];
$result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
$financialAccountSelect = array('' => ts('- select -')) + $result;
}
$this->add('select', 'financial_account_id', ts('Financial Account'), $financialAccountSelect, TRUE);
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->addFormRule(array('CRM_Financial_Form_FinancialTypeAccount', 'formRule'), $this);
}
示例15: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Financial_BAO_FinancialAccount::del($this->_id);
CRM_Core_Session::setStatus(ts('Selected Financial Account has been deleted.'));
} else {
// store the submitted values in an array
$params = $this->exportValues();
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params);
CRM_Core_Session::setStatus(ts('The Financial Account \'%1\' has been saved.', array(1 => $financialAccount->name)), ts('Saved'), 'success');
}
}