CRM-13833 Further Improvements
authorAtif Shaikh <shaikh388@gmail.com>
Mon, 14 Apr 2014 06:40:47 +0000 (12:10 +0530)
committerAtif Shaikh <shaikh388@gmail.com>
Mon, 14 Apr 2014 06:40:47 +0000 (12:10 +0530)
----------------------------------------
* CRM-13833: Implement Soft Credit Types
  https://issues.civicrm.org/jira/browse/CRM-13833

CRM/Utils/DeprecatedUtils.php

index 2c30fe614528d81f64ff7310469eddd5dc45dbd4..1c3849485c91ff9cd45c3501ebea78ef37effcf7 100644 (file)
@@ -311,7 +311,7 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
             }
           }
         }
-        elseif ($params['contribution_id'] || $params['trxn_id'] || $params['invoice_id']) {
+        elseif (!empty($params['contribution_id']) || !empty($params['trxn_id']) || !empty($params['invoice_id'])) {
           //when update mode check contribution id or trxn id or
           //invoice id
           $contactId = new CRM_Contribute_DAO_Contribution();
@@ -333,6 +333,14 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
             }
           }
         }
+        else {
+          if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
+            return civicrm_api3_create_error("Empty Contribution and Invoice and Transaction ID.Row was skipped.");
+          }
+          else {
+            return civicrm_api3_create_error("Empty Contact and External ID.Row was skipped.");
+          }
+        }
         break;
 
       case 'receive_date':
@@ -392,14 +400,6 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
         //import contribution record according to select contact type
         // validate contact id and external identifier.
         $value[$key] = $mismatchContactType = $softCreditContactIds = '';
-        if (!isset($params['contribution_id']) && empty($params['contribution_id']) && $onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
-          $errorMsg = ts("Empty Contribution Id. Row was skipped.");
-          return civicrm_api3_create_error($errorMsg, $value[$key]);
-        }
-        elseif (!isset($params['contribution_contact_id']) && empty($params['contribution_contact_id']) && $onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
-          $errorMsg = ts("Empty Contact Id. Row was skipped.");
-          return civicrm_api3_create_error($errorMsg, $value[$key]);
-        }
         if (isset($params[$key]) && is_array($params[$key])) {
           foreach ($params[$key] as $softKey => $softParam) {
             $contactId = CRM_Utils_Array::value('contact_id', $softParam);