本文整理汇总了PHP中CRM_Contribute_BAO_Contribution::_trxnIDs方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Contribution::_trxnIDs方法的具体用法?PHP CRM_Contribute_BAO_Contribution::_trxnIDs怎么用?PHP CRM_Contribute_BAO_Contribution::_trxnIDs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_Contribution
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Contribution::_trxnIDs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recordFinancialAccounts
//.........这里部分代码省略.........
if (!empty($params['contribution_status_id']) && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id) {
//Update Financial Records
self::updateFinancialAccounts($params, 'changedStatus');
$updated = TRUE;
}
// change Payment Instrument for a Completed contribution
// first handle special case when contribution is changed from Pending to Completed status when initial payment
// instrument is null and now new payment instrument is added along with the payment
$params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
$params['trxnParams']['check_number'] = CRM_Utils_Array::value('check_number', $params);
if (array_key_exists('payment_instrument_id', $params)) {
$params['trxnParams']['total_amount'] = -$trxnParams['total_amount'];
if (CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id) && !CRM_Utils_System::isNull($params['contribution']->payment_instrument_id)) {
//check if status is changed from Pending to Completed
// do not update payment instrument changes for Pending to Completed
if (!($params['contribution']->contribution_status_id == array_search('Completed', $contributionStatuses) && in_array($params['prevContribution']->contribution_status_id, $pendingStatus))) {
// for all other statuses create new financial records
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$updated = TRUE;
}
} elseif ((!CRM_Utils_System::isNull($params['contribution']->payment_instrument_id) || !CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id)) && $params['contribution']->payment_instrument_id != $params['prevContribution']->payment_instrument_id) {
// for any other payment instrument changes create new financial records
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$updated = TRUE;
} elseif (!CRM_Utils_System::isNull($params['contribution']->check_number) && $params['contribution']->check_number != $params['prevContribution']->check_number) {
// another special case when check number is changed, create new financial records
// create financial trxn with negative amount
$params['trxnParams']['check_number'] = $params['prevContribution']->check_number;
self::updateFinancialAccounts($params, 'changePaymentInstrument');
// create financial trxn with positive amount
$params['trxnParams']['check_number'] = $params['contribution']->check_number;
$params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$updated = TRUE;
}
}
//if Change contribution amount
$params['trxnParams']['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params);
$params['trxnParams']['net_amount'] = CRM_Utils_Array::value('net_amount', $params);
$params['trxnParams']['total_amount'] = $trxnParams['total_amount'] = $params['total_amount'] = $totalAmount;
$params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
if (isset($totalAmount) && $totalAmount != $params['prevContribution']->total_amount) {
//Update Financial Records
$params['trxnParams']['from_financial_account_id'] = NULL;
self::updateFinancialAccounts($params, 'changedAmount');
$updated = TRUE;
}
if (!$updated) {
// Looks like we might have a data correction update.
// This would be a case where a transaction id has been entered but it is incorrect &
// the person goes back in & fixes it, as opposed to a new transaction.
// Currently the UI doesn't support multiple refunds against a single transaction & we are only supporting
// the data fix scenario.
// CRM-17751.
if (isset($params['refund_trxn_id'])) {
$refundIDs = CRM_Core_BAO_FinancialTrxn::getRefundTransactionIDs($params['id']);
if (!empty($refundIDs['financialTrxnId']) && $refundIDs['trxn_id'] != $params['refund_trxn_id']) {
civicrm_api3('FinancialTrxn', 'create', array('id' => $refundIDs['financialTrxnId'], 'trxn_id' => $params['refund_trxn_id']));
}
}
}
}
if (!$update) {
// records finanical trxn and entity financial trxn
// also make it available as return value
self::recordAlwaysAccountsReceivable($trxnParams, $params);
$return = $financialTxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams);
$params['entity_id'] = $financialTxn->id;
if (empty($params['partial_payment_total']) && empty($params['partial_amount_pay'])) {
self::$_trxnIDs[] = $financialTxn->id;
}
}
}
// record line items and financial items
if (empty($params['skipLineItem'])) {
CRM_Price_BAO_LineItem::processPriceSet($entityId, CRM_Utils_Array::value('line_item', $params), $params['contribution'], $entityTable, $update);
}
// create batch entry if batch_id is passed and
// ensure no batch entry is been made on 'Pending' or 'Failed' contribution, CRM-16611
if (!empty($params['batch_id']) && !empty($financialTxn)) {
$entityParams = array('batch_id' => $params['batch_id'], 'entity_table' => 'civicrm_financial_trxn', 'entity_id' => $financialTxn->id);
CRM_Batch_BAO_Batch::addBatchEntity($entityParams);
}
// when a fee is charged
if (!empty($params['fee_amount']) && (empty($params['prevContribution']) || $params['contribution']->fee_amount != $params['prevContribution']->fee_amount) && $skipRecords) {
CRM_Core_BAO_FinancialTrxn::recordFees($params);
}
if (!empty($params['prevContribution']) && $entityTable == 'civicrm_participant' && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id) {
$eventID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $entityId, 'event_id');
$feeLevel[] = str_replace('', '', $params['prevContribution']->amount_level);
CRM_Event_BAO_Participant::createDiscountTrxn($eventID, $params, $feeLevel);
}
unset($params['line_item']);
self::$_trxnIDs = NULL;
return $return;
}