<script>
    function setRemainingAfterScheduleChange(val) {
        remaining_net_amount = parseInt($('#remianing_payable').val());
        net_amount = parseInt($('#net_amount').val());
        var add_amount = 0;
        $("input[name='add_amount[]']").each(function() {
            if (!this.value) {
                add_amount += 0;
            } else {
                add_amount += parseInt($(this).val());
            }
        });
        down_payment = parseInt($('#remaining_down-payment').val());
        possession = parseInt($('#remaining_possession').val());
        allotment = parseFloat($('#remaining_allotment').val());
        confirmation = parseFloat($('#remaining_confirmation').val());
        booking = parseFloat($('#remaining_booking').val());

        file_processing = parseFloat($('#remaining_file_processing').val());
        registration = parseFloat($('#remaining_registration').val());
        balloting = parseFloat($('#remaining_balloting').val());
        ballon = parseFloat($('#remaining_ballon').val());
        monthly_installment = parseInt($('#remaining_total_installment').val());
        annual_installment = 0;
        if (val != 'auto') {
            annual_installment = $('#' + val).val();
        }

        //   console.log('remaining_net_amount::',remaining_net_amount , 'down_payment::',down_payment , 'possession::',possession , 'monthly_installment::',monthly_installment ,
        //      'annual_installment::',annual_installment , 'add_amount::',add_amount , 'allotment::',allotment , 'confirmation::',confirmation , 'booking::',booking  ,
        //      'file_processing:',file_processing , 'registration::',registration , 'balloting::',balloting , 'ballon::',ballon);


        remaining_amount = remaining_net_amount - down_payment - possession - monthly_installment -
            ballon -
            add_amount - annual_installment - allotment - confirmation - booking - balloting - file_processing -
            registration;


        $('#remaining_amount').val(Math.round(remaining_amount));
    }

    function setDefaultValueForSchedule() {
        net_amount = parseInt($('#net_amount').val());
       
        if ({{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_mon_w_quar }} ||
            {{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_mon_exclude_quar }}) {
            // enableQuar();
            // console.log('this1');
            document.getElementById('custom').style.display = 'none';
            document.getElementById('auto').style.display = 'block';

            $('#remaining_amount').val(0);
            document.getElementById('quar_div').style.display = 'block';
            document.getElementById('bi_mon_div').style.display = 'none';
            document.getElementById('semi_div').style.display = 'none';
            document.getElementById('ann_div').style.display = 'none';
            if ({{ $remaining_installment_count }} != 0) {

                $('#quarterly-installment').val(Math.round({{ $per_insta }}));
                $('#total_quarterly_installment_count').val(Math.round(parseInt({{ $remaining_installment_count }})));

                $('#total_quarterly_installment').val(Math.round({{ $per_insta }} *
                    {{ $remaining_installment_count }}));
            } else {
                $('#quarterly-installment').val(0);
                $('#quarterly-installment').prop('disabled', true);
                $('#total_quarterly_installment_count').val(Math.round(parseInt({{ $remaining_installment_count }})));

                $('#total_quarterly_installment').val(Math.round({{ $per_insta }} *
                    {{ $remaining_installment_count }}));
            }
          
            $('#total_annual_installment_count').val( Math.round({{$schedule_plan->total_months}} / 12));
               $('#total_semi_installment_count').val( Math.round({{$schedule_plan->total_months}} / 6));
               
               $('#total_bi_mon_installment_count').val( Math.round({{$schedule_plan->total_months}} / 3));

        } else if ({{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_mon }} ||
            {{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_bi_mon }} ||
            {{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_quar }} ||
            {{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_semi }} ||
            {{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_ann }}) {
            // disableAnn({{ $property->schedular_type }});
            // console.log('this2');
            document.getElementById('custom').style.display = 'none';
            document.getElementById('auto').style.display = 'block';
            $('#remaining_amount').val(0);
            document.getElementById('semi_div').style.display = 'none';
            document.getElementById('ann_div').style.display = 'none';
            document.getElementById('quar_div').style.display = 'none';
            document.getElementById('bi_mon_div').style.display = 'none';
        } else if ({{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_mon_w_semi }} ||
            {{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_quar_w_semi }} ||
            {{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_mon_exclude_semi }} ||
            {{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_quar_exclude_semi }}) {
            // enableSemi();
            console.log('this3');
            document.getElementById('custom').style.display = 'none';
            document.getElementById('auto').style.display = 'block';
            $('#remaining_amount').val(0);
            document.getElementById('semi_div').style.display = 'block';
            document.getElementById('ann_div').style.display = 'none';
            document.getElementById('quar_div').style.display = 'none';
            document.getElementById('bi_mon_div').style.display = 'none';
            if ({{ $remaining_installment_count }} != 0) {

                // 
                
                var total = {{ $per_insta }} *
                    {{ $remaining_installment_count }};
                   
                $('#semi-installment').val(Math.round({{ $per_insta }}));


                $('#per_semi_installment').val(((parseInt({{ $per_insta }}) / net_amount) *
                    100).toFixed(
                    2));
               $('#per_total_semi_installment').val(((parseInt(total) / net_amount) *
                    100).toFixed(
                    2));

                 

                $('#total_semi_installment_count').val(Math.round(parseInt({{ $remaining_installment_count }})));

                $('#total_semi_installment').val(Math.round(total));
            } else {
                 
                $('#semi-installment').val(Math.round(0));
                $("#semi-installment").prop('disabled', true);
                $('#total_semi_installment_count').val(Math.round(parseInt({{ $remaining_installment_count }})));
                $('#total_semi_installment').val(Math.round({{ $per_insta }} *
                    {{ $remaining_installment_count }}));
            }
            $('#total_annual_installment_count').val( Math.round({{$schedule_plan->total_months}} / 12));
              
               $('#total_quarterly_installment_count').val( Math.round({{$schedule_plan->total_months}} / 3));
               $('#total_bi_mon_installment_count').val( Math.round({{$schedule_plan->total_months}} / 3));

        } else if ({{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_mon_w_ann }} ||
            {{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_mon_exclude_ann }}) {
            // enableAnn();
            document.getElementById('custom').style.display = 'none';
            document.getElementById('auto').style.display = 'block';
            // console.log('this4');
            $('#remaining_amount').val(0);
            document.getElementById('ann_div').style.display = 'block';
            document.getElementById('semi_div').style.display = 'none';
            document.getElementById('quar_div').style.display = 'none';
            document.getElementById('bi_mon_div').style.display = 'none';
            if ({{ $remaining_installment_count }} != 0) {
                if({{ $per_insta }} > 0){
                $('#annual-installment').val(Math.round({{ $per_insta }}));
                $('#total_annual_installment_count').val(Math.round(parseInt({{ $remaining_installment_count }})));
                $('#total_annual_installment').val(Math.round({{ $per_insta }} *
                    {{ $remaining_installment_count }}));
                    $('#per_total_annual_installment').val((($("#total_annual_installment").val() / net_amount) * 100).toFixed(2));
                    $('#per_annual-installment').val((($("#annual-installment").val() / net_amount) * 100).toFixed(2));

                } 
                $('#total_annual_installment_count').val(Math.round(parseInt({{ $remaining_installment_count }})));

            } else {
                $('#annual-installment').val(0);
                $('#annual-installment').prop('disabled', true);
                $('#total_annual_installment_count').val(Math.round(parseInt({{ $remaining_installment_count }})));
                $('#total_annual_installment').val(Math.round({{ $per_insta }} *
                    {{ $remaining_installment_count }}));
            }
           
               $('#total_semi_installment_count').val( Math.round({{$schedule_plan->total_months}}/ 6));
               $('#total_quarterly_installment_count').val( Math.round({{$schedule_plan->total_months}} / 3));
               $('#total_bi_mon_installment_count').val( Math.round({{$schedule_plan->total_months}} / 3));
 
        } else if ({{ $property->schedular_type }} === {{ \App\CustomerProperty::inst_custom }}) {
            // enableCustom();
          @php
       $custom_inst=   $customer_statement->where('payment_head', \App\CustomerStatement::installment);
     
       $i = 0;
       @endphp

       @foreach($custom_inst as  $inst)
      @php
       $i = $i +1;
       @endphp
       @if($inst->due != $inst->received)
     
     @if($i == 1)

//   
 
   $('input[name="custom_date[]"]').val("{{ date('Y-m-d', strtotime($inst->due_date))}}");
    $('input[name="custom_amount[]"]').val("{{$inst->due}}");
    
  
    @else
   
    var wrapper = $(".input_fields_wrap2"); //Fields wrapper
   
    $(wrapper).append(
                    `<div class="clearfix"><br><div class="form-group"><label class="control-label col-md-3">Installment
                    
                    <br> <span style="color: red">*</span></label><div class="col-md-9"><input style="display: inline-block;width: 43%;margin-right: 4px;" type="date" class="form-control" name="custom_date[]" placeholder="Date" value="{{ date("Y-m-d", strtotime($inst->due_date))}}" ><input style="display: inline-block;width: 49%;" type="integer" class="form-control" name="custom_amount[]" onkeyup="customPayment()"  placeholder="Amount" value="{{$inst->due}}" ></div> </div><a href="#" class="remove_field">Remove</a>`
                ); //add input box
                $(".bdpk").datepicker({
                    dateFormat: "dd-mm-yy"
                });
   
 @endif

        @endif
       @endforeach

            document.getElementById('custom').style.display = 'block';
            document.getElementById('auto').style.display = 'none';
        }


      

    }





    setDefaultValueForSchedule();
 
    function enableAnn() {

        document.getElementById('custom').style.display = 'none';
        document.getElementById('auto').style.display = 'block';


        document.getElementById('ann_div').style.display = 'block';
        document.getElementById('semi_div').style.display = 'none';
        document.getElementById('quar_div').style.display = 'none';
        document.getElementById('bi_mon_div').style.display = 'none';



        
            //    $('#total_semi_installment_count').val( Math.round(data.total_months / 6));
            //    $('#total_quarterly_installment_count').val( Math.round(data.total_months / 3));
            //    $('#total_bi_mon_installment_count').val( Math.round(data.total_months / 2));

        // $('#annual-installment').val('');

        // $('#total_annual_installment').val('');
        // $('#total_annual_installment_count').val('');
        // remaining_months = $('#remaining-total-months').val();
        // value = Math.round(parseInt({{ $per_insta }} * {{ $remaining_installment_count }}) / parseInt(
        //     remaining_months));


        // $('#remaining_total_installment').val(Math.round($("#remaining-per-total_install").val()));
        // $('#remaining_single_installment').val(Math.round(parseInt($("#remaining-per_installment").val()) + parseInt(
        //     value)));
        // $('#remaining_single_installment').val(Math.round(parseInt($("#remaining-per_installment").val()) + parseInt(
        // value))).keyup();
        setRemainingAfterScheduleChange('total_annual_installment');

    }

    function enableBiMonth() {

        document.getElementById('custom').style.display = 'none';
        document.getElementById('auto').style.display = 'block';


        document.getElementById('bi_mon_div').style.display = 'block';
        document.getElementById('quar_div').style.display = 'none';

        document.getElementById('semi_div').style.display = 'none';
        document.getElementById('ann_div').style.display = 'none';



        // $('#bi-mon-installment').val(0);
        // $('#total_bi_mon_installment_count').val(0);

        // $('#total_bi_mon_installment').val(0);
        // remaining_months = $('#remaining-total-months').val();

        // value = Math.round(parseInt({{ $per_insta }} * {{ $remaining_installment_count }}) / parseInt(
        //     remaining_months));


        // $('#remaining_total_installment').val(Math.round($("#remaining-per-total_install").val()));
        // $('#remaining_single_installment').val(Math.round(parseInt($("#remaining-per_installment").val()) + parseInt(
        //     value)));
        // $('#remaining_single_installment').val(Math.round(parseInt($("#remaining-per_installment").val()) + parseInt(
        // value))).keyup();
        setRemainingAfterScheduleChange('total_bi_mon_installment');

    }

    function enableQuar() {

        document.getElementById('custom').style.display = 'none';
        document.getElementById('auto').style.display = 'block';


        document.getElementById('quar_div').style.display = 'block';
        document.getElementById('bi_mon_div').style.display = 'none';
        document.getElementById('semi_div').style.display = 'none';
        document.getElementById('ann_div').style.display = 'none';



        // $('#quarterly-installment').val(0);
        // $('#total_quarterly_installment_count').val(0);

        // $('#total_quarterly_installment').val(0);
        // remaining_months = $('#remaining-total-months').val();

        // value = Math.round(parseInt({{ $per_insta }} * {{ $remaining_installment_count }}) / parseInt(
        //     remaining_months));


        // $('#remaining_total_installment').val(Math.round($("#remaining-per-total_install").val()));
        // $('#remaining_single_installment').val(Math.round(parseInt($("#remaining-per_installment").val()) + parseInt(
        //     value))).keyup();
        // $('#remaining_single_installment').val(Math.round(parseInt($("#remaining-per_installment").val()) + parseInt(
        // value)));
        setRemainingAfterScheduleChange('total_quarterly_installment');
    }

    function enableSemi() {

        document.getElementById('custom').style.display = 'none';
        document.getElementById('auto').style.display = 'block';


        document.getElementById('semi_div').style.display = 'block';
        document.getElementById('ann_div').style.display = 'none';
        document.getElementById('quar_div').style.display = 'none';
        document.getElementById('bi_mon_div').style.display = 'none';



        // $('#semi-installment').val(0);

        // $('#total_semi_installment_count').val(0);

        // $('#total_semi_installment').val(0);
        // remaining_months = $('#remaining-total-months').val();
        // value = Math.round(parseInt({{ $per_insta }} * {{ $remaining_installment_count }}) / parseInt(
        //     remaining_months));


        // $('#remaining_total_installment').val(Math.round($("#remaining-per-total_install").val()));
        // $('#remaining_single_installment').val(Math.round(parseInt($("#remaining-per_installment").val()) + parseInt(
        //     value))).keyup();
        // $('#remaining_single_installment').val(Math.round(parseInt($("#remaining-per_installment").val()) + parseInt(
        // value)));
        setRemainingAfterScheduleChange('total_semi_installment');

    }

    function disableAnn(val) {

        document.getElementById('custom').style.display = 'none';
        document.getElementById('auto').style.display = 'block';

        document.getElementById('semi_div').style.display = 'none';
        document.getElementById('ann_div').style.display = 'none';
        document.getElementById('quar_div').style.display = 'none';
        document.getElementById('bi_mon_div').style.display = 'none';

        remaining_months = $('#remaining-total-months').val();
        value = Math.round(parseInt({{ $per_insta }} * {{ $remaining_installment_count }}) / parseInt(
            remaining_months));


        // $('#remaining_total_installment').val(Math.round($("#remaining-per-total_install").val()));
        // $('#remaining_single_installment').val(Math.round(parseInt($("#remaining-per_installment").val()) + parseInt(
        // value)));
        // $('#remaining_single_installment').val(Math.round(parseInt($("#remaining-per_installment").val()) + parseInt(
        // value))).keyup();

        setRemainingAfterScheduleChange('auto');



    }

    function enableCustom(val) {
        document.getElementById('custom').style.display = 'block';
        document.getElementById('auto').style.display = 'none';

        remaining_net_amount = parseInt($('#remianing_payable').val());
        // net_amount = parseInt($('#net_amount').val());
        remaining_down_payment = parseInt($('#remaining_down-payment').val());
        remaining_possession = parseInt($('#remaining_possession').val());
        remaining_allotment = parseInt($('#remaining_allotment').val());
        remaining_confirmation = parseInt($('#remaining_confirmation').val());
        remaining_booking = parseInt($('#remaining_booking').val());

        remaining_file_processing = parseInt($('#remaining_file_processing').val());
        remaining_registration = parseInt($('#remaining_registration').val());
        balloting = parseFloat($('#remaining_balloting').val());
        ballon = parseFloat($('#remaining_ballon').val());
        var cus_amount = 0;
        $("input[name='custom_amount[]']").each(function() {
            if (!this.value) {
                cus_amount += 0;
            } else {
                cus_amount += parseInt($(this).val());
            }
        });

        remaining_amount = remaining_net_amount - remaining_down_payment - remaining_possession - remaining_allotment -
            remaining_confirmation - remaining_booking - remaining_file_processing -
            remaining_registration - cus_amount - balloting - ballon;
        // console.log(remaining_net_amount, remaining_down_payment, remaining_possession, remaining_allotment,
        //     remaining_confirmation, remaining_booking, remaining_file_processing,
        //     remaining_registration, cus_amount);
        $('#custome_rem').val(Math.round(remaining_amount));


    }




    // From add Statemtmt
