From d9a775658fb02dde03031397f883c6fff7b3aeed Mon Sep 17 00:00:00 2001 From: olayiwola-compucorp Date: Mon, 16 Oct 2023 05:40:48 +0100 Subject: [PATCH 1/2] BTHAB-257: Fetch discount information for case client --- .../quotations/directives/quotations-create.directive.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ang/civicase-features/quotations/directives/quotations-create.directive.js b/ang/civicase-features/quotations/directives/quotations-create.directive.js index 10008049a..ec8e1a466 100644 --- a/ang/civicase-features/quotations/directives/quotations-create.directive.js +++ b/ang/civicase-features/quotations/directives/quotations-create.directive.js @@ -123,6 +123,9 @@ }).then(function (caseContacts) { if (Array.isArray(caseContacts) && caseContacts.length > 0) { $scope.salesOrder.client_id = caseContacts[0].contact_id ?? null; + if ($scope.salesOrder.client_id) { + handleClientChange(); + } } }); } @@ -230,7 +233,7 @@ const clientID = $scope.salesOrder.client_id; crmApi4('Membership', 'get', { select: ['membership_type_id.Product_Discounts.Product_Discount_Amount'], - where: [['contact_id', '=', clientID]] + where: [['contact_id', '=', clientID], ['status_id.is_current_member', '=', true]] }).then(function (results) { let discountPercentage = 0; results.forEach((membership) => { From abb3f0614cfd2a7d9d67da16eb3ee3c23b269cec Mon Sep 17 00:00:00 2001 From: olayiwola-compucorp Date: Tue, 17 Oct 2023 05:02:09 +0100 Subject: [PATCH 2/2] BTHAB-257: Ensure quotation is attached to mail by default --- .../Hook/BuildForm/AttachQuotationToInvoiceMail.php | 1 + CRM/Civicase/Hook/alterMailParams/AttachQuotation.php | 7 ++++--- templates/CRM/Civicase/Form/Contribute/AttachQuotation.tpl | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CRM/Civicase/Hook/BuildForm/AttachQuotationToInvoiceMail.php b/CRM/Civicase/Hook/BuildForm/AttachQuotationToInvoiceMail.php index ea9dd080a..74a660cb0 100644 --- a/CRM/Civicase/Hook/BuildForm/AttachQuotationToInvoiceMail.php +++ b/CRM/Civicase/Hook/BuildForm/AttachQuotationToInvoiceMail.php @@ -22,6 +22,7 @@ public function run(CRM_Core_Form &$form, $formName) { } $form->add('checkbox', 'attach_quote', ts('Attach Quotation')); + $form->setDefaults(array_merge($form->_defaultValues, ['attach_quote' => TRUE])); CRM_Core_Region::instance('page-body')->add([ 'template' => "CRM/Civicase/Form/Contribute/AttachQuotation.tpl", diff --git a/CRM/Civicase/Hook/alterMailParams/AttachQuotation.php b/CRM/Civicase/Hook/alterMailParams/AttachQuotation.php index e368a33ef..d6a99919c 100644 --- a/CRM/Civicase/Hook/alterMailParams/AttachQuotation.php +++ b/CRM/Civicase/Hook/alterMailParams/AttachQuotation.php @@ -23,12 +23,13 @@ public function run(array &$params, $context) { return; } - $rendered = $this->getContributionQuotationInvoice($params['tokenContext']['contributionId']); + $contributionId = $params['tokenContext']['contributionId'] ?? $params['tplParams']['id']; + $rendered = $this->getContributionQuotationInvoice($contributionId); $attachment = CRM_Utils_Mail::appendPDF('quotation_invoice.pdf', $rendered['html'], $rendered['format']); if ($attachment) { - $params['attachments'][] = $attachment; + $params['attachments']['quotaition_invoice'] = $attachment; } } @@ -73,7 +74,7 @@ private function getContributionQuotationInvoice($contributionId) { */ private function shouldRun(array $params, $context, $shouldAttachQuote) { $component = $params['tplParams']['component'] ?? ''; - if ($component !== 'contribute' || $context !== 'messageTemplate' || empty($shouldAttachQuote)) { + if ($component !== 'contribute' || empty($shouldAttachQuote)) { return FALSE; } diff --git a/templates/CRM/Civicase/Form/Contribute/AttachQuotation.tpl b/templates/CRM/Civicase/Form/Contribute/AttachQuotation.tpl index b84493606..68e374fef 100644 --- a/templates/CRM/Civicase/Form/Contribute/AttachQuotation.tpl +++ b/templates/CRM/Civicase/Form/Contribute/AttachQuotation.tpl @@ -9,6 +9,7 @@ {literal}