ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Onchange of Sales Invoice Item Qty it should display on Sales Invoice


#1

Onchange of Sales Invoice Item Qty I want to display sum of qty of Sales Invoice Item should display on Sales Invoice


Row Total on sales invoice
#2

Have you tried anything?


#3

No I could not because I don’t know that how I will it be written.


#4
frappe.ui.form.on("Sales Invoice Item", "qty", function(frm, cdt, cdn) {
	var row = locals[cdt][cdn];
	// code for calculate total and set on parent field.
});

Also check existing similar functionality.


#5

Would you please write syntax to update Parent form field? Can I use for loop to sum all rows QTY?


#6

I have already written that in your other thread:


#7
frappe.ui.form.on("Sales Invoice Item", "qty", function(frm, cdt, cdn) {
	// code for calculate total and set on parent field.
	total_qty = 0;
	$.each(frm.doc.items || [], function(i, d) {
		total_qty += flt(d.qty);
	});
	frm.set_value("net_weight", total_qty);
});

#8

Mr Nabin, if I copy this code in the invoice. Will it calculate the SUM.


#9

@loliflimited It will almost work. Only thing you need to change is fieldname of custo field “total qty”, in this case it is “net_weight”.


#10

@nabinhait what should be the date type of custom field “total qty” ?


#11

We generally use “Float” fieldtype for qty field.


#12

dear
thanks a lot

i try your code and really it works well for qty

But when i attempt to make it works against another Tables Column it fails

This is my script

i am trying to sum the gm column and put it in the custom filed Total Gm

so it suppose Total GM = 60+30=90
But actually it didnt works !

please advice me.
thanks a lot


#13

hello

I have same sort of problem where i want to calculate the total items in one sales invoice.as per previous guidelines I have created custom field “total_qty” of float type to store total items involved. and added following script on sales invoice custom script section but it’s not working.
please have a look on it.

frappe.ui.form.on(“Sales Invoice”, {
validate: function(frm) {
total_qty = 0;
$.each(frm.doc.items || [], function(i, d) {
total_qty += flt(d.qty);
});
frm.set_value(“net_weight”, total_qty);
}
});


#14

frappe.ui.form.on(“Sales Invoice”, “refresh”, function(frm, cdt, cdn) {
total_qty = 0;
$.each(frm.doc.items || [], function(i, d) {
total_qty += flt(d.qty);
});
frm.set_value(“total_qty”, total_qty);
});

This worked for me…!


#15

Thanks for the update - you fixed your problem!

Please don’t direct requests to individuals to seek their help, unless you have that understanding with them.

cheers