// function enableAnn() {
   
//     document.getElementById('custom').style.display = 'none';
//     document.getElementById('auto').style.display = 'block';

//     $('#remaining_amount').val(0);
//     document.getElementById('ann_div').style.display = 'block';
//     document.getElementById('semi_div').style.display = 'none';
//     document.getElementById('quar_div').style.display = 'none';
//     document.getElementById('bi_mon_div').style.display = 'none';

//     price = parseInt($('#net_amount').val());
//     count = $('#total_annual_installment_count').val();

//      $('#installment').val( Math.round(parseFloat($('#monthly_installment_per').val()) / 100 * price / (parseInt($('#total_month_per').val()))));

//     $('#total_installment').val( Math.round(parseFloat($('#monthly_installment_per').val()) / 100 * price));
//     ballon=  parseFloat($('#ballon').val());
//     bullating=   parseFloat($('#bulleting').val());
//     net_amount = parseInt($('#net_amount').val());
//     down_payment = parseInt($('#down-payment').val());
//     possession = parseInt($('#possession').val());
//     monthly_installment = parseInt($('#total_installment').val());

//     annual_installment = parseInt($('#total_annual_installment').val());

//     allotment = parseInt($('#allotment').val());
//     confirmation = parseInt($('#confirmation').val());
//     booking = parseInt($('#booking').val());
     
