Skip to content

Commit

Permalink
Update online_event_template to use workflow message
Browse files Browse the repository at this point in the history
This updates the default online event template to use the variables assigned by
the workflow template

This works to standardise the variables previously in dataArray
, lineItem, totalAmount, taxAmount to reflect the
approach in other templates per
https://docs.civicrm.org/user/en/latest/email/message-templates/#variables-and-tokens-in-workflow-message-templates

However, for participants, per the helpful discussion at
#24576

the expectation is that the primaryParticipant gets the values for
all participants whereas the others only get line items,
tax breakdowns, totals that relate to them.

Hence I have assigned an array participants that holds detials for all participants
and the template iterates through them showing all or just the
one that relates to the assigned participant id depending on
whether it is primary.

This allows the template to display in the Message preview and should
also mean that those values that I have addressed will always reflect
the participantID being used. This also addresses some notices
and incompatibility with secure smarty.

However, there are still values I haven't made sense of, or otherwise left
out of the scope of this PR in the template.

Also note I updated the taxBreakdown in the contribution trait - I decided it
was cloberring the amount as it iterated through the line items - rather than
doing a running total.
  • Loading branch information
eileenmcnaughton committed Jun 23, 2023
1 parent b25746b commit 2cad7a6
Show file tree
Hide file tree
Showing 4 changed files with 4,556 additions and 4,599 deletions.
19 changes: 14 additions & 5 deletions CRM/Contribute/WorkflowMessage/ContributionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,20 @@ public function getTaxRateBreakdown(): array {
}
$this->taxRateBreakdown = [];
foreach ($this->getLineItems() as $lineItem) {
$this->taxRateBreakdown[$lineItem['tax_rate']] = [
'amount' => $lineItem['tax_amount'] ?? 0,
'rate' => $lineItem['tax_rate'],
'percentage' => sprintf('%.2f', $lineItem['tax_rate']),
];
if (!isset($this->taxRateBreakdown[$lineItem['tax_rate']])) {
$this->taxRateBreakdown[$lineItem['tax_rate']] = [
'amount' => 0,
'rate' => $lineItem['tax_rate'],
'percentage' => sprintf('%.2f', $lineItem['tax_rate']),
];
}
$this->taxRateBreakdown[$lineItem['tax_rate']]['amount'] += $lineItem['tax_amount'] ?? 0;
}
// Remove the rates with no value.
foreach ($this->taxRateBreakdown as $rate => $details) {
if ($details['amount'] === 0.0) {
unset($this->taxRateBreakdown[$rate]);
}
}
if (array_keys($this->taxRateBreakdown) === [0]) {
// If the only tax rate charged is 0% then no tax breakdown is returned.
Expand Down
Loading

0 comments on commit 2cad7a6

Please sign in to comment.