In words change value to custom amount

I have changed amount and total of my sales invoice with this code snippet:

   ` frappe.ui.form.on('Sales Invoice',{refresh :function(frm){
    	 var custom_total=0;
    	 $.each(frm.doc.items || [], function(i, d) {
    		d.amount =flt( d.rate * d.qty * d.custom_field);
            custom_total+=d.amount;
            console.log(custom_total)      
    	  });
    	  frm.doc.total=custom_total;
    }});

but field in words prints out the old default value in words not new values;
so how to make it print out total in words with the new custom value words?