本文整理汇总了PHP中CRM_Contribute_BAO_ContributionRecur::updateOnNewPayment方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_ContributionRecur::updateOnNewPayment方法的具体用法?PHP CRM_Contribute_BAO_ContributionRecur::updateOnNewPayment怎么用?PHP CRM_Contribute_BAO_ContributionRecur::updateOnNewPayment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_ContributionRecur
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_ContributionRecur::updateOnNewPayment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
//.........这里部分代码省略.........
*
* @return CRM_Contribute_BAO_Contribution|void
*/
public static function add(&$params, $ids = array())
{
if (empty($params)) {
return NULL;
}
//per http://wiki.civicrm.org/confluence/display/CRM/Database+layer we are moving away from $ids array
$contributionID = CRM_Utils_Array::value('contribution', $ids, CRM_Utils_Array::value('id', $params));
$duplicates = array();
if (self::checkDuplicate($params, $duplicates, $contributionID)) {
$error = CRM_Core_Error::singleton();
$d = implode(', ', $duplicates);
$error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Duplicate error - existing contribution record(s) have a matching Transaction ID or Invoice ID. Contribution record ID(s) are: {$d}");
return $error;
}
// first clean up all the money fields
$moneyFields = array('total_amount', 'net_amount', 'fee_amount', 'non_deductible_amount');
//if priceset is used, no need to cleanup money
if (!empty($params['skipCleanMoney'])) {
unset($moneyFields[0]);
}
foreach ($moneyFields as $field) {
if (isset($params[$field])) {
$params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
}
}
//set defaults in create mode
if (!$contributionID) {
CRM_Core_DAO::setCreateDefaults($params, self::getDefaults());
}
//if contribution is created with cancelled or refunded status, add credit note id
if (!empty($params['contribution_status_id'])) {
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
if ($params['contribution_status_id'] == array_search('Refunded', $contributionStatus) || $params['contribution_status_id'] == array_search('Cancelled', $contributionStatus)) {
if (empty($params['creditnote_id']) || $params['creditnote_id'] == "null") {
$params['creditnote_id'] = self::createCreditNoteId();
}
}
} else {
// Since the fee amount is expecting this (later on) ensure it is always set.
// It would only not be set for an update where it is unchanged.
$params['contribution_status_id'] = civicrm_api3('Contribution', 'getvalue', array('id' => $contributionID, 'return' => 'contribution_status_id'));
}
self::calculateMissingAmountParams($params, $contributionID);
if (!empty($params['payment_instrument_id'])) {
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument('name');
if ($params['payment_instrument_id'] != array_search('Check', $paymentInstruments)) {
$params['check_number'] = 'null';
}
}
$setPrevContribution = TRUE;
// CRM-13964 partial payment
if (!empty($params['partial_payment_total']) && !empty($params['partial_amount_pay'])) {
$partialAmtTotal = $params['partial_payment_total'];
$partialAmtPay = $params['partial_amount_pay'];
$params['total_amount'] = $partialAmtTotal;
if ($partialAmtPay < $partialAmtTotal) {
$params['contribution_status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Partially paid', 'name');
$params['is_pay_later'] = 0;
$setPrevContribution = FALSE;
}
}
if ($contributionID && $setPrevContribution) {
$params['prevContribution'] = self::getValues(array('id' => $contributionID), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
}
if ($contributionID) {
CRM_Utils_Hook::pre('edit', 'Contribution', $contributionID, $params);
} else {
CRM_Utils_Hook::pre('create', 'Contribution', NULL, $params);
}
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->copyValues($params);
$contribution->id = $contributionID;
if (empty($contribution->id)) {
// (only) on 'create', make sure that a valid currency is set (CRM-16845)
if (!CRM_Utils_Rule::currencyCode($contribution->currency)) {
$contribution->currency = CRM_Core_Config::singleton()->defaultCurrency;
}
}
$result = $contribution->save();
// Add financial_trxn details as part of fix for CRM-4724
$contribution->trxn_result_code = CRM_Utils_Array::value('trxn_result_code', $params);
$contribution->payment_processor = CRM_Utils_Array::value('payment_processor', $params);
//add Account details
$params['contribution'] = $contribution;
self::recordFinancialAccounts($params);
if (self::isUpdateToRecurringContribution($params)) {
CRM_Contribute_BAO_ContributionRecur::updateOnNewPayment(!empty($params['contribution_recur_id']) ? $params['contribution_recur_id'] : $params['prevContribution']->contribution_recur_id, $contributionStatus[$params['contribution_status_id']]);
}
// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
if ($contributionID) {
CRM_Utils_Hook::post('edit', 'Contribution', $contribution->id, $contribution);
} else {
CRM_Utils_Hook::post('create', 'Contribution', $contribution->id, $contribution);
}
return $result;
}