Skip to content

Commit

Permalink
Simplify handling of soft credit
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Jun 1, 2022
1 parent fb293ce commit 2ea36d0
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 195 deletions.
2 changes: 1 addition & 1 deletion CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ public static function &importableFields($contactType = 'Individual', $status =

$tmpContactField['external_identifier'] = $contactFields['external_identifier'];
$tmpContactField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . ' ' . ts('(match to contact)');
$tmpFields['contribution_contact_id']['title'] = $tmpFields['contribution_contact_id']['title'] . ' ' . ts('(match to contact)');
$tmpFields['contribution_contact_id']['title'] = $tmpFields['contribution_contact_id']['html']['label'] = $tmpFields['contribution_contact_id']['title'] . ' ' . ts('(match to contact)');
$fields = array_merge($fields, $tmpContactField);
$fields = array_merge($fields, $tmpFields);
$fields = array_merge($fields, $note);
Expand Down
7 changes: 4 additions & 3 deletions CRM/Contribute/Import/Form/MapField.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ public function buildQuickForm() {
foreach ($mapperKeys as $key) {
$this->_fieldUsed[$key] = FALSE;
}
$this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$sel1 = $this->_mapperFields;

if (!$this->get('onDuplicate')) {
Expand Down Expand Up @@ -420,8 +419,9 @@ public function postProcess() {
$this->controller->resetPage($this->_name);
return;
}
$this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues());

$mapper = $mapperKeys = $mapperKeysMain = $mapperSoftCredit = $softCreditFields = $mapperPhoneType = $mapperSoftCreditType = [];
$mapper = $mapperKeysMain = $mapperSoftCredit = $softCreditFields = $mapperPhoneType = $mapperSoftCreditType = [];
$mapperKeys = $this->controller->exportValue($this->_name, 'mapper');

$softCreditTypes = CRM_Core_OptionGroup::values('soft_credit_type');
Expand Down Expand Up @@ -478,7 +478,8 @@ public function postProcess() {
$this->set('savedMapping', $saveMapping->id);
}

$parser = new CRM_Contribute_Import_Parser_Contribution($mapperKeysMain, $mapperSoftCredit, $mapperPhoneType);
$parser = new CRM_Contribute_Import_Parser_Contribution($mapperKeysMain);
$parser->setUserJobID($this->getUserJobID());
$parser->run(
$this->getSubmittedValue('uploadFile'),
$this->getSubmittedValue('fieldSeparator'),
Expand Down
21 changes: 3 additions & 18 deletions CRM/Contribute/Import/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,12 @@ public function preProcess() {
*/
public function postProcess() {
$fileName = $this->controller->exportValue('DataSource', 'uploadFile');
$invalidRowCount = $this->get('invalidRowCount');
$onDuplicate = $this->get('onDuplicate');
$mapperSoftCreditType = $this->get('mapperSoftCreditType');

$this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues());
$mapper = $this->controller->exportValue('MapField', 'mapper');
$mapperKeys = [];
$mapperSoftCredit = [];
$mapperPhoneType = [];

foreach ($mapper as $key => $value) {
$mapperKeys[$key] = $mapper[$key][0];
if (isset($mapper[$key][0]) && $mapper[$key][0] == 'soft_credit' && isset($mapper[$key])) {
$mapperSoftCredit[$key] = $mapper[$key][1] ?? '';
$mapperSoftCreditType[$key] = $mapperSoftCreditType[$key]['value'];
}
else {
$mapperSoftCredit[$key] = $mapperSoftCreditType[$key] = NULL;
}
}

$parser = new CRM_Contribute_Import_Parser_Contribution($mapperKeys, $mapperSoftCredit, $mapperPhoneType, $mapperSoftCreditType);
$parser = new CRM_Contribute_Import_Parser_Contribution();
$parser->setUserJobID($this->getUserJobID());

$mapFields = $this->get('fields');

Expand Down
Loading

0 comments on commit 2ea36d0

Please sign in to comment.