//     file_processing = parseInt($('#file_processing').val());
//     registration = parseInt($('#registration').val());


//     remaining_amount = net_amount - down_payment - possession - monthly_installment - annual_installment - allotment - confirmation - booking  - file_processing - registration - ballon - bullating;
     

    


//     // $('#annual-installment').val( Math.round(remaining_amount / count)).trigger("keyup");
//     // $('#total-months').val( Math.round(parseInt($('#total_month_per').val()))).trigger("keyup");;
//      $('#total_annual_installment').val( Math.round(remaining_amount)).trigger("keyup");;


// }
// function enableBiMonth() {
//     makeInstallmentZero();
//     document.getElementById('custom').style.display = 'none';
//     document.getElementById('auto').style.display = 'block';

//     $('#remaining_amount').val(0);
//     document.getElementById('bi_mon_div').style.display = 'block';
//     document.getElementById('quar_div').style.display = 'none';

//     document.getElementById('semi_div').style.display = 'none';
//     document.getElementById('ann_div').style.display = 'none';

//     price = $('#net_amount').val();
//     count = $('#total_bi_mon_installment_count').val();

//      $('#installment').val( Math.round(parseFloat($('#monthly_installment_per').val()) / 100 * price / (parseInt($('#total_month_per').val()))));

//     $('#total_installment').val( Math.round(parseFloat($('#monthly_installment_per').val()) / 100 * price));

