Simplify calls to is_email_pdf
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 11 Aug 2021 20:19:22 +0000 (08:19 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 11 Aug 2021 23:48:51 +0000 (11:48 +1200)
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
CRM/Contribute/BAO/ContributionPage.php
CRM/Contribute/Form/AdditionalInfo.php
CRM/Event/BAO/Event.php
CRM/Event/Form/Participant.php
CRM/Member/Form/Membership.php
tests/phpunit/CiviTest/CiviUnitTestCase.php

index 79971447be4db7d9753bd4f62fe4c1cb1a685457..e39156fdd12a192fa8159cd5911440983ba7430d 100644 (file)
@@ -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),
       ]
index f5656cdefe1172a6693e3bab1c1751273791a676..447f38395f213247cdb5a56c757344cd13115743 100644 (file)
@@ -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'];
         }
index 4da64147daef860a9944c57f970b54ec07c0232a..fdbaaade148f3b6c8a83f8fb3e238bde86f48af6 100644 (file)
@@ -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'),
       ]
     );
 
index 8db65e8a02859d8ed1d975fbb40ad7277acbdc27..6baa7a793d492fbcb2e4e6cda97cc49394eb6494 100644 (file)
@@ -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'];
           }
index 65982e3cdb2373d1f8cb84b40d44fc1cdb206266..204304aaf00eeb0fc66aabca335d6d34a9d3ed8f 100644 (file)
@@ -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;
         }
index e19cb2bb6a1688312a2f0d17257a6de60fd9b55a..a8dcb2de71c347c5a5aae172a0d0a483b040ab71 100644 (file)
@@ -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),
       ]
index d3dfb75fa5982852fb598a8c95201f3d4b7732f4..a54aee406184754777087d5b04962467f4ac097d 100644 (file)
@@ -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);
   }
 
   /**