column not directly summing

column not directly summing

i have dynamic table

i want to update total, but total only summing old row ( not include new row )


< table id = "so_data" class = "table table-bordered table-hover" >
< thead >
< tr class = "kop" >
< th class = "text-center" style = " width:50px;" > Code </ th >
< th class = "text-center" > Description </ th >
< th class = "text-center" style = " width:100px;" > Qty </ th >
< th class = "text-center" style = " width:30px;" > Unit </ th >
< th class = "text-center" style = " width:100px;" > Price </ th >
< th class = "text-center" > Total </ th >
< th class = "text-center" style = " width:50px;" > Delete </ th >
</ tr >
</ thead >
< tbody >
<?php foreach ( $soDtl as $row ) { ? >
< tr >
< td > <?php echo $row -> Code ; ? > </ td >
< td > <?php echo $row -> description ; ? > </ td >
< td >
< input type = "text" value = " <?php echo $row -> QtyTemp ? > "
class = "eData" />
</ td >
< td > <?php echo $row -> UnitName ; ? > </ td >
< td >
< input type = "text" value = " <?php echo $row -> Price ? > "
class = "eData" />
</ td >
< td class = "text-right total" > <?php echo number_format ( $row -> Total ); ? > </ td >
< td >
< button class = "hapusBaris" ></ button >
</ td >

</ tr >
<?php } ? >
</ tbody >
</ table >




< script type = "text/javascript" >
$ ( '#insert' ). on ( 'click' , function (){
var code = $ ( '#inputCode' ). val ();
var price = $ ( '#inputPrice' ). val ();
var qty = $ ( '#inputQty' ). val ();
$ . ajax ({
url: " <?php echo base_url () ? > stock/insertData" ,
method: "POST" ,
data: { code:code , price:price , qty:qty },
success : function ( data )
{
$ ( '#so_data tr:last' ). after ( data );

// after i append New row

}
});

// i want to update total
// but total is not summing all rows ( exclude new row )
  updateTotals ();
});

function updateTotals () {
var tot = $ ( "#so_data tbody tr>td:nth-child(6)" ). map ( function ()
{
return parseFloat ( $ ( this ). text (). replace ( /,/ g , "" ) );
}). get (). reduce ( sum );
alert ( tot );
$ ( "#txtTotal" ). val ( tot );
}

function sum ( a , b )
{
return a + b
}
</script>