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

dev/core#756 - CRM/Contribute - Fix multi-currency soft credit summary #13711

Merged

Conversation

pfigel
Copy link
Contributor

@pfigel pfigel commented Feb 26, 2019

Overview

This attempts to fix the multi-currency soft credit bug reported in dev/core#756 and some inconsistencies.

Before

Viewing the contribution tab of a contact with soft credits in multiple currencies causes an exception.

After

Soft credits with multiple currencies don't cause an exception and the soft credit summary is rendered more similar to the contribution summary.

Technical Details

This changes the return value signature of CRM_Contribute_BAO_ContributionSoft::getSoftContributionTotals(). Looks like it's only used by one method which I adapted, but I'm not sure what the approach to backwards-compatibility is for something like that. Could also go with new method + deprecation.

@civibot
Copy link

civibot bot commented Feb 26, 2019

(Standard links)

@civibot civibot bot added the master label Feb 26, 2019
@pfigel pfigel force-pushed the fix-multi-currency-soft-credit branch from 1f7d6f0 to fbcdfde Compare February 26, 2019 20:06
@mattwire
Copy link
Contributor

@pfigel My only concern here is using CRM_Utils_Money::format() directly in the BAO as it has a habit of causing issues and formatting is only needed when it's actually displayed to the user. Ideally I think we'd see something like {$amount|crmMoney:$currency} on the smarty template - @eileenmcnaughton thoughts?

@pfigel
Copy link
Contributor Author

pfigel commented Feb 27, 2019

@mattwire definitely agree with the sentiment. I went with this approach because:

  1. getSoftContributionTotals already has some code that's more of a template thing, i.e. implode(', ', ...
  2. It matches what we do in CRM_Contribute_BAO_Contribution for contribution summaries
  3. It allows us to DRY up the template a bit (the soft contribution totals table existed in two templates, with some inconsistencies)

(tl;dr: it sucks, but in a consistent way 😄)

Maybe we can use this fix to deal with the regression, and then later on do a bit of refactoring for the whole contribution summary thing where we move the presentation stuff out of BAO.

@pfigel pfigel changed the base branch from master to 5.11 February 27, 2019 20:31
@civibot civibot bot added 5.11 and removed master labels Feb 27, 2019
This fixes an exception caused by multiple currencies being passed to
CRM_Utils_Money::format. It also resolves some inconsistencies in how
the summary table is rendered for soft credits.
@pfigel pfigel force-pushed the fix-multi-currency-soft-credit branch from fbcdfde to d9c8c3c Compare February 27, 2019 20:39
@pfigel pfigel changed the title (WIP) dev/core#756 - CRM/Contribute - Fix multi-currency soft credit summary dev/core#756 - CRM/Contribute - Fix multi-currency soft credit summary Feb 27, 2019
@eileenmcnaughton
Copy link
Contributor

I tested this & was able to replicate the bug & see this fixes it - merging

@eileenmcnaughton eileenmcnaughton merged commit c2db3ab into civicrm:5.11 Feb 28, 2019
@pfigel pfigel deleted the fix-multi-currency-soft-credit branch February 28, 2019 10:11
@mattwire
Copy link
Contributor

Maybe we can use this fix to deal with the regression, and then later on do a bit of refactoring for the whole contribution summary thing where we move the presentation stuff out of BAO.

@pfigel Agreed :-)

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.

3 participants