ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Custom Script for add, multiply and division


#1

Hello Guys!

I’ve created doctype and I have 3 fields I put any number for example

on field 1, I put number 3
on field 2, I put number 3
on field 3, I put number 3

for my other field, I named it total to show the total of 3 inputted numbers.

then multiply by 0.95 it will shows on the other field I name it charge

then multiply by 0.05 it will shows on the other field I name it charge_x

then divide by 1.12 it will shows on the other field I name it charge_y

then multiply by 0.12 it will shows on the other field I name it charge_u

my question is how can I possible to create this on custom script.

Thanks guys for your.

Still learning on ERP.

It helps me a lot.


#2

Likely you have referred to these basic howto notes

So a search like this will help with your learning


#3

Thanks @clarkej


#4

Hi @clarkej

I able to multiply 3 fields and multiply into 95% and 5%

but when I tries to divide the of 5% into 1.12 I receive error

here’s my custom script

frappe.ui.form.on(“Beta”, “a_charges”, function(frm) {
frm.set_value(“5_charges”, flt(frm.doc.a_charges) * 0.05);
})
frappe.ui.form.on(“Beta”, “5_charges”, function(frm) {
frm.set_value(“5_vat”, flt(frm.doc.5_charges) / 1.12);
})

Thanks

Regards
@Foxdemon96


#5

Change the field name of “5_charges”
Field Name cannot be start with a digit, it should only starts with a alphabet, just like variables.


#6

Thanks @shahid