//     ballon=  parseFloat($('#ballon').val());
//     bullating=   parseFloat($('#bulleting').val());
//     net_amount = parseInt($('#net_amount').val());
//     down_payment = parseInt($('#down-payment').val());
//     possession = parseInt($('#possession').val());
//     monthly_installment = parseInt($('#total_installment').val());

//     annual_installment = parseInt($('#total_annual_installment').val());

//     allotment = parseInt($('#allotment').val());
//     confirmation = parseInt($('#confirmation').val());
//     booking = parseInt($('#booking').val());
    
//     file_processing = parseInt($('#file_processing').val());
//     registration = parseInt($('#registration').val());


//     remaining_amount = net_amount - down_payment - possession - monthly_installment - annual_installment - allotment - confirmation - booking - file_processing - registration - ballon - bullating;
     
//      $('#bi-mon-installment').val( Math.round(remaining_amount / count));
//     $('#total-months').val( Math.round(parseInt($('#total_month_per').val())));

//     $('#total_bi_mon_installment').val( Math.round(remaining_amount));

// }

// function enableQuar() {

//     makeInstallmentZero();
//     document.getElementById('custom').style.display = 'none';
//     document.getElementById('auto').style.display = 'block';

//     $('#remaining_amount').val(0);
//     document.getElementById('quar_div').style.display = 'block';
//     document.getElementById('bi_mon_div').style.display = 'none';
//     document.getElementById('semi_div').style.display = 'none';
//     document.getElementById('ann_div').style.display = 'none';

