Skip to content

Commit

Permalink
BTHAMM-15: Add delay between lineitem population
Browse files Browse the repository at this point in the history
  • Loading branch information
olayiwola-compucorp committed May 27, 2024
1 parent fbbac39 commit e10157d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions js/sales-order-contribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,26 @@
if (Array.isArray(lineItems)) {
CRM.$.blockUI();
CRM.$('form#Contribution').css('visibility', 'hidden');
await new Promise(resolve => setTimeout(resolve, 2000));
await new Promise(resolve => setTimeout(resolve, 1000));
CRM.api4(apiRequest).then(function (batch) {
const caseSalesOrder = batch.caseSalesOrders[0];

lineItems.forEach(lineItem => {
addLineItem(lineItem.qty, lineItem.unit_price, lineItem.label, lineItem.financial_type_id, lineItem.tax_amount);
setTimeout(
() => addLineItem(lineItem.qty, lineItem.unit_price, lineItem.label, lineItem.financial_type_id, lineItem.tax_amount),
2000
);
});

$('#total_amount').val(0);
$('input[id="total_amount"]').trigger('change');
$('#contribution_status_id').val(batch.optionValues[0].value);
$('#source').val(`Quotation ${caseSalesOrder.id}`).trigger('change');
$('#contact_id').select2('val', caseSalesOrder.client_id).trigger('change');
$('input[id="total_amount"]', 'form.CRM_Contribute_Form_Contribution').trigger('change');
$(`<input type="hidden" value="${salesOrderId}" name="sales_order" />`).insertBefore('#source');
$(`<input type="hidden" value="${toBeInvoiced}" name="to_be_invoiced" />`).insertBefore('#source');
$(`<input type="hidden" value="${percentValue}" name="percent_value" />`).insertBefore('#source');
$(`<input type="hidden" value="${salesOrderStatusId}" name="sales_order_status_id" />`).insertBefore('#source');
$('#totalAmount, #totalAmountORaddLineitem, #totalAmountORPriceSet, #price_set_id, #choose-manual').hide();
$(' #totalAmountORaddLineitem, #totalAmountORPriceSet, #price_set_id, #choose-manual').hide();

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

0 comments on commit e10157d

Please sign in to comment.