Skip to content

Commit

Permalink
Merge pull request #12205 from eileenmcnaughton/soft_error
Browse files Browse the repository at this point in the history
dev/core#139 Fail more gracefully on contribution detail report with invalid combination
  • Loading branch information
eileenmcnaughton authored May 29, 2018
2 parents 823270c + a9cf37f commit ef67a1d
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions CRM/Report/Form/Contribute/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,26 +478,12 @@ public function statistics(&$rows) {
* Soft credit functionality is not currently unit tested for this report.
*/
public function postProcess() {
// @todo in order to make this report testable we need to remove this function override in favour of the
// functions called by the reportTemplate.getrows api - this requires a bit of tidy up!
// get the acl clauses built before we assemble the query
$this->buildACLClause($this->_aliases['civicrm_contact']);

$this->beginPostProcess();
// CRM-18312 - display soft_credits and soft_credits_for column
// when 'Contribution or Soft Credit?' column is not selected
if (empty($this->_params['fields']['contribution_or_soft'])) {
$this->_params['fields']['contribution_or_soft'] = 1;
$this->noDisplayContributionOrSoftColumn = TRUE;
}

if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) ==
'contributions_only' &&
!empty($this->_params['fields']['soft_credit_type_id'])
) {
unset($this->_params['fields']['soft_credit_type_id']);
if (!empty($this->_params['soft_credit_type_id_value'])) {
$this->_params['soft_credit_type_id_value'] = array();
}
}

// 1. use main contribution query to build temp table 1
$sql = $this->buildQuery();
Expand Down Expand Up @@ -577,6 +563,33 @@ public function postProcess() {
$this->endPostProcess($rows);
}

/**
* Shared function for preliminary processing.
*
* This is called by the api / unit tests and the form layer and is
* the right place to do 'initial analysis of input'.
*/
public function beginPostProcessCommon() {
// CRM-18312 - display soft_credits and soft_credits_for column
// when 'Contribution or Soft Credit?' column is not selected
if (empty($this->_params['fields']['contribution_or_soft'])) {
$this->_params['fields']['contribution_or_soft'] = 1;
$this->noDisplayContributionOrSoftColumn = TRUE;
}

if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) ==
'contributions_only' &&
(!empty($this->_params['fields']['soft_credit_type_id'])
|| !empty($this->_params['soft_credit_type_id_value']))
) {
unset($this->_params['fields']['soft_credit_type_id']);
if (!empty($this->_params['soft_credit_type_id_value'])) {
$this->_params['soft_credit_type_id_value'] = array();
CRM_Core_Session::setStatus(ts('Is it not possible to filter on soft contribution type when not including soft credits.'));
}
}
}

/**
* Alter display of rows.
*
Expand Down

0 comments on commit ef67a1d

Please sign in to comment.