From 4f4d52d5007dea3552ef29535427192a0eac35cf Mon Sep 17 00:00:00 2001
From: eileen <emcnaughton@wikimedia.org>
Date: Fri, 11 Dec 2020 10:08:55 +1300
Subject: [PATCH] dev/financial#162 Simplify decision as to whether to use a
 pdf on membership emails

Currently the code that determines whether to attach a pdf for membership emails only attaches it as a pdf if the tax amount is non-zero
This seems both confusing and pointless  - the proposal here is to send as a pdf as long as

is_email_pdf is true and
invoicing is enabled

I feel like 1 and 2 could be separated but they are currently linked so I would suggest any proposals to change that are a follow up
---
 CRM/Member/Form/Membership.php | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php
index b5846d21777..6d40a7ac1e0 100644
--- a/CRM/Member/Form/Membership.php
+++ b/CRM/Member/Form/Membership.php
@@ -986,20 +986,8 @@ DESC limit 1");
         $form->_receiptContactId = $formValues['contact_id'];
       }
     }
-    // @todo determine isEmailPdf in calling function.
-    $template = CRM_Core_Smarty::singleton();
-    $taxAmt = $template->get_template_vars('dataArray');
-    $eventTaxAmt = $template->get_template_vars('totalTaxAmount');
-    $prefixValue = Civi::settings()->get('contribution_invoice_settings');
-    $invoicing = $prefixValue['invoicing'] ?? NULL;
-    if ((!empty($taxAmt) || isset($eventTaxAmt)) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
-      $isEmailPdf = TRUE;
-    }
-    else {
-      $isEmailPdf = FALSE;
-    }
 
-    list($mailSend, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(
+    CRM_Core_BAO_MessageTemplate::sendTemplate(
       [
         'groupName' => 'msg_tpl_workflow_membership',
         'valueName' => 'membership_offline_receipt',
@@ -1008,7 +996,7 @@ DESC limit 1");
         'toName' => $form->_contributorDisplayName,
         'toEmail' => $form->_contributorEmail,
         'PDFFilename' => ts('receipt') . '.pdf',
-        'isEmailPdf' => $isEmailPdf,
+        'isEmailPdf' => Civi::settings()->get('invoicing') && Civi::settings()->get('is_email_pdf'),
         'contributionId' => $formValues['contribution_id'],
         'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW),
       ]
-- 
GitLab