How to perform calculation between feilds

I’m new to ERP
I need to calculate the product price in amount (field) based on the quantity I choose
thanks in advance

2 Likes

Hi @Dharanipathi,

Please check the syntax.

Thank You!

1 Like

I’ve never done it so I can’t suggest any fix solution, but I think Price Rule is a way to do it.

Thanks for the solution @NCP
I have a few problems
How to add the amount field and fetch it on the Grand total field

Hi @Dharanipathi,

Please check it.

frappe.ui.form.on('Parent DocType',  {
    validate: function(frm) {
        gt = 0;
        $.each(frm.doc.items,  function(i,  d) {
            gt += flt(d.amount);
        });
        frm.doc.grand_total = gt;
    } 
});

here,
Parent DocType = Main Doctype name (eg. Orders)
frm.doc.items = child table field name
d.amount = child table field name
frm.doc.grand_total = parent field name

Please set your field name according.

Thank You!

4 Likes

NCP provided the solution, You can refer to that
thank you : )

Thanks a lot, @NCP. Appreciated it!