Skip to content

Commit

Permalink
BTHAB-386: Populate the list of relevant premium products on the quot…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
olayiwola-compucorp committed Jan 7, 2025
1 parent e9c8a7f commit f1e798f
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
$scope.ts = CRM.ts('civicase');
const ctrl = angular.extend(this, $scope.model, searchTaskBaseTrait);
ctrl.stage = 'form';
ctrl.products = [];
$scope.submitInProgress = false;

this.applyDiscount = () => {
Expand All @@ -47,5 +48,24 @@
CRM.alert(`Discount applied to ${Object.values(updatedSalesOrder).length} Quotation(s) successfully`, ts('Success'), 'success');
});
};

$q(async function () {
CRM.$.blockUI();
const productIds = new Set();

for (const salesOrderId of ctrl.ids) {
const result = await CaseUtils.getSalesOrderAndLineItems(salesOrderId);
result.items.forEach((lineItem) => {
if (lineItem.product_id) {
productIds.add(lineItem.product_id);
}
});
}

ctrl.products = [...productIds];
CRM.$('.crm-product-ref').val([...productIds]);
CRM.$('.crm-product-ref').change();
CRM.$.unblockUI();
});
}
})(angular, CRM._);

0 comments on commit f1e798f

Please sign in to comment.