From d5d1dca1e7d1819f9c8824aa982ba47aaa13c857 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 9 Mar 2021 00:20:43 +1300 Subject: [PATCH] [REF] Minor simplification around assigning taxAmount to the template Just assign it based on the calculated tax amount for the contribution. If no tax then just assign that to the tpl. Bye copy & paste --- CRM/Member/Form/Membership.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index b2d0bbd377ab..6fcc546b29d7 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1440,9 +1440,6 @@ public function submit(): void { // This would always be true as we always add price set id into both // quick config & non quick config price sets. if (!empty($lineItem[$this->_priceSetId])) { - $invoicing = Civi::settings()->get('invoicing'); - $taxAmount = FALSE; - $totalTaxAmount = 0; foreach ($lineItem[$this->_priceSetId] as & $priceFieldOp) { if (!empty($priceFieldOp['membership_type_id'])) { $priceFieldOp['start_date'] = $membershipTypeValues[$priceFieldOp['membership_type_id']]['start_date'] ? CRM_Utils_Date::formatDateOnlyLong($membershipTypeValues[$priceFieldOp['membership_type_id']]['start_date']) : '-'; @@ -1451,12 +1448,8 @@ public function submit(): void { else { $priceFieldOp['start_date'] = $priceFieldOp['end_date'] = 'N/A'; } - if ($invoicing && isset($priceFieldOp['tax_amount'])) { - $taxAmount = TRUE; - $totalTaxAmount += $priceFieldOp['tax_amount']; - } } - if ($invoicing) { + if (Civi::settings()->get('invoicing')) { $dataArray = []; foreach ($lineItem[$this->_priceSetId] as $key => $value) { if (isset($value['tax_amount']) && isset($value['tax_rate'])) { @@ -1468,11 +1461,10 @@ public function submit(): void { } } } - if ($taxAmount) { - $this->assign('totalTaxAmount', $totalTaxAmount); + + $this->assign('totalTaxAmount', $this->order->getTotalTaxAmount()); // Not sure why would need this on Submit.... unless it's being used when sending mails in which case this is the wrong place - $this->assign('taxTerm', $this->getSalesTaxTerm()); - } + $this->assign('taxTerm', $this->getSalesTaxTerm()); $this->assign('dataArray', $dataArray); } }