Hi,
I’ve created a custom doctype to store and calculate few details for Foreign Purchase. In this form, there’s two field called “Pad Amount” & “Excess Tk” which are changing based on the script, instantly; rest fields are just float data fields (no calculation) As for the Total Amount, I need help so that I can see the Total calculation instantly/real-time if I change any of the values.
The form is:
The script I managed to write from various posts in this forum [I’m not a developer/programmer, duh]
frappe.ui.form.on('LC Details', {
refresh(frm) {
//First Event
cur_frm.cscript.us_dollar = function(doc, cdt, cdn) {
doc.pad_amount = flt(doc.us_dollar)*flt(doc.us_dollar_rate);
refresh_field('pad_amount');
}
cur_frm.cscript.us_dollar_rate = cur_frm.cscript.us_dollar;
//End of first Event
//Second Event
cur_frm.cscript.excess_us_dollar = function(doc, cdt, cdn) {
doc.excess_tk = flt(doc.excess_us_dollar)*flt(doc.excess_us_dollar_rate);
refresh_field('excess_tk');
}
cur_frm.cscript.excess_us_dollar_rate = cur_frm.cscript.excess_us_dollar;
//End of Second Event
//Calculate Total
frm.set_value("total", frm.doc.pad_amount + frm.doc.excess_tk + frm.doc.commission + frm.doc.cnf + frm.doc.atvat + frm.doc.freight + frm.doc.carriage + frm.doc.unloading + frm.doc.ait);
}
})
I tried few things similar to the first and second event; but I’m sure as there are more variables, I’ll need to do something else.
Thanks in advance!