Try ERPNext Buy Support Partners Foundation

While duplicating a doctype , amount is not calculating automatically

While duplicating a doctype , amount is not calculating automatically

Any update???

Thanks in Advance

You’ll have to give us more details. Tell us step wise what exactly you were doing, what you were expecting and what you got instead. Also show us any custom python or javascript code you may have written in order to get this done.

Hi

In Quotation , i duplicated the ‘Quotation Item’ Doctype as " Optional accessories " in the same Quotation Page. And it works fine.

But while choosing the item Rate is populating but the Amount is not calculated as based on the Rate and Qty. Its displaying zero

i tried using this code , still its not working

frappe.ui.form.on("Optional Accesories", {
        validate: function) frm) {
        frm.trigger("calculate_amount")
    },
    qty: function(frm) {
        frm.trigger("calculate_amount")
    },
    rate: function(frm) {
        frm.trigger("calculate_amount")
    },
    calculate_amount: function(frm) {
        if (frm.doc.qty && frm.doc.rate) {
            amount = flt(frm.doc.qty * frm.doc.rate);
            frm.set_value('amount', amount)
        }
    }
})

Kindly help

i was doing some calculation on quotation item recently kindly read my post hope it might help

1 Like

Thanks a lot, let me check and update

@Pirated

Hi please see the below screenshot

and i used the script like this , but not working

frappe.ui.form.on(‘Optional Accessories’,
{
opt:function(frm,cdt,cdn)
{
var d = locals[cdt][cdn];
var opt_amount = (flt(d.qty) * flt(d.rate));
frappe.model.set_value(cdt, cdn, “amount”, opt_amount);

},
qty:function(frm,cdt,cdn)

{
var d = locals[cdt][cdn];
var opt_amount = (flt(d.qty) * flt(d.rate));
frappe.model.set_value(cdt, cdn, “amount”, opt_amount);

},
rate:function(frm,cdt,cdn)

{
var d = locals[cdt][cdn];
var opt_amount = (flt(d.qty) * flt(d.rate));
frappe.model.set_value(cdt, cdn, “amount”, opt_amount);
}
})

@root13F @Pirated

try this script enter your correct child doctype name in the first line.

   frappe.ui.form.on('Doctype_Name', {
    	qty:function(frm,cdt,cdn){
    		var d = locals[cdt][cdn];
    		var amount = flt(d.qty) * flt(d.rate) ;
    		frappe.model.set_value(cdt, cdn, "amount", amount);
    	},
    	rate:function(frm,cdt,cdn){
    		var d = locals[cdt][cdn];
    		var amount = flt(d.qty) * flt(d.rate) ;
    		frappe.model.set_value(cdt, cdn, "amount", amount);
    	}
    })
1 Like

@Pirated

Hi , thanks for the code, its working. but once i refresh the qty Suppose change Qty 1 from 2 then only it will works, how we can refresh that qty field

Kindly assist

them amount field will be recalculated whenever you make changes to qty field or rate field .

Yes that is right but here when logged in to screen itself amount is showing 0 , when changing qty from 1 to 2 amount value comes, if it is 1 i need to change again to 1 as qty