From 7f2c42bf15d296e1f0d2d8227f3daa09faa5ff79 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 16 Dec 2020 14:10:48 +1300 Subject: [PATCH] Remove duplicated tax assignments from copied code The assignment of tax data is happening twice on the form - once in generic code and once in code only reached for recurring contributions that was in previously-shared code. We can be fairly comfortable that in this latter case we don't need it as this is a marginal flow on this form whereas the main flow is being used 90% of the time & is doing the assignment --- CRM/Member/Form/Membership.php | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index caa74005d9..212b6d0659 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1492,6 +1492,8 @@ DESC limit 1"); $isRecur, $calcDates)); } + // 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; @@ -1938,29 +1940,6 @@ DESC limit 1"); $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams); - $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = $invoiceSettings['invoicing'] ?? NULL; - if ($invoicing) { - $dataArray = []; - // @todo - interrogate the line items passed in on the params array. - // No reason to assume line items will be set on the form. - foreach ($form->_lineItem as $lineItemKey => $lineItemValue) { - foreach ($lineItemValue as $key => $value) { - if (isset($value['tax_amount']) && isset($value['tax_rate'])) { - if (isset($dataArray[$value['tax_rate']])) { - $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + $value['tax_amount']; - } - else { - $dataArray[$value['tax_rate']] = $value['tax_amount']; - } - } - } - } - $smarty = CRM_Core_Smarty::singleton(); - $smarty->assign('dataArray', $dataArray); - $smarty->assign('totalTaxAmount', $params['tax_amount'] ?? NULL); - } - // lets store it in the form variable so postProcess hook can get to this and use it $form->_contributionID = $contribution->id; } -- 2.25.1