From 0fba5cf89d707bc8f305bc9f12a3832c110a11c7 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 12 Aug 2021 08:19:22 +1200 Subject: [PATCH] Simplify calls to is_email_pdf Per reviewer feedback - we don't need to check more than just the one setting. The UI (for better or worse) ties the 2 together so under normal operation they will be set together but we don't need to check that --- CRM/Batch/Form/Entry.php | 2 +- CRM/Contribute/BAO/ContributionPage.php | 2 +- CRM/Contribute/Form/AdditionalInfo.php | 2 +- CRM/Event/BAO/Event.php | 2 +- CRM/Event/Form/Participant.php | 2 +- CRM/Member/Form/Membership.php | 2 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 7 +++---- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index 79971447be..e39156fdd1 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -942,7 +942,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { 'toName' => $form->_contributorDisplayName, 'toEmail' => $form->_contributorEmail, 'PDFFilename' => ts('receipt') . '.pdf', - 'isEmailPdf' => Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf'), + 'isEmailPdf' => Civi::settings()->get('invoice_is_email_pdf'), 'contributionId' => $this->getCurrentRowContributionID(), 'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW), ] diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index f5656cdefe..447f38395f 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -440,7 +440,7 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio $sendTemplateParams['cc'] = $values['cc_receipt'] ?? NULL; $sendTemplateParams['bcc'] = $values['bcc_receipt'] ?? NULL; //send email with pdf invoice - if (Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf')) { + if (Civi::settings()->get('invoice_is_email_pdf')) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $values['contribution_id']; } diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index 4da64147da..fdbaaade14 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -432,7 +432,7 @@ class CRM_Contribute_Form_AdditionalInfo { 'toEmail' => $contributorEmail, 'isTest' => $form->_mode == 'test', 'PDFFilename' => ts('receipt') . '.pdf', - 'isEmailPdf' => Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf'), + 'isEmailPdf' => Civi::settings()->get('invoice_is_email_pdf'), ] ); diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 8db65e8a02..6baa7a793d 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -1242,7 +1242,7 @@ WHERE civicrm_event.is_active = 1 $values['event'] ); - if (Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf') && !empty($values['contributionId'])) { + if (Civi::settings()->get('invoice_is_email_pdf') && !empty($values['contributionId'])) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $values['contributionId']; } diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 65982e3cdb..204304aaf0 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1546,7 +1546,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment ); $prefixValue = Civi::settings()->get('contribution_invoice_settings'); $invoicing = $prefixValue['invoicing'] ?? NULL; - if (!empty($taxAmt) && (isset($invoicing) && Civi::settings()->get('invoice_is_email_pdf'))) { + if (Civi::settings()->get('invoice_is_email_pdf')) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $contributionId; } diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index e19cb2bb6a..a8dcb2de71 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -993,7 +993,7 @@ DESC limit 1"); 'toName' => $form->_contributorDisplayName, 'toEmail' => $form->_contributorEmail, 'PDFFilename' => ts('receipt') . '.pdf', - 'isEmailPdf' => Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf'), + 'isEmailPdf' => Civi::settings()->get('invoice_is_email_pdf'), 'contributionId' => $formValues['contribution_id'], 'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW), ] diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index d3dfb75fa5..a54aee4061 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -3095,10 +3095,8 @@ VALUES /** * Enable Tax and Invoicing - * - * @throws \CRM_Core_Exception */ - protected function disableTaxAndInvoicing(): \Civi\Core\SettingsBag { + protected function disableTaxAndInvoicing(): void { $accounts = $this->callAPISuccess('EntityFinancialAccount', 'get', ['account_relationship' => 'Sales Tax Account is'])['values']; foreach ($accounts as $account) { $this->callAPISuccess('EntityFinancialAccount', 'delete', ['id' => $account['id']]); @@ -3108,7 +3106,8 @@ VALUES if (!empty(\Civi::$statics['CRM_Core_PseudoConstant']) && isset(\Civi::$statics['CRM_Core_PseudoConstant']['taxRates'])) { unset(\Civi::$statics['CRM_Core_PseudoConstant']['taxRates']); } - return Civi::settings()->set('invoicing', FALSE); + Civi::settings()->set('invoice_is_email_pdf', FALSE); + Civi::settings()->set('invoicing', FALSE); } /** -- 2.25.1