From: eileen Date: Mon, 8 Mar 2021 11:20:43 +0000 (+1300) Subject: [REF] Minor simplification around assigning taxAmount to the template X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4d540f372d9f7033c265dab3e0c61587872e37ad;p=civicrm-core.git [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 --- diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index b2d0bbd377..307e445723 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1440,9 +1440,6 @@ DESC limit 1"); // 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 @@ DESC limit 1"); 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 @@ DESC limit 1"); } } } - if ($taxAmount) { - $this->assign('totalTaxAmount', $totalTaxAmount); - // 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('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('dataArray', $dataArray); } }