Created
July 14, 2015 11:38
-
-
Save monishdeb/8b77b5c58fbdeeffd744 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..92188b6 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', | |
@@ -399,16 +400,11 @@ 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 $key => $softParam) { | |
+ if (!empty($softIDs)) { | |
+ $softParam['id'] = $softIDs[$key]; | |
+ unset($softIDs[$key]); | |
} | |
- } | |
- | |
- foreach ($softParams as $softParam) { | |
$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