From 2be8538f9e7678f79e99e76e29ddc74690d52156 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 30 Dec 2022 11:58:13 +1300 Subject: [PATCH] Remove conditional assignment around If we ensure it is always assigned we can remove the empty checks. Note that I could not find any other tpl that used this so I removed the set & the assign on the thank you page too to simplify --- CRM/Contribute/Form/Contribution/Confirm.php | 11 ++++------- CRM/Contribute/Form/Contribution/ThankYou.php | 2 -- .../contribution_online_receipt_html.tpl | 2 +- .../contribution_online_receipt_html.tpl | 2 +- .../contribution_online_receipt_text.tpl | 2 +- .../membership_online_receipt_html.tpl | 2 +- .../membership_online_receipt_text.tpl | 2 +- 7 files changed, 9 insertions(+), 14 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 891ebcbc5b..2318029a6e 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -2675,20 +2675,17 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $isRecur ): array { $form = $this; - CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE); - $isPaymentTransaction = self::isPaymentTransaction($form); + CRM_Core_Payment_Form::mapParams($this->_bltID, $form->_params, $paymentParams, TRUE); + $isPaymentTransaction = self::isPaymentTransaction($this); $financialType = new CRM_Financial_DAO_FinancialType(); $financialType->id = $financialTypeID; $financialType->find(TRUE); - if ($financialType->is_deductible) { - $form->assign('is_deductible', TRUE); - $form->set('is_deductible', TRUE); - } + $this->assign('is_deductible', $financialType->is_deductible); // add some financial type details to the params list // if folks need to use it - $paymentParams['financial_type_id'] = $paymentParams['financialTypeID'] = $financialType->id; + $paymentParams['financial_type_id'] = $paymentParams['financialTypeID'] = $financialTypeID; //CRM-15297 - contributionType is obsolete - pass financial type as well so people can deprecate it $paymentParams['financialType_name'] = $paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $financialType->name; //CRM-11456 diff --git a/CRM/Contribute/Form/Contribution/ThankYou.php b/CRM/Contribute/Form/Contribution/ThankYou.php index 8887d38f7f..c5a510f621 100644 --- a/CRM/Contribute/Form/Contribution/ThankYou.php +++ b/CRM/Contribute/Form/Contribution/ThankYou.php @@ -41,8 +41,6 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont $this->_params = $this->get('params'); $this->_lineItem = $this->get('lineItem'); $this->_useForMember = $this->get('useForMember'); - $is_deductible = $this->get('is_deductible'); - $this->assign('is_deductible', $is_deductible); $this->assign('thankyou_title', CRM_Utils_Array::value('thankyou_title', $this->_values)); $this->assign('thankyou_text', CRM_Utils_Array::value('thankyou_text', $this->_values)); $this->assign('thankyou_footer', CRM_Utils_Array::value('thankyou_footer', $this->_values)); diff --git a/tests/templates/message_templates/contribution_online_receipt_html.tpl b/tests/templates/message_templates/contribution_online_receipt_html.tpl index 4ced13c285..019fd67e01 100644 --- a/tests/templates/message_templates/contribution_online_receipt_html.tpl +++ b/tests/templates/message_templates/contribution_online_receipt_html.tpl @@ -97,7 +97,7 @@ start_date:::{$start_date} end_date:::{$end_date} {/if} - {if !empty($is_deductible)} + {if $is_deductible} is_deductible:::{$is_deductible} {/if} {if !empty($contact_email)} diff --git a/xml/templates/message_templates/contribution_online_receipt_html.tpl b/xml/templates/message_templates/contribution_online_receipt_html.tpl index 13623e7c15..a3d4ec3f88 100644 --- a/xml/templates/message_templates/contribution_online_receipt_html.tpl +++ b/xml/templates/message_templates/contribution_online_receipt_html.tpl @@ -391,7 +391,7 @@ {/if} - {if !empty($is_deductible) AND !empty($price)} + {if $is_deductible AND !empty($price)}

{ts 1=$price|crmMoney:$currency}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}

diff --git a/xml/templates/message_templates/contribution_online_receipt_text.tpl b/xml/templates/message_templates/contribution_online_receipt_text.tpl index 3927b5fed8..c59a8976e8 100644 --- a/xml/templates/message_templates/contribution_online_receipt_text.tpl +++ b/xml/templates/message_templates/contribution_online_receipt_text.tpl @@ -176,7 +176,7 @@ {$contact_phone} {/if} {/if} -{if !empty($is_deductible) AND !empty($price)} +{if $is_deductible AND !empty($price)} {ts 1=$price|crmMoney:$currency}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}{/if} {/if} diff --git a/xml/templates/message_templates/membership_online_receipt_html.tpl b/xml/templates/message_templates/membership_online_receipt_html.tpl index 3bb4b2f417..efc2fa10a7 100644 --- a/xml/templates/message_templates/membership_online_receipt_html.tpl +++ b/xml/templates/message_templates/membership_online_receipt_html.tpl @@ -496,7 +496,7 @@ {/if} - {if !empty($is_deductible) AND !empty($price)} + {if $is_deductible AND !empty($price)}

{ts 1=$price|crmMoney}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}

diff --git a/xml/templates/message_templates/membership_online_receipt_text.tpl b/xml/templates/message_templates/membership_online_receipt_text.tpl index 02be9e48f3..ce1b0e7566 100644 --- a/xml/templates/message_templates/membership_online_receipt_text.tpl +++ b/xml/templates/message_templates/membership_online_receipt_text.tpl @@ -210,7 +210,7 @@ {$contact_phone} {/if} {/if} -{if !empty($is_deductible) AND !empty($price)} +{if $is_deductible AND !empty($price)} {ts 1=$price|crmMoney}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}{/if} {/if} -- 2.25.1