Try ERPNext Buy Support Partners Foundation

[Closed]Need Help with Custom Script for my quotation

Hi friends
i need a little help regarding the custom script. I need to calculate two of my custom fields. as from the image below i have marked the four columns as A, B, C, D. both C and D fields are custom fields and are type currency.
1: C field is GST amount which needs to be calculated from A and B
2: D field is the addition of A and C

Hello @Pirated,
You need to create custom app for this.

Here you will get help from this video.
1 Like

@vainikshiv dont need custom app … i created those fields only to display it on print format. only need custom scrip to calculate these two fields

I have checked the video but i am unable move forward. i know python but moving inside erpnext is different. can some body share some example code regarding my issue. Thanks

@vainikshiv my custom scrip but its not working
frappe.ui.form.on(‘Quotation Item’, “validate” , function (frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, “gst”, d.amount * (flt(d.item_tax_template)/100));

If you already have the field gst and item tax template in you quatation item table then you can do it using this script

validate:function (frm) {
for(var i =0;i <cur_frm.doc.items.length;i++){
d = cur_frm.doc.items[i];
d.gst = d.amount * (parseFloat(d.item_tax_template)/100)

You can do it also in PY. with the same logic

@Pirated I don’t get it, why did you ever created custom field for calculating “GST” and “Total Amount” as per product wise.

Using “Print Format Builder” you can add this field in your Quotation. When you will create quotation you need to fill “Taxes and Charges” field then it will calculate taxes and total amount automatically .

Refer this link

@vainikshiv yes bro you are right but the tax breakup is on separate table and the to the company to whom i submit quotation accept quotation in specific format. if there is any way i can add item tax and total amount with gst in quotation item table my problem is solved. only need this for quotation.

@Pirated, You can add the changes as suggested by @Justine_Jay_Caneza or on change of quantity and rate also you can make the changes in your custom script for quotation items.

i have tried few things you people suggested but it seem my custom script is not working at all. so i wanted to try simple addition ojn custom three custom fields in order to check that.
i added [one, two, three] as custom fields in quotation doctype via customize form

then applied the custom script to do a simple calculation of adding two and store the result in the third
custom script is below

but script seems not working at all can any body know what i am doing wrong as this is my first time custom scripts

@Justine_Jay_Caneza this is not working either :frowning:

    validate:function (frm) {
        for(var i =0;i <cur_frm.doc.items.length;i++){
        d = cur_frm.doc.items[i];
        d.gst = d.amount * (parseFloat(d.item_tax_template)/100);

Try this:

frappe.ui.form.on('Quotation', { 
        validate: function(frm) { 
              frm.set_value('three', + frm.doc.two ); 
1 Like

@vainikshiv yay … thanks bro … i got my script working … so happy. now i need the calculation on my child table to calculate gst and Total amount custom field

Help needed badly … kindly if some body can help me with this

i am closing this topic will create another to be more specific as this one discussed as much as possible. thanks everyone for the effort.