Replace math in template with variable, smarty3 support
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 14 Nov 2023 22:59:59 +0000 (11:59 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 14 Nov 2023 22:59:59 +0000 (11:59 +1300)
The handling for math in smarty2 & 3 differs wrt precedence, when used
with a modifier. It's a bit tricky supporting both but in this
case we can simply rely on another key in the array that already exists
and is equivalent

Note that the membership online template is excluded deliberately for now
as it does not currently access the same lineItems variable
as all the other templates

xml/templates/message_templates/contribution_offline_receipt_html.tpl
xml/templates/message_templates/contribution_offline_receipt_text.tpl
xml/templates/message_templates/contribution_online_receipt_html.tpl
xml/templates/message_templates/contribution_online_receipt_text.tpl
xml/templates/message_templates/event_online_receipt_text.tpl
xml/templates/message_templates/membership_offline_receipt_html.tpl
xml/templates/message_templates/membership_offline_receipt_text.tpl

index c7bcc10fb44364d729ee3b541193c39d5cff3800..4675e488c8feef4ab9dd50c0d1dc1a8a356c02f4 100644 (file)
@@ -82,7 +82,7 @@
             </td>
             {if $isShowTax && {contribution.tax_amount|boolean}}
               <td>
-                {$line.unit_price*$line.qty|crmMoney:'{contribution.currency}'}
+                {$line.line_total|crmMoney:'{contribution.currency}'}
               </td>
               {if $line.tax_rate || $line.tax_amount != ""}
                 <td>
index 0c067179eacf4baf771e9dfb21ed78972860811c..2049f45086c04d015042ad5ac8056b6d2cfe9831 100644 (file)
@@ -27,7 +27,7 @@
 {$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {if $isShowTax && {contribution.tax_amount|boolean}} {$ts_subtotal|string_format:"%10s"} {$ts_taxRate} {$ts_taxAmount|string_format:"%10s"} {/if} {$ts_total|string_format:"%10s"}
 ----------------------------------------------------------
 {foreach from=$lineItems item=line}
-{capture assign=ts_item}{$line.title}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:'{contribution.currency}'|string_format:"%10s"} {if $isShowTax && {contribution.tax_amount|boolean}}{$line.unit_price*$line.qty|crmMoney:'{contribution.currency}'|string_format:"%10s"} {if $line.tax_rate || $line.tax_amount != ""} {$line.tax_rate|string_format:"%.2f"} %   {$line.tax_amount|crmMoney:'{contribution.currency}'|string_format:"%10s"} {else}                  {/if} {/if}   {$line.line_total_inclusive|crmMoney:'{contribution.currency}'|string_format:"%10s"}
+{capture assign=ts_item}{$line.title}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:'{contribution.currency}'|string_format:"%10s"} {if $isShowTax && {contribution.tax_amount|boolean}}{$line.line_total|crmMoney:'{contribution.currency}'|string_format:"%10s"} {if $line.tax_rate || $line.tax_amount != ""} {$line.tax_rate|string_format:"%.2f"} %   {$line.tax_amount|crmMoney:'{contribution.currency}'|string_format:"%10s"} {else}                  {/if} {/if}   {$line.line_total_inclusive|crmMoney:'{contribution.currency}'|string_format:"%10s"}
 {/foreach}
 {/if}
 
index 118a29f760247f0775ede230cc16f13e6a9f6986..d148b5218a278c67bd58ac93b6cf4db5bca1cee6 100644 (file)
@@ -61,7 +61,7 @@
                 <td>{$line.qty}</td>
                 <td>{$line.unit_price|crmMoney:$currency}</td>
                 {if $isShowTax && {contribution.tax_amount|boolean}}
-                  <td>{$line.unit_price*$line.qty|crmMoney:$currency}</td>
+                  <td>{$line.line_total|crmMoney:$currency}</td>
                   {if $line.tax_rate || $line.tax_amount != ""}
                     <td>{$line.tax_rate|string_format:"%.2f"}%</td>
                     <td>{$line.tax_amount|crmMoney:$currency}</td>
