From e77a5a36500ca472957405f30c3c15c2683f5199 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Tue, 8 Aug 2017 09:08:04 +0100 Subject: [PATCH] Revert "Remove trailing zeros in tax rate for online Confirm/Thankyou forms. The actual change is a cast to float, but a small amount of rearranging the function was required so it was actually set. Added note that buildQuickform() in Confirm.php and Thankyou.php share quite a bit of code and would benefit from refactoring" This reverts commit 4b58e3b405345eb95f9e45121c486a76aa9f6b33. --- CRM/Contribute/Form/Contribution/Confirm.php | 21 +++++------- CRM/Contribute/Form/Contribution/ThankYou.php | 34 ++++++++----------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 11262ce515..9646ddcae8 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -524,11 +524,10 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $getTaxDetails = FALSE; $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); foreach ($this->_lineItem as $key => $value) { - foreach ($value as $k => $v) { + foreach ($value as $v) { if (isset($v['tax_rate'])) { if ($v['tax_rate'] != '') { $getTaxDetails = TRUE; - $this->_lineItem[$key][$k]['tax_rate'] = (float) $v['tax_rate']; // Cast to float to display without trailing zero decimals } } } @@ -537,16 +536,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $this->assign('taxTerm', $taxTerm); $this->assign('totalTaxAmount', $params['tax_amount']); } - - if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) { - $this->assign('lineItem', $this->_lineItem); - } - else { - $this->assign('is_quick_config', 1); - $this->_params['is_quick_config'] = 1; - } - $this->assign('priceSetID', $this->_priceSetId); - if (!empty($params['selectProduct']) && $params['selectProduct'] != 'no_thanks') { $option = CRM_Utils_Array::value('options_' . $params['selectProduct'], $params); $productID = $params['selectProduct']; @@ -601,6 +590,14 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $this->_separateMembershipPayment = $this->get('separateMembershipPayment'); $this->assign('is_separate_payment', $this->_separateMembershipPayment); + if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) { + $this->assign('lineItem', $this->_lineItem); + } + else { + $this->assign('is_quick_config', 1); + $this->_params['is_quick_config'] = 1; + } + $this->assign('priceSetID', $this->_priceSetId); // The concept of contributeMode is deprecated. // the is_monetary concept probably should be too as it can be calculated from diff --git a/CRM/Contribute/Form/Contribution/ThankYou.php b/CRM/Contribute/Form/Contribution/ThankYou.php index 7d9b66a501..09b44253bb 100644 --- a/CRM/Contribute/Form/Contribution/ThankYou.php +++ b/CRM/Contribute/Form/Contribution/ThankYou.php @@ -90,8 +90,6 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont public function buildQuickForm() { // FIXME: Some of this code is identical to Confirm.php and should be broken out into a shared function $this->assignToTemplate(); - $params = $this->_params; - $this->_ccid = $this->get('ccid'); $productID = $this->get('productID'); $option = $this->get('option'); @@ -101,18 +99,30 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont if ($productID) { CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, FALSE, $productID, $option); } + if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) { + $this->assign('lineItem', $this->_lineItem); + } + else { + if (is_array($membershipTypeID)) { + $membershipTypeID = current($membershipTypeID); + } + $this->assign('is_quick_config', 1); + $this->_params['is_quick_config'] = 1; + } + $this->assign('priceSetID', $this->_priceSetId); + $this->assign('useForMember', $this->get('useForMember')); + $params = $this->_params; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); if ($invoicing) { $getTaxDetails = FALSE; $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); - foreach ($this->_lineItem as $key => $value) { - foreach ($value as $k => $v) { + foreach ($this->_lineItem as $value) { + foreach ($value as $v) { if (isset($v['tax_rate'])) { if ($v['tax_rate'] != '') { $getTaxDetails = TRUE; - $this->_lineItem[$key][$k]['tax_rate'] = (float) $v['tax_rate']; // Cast to float to display without trailing zero decimals } } } @@ -121,20 +131,6 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont $this->assign('taxTerm', $taxTerm); $this->assign('totalTaxAmount', $params['tax_amount']); } - - if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) { - $this->assign('lineItem', $this->_lineItem); - } - else { - if (is_array($membershipTypeID)) { - $membershipTypeID = current($membershipTypeID); - } - $this->assign('is_quick_config', 1); - $this->_params['is_quick_config'] = 1; - } - $this->assign('priceSetID', $this->_priceSetId); - $this->assign('useForMember', $this->get('useForMember')); - if (!empty($this->_values['honoree_profile_id']) && !empty($params['soft_credit_type_id'])) { $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE); -- 2.25.1