Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Name Extraction in Banking Matcher Plugin #112

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions CRM/Banking/PluginImpl/Matcher/GetOrCreateContactAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,33 @@ protected function applyNameExtraction($btx, &$xcm_values, $name_mode)
$xcm_values['last_name'] = implode(' ', $last_names);
break;

// See PR #112
case 'db2':
$first_names = [];
$last_names = [];
foreach ($name_bits as $name_bit) {
if (!$this->isNameBlacklisted($name_bit, $config->name_blacklist)) {
if ((!$this->isNameBlacklisted($name_bit, $config->first_name_blacklist))
&& $this->isDBFirstName($name_bit)
&& empty($last_names)) {
$first_names[] = $name_bit;
} else {
$last_names[] = $name_bit;
}
}
}

// If we didn't find any last names, but we found more than one first name,
// then we assume that the last one is the last name of the contact
if (empty($last_names) && count($first_names) > 1) {
$last_names[] = array_pop($first_names);
}

$this->logMessage("Identified (by DB) first names of '{$btx_name}' are: " . implode(',', $first_names), 'debug');
$xcm_values['first_name'] = implode(' ', $first_names);
$xcm_values['last_name'] = implode(' ', $last_names);
break;

default:
case 'off':
break;
Expand Down