Skip to content

Commit

Permalink
Remove some more unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Jun 10, 2022
1 parent bc38b6d commit 9140019
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
36 changes: 8 additions & 28 deletions CRM/Contribute/Import/Parser/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ public function addField($name, $title, $type = CRM_Utils_Type::T_INT, $headerPa
* The initializer code, called before the processing
*/
public function init() {
// Force re-load of user job.
unset($this->userJob);
$this->setFieldMetadata();
foreach ($this->getImportableFieldsMetadata() as $name => $field) {
$this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']);
Expand All @@ -212,14 +214,15 @@ public function init() {
*/
protected function setFieldMetadata() {
if (empty($this->importableFieldsMetadata)) {
$fields = CRM_Contribute_BAO_Contribution::importableFields($this->_contactType, FALSE);
$fields = CRM_Contribute_BAO_Contribution::importableFields($this->getContactType(), FALSE);

$fields = array_merge($fields,
[
'soft_credit' => [
'title' => ts('Soft Credit'),
'softCredit' => TRUE,
'headerPattern' => '/Soft Credit/i',
'options' => FALSE,
],
]
);
Expand Down Expand Up @@ -250,29 +253,6 @@ protected function setFieldMetadata() {
}
}

/**
* Handle the values in summary mode.
*
* @param array $values
* The array of values belonging to this line.
*
* @return int
* CRM_Import_Parser::VALID or CRM_Import_Parser::ERROR
*/
public function summary(&$values) {
$rowNumber = (int) ($values[array_key_last($values)]);
$params = $this->getMappedRow($values);
$errorMessage = implode(';', $this->getInvalidValues($params));
$params['contact_type'] = 'Contribution';

if ($errorMessage) {
$this->setImportStatus($rowNumber, 'ERROR', "Invalid value for field(s) : $errorMessage");
return CRM_Import_Parser::ERROR;
}

return CRM_Import_Parser::VALID;
}

/**
* Handle the values in import mode.
*
Expand Down Expand Up @@ -302,15 +282,15 @@ public function import($values): void {
if ($this->isSkipDuplicates() &&
(!empty($paramValues['contribution_contact_id']) || !empty($paramValues['external_identifier']))
) {
$paramValues['contact_type'] = $this->_contactType;
$paramValues['contact_type'] = $this->getContactType();
}
elseif ($this->isUpdateExisting() &&
(!empty($paramValues['contribution_id']) || !empty($values['trxn_id']) || !empty($paramValues['invoice_id']))
) {
$paramValues['contact_type'] = $this->_contactType;
$paramValues['contact_type'] = $this->getContactType();
}
elseif (!empty($paramValues['pledge_payment'])) {
$paramValues['contact_type'] = $this->_contactType;
$paramValues['contact_type'] = $this->getContactType();
}

$formatError = $this->deprecatedFormatParams($paramValues, $formatted);
Expand Down Expand Up @@ -451,7 +431,7 @@ public function import($values): void {

// Using new Dedupe rule.
$ruleParams = [
'contact_type' => $this->_contactType,
'contact_type' => $this->getContactType(),
'used' => 'Unsupervised',
];
$fieldsArray = CRM_Dedupe_BAO_DedupeRule::dedupeRuleFields($ruleParams);
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Contribute/Import/Form/Preview.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<p>{ts}Click 'Import Now' if you are ready to proceed.{/ts}</p>
</div>
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
{include file="CRM/common/importProgress.tpl"}

{* Summary Preview (record counts) *}
<table id="preview-counts" class="report">
<tr><td class="label crm-grid-cell">{ts}Total Rows{/ts}</td>
Expand Down

0 comments on commit 9140019

Please sign in to comment.