From 9611497cf4ab399afceccf98ca8bbecc1e6164a7 Mon Sep 17 00:00:00 2001 From: olayiwola-compucorp Date: Tue, 20 Aug 2024 11:26:02 +0100 Subject: [PATCH 1/3] BTHA-188: Avoid calculating opportunity detail for deleted contribution --- CRM/Civicase/Service/CaseSalesOrderOpportunityCalculator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CRM/Civicase/Service/CaseSalesOrderOpportunityCalculator.php b/CRM/Civicase/Service/CaseSalesOrderOpportunityCalculator.php index 47c157b16..18859fc4a 100644 --- a/CRM/Civicase/Service/CaseSalesOrderOpportunityCalculator.php +++ b/CRM/Civicase/Service/CaseSalesOrderOpportunityCalculator.php @@ -172,7 +172,10 @@ private function calculateOpportunityFinancialAmount($contributions) { private function getContributions($caseId) { $contributions = Contribution::get(FALSE) ->addSelect('*', 'Opportunity_Details.Quotation') - ->addWhere('Opportunity_Details.Case_Opportunity', '=', $caseId); + ->addWhere('Opportunity_Details.Case_Opportunity', '=', $caseId) + ->addJoin('CaseSalesOrder AS case_sales_order', 'INNER', + ['Opportunity_Details.Quotation', '=', 'case_sales_order.id'] + ); if ($this->deletingContributionId !== NULL) { $contributions->addWhere('id', '!=', $this->deletingContributionId); From 9b418c1d03754d811e29fba9cdf84b9b32ca5d7c Mon Sep 17 00:00:00 2001 From: olayiwola-compucorp Date: Tue, 20 Aug 2024 14:46:20 +0100 Subject: [PATCH 2/3] BTHA-190: Ensure contribution sales order field is always set --- js/contribution-entityref-field.js | 12 ++++++++++++ js/sales-order-contribution.js | 8 ++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/js/contribution-entityref-field.js b/js/contribution-entityref-field.js index 11731408e..7164866e8 100644 --- a/js/contribution-entityref-field.js +++ b/js/contribution-entityref-field.js @@ -24,6 +24,18 @@ if (field.value) { $(`[name^=${field.name}_]`).val(field.value).trigger('change'); } + + $(`[name^=${field.name}_]`).on('change', field, function (event) { + const f = event.data; + + $(`[name^=${f.name}_]`) + .attr('placeholder', f.placeholder) + .attr('disabled', false) + .crmEntityRef({ + entity: f.entity, + create: false + }); + }); }); }); }); diff --git a/js/sales-order-contribution.js b/js/sales-order-contribution.js index c423d2def..02c2245de 100644 --- a/js/sales-order-contribution.js +++ b/js/sales-order-contribution.js @@ -43,9 +43,13 @@ $(``).insertBefore('#source'); $(' #totalAmountORaddLineitem, #totalAmountORPriceSet, #price_set_id, #choose-manual').hide(); + if ($('#customData')) { + CRM.$(`[name^=${caseCustomField}_]`).val(caseSalesOrder.case_id).trigger('change'); + CRM.$(`[name^=${quotationCustomField}_]`).val(caseSalesOrder.id).trigger('change'); + } waitForElement($, '#customData', function ($, elem) { - $(`[name^=${caseCustomField}_]`).val(caseSalesOrder.case_id).trigger('change'); - $(`[name^=${quotationCustomField}_]`).val(caseSalesOrder.id).trigger('change'); + CRM.$(`[name^=${caseCustomField}_]`).val(caseSalesOrder.case_id).trigger('change'); + CRM.$(`[name^=${quotationCustomField}_]`).val(caseSalesOrder.id).trigger('change'); }); }).finally(() => { CRM.$.unblockUI(); From f8d7390af9a4537a4b8d551f3f0c1e770b8b9813 Mon Sep 17 00:00:00 2001 From: olayiwola-compucorp Date: Wed, 21 Aug 2024 12:31:13 +0100 Subject: [PATCH 3/3] BTHA-188: Ensure select box displays as expected --- .../Civicase/Form/CaseSalesOrderContributionCreate.tpl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/templates/CRM/Civicase/Form/CaseSalesOrderContributionCreate.tpl b/templates/CRM/Civicase/Form/CaseSalesOrderContributionCreate.tpl index d575b8bae..5bd651fa7 100644 --- a/templates/CRM/Civicase/Form/CaseSalesOrderContributionCreate.tpl +++ b/templates/CRM/Civicase/Form/CaseSalesOrderContributionCreate.tpl @@ -61,3 +61,12 @@ }); {/literal} + +{literal} + + +{/literal} \ No newline at end of file