Skip to content

Commit

Permalink
Simplify calls to is_email_pdf
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eileenmcnaughton committed Aug 11, 2021
1 parent 0be69b5 commit 0fba5cf
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CRM/Batch/Form/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ protected function emailReceipt($form, &$formValues, $membership): bool {
'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),
]
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/BAO/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes
$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'];
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/AdditionalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public static function emailReceipt(&$form, &$params, $ccContribution = FALSE) {
'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'),
]
);

Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/BAO/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F
$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'];
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ public function submit($params) {
);
$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;
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ protected function emailReceipt($form, &$formValues) {
'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),
]
Expand Down
7 changes: 3 additions & 4 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3095,10 +3095,8 @@ protected function enableTaxAndInvoicing(array $params = []): void {

/**
* 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']]);
Expand All @@ -3108,7 +3106,8 @@ protected function disableTaxAndInvoicing(): \Civi\Core\SettingsBag {
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);
}

/**
Expand Down

0 comments on commit 0fba5cf

Please sign in to comment.