text: $( document ).ready(function() {
         addNewField(1);
  
  
  });
  
  function addNewField(val) {
      // alert(val)
   if(val){
  
              var id = $("#break_down tbody  tr:last input[name=row_count]").val();
  
              if (id == undefined) {
                  var r_count = 1;
              } else {
                  var r_count = parseInt(id) + 1;
  
              }
              var html = '';
              html='<tr class="var_row">'+'<td>'+r_count+'st insstallment</td><td><input type="hidden"  name="installment['+r_count+'][type]" value="'+r_count+'st insstallment"><div class="form-group"><input  type="date" name="installment['+r_count+'][start_date]" class="form-control"   required></div></td><td><div class="form-group"><input  type="date" name="installment['+r_count+'][end_date]" class="form-control"   required></div></td>';
  
              html+='<td><div class="form-group"><input  type="text" name="installment['+r_count+'][rent]" class="form-control amount"  placeholder="0" required></div></td>' ;
              html+='<td><div class="form-group"><input  type="text" readonly name="installment['+r_count+'][vat]" class="form-control vat"  placeholder="0" required></div></td>' ;
              html+='<td><div class="form-group"><input type="text"  name="installment['+r_count+'][cheque_amount]"class="form-control total" cols="3" placeholder="0" required></div></td><td><div class="form-group"><input  type="date" name="installment['+r_count+'][cheque_date]" class="form-control"   required></div></td><td> <a type="button" class="btn bg-gradient-danger btn-sm" onclick="removeField(this)"><i class="las la-trash"></i></a><input type="hidden" name="row_count"  value="' + r_count + '"></td></tr>';
              var count_table_tbody_tr = $("#break_down tbody tr").length;
                      if (count_table_tbody_tr >= 1) {
                          $("#break_down tbody tr:last").after(html);
                      } else {
  
                          $("#break_down tbody").html(html);
                      }
            }
   }
  
  
   function removeField(val) {
    $(val).closest('.var_row').remove();
  
  }
    $(document).on('change', 'input.amount', function (e) {
    var vat=0; var total=0;
    var tr_obj = $(this).closest('tr');
    var amount = tr_obj.find('input.amount').val();
    var vat =amount*5/100;
    tr_obj.find('input.vat').val(vat);
    total = (parseFloat(amount) + parseFloat(vat));
    total = total.toFixed(2);
    tr_obj.find('input.total').val(total);
  
   });
  