Subversion Repositories SmartDukaan

Rev

Rev 33437 | Rev 34168 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33437 Rev 33795
Line 33... Line 33...
33
            calculateTotalAmount();
33
            calculateTotalAmount();
34
        }
34
        }
35
        $row.find('.mk_check_plans').trigger('click', ['manual']); // Trigger the button within the same row
35
        $row.find('.mk_check_plans').trigger('click', ['manual']); // Trigger the button within the same row
36
    });
36
    });
37
 
37
 
-
 
38
    $(document).on('click', ".upgrade-offer", function () {
-
 
39
        var itemId = $(this).data('itemid');
-
 
40
        doGetAjaxRequestHandler(`${context}/getItemWiseUpgradeOffer?itemId=` + itemId, function (response) {
-
 
41
            $('#upgradeOfferModal .modal-content').html(response);
-
 
42
        });
-
 
43
    });
-
 
44
 
38
 
45
 
39
 
46
 
40
    $(document).on('change', "form#cd input.insuranceamount", function () {
47
    $(document).on('change', "form#cd input.insuranceamount", function () {
41
        calculateTotalAmount();
48
        calculateTotalAmount();
42
    });
49
    });
Line 200... Line 207...
200
    } else {
207
    } else {
201
        $(".mk_insurance_row").hide();
208
        $(".mk_insurance_row").hide();
202
    }
209
    }
203
    $('#cd').find('input.netPayableAmount').val(netPayableAmount);
210
    $('#cd').find('input.netPayableAmount').val(netPayableAmount);
204
}
211
}
-
 
212
 
-
 
213
$(document).on('change', '.offerSelect', function () {
-
 
214
    calculateAndUpdatePaymentOptions();
-
 
215
});
-
 
216
 
-
 
217
function calculateAndUpdatePaymentOptions() {
-
 
218
    let totalSchemePayout = 0;
-
 
219
    let totalPartnerPayout = 0;
-
 
220
 
-
 
221
    // Loop through all selected options in each row
-
 
222
    $('.offerSelect').each(function () {
-
 
223
        let selectedOption = $(this).find('option:selected');
-
 
224
 
-
 
225
        let schemePayout = parseFloat(selectedOption.data('scheme-payout')) || 0;
-
 
226
        let partnerPayout = parseFloat(selectedOption.data('partner-payout')) || 0;
-
 
227
 
-
 
228
        // Accumulate the payouts
-
 
229
        totalSchemePayout += schemePayout;
-
 
230
        totalPartnerPayout += partnerPayout;
-
 
231
    });
-
 
232
 
-
 
233
    // Now update the payment options with the accumulated values
-
 
234
    updatePaymentOptions(totalSchemePayout, totalPartnerPayout);
-
 
235
}
-
 
236
 
-
 
237
function updatePaymentOptions(schemePayout, partnerPayout) {
-
 
238
    $("#payment-option-id-amount-container").find('.paymentOptionAmount').each(function () {
-
 
239
        let paymentOptionName = $(this).closest('.row').find('h5').text().trim();
-
 
240
 
-
 
241
        if (paymentOptionName.includes('SAMSUNG UPGRADE')) {
-
 
242
            $(this).val(schemePayout);  // Set the total scheme payout
-
 
243
        }
-
 
244
 
-
 
245
        if (paymentOptionName.includes('CASH DISCOUNT')) {
-
 
246
            $(this).val(partnerPayout);  // Set the total partner payout
-
 
247
        }
-
 
248
    });
-
 
249
}
-
 
250
 
-
 
251
 
-
 
252
 
-
 
253
 
-
 
254
 
-
 
255
 
-
 
256