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',
}
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
}
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();