//     price = $('#net_amount').val();
//     count = $('#total_quarterly_installment_count').val();

//      $('#installment').val( Math.round(parseFloat($('#monthly_installment_per').val()) / 100 * price / (parseInt($('#total_month_per').val()))));

//     $('#total_installment').val( Math.round(parseFloat($('#monthly_installment_per').val()) / 100 * price));

//     ballon=  parseFloat($('#ballon').val());
//     bullating=   parseFloat($('#bulleting').val());

//     net_amount = parseInt($('#net_amount').val());
//     down_payment = parseInt($('#down-payment').val());
//     possession = parseInt($('#possession').val());
//     monthly_installment = parseInt($('#total_installment').val());

//     annual_installment = parseInt($('#total_annual_installment').val());

//     allotment = parseInt($('#allotment').val());
//     confirmation = parseInt($('#confirmation').val());
//     booking = parseInt($('#booking').val());
    
//     file_processing = parseInt($('#file_processing').val());
//     registration = parseInt($('#registration').val());


//     remaining_amount = net_amount - down_payment - possession - monthly_installment - annual_installment - allotment - confirmation - booking - file_processing - registration - ballon - bullating;
    
//      $('#quarterly-installment').val( Math.round(remaining_amount / count));
//     $('#total-months').val( Math.round(parseInt($('#total_month_per').val())));

