<tr>
    <td><input type="number" id="srno" name="srno" class="form-control" value="1" > </td>
    <td><input type="text" id="item" name="item[]" class="form-control" value="{{ $data->item ?? '' }}"> </td>
    <td><input type="number" id="qty" name="qty[]" class="form-control" value="1" style="width: 50px;"> </td>
    <td><input type="number" name="grosswtgms[]" class="form-control" value="{{ $data->grosswtgms ?? '' }}"></td>
    <td><input type="number" id="purity" name="Purity[]" class="form-control" > </td>
    <td><input type="number" name="netgoldwtgms[]" class="form-control" value="{{ $data->netgoldwtgms ?? '' }}" style="width: 80px;"> </td>
    <td><input type="number" class="labourgold_input form-control" name="labourgold[]"  > </td>
    <td><input type="text" name="diamondwtcts[]" class="form-control" value="{{ $data->diamondwtcts ?? ''  }}" style="width: 80px;"> </td>
    <td><input type="number" class="diamondrate_input form-control" style="width: 80px;" name="diamondrate[]"></td>
    <td><input type="number" name="colorstonewtcts[]" class="form-control" value="{{ $data->colorstonewtcts ?? ''}}" style="width: 80px;"> </td>
    <td><input type="number" name="colorstonerate[]" class="form-control" value="{{ $data->colorstonerate ?? '' }}" style="width: 80px;"> </td>
    <td><input type="number" name="certify[]" class="form-control" style="width: 80px;"> </td>
    <td><input type="number" name="diacsamount[]" class="form-control" value="{{ $data->diacsamount ?? '' }}" > </td>
    <td><input type="number" name="totalamount[]" class="form-control" value="{{ $data->totalamount ?? '' }}" style="width: 80px;"> </td>
    <td><input type="number" class="custom_input form-control "  name="custom[]" style="width: 80px;"> </td>
    <td><input type="number" class="kwdcost_input form-control" name="kwdcost[]"style="width: 80px;" > </td>
    <td><input type="hidden" id="stockid" name="stockid[]" value="{{ $data->id ?? '' }}" > </td>
    <td><input type="hidden" id="saletype" name="saletype" value="Wholesale" > </td>
</tr>
<script>
    $(document).ready(function () {
   $('input[name="qtytotal"]').val(calcSum());
       $('input[name="qty[]"]').change(function () { 
         $('input[name="qtytotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="qty[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="grosswtgmstotal"]').val(calcSum());
       $('input[name="grosswtgms[]"]').change(function () { 
         $('input[name="grosswtgmstotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="grosswtgms[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="netgoldwtgmstotal"]').val(calcSum());
       $('input[name="netgoldwtgms[]"]').change(function () { 
         $('input[name="netgoldwtgmstotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="netgoldwtgms[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="labourgoldtotal"]').val(calcSum());
       $('input[name="labourgold[]"]').change(function () { 
         $('input[name="labourgoldtotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="labourgold[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="diamondwtctstotal"]').val(calcSum());
       $('input[name="diamondwtcts[]"]').change(function () { 
         $('input[name="diamondwtctstotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="diamondwtcts[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="colorstonewtctstotal"]').val(calcSum());
       $('input[name="colorstonewtcts[]"]').change(function () { 
         $('input[name="colorstonewtctstotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="colorstonewtcts[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="colorstoneratetotal"]').val(calcSum());
       $('input[name="colorstonerate[]"]').change(function () { 
         $('input[name="colorstoneratetotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="colorstonerate[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="certifytotal"]').val(calcSum());
       $('input[name="certify[]"]').change(function () { 
         $('input[name="certifytotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="certify[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="diacsamounttotal"]').val(calcSum());
       $('input[name="diacsamount[]"]').change(function () { 
         $('input[name="diacsamounttotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="diacsamount[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="totalamounttotal"]').val(calcSum());
       $('input[name="totalamount[]"]').change(function () { 
         $('input[name="totalamounttotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="totalamount[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="customtotal"]').val(calcSum());
       $('input[name="custom[]"]').change(function () { 
         $('input[name="customtotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="custom[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

$(document).ready(function () {
   $('input[name="kwdcosttotal"]').val(calcSum());
       $('input[name="kwdcost[]"]').change(function () { 
         $('input[name="kwdcosttotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="kwdcost[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});


function numberRows() {
      $('input[name ="srno"]').each(function(i) {
            $(this).val(i + 1);
      });
		}
numberRows();
</script>