Skip to content

Script for Calculation Between Fields

umairsy edited this page Jan 17, 2013 · 7 revisions

Following the script used for a customer who needed system to calculate the amount of Down Payment after determining % of Down Payment. System needed to calculate the % of Grand Total and render the down payment amount. Following was the steps taken to achieve required customization.

  1. I inserted two custom field. One for determining % of down payment. Another for auto-calculation of down payment amount which will be (x/100 * grand total), where x = % of down payment.


  1. Wrote a following Custom Script:

    cur_frm.cscript.down_payment_rate = function(doc, dt, dn) {
    doc.down_payment = flt(doc.grand_total) * flt(doc.down_payment_rate) / 100.0;
    refresh_field("down_payment");
    };

Regards, ERPNext Team