getId=(idName)=>{
    return document.getElementById(idName);
}
let paymentMethod = getId("paymentMethod");
let cashPay = getId("cashEntry");
let bankPay = getId("bankEntry");
let chequeNo = getId("chequeNo");
handlePaymentMethod=()=>{
    let pay = paymentMethod.value;
if(pay == "cash")
{
bankPay.readOnly=true;
cashPay.readOnly =false;
chequeNo.readOnly=true;
bankPay.value = 0;
chequeNo.value = "-";
}
if(pay == "bank")
{
bankPay.readOnly=false;
cashPay.readOnly =true;
chequeNo.readOnly=false;
cashPay.value=0;
}
if(pay == "all")
{
bankPay.readOnly=false;
cashPay.readOnly =false;
chequeNo.readOnly=false;
}
}
paymentMethod.addEventListener("change",function(e){
    handlePaymentMethod();
});

$(document).ready(function(){
    handlePaymentMethod();
    let customer = $("#customerAdd").val();
    $.ajax({
        type:'POST',
        url:'ajaxpath1/fetch_amount_details.php',
        data:{customer:customer},
        success:function(data){
        var output = data.split("||");
        $("#totalAmount").val(output[0]);
        $("#pendingAmount").val(Number(output[1])+Number(cashPay.value)+Number(bankPay.value));
                    }
       });  
    $("#customerAdd").on("change",function(){
        $.ajax({
            type:'POST',
            url:'ajaxpath1/fetch_amount_details.php',
            data:{customer:customer},
            success:function(data){
            var output = data.split("||");
            $("#totalAmount").val(output[0]);
            $("#pendingAmount").val(output[1]);
                        }
           });  
    });
});