//     $('#total_quarterly_installment').val( Math.round(remaining_amount));

// }

// function enableSemi() {
//     makeInstallmentZero();
//     document.getElementById('custom').style.display = 'none';
//     document.getElementById('auto').style.display = 'block';

   
//     document.getElementById('semi_div').style.display = 'block';
//     document.getElementById('ann_div').style.display = 'none';
//     document.getElementById('quar_div').style.display = 'none';
//     document.getElementById('bi_mon_div').style.display = 'none';

//     price = $('#net_amount').val();
//     count = $('#total_semi_installment_count').val();

//      $('#installment').val( Math.round(parseFloat($('#monthly_installment_per').val()) / 100 * price / (parseInt($('#total_month_per').val()))));

//     $('#total_installment').val( Math.round(parseFloat($('#monthly_installment_per').val()) / 100 * price));

//     ballon=  parseFloat($('#ballon').val());
//     bullating=   parseFloat($('#bulleting').val());

//     net_amount = parseInt($('#net_amount').val());
//     down_payment = parseInt($('#down-payment').val());
//     possession = parseInt($('#possession').val());

//     monthly_installment = parseInt($('#total_installment').val());

//     annual_installment = parseInt($('#total_annual_installment').val());

//     allotment = parseInt($('#allotment').val());
//     confirmation = parseInt($('#confirmation').val());
//     booking = parseInt($('#booking').val());
    
//     file_processing = parseInt($('#file_processing').val());
//     registration = parseInt($('#registration').val());

//     semi_install_per=   parseInt($('#semi_installment_hid_per').val());
//  semi_install_amount=   parseInt($('#semi_installment_hid_amount').val());
//  $('#total_semi_installment').val( Math.round(semi_install_amount));
//  $('#per_total_semi_installment').val( Math.round(semi_install_per));


//  $('#semi-installment').val( Math.round(semi_install_per / 100 * net_amount / ( count)));
//  $('#per_semi_installment').val((( parseInt($('#semi-installment').val()) / net_amount) * 100).toFixed(2));

//     remaining_amount = net_amount - down_payment - possession - monthly_installment - annual_installment - allotment - confirmation - booking  - file_processing - registration - ballon - bullating -semi_install_amount;
  
