I have added two fields Transportation Charges and Label Charges to Sales Invoice through Custom Fields.
I have write the following custom script
frappe.ui.form.on('Sales Invoice', {
refresh: function(frm) {
calculate_total_and_refresh(frm);
},
custom_label_charges: function(frm) {
calculate_total_and_refresh(frm);
},
custom_transportation_charges: function(frm) {
calculate_total_and_refresh(frm);
}
});
function calculate_total_and_refresh(frm) {
let label_charges = frm.doc.custom_label_charges || 0;
let transportation_charges = frm.doc.custom_transportation_charges || 0;
let net_total = frm.doc.net_total || 0;
let new_total = net_total + label_charges + transportation_charges;
frm.set_value('total', new_total);
}
It does add these charges to the total but how can I calculate the other fields like tota_taxes_and_charges, grand_total etc.
I want to accomodate these charges to the total fields before the tax.
I have erpnext installed on frappe cloud so I don’t have access to the files beside that I create a custom app but for this small task i don’t want to create a custom app.
How can i trigger those fields ?