Created
July 15, 2015 05:25
-
-
Save monishdeb/f88ec0e8179fda638be7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php | |
index d46fb26..9062f5c 100644 | |
--- a/CRM/Contribute/BAO/Contribution.php | |
+++ b/CRM/Contribute/BAO/Contribution.php | |
@@ -374,6 +374,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { | |
if ($pcp = CRM_Utils_Array::value('pcp', $params)) { | |
$softParams = array(); | |
+ $softParams['id'] = $pcpId ? $pcpId : NULL; | |
$softParams['contribution_id'] = $contribution->id; | |
$softParams['pcp_id'] = $pcp['pcp_made_through_id']; | |
$softParams['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', | |
@@ -398,17 +399,12 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { | |
} | |
if (isset($params['soft_credit'])) { | |
$softParams = $params['soft_credit']; | |
- | |
- if (!empty($softIDs)) { | |
- foreach ($softIDs as $softID) { | |
- if (!in_array($softID, $params['soft_credit_ids'])) { | |
- $deleteParams = array('id' => $softID); | |
- CRM_Contribute_BAO_ContributionSoft::del($deleteParams); | |
- } | |
- } | |
- } | |
- | |
foreach ($softParams as $softParam) { | |
+ if (!empty($softIDs)) { | |
+ $key = key($softIDs); | |
+ $softParam['id'] = $softIDs[$key]; | |
+ unset($softIDs[$key]); | |
+ } | |
$softParam['contribution_id'] = $contribution->id; | |
$softParam['currency'] = $contribution->currency; | |
//case during Contribution Import when we assign soft contribution amount as contribution's total_amount by default | |
@@ -417,6 +413,15 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { | |
} | |
CRM_Contribute_BAO_ContributionSoft::add($softParam); | |
} | |
+ | |
+ if (!empty($softIDs)) { | |
+ foreach ($softIDs as $softID) { | |
+ if (!in_array($softID, $params['soft_credit_ids'])) { | |
+ $deleteParams = array('id' => $softID); | |
+ CRM_Contribute_BAO_ContributionSoft::del($deleteParams); | |
+ } | |
+ } | |
+ } | |
} | |
$transaction->commit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment