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

Only format smarty aliases as money if specified #22547

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Jan 17, 2022

Overview

Only format smarty aliases as money if specified

Before

When defining a token that should be assigned as a smarty variable in a smarty template it is always assigned money formatted, if it is money

After

When defining a token that should be assigned as a smarty variable in a smarty template formatting should be specified

Technical Details

Smarty aliases allow tokens to be assigned to the template as smarty variables. They are very new,
have only been implemented in these 2 places and are not accessible from outside of core, which
both have unit test cover.

When trying to extend it to cover another variable (totalTaxAmount) in another template I found
that a raw format is appropriate. I think it makes sense to explicitly specify.

Comments

@civibot civibot bot added the master label Jan 17, 2022
@civibot
Copy link

civibot bot commented Jan 17, 2022

(Standard links)

@eileenmcnaughton
Copy link
Contributor Author

test this please

eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Jan 18, 2022
This gets us away from the empty checks & the isset that causes a crash with smarty modifiers.
There is no change at the moment as to what is assigned so we don't need to make any changes to existing sites.

The goal is to specify the mappings on the workflow template class later. That will allow
us to remove significant amounts of code (& leakage points) from the form layer.
However we still need to resolve civicrm#22547
because at the moment values in this template expect raw values - which is
not the case with mapped params at the moment.

Note the biggest thing to contemplate in this PR is the addition of an
-always-there-in-contribution-smarty-templates smarty value isShowTax.
The way it is currently checking is that there should pretty much
be 'something' assigned if invoicing is enabled & it makes sense
that tax would show even if zero if enabled - which is what I *think*
is already happening (with maybe some random variation).

I added 'taxTerm' as a domain token and I do kinda prefer that but
it is available more places (unless we change the audience).
invoice_notes is another contribution setting that effects display.
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Jan 18, 2022
This gets us away from the empty checks & the isset that causes a crash with smarty modifiers.
There is no change at the moment as to what is assigned so we don't need to make any changes to existing sites.

The goal is to specify the mappings on the workflow template class later. That will allow
us to remove significant amounts of code (& leakage points) from the form layer.
However we still need to resolve civicrm#22547
because at the moment values in this template expect raw values - which is
not the case with mapped params at the moment.

Note the biggest thing to contemplate in this PR is the addition of an
-always-there-in-contribution-smarty-templates smarty value isShowTax.
The way it is currently checking is that there should pretty much
be 'something' assigned if invoicing is enabled & it makes sense
that tax would show even if zero if enabled - which is what I *think*
is already happening (with maybe some random variation).

I added 'taxTerm' as a domain token and I do kinda prefer that but
it is available more places (unless we change the audience).
invoice_notes is another contribution setting that effects display.
@seamuslee001
Copy link
Contributor

This seems fine to me

smarty aliases allow tokens to be assigned to the template as smarty variables. They are very new,
have only been implemented in these 2 places and are not accessible from outside of core, which
both have unit test cover.

When trying to extend it to cover another variable (totalTaxAmount) in another template I found
that a raw format is appropriate. I think it makes sense to explicitly specify.

Code comment

Co-authored-by: Tim Otten <totten@civicrm.org>
@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 I'm confused - it says you closed this 'in #22560' - but I can't see any action you did on there that closed it - I've re-opened & re-based

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Jan 24, 2022

It's because the description there uses a magic word followed by the pr number, so github figures it means to autoclose it. Or maybe there is some plugin enabled that recognizes that phrase.

@eileenmcnaughton
Copy link
Contributor Author

@demeritcowboy ah that makes sense

@demeritcowboy
Copy link
Contributor

This seems to run ok.

Maybe out of scope since it was like this before the PR but while the email itself has money formatting, the amount that appears on the email activity copy on the contact is raw. I'm not sure if it's always been like that.

@demeritcowboy demeritcowboy merged commit ac90ec6 into civicrm:master Jan 25, 2022
@eileenmcnaughton eileenmcnaughton deleted the smart branch January 25, 2022 03:23
@eileenmcnaughton
Copy link
Contributor Author

Thanks @demeritcowboy - I'm a bit surprised by that but hopefully I'll track it down....

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