Custom Script working on Firefox but not working on Google Chrome or Internet Explorer

Hi,

This is quite strange. I have a custom script that works on Mozilla Firefox but is not working on Google Chrome or Microsoft Internet Explorer. My custom script is on Sales invoice for calculating the excise amount and vat amount separately from the sales taxes and charges table and save it on the file.

frappe.ui.form.on(“Sales Invoice”, {
validate: function(frm) {

  frappe.model.set_value(frm.doc.doctype, frm.doc.name, "date_and_time_of_removal_of_goods", frm.doc.posting_date + " " + frm.doc.posting_time);

    refresh_field("date_time_of_removal_of_goods");
    frappe.model.set_value(frm.doc.doctype, frm.doc.name, "date_and_time_of_preparation_of_invoice", frm.doc.posting_date + " " + frm.doc.posting_time);
    refresh_field("date_time_of_invoice");

// calculate excise amount
   
  total_excise_amount = 0
  total_vat_amount = 0
   if(frm.doc.taxes) {
     $.each(frm.doc.taxes, function(i, d) {
        var excise_amount = 0;
        var vat_amount = 0;
        var tax_desc = d.description;
       
         if (tax_desc.contains("Excise")) {
           
          excise_amount = d.tax_amount;
          total_excise_amount += flt(d.tax_amount)
                                            
          } else  {
          
           
         }
        
    if (tax_desc.contains("VAT")) {
           
          vat_amount = d.tax_amount;
          total_vat_amount += flt(d.tax_amount)
                                            
          } else  {
                         
         }                   
            
    });
   }
    frappe.model.set_value(frm.doc.doctype, frm.doc.name, "excise_amount", total_excise_amount);
    frappe.model.set_value(frm.doc.doctype, frm.doc.name, "vat_amount", total_vat_amount);
      

}

});

Once the sales invoice is opened and saved, it is not getting saved and is getting stuck up at that point in Chrome, whereas it is getting saved in Firefox and is also reflecting the values. What could be wrong? Is there something wrong in my custom script? Or, should there be something else that I should be looking at?

Thanks
Uma

@UmaG
After changing script you need to reload page.
Can you reload page in Chrome, you can also clear website cache and test your script.

Regards,
Sambhaji Kolate,
New Indictrans Technologies Pvt Ltd.

Thanks a lot for replying back to my query. I tried reloading the page several times and have also cleared the website cache but am still facing the same problem. The page is hung on the save option.

@UmaG
Share your chrome console log.

VM598:1092 Uncaught TypeError: tax_desc.contains is not a function(anonymous function) @ VM598:1092each @ jquery.min.js:2validate @ VM598:1087(anonymous function) @ form.min.js:213(anonymous function) @ form.min.js:213map @ jquery.min.js:2trigger @ form.min.js:213_f.Frm._save @ form.min.js:79(anonymous function) @ form.min.js:73
desk.min.js:3084 GET http://52.36.100.137/socket.io/?EIO=3&transport=polling&t=1469088373522-12 502 (Bad Gateway)Request.create @ desk.min.js:3084Request @ desk.min.js:3007XHR.request @ desk.min.js:2938XHR.doPoll @ desk.min.js:2968Polling.poll @ desk.min.js:3357Polling.doOpen @ desk.min.js:3301Transport.open @ desk.min.js:2478Socket.open @ desk.min.js:1908Socket @ desk.min.js:1790Socket @ desk.min.js:1725Manager.open.Manager.connect @ desk.min.js:464(anonymous function) @ desk.min.js:729

This log shows that the contains() is not recognizable… But, this function works on Mozilla Firefox. What should be done for this?

Hi @UmaG

Remove else part and check

Thanks, Rohit

Hi @rohit_w,

Thanks for the reply. I have tried by removing else also. It is still giving me the same problem.

VM1510:1092 Uncaught TypeError: tax_desc.contains is not a function.

Looks like this function works on Firefox but not on Chrome. Is there any equivalent function, which I can use to do string comparisons and which can work on Chrome also?

Hi @UmaG

It’s clearly mentioned, check below links

Thanks, Rohit

Thanks a lot @rohit_w… It worked. I used the search function instead of contains and it worked… You may please close this issue… :slight_smile:

1 Like