Skip to content

Commit

Permalink
Merge pull request #17218 from seamuslee001/5.25
Browse files Browse the repository at this point in the history
[REF] Fix retrieving invoice related settings when doing complete tra…
  • Loading branch information
eileenmcnaughton authored May 2, 2020
2 parents d9d9e06 + e3eb020 commit 1e4d286
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions CRM/Contribute/BAO/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,9 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes
//send email with pdf invoice
$template = CRM_Core_Smarty::singleton();
$taxAmt = $template->get_template_vars('dataArray');
$prefixValue = Civi::settings()->get('contribution_invoice_settings');
$invoicing = $prefixValue['invoicing'] ?? NULL;
if (isset($invoicing) && isset($prefixValue['is_email_pdf'])) {
$isEmailPDF = Civi::settings()->get('invoice_is_email_pdf');
$invoicing = Civi::settings()->get('invoicing');
if ($invoicing && !empty($isEmailPDF)) {
$sendTemplateParams['isEmailPdf'] = TRUE;
$sendTemplateParams['contributionId'] = $values['contribution_id'];
}
Expand Down
11 changes: 6 additions & 5 deletions CRM/Contribute/Form/Task/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,6 @@ public static function printPDF($contribIDs, &$params, $contactIds) {
$cancelledStatusId = CRM_Utils_Array::key('Cancelled', $contributionStatusID);
$pendingStatusId = CRM_Utils_Array::key('Pending', $contributionStatusID);

// getting data from admin page
$prefixValue = Civi::settings()->get('contribution_invoice_settings');

foreach ($invoiceElements['details'] as $contribID => $detail) {
$input = $ids = $objects = [];
if (in_array($detail['contact'], $invoiceElements['excludeContactIds'])) {
Expand Down Expand Up @@ -268,7 +265,9 @@ public static function printPDF($contribIDs, &$params, $contactIds) {
//to obtain due date for PDF invoice
$contributionReceiveDate = date('F j,Y', strtotime(date($input['receive_date'])));
$invoiceDate = date("F j, Y");
$dueDate = date('F j, Y', strtotime($contributionReceiveDate . "+" . $prefixValue['due_date'] . "" . $prefixValue['due_date_period']));
$dueDateSetting = Civi::settings()->get('invoice_due_date');
$dueDatePeriodSetting = Civi::settings()->get('invoice_due_date_period');
$dueDate = date('F j, Y', strtotime($contributionReceiveDate . "+" . $dueDateSetting . "" . $dueDatePeriodSetting));

$amountPaid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($contribID, TRUE);
$amountDue = ($input['amount'] - $amountPaid);
Expand Down Expand Up @@ -349,6 +348,8 @@ public static function printPDF($contribIDs, &$params, $contactIds) {
$countryDomain = '';
}

$invoiceNotes = Civi::settings()->get('invoice_notes') ?? NULL;

// parameters to be assign for template
$tplParams = [
'title' => $title,
Expand All @@ -364,7 +365,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) {
'amountPaid' => $amountPaid,
'invoice_date' => $invoiceDate,
'dueDate' => $dueDate,
'notes' => $prefixValue['notes'] ?? NULL,
'notes' => $invoiceNotes,
'display_name' => $contribution->_relatedObjects['contact']->display_name,
'lineItem' => $lineItem,
'dataArray' => $dataArray,
Expand Down

0 comments on commit 1e4d286

Please sign in to comment.