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

WIP: dev/core#326: WIP: Fix for fatal error and for missing dollar totals … #12737

Conversation

twomice
Copy link
Contributor

@twomice twomice commented Aug 28, 2018

…in section headers.

Overview

On Contribution detail report when section header is enabled (under Sort tab), you get a fatal error:
Error code : Database Error Code: Unknown column 'civicrm_contribution_total_amount' in 'field list', 1054

Before

Fatal error. Reference this animation from the ticket:
peek_2018-08-14_16-19

After

Fatal error is gone. Section totals include dollar amounts. Screenshot:
after

Technical Details

I've got questions about specific parts of this PR, which I'll outline in the comments.

Comments

Thanks to @eileenmcnaughton for getting me started with this.

@civibot
Copy link

civibot bot commented Aug 28, 2018

(Standard links)

* If we are generating a table of soft credits we do not want to be using
* group by.
*/
protected function storeGroupByArray() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton Obviously this method was created for a reason (in e6bab5ea#diff-585f40aa84b2e15ef6b0768dd64bfd0cR612), and I'm not sure what that was. So it probably can't just be removed like this. But it is having the side effect of causing the civicrm_contribution_total_amount_sum _selectAlias to be renamed to civicrm_contribution_total_amount, which causes the fatal error and (even with the "hack alert" patch at https://lab.civicrm.org/dev/core/issues/326#note_8150) causes dollar totals to be omitted in section headers.

I've tried a few things, related to Soft Credit options, to break the report after making this change, but all seems well in spite of it. Why was this logic added here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To stop weird grouping on that softcredit I guess. TBH this report is badly designed from the start. In extended reports there is a copy of it & I recently decided to strip out all the soft credit handling due to it's awfulness. The only way I can see to end the whackamole is to add tests on each fix religiously.

My understanding is that without this part we go from totally broken to partially broken so I probably still would merge in chunks - since the main part of this locks in the query not failing & then we need to figure out how to test the headers.

The current action that is tested does support some metadata retrieval

  /**
   * Test getrows on contact summary report.
   */
  public function testReportTemplateGetRowsContactSummary() {
    $description = "Retrieve rows from a report template (optionally providing the instance_id).";
    $result = $this->callAPIAndDocument('report_template', 'getrows', array(
      'report_id' => 'contact/summary',
      'options' => array('metadata' => array('labels', 'title')),
    ), __FUNCTION__, __FILE__, $description, 'Getrows');
    $this->assertEquals('Contact Name', $result['metadata']['labels']['civicrm_contact_sort_name']);

although in extended reports I recently added a getmetadata action thinking that might be a better way

https://github.com/eileenmcnaughton/nz.co.fuzion.extendedreport/commit/443812912ea9e1fca3d3f739b75312f6a96d8839#diff-bfc47780dcc610e8169649bb84456669R257

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an aside -I am fairly sure a test will fail if this change breaks something. Also I think since the sectionTotals() function is already a massive hack more hacking in there is ok

@twomice twomice changed the title dev/core#326: WIP: Fix for fatal error and for missing dollar totals … WIP: dev/core#326: WIP: Fix for fatal error and for missing dollar totals … Aug 28, 2018
@twomice twomice force-pushed the lab326_contrib_detail_report_header_fatal branch from 90616cf to 00806fc Compare August 28, 2018 22:11
@twomice
Copy link
Contributor Author

twomice commented Aug 29, 2018

Jenkins test this please.

1 similar comment
@twomice
Copy link
Contributor Author

twomice commented Aug 30, 2018

Jenkins test this please.

@mlutfy
Copy link
Member

mlutfy commented Aug 30, 2018

jenkins, test this please

@eileenmcnaughton
Copy link
Contributor

I think the test fail kind of answers the error question about why that code exists...

@twomice
Copy link
Contributor Author

twomice commented Sep 3, 2018

@eileenmcnaughton Agreed, I'll address that. BTW, have you found a way to get alerts on test failures like this, or are you just manually checking the results by viewing the PR on github.com?

@twomice twomice force-pushed the lab326_contrib_detail_report_header_fatal branch from 00806fc to 1ff16f8 Compare September 3, 2018 19:17
@eileenmcnaughton
Copy link
Contributor

@twomice the latter

@totten totten added the master label Sep 5, 2018
@twomice
Copy link
Contributor Author

twomice commented Sep 6, 2018

Closed in favor of #12766

@twomice twomice closed this Sep 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants