Skip to content

Commit

Permalink
Merge pull request #24838 from eileenmcnaughton/import_reg
Browse files Browse the repository at this point in the history
dev/core#3939 Fix import mandatory field validation regression
  • Loading branch information
seamuslee001 authored Oct 31, 2022
2 parents b3c3e52 + 53809cc commit 14c5d3f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
10 changes: 7 additions & 3 deletions CRM/Contribute/Import/Form/MapField.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,17 @@ protected function validateDedupeFieldsSufficientInMapping(array $rule, array $m
$ruleFields = $rule['fields'];
$weightSum = 0;
foreach ($mapper as $mapping) {
if ($mapping[0] === 'external_identifier' || $mapping[0] === 'contribution_contact_id' || $mapping[0] === 'contact__id') {
// Because api v4 style fields have a . and QuickForm multiselect js does
// not cope with a . the quick form layer will use a double underscore
// as a stand in (the angular layer will not)
$fieldName = str_replace('__', '.', $mapping[0]);
if ($fieldName === 'external_identifier' || $fieldName === 'contribution_contact_id' || $fieldName === 'contact__id') {
// It is enough to have external identifier mapped.
$weightSum = $threshold;
break;
}
if (array_key_exists($mapping[0], $ruleFields)) {
$weightSum += $ruleFields[$mapping[0]];
if (array_key_exists($fieldName, $ruleFields)) {
$weightSum += $ruleFields[$fieldName];
}
}
if ($weightSum < $threshold) {
Expand Down
18 changes: 18 additions & 0 deletions tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,24 @@ public function testImportMatch() :void {

}

/**
* Tests the form flow copes with QuickForm style dots.
*
* Because the QuickForm hierarchical select won't cope with dots
* we are using a double underscore on that form. The test checks that works.
*/
public function testImportQuickFormEmailMatch() :void {
$this->individualCreate(['email' => 'jenny@example.com']);
$this->importCSV('checkboxes.csv', [
['name' => 'total_amount'],
['name' => 'receive_date'],
['name' => 'financial_type_id'],
['name' => ''],
['name' => 'email_primary__email'],
['name' => ''],
]);
}

/**
* Test whether importing a contribution using email match will match a non-primary.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Total Amount,Date Received,Financial Type,Colour,Contact email,Soft credit email
50,2022-03-09,Donation,"Red,Yellow,Blue",jenny@example.com,demo@example.com
60,2022-04-09,Donation,"1,2,3",jenny@example.com,demo@example.com

0 comments on commit 14c5d3f

Please sign in to comment.