Skip to content

Commit

Permalink
COMCL-866: Ensure contribution is appropraitely linked to quotation
Browse files Browse the repository at this point in the history
  • Loading branch information
olayiwola-compucorp committed Oct 8, 2024
1 parent 577c1ba commit 779ab1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CRM/Civicase/Hook/Post/CreateSalesOrderContribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ public function run($op, $objectName, $objectId, &$objectRef) {

$salesOrderStatusId = CRM_Utils_Request::retrieve('sales_order_status_id', 'Integer');
if (empty($salesOrderStatusId)) {
$salesOrder = $salesOrder['status_id'];
$salesOrderStatusId = $salesOrder['status_id'];
}

$transaction = CRM_Core_Transaction::create();
try {
Contribution::update(FALSE)
->addWhere('id', '=', $objectId)
->addValue('Opportunity_Details.Case_Opportunity', $salesOrder['case_id'] ?? NULL)
->addValue('Opportunity_Details.Quotation', $salesOrderId)
->execute();

$caseSaleOrderContributionService = new CRM_Civicase_Service_CaseSalesOrderContributionCalculator($salesOrderId);
$paymentStatusID = $caseSaleOrderContributionService->calculatePaymentStatus();
$invoicingStatusID = $caseSaleOrderContributionService->calculateInvoicingStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
if ($('.civicase__features-filters-clear').length) {
// Handle clear filter button.
$('.civicase__features-filters-clear').off('click').click(event => {
CRM.$("input[id*='id']").select2('data', null)
CRM.$("input[id*='id']").select2('data', null);
CRM.$('.civicase__features input, .civicase__features textarea').val('').change();
});
}
Expand Down
4 changes: 2 additions & 2 deletions js/sales-order-contribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
$(`<input type="hidden" value="${salesOrderStatusId}" name="sales_order_status_id" />`).insertBefore('#source');
$(' #totalAmountORaddLineitem, #totalAmountORPriceSet, #price_set_id, #choose-manual').hide();

if ($('#customData')) {
if ($('#customData_Contribution')) {
CRM.$(`[name^=${caseCustomField}_]`).val(caseSalesOrder.case_id).trigger('change');
CRM.$(`[name^=${quotationCustomField}_]`).val(caseSalesOrder.id).trigger('change');
}
waitForElement($, '#customData', function ($, elem) {
waitForElement($, '#customData_Contribution', function ($, elem) {
CRM.$(`[name^=${caseCustomField}_]`).val(caseSalesOrder.case_id).trigger('change');
CRM.$(`[name^=${quotationCustomField}_]`).val(caseSalesOrder.id).trigger('change');
});
Expand Down

0 comments on commit 779ab1c

Please sign in to comment.