Skip to content

Commit

Permalink
dev/core#212 - Contribution Details report fails when 'Is not one of'…
Browse files Browse the repository at this point in the history
… condition is used for Groups field
  • Loading branch information
Jitendra Purohit committed Jul 4, 2018
1 parent 6673795 commit 7702880
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CRM/Report/Form/Contribute/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,9 @@ public function softCreditFrom() {
{$this->_aclFrom}
";

if (!empty($this->_params['gid_op']) && $this->_params['gid_op'] == 'notin') {
$this->joinGroupTempTable('civicrm_contact', 'id', $this->_aliases['civicrm_contact']);
}
$this->appendAdditionalFromJoins();
}

Expand Down
5 changes: 5 additions & 0 deletions CRM/Report/Form/Contribute/Repeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ public function from() {
.{$this->contributionJoinTableColumn}
LEFT JOIN $this->tempTableRepeat2 {$this->_aliases['civicrm_contribution']}2
ON {$this->groupByTableAlias}.$fromCol = {$this->_aliases['civicrm_contribution']}2.{$this->contributionJoinTableColumn}";

if (!empty($this->_params['gid_op']) && $this->_params['gid_op'] == 'notin') {
$this->joinGroupTempTable('civicrm_contact', 'id', $this->_aliases['civicrm_contact']);
}
}

/**
Expand Down Expand Up @@ -825,6 +829,7 @@ public function statistics(&$rows) {
public function postProcess() {
$this->beginPostProcess();

$this->buildGroupTempTable();
$this->select();
$this->from();
$this->where();
Expand Down
21 changes: 20 additions & 1 deletion tests/phpunit/api/v3/ReportTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public function testLybuntReportWithFYData() {
SELECT SQL_CALC_FOUND_ROWS contact_civireport.id as cid FROM civicrm_contact contact_civireport INNER JOIN civicrm_contribution contribution_civireport USE index (received_date) ON contribution_civireport.contact_id = contact_civireport.id
AND contribution_civireport.is_test = 0
AND contribution_civireport.receive_date BETWEEN \'20140701000000\' AND \'20150630235959\'
LEFT JOIN civicrm_contribution cont_exclude ON cont_exclude.contact_id = contact_civireport.id
AND cont_exclude.receive_date BETWEEN \'2015-7-1\' AND \'20160630235959\' WHERE cont_exclude.id IS NULL AND 1 AND ( contribution_civireport.contribution_status_id IN (1) )
GROUP BY contact_civireport.id', $rows['metadata']['sql'][0]);
Expand Down Expand Up @@ -756,4 +756,23 @@ public function testDeferredRevenueReport() {
}
}

/**
* Test the group filter works on the various reports.
*
* @dataProvider getMembershipAndContributionReportTemplatesForGroupTests
*
* @param string $template
* Report template unique identifier.
*/
public function testReportsWithNoTInSmartGroupFilter($template) {
$groupID = $this->setUpPopulatedGroup();
$rows = $this->callAPISuccess('report_template', 'getrows', array(
'report_id' => $template,
'gid_value' => array($groupID),
'gid_op' => 'notin',
'options' => array('metadata' => array('sql')),
));
$this->assertNumberOfContactsInResult(2, $rows, $template);
}

}

0 comments on commit 7702880

Please sign in to comment.