//     $('#remaining_amount').val( remaining_amount );

 
 
//     //  $('#semi-installment').val( Math.round(remaining_amount / count));
//     // $('#total-months').val( Math.round(parseInt($('#total_month_per').val())));

//     // $('#total_semi_installment').val( Math.round(remaining_amount));

// }

// function disableAnn(val) {
//     makeInstallmentZero();
//     document.getElementById('custom').style.display = 'none';
//     document.getElementById('auto').style.display = 'block';

//     $('#remaining_amount').val(0);
//     document.getElementById('semi_div').style.display = 'none';
//     document.getElementById('ann_div').style.display = 'none';
//     document.getElementById('quar_div').style.display = 'none';
//     document.getElementById('bi_mon_div').style.display = 'none';
//     price = $('#net_amount').val();

//     ballon=  parseFloat($('#ballon').val());
//     bullating=   parseFloat($('#bulleting').val());

//     net_amount = parseInt($('#net_amount').val());
//     down_payment = parseInt($('#down-payment').val());
//     possession = parseInt($('#possession').val());
//     allotment = parseFloat($('#allotment').val());
//     confirmation = parseFloat($('#confirmation').val());
//     booking = parseFloat($('#booking').val());
    
//     file_processing = parseFloat($('#file_processing').val());
//     registration = parseFloat($('#registration').val());

//     remaining_amount = net_amount - down_payment - possession  - allotment - confirmation - booking  - file_processing - registration - ballon - bullating;


 
//     if(val == {{\App\CustomerProperty::inst_mon}}) {

//         $('#total_installment').val(Math.round(remaining_amount));

//         $('#installment').val(Math.round((remaining_amount)/parseInt($('#total_month_per').val())));

//         $('#total-months').val( Math.round(parseInt($('#total_month_per').val())));
//     }
//     else if(val == {{\App\CustomerProperty::inst_bi_mon}}) {

//         $('#total_installment').val(Math.round(remaining_amount));

//         $('#installment').val(Math.round((remaining_amount)/(parseInt($('#total_month_per').val())/2)));
        
//         $('#total-months').val( Math.round(parseInt($('#total_month_per').val()/2)));

//     }
//     else if(val == {{\App\CustomerProperty::inst_quar}}) {

       
//         $('#total_installment').val(Math.round(remaining_amount));

//         $('#installment').val(Math.round((remaining_amount)/(parseInt($('#total_month_per').val())/3)));
       
//         $('#total-months').val( Math.round(parseInt($('#total_month_per').val()/3)));

//     }
//     else if(val == {{\App\CustomerProperty::inst_semi}}) {



//         $('#total_installment').val(Math.round(remaining_amount));

//         $('#installment').val(Math.round((remaining_amount)/(parseInt($('#total_month_per').val())/6)));

//         $('#total-months').val( Math.round(parseInt($('#total_month_per').val()/6)));

//     }
//     else if(val == {{\App\CustomerProperty::inst_ann}}) {


//         $('#total_installment').val(Math.round(remaining_amount));

//         $('#installment').val(Math.round((remaining_amount)/
//             (parseInt($('#total_month_per').val()/12))));
     
//         $('#total-months').val( Math.round(parseInt($('#total_month_per').val()/12)));

//     }



// }


// function enableCustom(val) {
//     makeInstallmentZero();
//     document.getElementById('custom').style.display = 'block';
//     document.getElementById('auto').style.display = 'none';



//     ballon=  parseFloat($('#ballon').val());
//     bullating=   parseFloat($('#bulleting').val());

//     net_amount = parseInt($('#net_amount').val());
//     down_payment = parseInt($('#down-payment').val());
//     possession = parseInt($('#possession').val());
//     allotment = parseInt($('#allotment').val());
//     confirmation = parseInt($('#confirmation').val());
//     booking = parseInt($('#booking').val());
  
//     file_processing = parseInt($('#file_processing').val());
//     registration = parseInt($('#registration').val());

 

//     remaining_amount = net_amount - down_payment - possession  - allotment - confirmation - booking  - file_processing - registration - ballon - bullating;
    
//     $('#custome_rem').val(Math.round(remaining_amount) );

    
// }
    
</script>
