$contributionStatus = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', (int) $params['contribution_status_id']);
if (!$contributionID
- && CRM_Utils_Array::value('membership_id', $params)
+ && !empty($params['membership_id'])
&& Civi::settings()->get('deferred_revenue_enabled')
) {
$memberStartDate = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $params['membership_id'], 'start_date');
CRM_Core_BAO_Note::add($noteParams);
}
- // make entry in batch entity batch table
- if (!empty($params['batch_id'])) {
- // in some update cases we need to get extra fields - ie an update that doesn't pass in all these params
- $titleFields = [
- 'contact_id',
- 'total_amount',
- 'currency',
- 'financial_type_id',
- ];
- $retrieveRequired = 0;
- foreach ($titleFields as $titleField) {
- if (!isset($contribution->$titleField)) {
- $retrieveRequired = 1;
- break;
- }
- }
- if ($retrieveRequired == 1) {
- $contribution->find(TRUE);
- }
- }
-
CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);
$transaction->commit();
CRM_Core_BAO_CustomField::getFieldsForImport('Contribution', FALSE, FALSE, FALSE, $checkPermission)
);
+ $fields['financial_type_id']['title'] = ts('Financial Type ID');
+
self::$_exportableFields = $fields;
}
if (empty($resultDAO->payment_processor_id) && CRM_Core_Permission::check('edit contributions')) {
$links = [
CRM_Core_Action::UPDATE => [
- 'name' => "<i class='crm-i fa-pencil'></i>",
+ 'name' => ts('Edit Payment'),
+ 'icon' => 'fa-pencil',
'url' => 'civicrm/payment/edit',
'class' => 'medium-popup',
'qs' => "reset=1&id=%%id%%&contribution_id=%%contribution_id%%",
* @return bool
* @throws Exception
*/
- public function loadRelatedObjects(&$input, &$ids, $loadAll = FALSE) {
+ public function loadRelatedObjects($input, &$ids, $loadAll = FALSE) {
// @todo deprecate this function - the steps should be
// 1) add additional functions like 'getRelatedMemberships'
// 2) switch all calls that refer to ->_relatedObjects to
}
}
+ $relatedContact = CRM_Contribute_BAO_Contribution::getOnbehalfIds($this->id);
+ if (!empty($relatedContact['individual_id'])) {
+ $ids['related_contact'] = $relatedContact['individual_id'];
+ }
+
if ($paymentProcessorID) {
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID,
$this->is_test ? 'test' : 'live'
$newFinancialAccount = CRM_Financial_BAO_FinancialAccount::getFinancialAccountForFinancialTypeByRelationship($params['financial_type_id'], $accountRelationship);
if ($oldFinancialAccount != $newFinancialAccount) {
$params['total_amount'] = 0;
+ // If we have a fee amount set reverse this as well.
+ if (isset($params['fee_amount'])) {
+ $params['trxnParams']['fee_amount'] = 0 - $params['fee_amount'];
+ }
if (in_array($params['contribution']->contribution_status_id, $pendingStatus)) {
$params['trxnParams']['to_financial_account_id'] = CRM_Financial_BAO_FinancialAccount::getFinancialAccountForFinancialTypeByRelationship(
$params['prevContribution']->financial_type_id, $accountRelationship);
/* $params['trxnParams']['to_financial_account_id'] = $trxnParams['to_financial_account_id']; */
$params['financial_account_id'] = $newFinancialAccount;
$params['total_amount'] = $params['trxnParams']['total_amount'] = $params['trxnParams']['net_amount'] = $trxnParams['total_amount'];
+ // Set the transaction fee amount back to the original value for creating the new positive financial trxn.
+ if (isset($params['fee_amount'])) {
+ $params['trxnParams']['fee_amount'] = $params['fee_amount'];
+ }
self::updateFinancialAccounts($params);
CRM_Core_BAO_FinancialTrxn::createDeferredTrxn(CRM_Utils_Array::value('line_item', $params), $params['contribution'], TRUE);
$params['trxnParams']['to_financial_account_id'] = $trxnParams['to_financial_account_id'];
public static function checkTaxAmount($params, $isLineItem = FALSE) {
$taxRates = CRM_Core_PseudoConstant::getTaxRates();
- // This function should be only called after standardisation (removal of
- // thousand separator & using a decimal point for cents separator.
- // However, we don't know if that is always true :-(
- // There is a deprecation notice tho :-)
- $unknownIfMoneyIsClean = empty($params['skipCleanMoney']) && !$isLineItem;
// Update contribution.
if (!empty($params['id'])) {
// CRM-19126 and CRM-19152 If neither total or financial_type_id are set on an update
empty($params['skipLineItem']) && !$isLineItem
) {
$taxRateParams = $taxRates[$params['financial_type_id']];
- $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount(CRM_Utils_Array::value('total_amount', $params), $taxRateParams, $unknownIfMoneyIsClean);
+ $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount(CRM_Utils_Array::value('total_amount', $params), $taxRateParams);
$params['tax_amount'] = round($taxAmount['tax_amount'], 2);
// Get Line Item on update of contribution
// update line item of contrbution
if (isset($params['financial_type_id']) && array_key_exists($params['financial_type_id'], $taxRates) && $isLineItem) {
$taxRate = $taxRates[$params['financial_type_id']];
- $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($params['line_total'], $taxRate, $unknownIfMoneyIsClean);
+ $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($params['line_total'], $taxRate);
$params['tax_amount'] = round($taxAmount['tax_amount'], 2);
}
}
if (empty($contribution->_relatedObjects['participant']) && !empty($contribution->_relatedObjects['membership'])) {
// @fixme Can we remove this if altogether? - we removed the participant if / else and left relatedObjects['participant'] to ensure behaviour didn't change but it is probably not required.
// @todo - use getRelatedMemberships instead
- $contribution->contribution_status_id = $contributionParams['contribution_status_id'];
$contribution->trxn_id = $input['trxn_id'] ?? NULL;
$contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
}
+ $contribution->contribution_status_id = $contributionParams['contribution_status_id'];
CRM_Core_Error::debug_log_message("Contribution record updated successfully");
$transaction->commit();