title: Javascript calculation (Products sum without Vat)
body: <p>Hello I have a problem with some calculation in javascript(see image)</p>
  
  <p><a href="https://i.stack.imgur.com/7Xkvp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Xkvp.png" alt="enter image description here"></a></p>
  
  <p>The cell that is with red border calculate product  price sum with vat.
  What im trying to do but didnt success is to calculate product price sum WITHOUT VAT(the cell with red broder should be 2000 not 2200)</p>
  
  <p>Here is the code that im using,</p>
  
  <pre><code>        var row_no = (new Date).getTime();
          var newTr = $('&lt;tr id="row_' + row_no + '" class="row_' + item_id + '" data-item-id="' + item_id + '"&gt;&lt;/tr&gt;');
          tr_html = '&lt;td&gt;&lt;input name="product_id[]" type="hidden" class="rid" value="' + product_id + '"&gt;&lt;input name="product[]" type="hidden" class="rcode" value="' + item_code + '"&gt;&lt;input name="product_name[]" type="hidden" class="rname" value="' + item_name + '"&gt;&lt;input name="product_option[]" type="hidden" class="roption" value="' + item_option + '"&gt;&lt;input name="part_no[]" type="hidden" class="rpart_no" value="' + item_supplier_part_no + '"&gt;&lt;span class="sname" id="name_' + row_no + '"&gt;' + item_code +' - '+ item_name +(sel_opt != '' ? ' ('+sel_opt+')' : '')+' &lt;span class="label label-default"&gt;'+item_supplier_part_no+'&lt;/span&gt;&lt;/span&gt; &lt;i class="pull-right fa fa-edit tip edit" id="' + row_no + '" data-item="' + item_id + '" title="Edit" style="cursor:pointer;"&gt;&lt;/i&gt;&lt;/td&gt;';
          if (site.settings.product_expiry == 1) {
              tr_html += '&lt;td&gt;&lt;input class="form-control date rexpiry" name="expiry[]" type="text" value="' + item_expiry + '" data-id="' + row_no + '" data-item="' + item_id + '" id="expiry_' + row_no + '"&gt;&lt;/td&gt;';
          }
          tr_html += '&lt;td class="text-right"&gt;&lt;input class="form-control input-sm text-right rcost" name="net_cost[]" type="hidden" id="cost_' + row_no + '" value="' + item_cost + '"&gt;&lt;input class="rucost" name="unit_cost[]" type="hidden" value="' + unit_cost + '"&gt;&lt;input class="realucost" name="real_unit_cost[]" type="hidden" value="' + item.row.real_unit_cost + '"&gt;&lt;span class="text-right scost" id="scost_' + row_no + '"&gt;' + formatMoney(item_cost) + '&lt;/span&gt;&lt;/td&gt;';
          tr_html += '&lt;td&gt;&lt;input name="quantity_balance[]" type="hidden" class="rbqty" value="' + item_bqty + '"&gt;&lt;input class="form-control text-center rquantity" name="quantity[]" type="text" tabindex="'+((site.settings.set_focus == 1) ? an : (an+1))+'" value="' + formatQuantity2(item_qty) + '" data-id="' + row_no + '" data-item="' + item_id + '" id="quantity_' + row_no + '" onClick="this.select();"&gt;&lt;input name="product_unit[]" type="hidden" class="runit" value="' + product_unit + '"&gt;&lt;input name="product_base_quantity[]" type="hidden" class="rbase_quantity" value="' + base_quantity + '"&gt;&lt;/td&gt;';
          if (po_edit) {
              tr_html += '&lt;td class="rec_con"&gt;&lt;input name="ordered_quantity[]" type="hidden" class="oqty" value="' + item_oqty + '"&gt;&lt;input class="form-control text-center received" name="received[]" type="text" value="' + formatDecimal(unit_qty_received) + '" data-id="' + row_no + '" data-item="' + item_id + '" id="received_' + row_no + '" onClick="this.select();"&gt;&lt;input name="received_base_quantity[]" type="hidden" class="rrbase_quantity" value="' + qty_received + '"&gt;&lt;/td&gt;';
          }
          if (site.settings.product_discount == 1) {
              tr_html += '&lt;td class="text-right"&gt;&lt;input class="form-control input-sm rdiscount" name="product_discount[]" type="hidden" id="discount_' + row_no + '" value="' + item_ds + '"&gt;&lt;span class="text-right sdiscount text-danger" id="sdiscount_' + row_no + '"&gt;' + formatMoney(0 - (item_discount * item_qty)) + '&lt;/span&gt;&lt;/td&gt;';
          }
          tr_html += '&lt;td class="text-right"&gt;&lt;span class="text-right ssubtotal" id="subtotal_' + row_no + '"&gt;' + formatMoney((parseFloat(item_cost) * parseFloat(item_qty))) + '&lt;/span&gt;&lt;/td&gt;';
          if (site.settings.tax1 == 1) {
              tr_html += '&lt;td class="text-right"&gt;&lt;input class="form-control input-sm text-right rproduct_tax" name="product_tax[]" type="hidden" id="product_tax_' + row_no + '" value="' + pr_tax.id + '"&gt;&lt;span class="text-right sproduct_tax" id="sproduct_tax_' + row_no + '"&gt;' + (pr_tax_rate ? '(' + pr_tax_rate + ')' : '') + ' ' + formatMoney(pr_tax_val * item_qty) + '&lt;/span&gt;&lt;/td&gt;';
          }
  
          tr_html += '&lt;td class="text-right"&gt;&lt;span class="text-right ssubtotal" id="subtotal_' + row_no + '"&gt;' + formatMoney(((parseFloat(item_cost) + parseFloat(pr_tax_val)) * parseFloat(item_qty))) + '&lt;/span&gt;&lt;/td&gt;';
          tr_html += '&lt;td class="text-center"&gt;&lt;i class="fa fa-times tip podel" id="' + row_no + '" title="Remove" style="cursor:pointer;"&gt;&lt;/i&gt;&lt;/td&gt;';
          newTr.html(tr_html);
          newTr.prependTo("#poTable");
          total += formatDecimal(((parseFloat(item_cost) + parseFloat(pr_tax_val)) * parseFloat(item_qty)), 4);
          count += parseFloat(item_qty);
          an++;
          if(!belong)
              $('#row_' + row_no).addClass('warning');
      });
  
      var col = 2;
      if (site.settings.product_expiry == 1) { col++; }
      var tfoot = '&lt;tr id="tfoot" class="tfoot active"&gt;&lt;th colspan="'+col+'"&gt;Total&lt;/th&gt;&lt;th class="text-center"&gt;' + formatQty(parseFloat(count) - 1) + '&lt;/th&gt;';
      if (po_edit) {
          tfoot += '&lt;th class="rec_con"&gt;&lt;/th&gt;';
      }
      if (site.settings.product_discount == 1) {
          tfoot += '&lt;th class="text-right"&gt;'+formatMoney(product_discount)+'&lt;/th&gt;';
      }
      tfoot += '&lt;th class="text-right"&gt;'+formatMoney(total)+'&lt;/th&gt;';
      if (site.settings.tax1 == 1) {
          tfoot += '&lt;th class="text-right"&gt;'+formatMoney(product_tax)+'&lt;/th&gt;';
      }
      tfoot += '&lt;th class="text-right"&gt;'+formatMoney(total)+'&lt;/th&gt;&lt;th class="text-center"&gt;&lt;i class="fa fa-trash-o" style="opacity:0.5; filter:alpha(opacity=50);"&gt;&lt;/i&gt;&lt;/th&gt;&lt;/tr&gt;';
      $('#poTable tfoot').html(tfoot);
  </code></pre>