Fix error when importing a soft credit AND a note when currency not provided
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 2 Apr 2023 07:18:24 +0000 (19:18 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 2 Apr 2023 07:18:24 +0000 (19:18 +1200)
CRM/Contribute/Import/Parser/Contribution.php
tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php

index 6f47c715d30ad638eb303a30d32ea2835b0f0ca7..0a4705ff79933d8d14591c82489f6712d0a87628 100644 (file)
@@ -471,7 +471,7 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Import_Parser {
 
       if (!empty($softCreditParams)) {
         if (empty($contributionParams['total_amount']) || empty($contributionParams['currency'])) {
-          $contributionParams = Contribution::get()->addSelect('total_amount', 'currency')->addWhere('id', '=', $contributionID)->execute()->first();
+          $contributionParams = array_merge($contributionParams, Contribution::get()->addSelect('total_amount', 'currency')->addWhere('id', '=', $contributionID)->execute()->first());
         }
         foreach ($softCreditParams as $softCreditParam) {
           $softCreditParam['contribution_id'] = $contributionID;
index caaa6240322a0d0f8a29a4af5c6b5cfa6ca7c3e6..7ecfdc14f950158ff5957914578b2b5d19fe519f 100644 (file)
@@ -112,7 +112,7 @@ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase {
       ['name' => 'financial_type_id'],
       ['name' => 'external_identifier'],
       ['name' => 'soft_credit.contact.external_identifier', 'soft_credit_type_id' => 1],
-      ['name' => ''],
+      ['name' => 'note'],
     ];
     $this->importCSV('contributions_amount_validate.csv', $mapping, ['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]);