index 7aa62279256b18aa8a6a5378518516fef0c31a49..498921a4813b2ab8d8468140f865dacdc11b4146 100644 (file)
@@ -29,7 +29,7 @@
 {$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {if $isShowTax && {contribution.tax_amount|boolean}} {$ts_subtotal|string_format:"%10s"} {$ts_taxRate} {$ts_taxAmount|string_format:"%10s"} {/if} {$ts_total|string_format:"%10s"}
 ----------------------------------------------------------
 {foreach from=$lineItems item=line}
-{capture assign=ts_item}{$line.title}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {if $isShowTax && {contribution.tax_amount|boolean}}{$line.unit_price*$line.qty|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate || $line.tax_amount != ""}  {$line.tax_rate|string_format:"%.2f"} %  {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else}                  {/if}  {/if} {$line.line_total_inclusive|crmMoney:$currency|string_format:"%10s"}
+{capture assign=ts_item}{$line.title}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {if $isShowTax && {contribution.tax_amount|boolean}}{$line.line_total|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate || $line.tax_amount != ""}  {$line.tax_rate|string_format:"%.2f"} %  {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else}                  {/if}  {/if} {$line.line_total_inclusive|crmMoney:$currency|string_format:"%10s"}
 {/foreach}
 
 {if $isShowTax && {contribution.tax_amount|boolean}}
index dc06ad1a78fdbfa54e06b58358e5df438d2a7d1c..1b49df076c9fd6da42fdb467705cb6d6803da822 100644 (file)
@@ -113,7 +113,7 @@ You were registered by: {$payer.name}
 
 {foreach from=$value item=line}
 {if !empty($pricesetFieldsCount)}{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {if $isShowTax && {contribution.tax_amount|boolean}} {$line.unit_price*$line.qty|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate || $line.tax_amount != ""}  {$line.tax_rate|string_format:"%.2f"} %  {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else}                  {/if}  {/if} {$line.line_total+$line.tax_amount|crmMoney:$currency|string_format:"%10s"}{if !empty($ts_participant_count)}{$ts_participant_count|string_format:"%10s"}{/if}
+{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {if $isShowTax && {contribution.tax_amount|boolean}} {$line.line_total|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate || $line.tax_amount != ""}  {$line.tax_rate|string_format:"%.2f"} %  {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else}                  {/if}  {/if} {$line.line_total+$line.tax_amount|crmMoney:$currency|string_format:"%10s"}{if !empty($ts_participant_count)}{$ts_participant_count|string_format:"%10s"}{/if}
 {/foreach}
 ----------------------------------------------------------------------------------------------------------------
 {if !empty($individual)}{ts}Participant Total{/ts} {$individual.$priceset.totalAmtWithTax-$individual.$priceset.totalTaxAmt|crmMoney:$currency|string_format:"%29s"} {$individual.$priceset.totalTaxAmt|crmMoney:$currency|string_format:"%33s"} {$individual.$priceset.totalAmtWithTax|crmMoney:$currency|string_format:"%12s"}{/if}
index a22a3449475eeb0d6c23841e34b5c96015676c6e..49987091cef69b102dca1666116f89d6bfee1d3b 100644 (file)
                             </td>
                             {if $isShowTax && {contribution.tax_amount|boolean}}
                               <td>
-                                {$line.unit_price*$line.qty|crmMoney:'{contribution.currency}'}
+                                {$line.line_total|crmMoney:'{contribution.currency}'}
                               </td>
                               {if $line.tax_rate || $line.tax_amount != ""}
                                 <td>
index 29c852f1b44a77fd0fd1cd7dde8efa1d33d01c98..13134f8b1c51e2b427401802e7378e6a5568f435 100644 (file)
@@ -40,7 +40,7 @@
 --------------------------------------------------------------------------------------------------
 
 {foreach from=$lineItems item=line}
-{line.title} {$line.line_total|crmMoney|string_format:"%10s"}  {if $isShowTax && {contribution.tax_amount|boolean}} {$line.unit_price*$line.qty|crmMoney:'{contribution.currency}'|string_format:"%10s"} {if $line.tax_rate || $line.tax_amount != ""}  {$line.tax_rate|string_format:"%.2f"} %  {$line.tax_amount|crmMoney:'{contribution.currency}'|string_format:"%10s"}  {else}                  {/if}   {$line.line_total_inclusive|crmMoney|string_format:"%10s"} {/if} {$line.membership.start_date|string_format:"%20s"} {$line.membership.end_date|string_format:"%20s"}
+{line.title} {$line.line_total|crmMoney|string_format:"%10s"}  {if $isShowTax && {contribution.tax_amount|boolean}} {$line.line_total|crmMoney:'{contribution.currency}'|string_format:"%10s"} {if $line.tax_rate || $line.tax_amount != ""}  {$line.tax_rate|string_format:"%.2f"} %  {$line.tax_amount|crmMoney:'{contribution.currency}'|string_format:"%10s"}  {else}                  {/if}   {$line.line_total_inclusive|crmMoney|string_format:"%10s"} {/if} {$line.membership.start_date|string_format:"%20s"} {$line.membership.end_date|string_format:"%20s"}
 {/foreach}
 
 {if $isShowTax && {contribution.tax_amount|boolean}}