/**
* @method array getContribution()
- * @method ?int getContributionID()
+ * @method int|null getContributionID()
* @method $this setContributionID(?int $contributionId)
*/
trait CRM_Contribute_WorkflowMessage_ContributionTrait {
if (!$this->order && $this->contributionID) {
$this->order = new CRM_Financial_BAO_Order();
$this->order->setTemplateContributionID($this->contributionID);
+ if (!empty($this->eventID)) {
+ // Temporary support for tests that are making a mess of this.
+ // It should always be possible to get this from the line items.
+ $this->order->setPriceSetIDByEventPageID($this->eventID);
+ }
}
return $this->order;
}
}
$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.