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 ac3425a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 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 {
\Civi\Api4\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
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 ac3425a

Please sign in to comment.