Update Sales Invoice Taxes and charges through custom script

Dear Sir,

I have fields for taxes and charges and want to update through custom script. Please help. Please find below.

Thanks
Mithilesh

@2002

cur_frm.doc.taxes.forEach(function(row){
  if (row.tax === "????"){
      // do something
  } else if (row.tax === "!!!!") {
      // do another thing
  }
});

Thanks for quick response.

Uncaught TypeError: Cannot read property ‘forEach’ of undefined

cur_frm.doc.taxes.forEach(function(row){
if (row.description === “GR Charges”){
row.tax_amount=frm.doc.net_gr_ch;
} else if (row.description === “Loading Charges”) {
row.tax_amount=frm.doc.net_labour_loading;
} else if (row.description === “Door Delivery Charges”) {
row.tax_amount=frm.doc.net_door_delivery;
} else if (row.description === “Barrier Charges”) {
row.tax_amount=frm.doc.net_barrier_chgs;
} else if (row.description === “Green Tax”) {
row.tax_amount=frm.doc.net_green_tax;
} else if (row.description === “Toll Tax”) {
row.tax_amount=frm.doc.net_toll_tax;
} else if (row.description === “Unloading Charges”) {
row.tax_amount=frm.doc.net_unloading_charges;
} else if (row.description === “Door Pickup Charges”) {
row.tax_amount=frm.doc.net_door_pickup;
} else if (row.description === “Other Charges”) {
row.tax_amount=frm.doc.net_other_charges;
} else if (row.description === “Misc Charges”) {
row.tax_amount=frm.doc.net_misc_charges;
}
});

Now I can update taxes with the below script. Thanks a lot.

$.each(frm.doc.taxes || [], function(i, d) {
if (d.account_head===“GR Charges - SGSN”){
d.tax_amount=total_gr_ch;
} else if (d.account_head===“Labour Loading Charges - SGSN”) {
d.tax_amount=total_loading;
}
});

1 Like