Total Price Calculation in Item Price List

Dear Experts,

i have added 2 fields as Margin percentage and Final price.

I would like to have Final Price calculated based on Item Price X Margin Percentage.

Please guide me on this

You have to apply the client/server script for that.

here syntax of client script.

frappe.ui.form.on('YourDoctype', {
    item_price: function(frm) {
        calculate_final_price(frm);
    },
    margin_percentage: function(frm) {
        calculate_final_price(frm);
    }
});

function calculate_final_price(frm) {
    var item_price = frm.doc.item_price || 0;
    var margin_percentage = frm.doc.margin_percentage || 0;
    var final_price = item_price * (1 + (margin_percentage / 100));
    frm.set_value('final_price', final_price);
}

Please set your doctype name and field name in script. and also set your margin calculation your according.

below are the variables which are updated

But still not working in the client script

If you select the doctype Item Price. you have to set the Item Price instead of the Stock in the script. I think you have to understand the concept of client script.

And also read the below line carefully.

1 Like

thanks @NCP . it worked.

Yes , am learning the Client scripts, not much aware of it . Thanks