Merge pull request #17098 from rohitwaghchaure/incorrect_calculation_of_imponibile_importo_develop

fix: incorrect  calcualtion of ImponibileImporto if tax rate is zero
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index 8c1ddbb..01b935c 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -164,7 +164,7 @@
 		args_copy.update(item)
 		data = get_pricing_rule_for_item(args_copy, item.get('price_list_rate'), doc=doc)
 		out.append(data)
-		if set_serial_nos_based_on_fifo and not args.get('is_return'):
+		if not item.get("serial_no") and set_serial_nos_based_on_fifo and not args.get('is_return'):
 			out[0].update(get_serial_no_for_item(args_copy))
 
 	return out
diff --git a/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py b/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py
index 2e9f536..d50eaeb 100644
--- a/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py
+++ b/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py
@@ -5,6 +5,7 @@
 
 import frappe
 import unittest
+from frappe.utils import getdate
 from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
 from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
 from erpnext.stock.doctype.item.test_item import make_item
@@ -12,10 +13,27 @@
 
 class TestGSTR3BReport(unittest.TestCase):
 	def test_gstr_3b_report(self):
+
+		month_number_mapping = {
+			1: "January",
+			2: "February",
+			3: "March",
+			4: "April",
+			5: "May",
+			6: "June",
+			7: "July",
+			8: "August",
+			9: "September",
+			10: "October",
+			11: "November",
+			12: "December"
+		}
+
 		frappe.set_user("Administrator")
 
 		frappe.db.sql("delete from `tabSales Invoice` where company='_Test Company GST'")
 		frappe.db.sql("delete from `tabPurchase Invoice` where company='_Test Company GST'")
+		frappe.db.sql("delete from `tabGSTR 3B Report` where company='_Test Company GST'")
 
 		make_company()
 		make_item("Milk", properties = {"is_nil_exempt": 1, "standard_rate": 0.000000})
@@ -33,8 +51,8 @@
 				"doctype": "GSTR 3B Report",
 				"company": "_Test Company GST",
 				"company_address": "_Test Address-Billing",
-				"year": "2019",
-				"month": "March"
+				"year": getdate().year,
+				"month": month_number_mapping.get(getdate().month)
 			}).insert()
 
 		output = json.loads(report.json_output)
@@ -55,7 +73,6 @@
 			income_account = 'Sales - _GST',
 			expense_account = 'Cost of Goods Sold - _GST',
 			cost_center = 'Main - _GST',
-			posting_date = '2019-03-10',
 			do_not_save=1
 		)
 
@@ -77,7 +94,6 @@
 			income_account = 'Sales - _GST',
 			expense_account = 'Cost of Goods Sold - _GST',
 			cost_center = 'Main - _GST',
-			posting_date = '2019-03-10',
 			do_not_save=1
 		)
 
@@ -99,7 +115,6 @@
 			income_account = 'Sales - _GST',
 			expense_account = 'Cost of Goods Sold - _GST',
 			cost_center = 'Main - _GST',
-			posting_date = '2019-03-10',
 			do_not_save=1
 		)
 
@@ -122,7 +137,6 @@
 			income_account = 'Sales - _GST',
 			expense_account = 'Cost of Goods Sold - _GST',
 			cost_center = 'Main - _GST',
-			posting_date = '2019-03-10',
 			do_not_save=1
 		)
 	si3.submit()
@@ -135,7 +149,6 @@
 			currency = 'INR',
 			warehouse = 'Finished Goods - _GST',
 			cost_center = 'Main - _GST',
-			posting_date = '2019-03-10',
 			do_not_save=1,
 		)
 
@@ -157,7 +170,6 @@
 			currency = 'INR',
 			warehouse = 'Finished Goods - _GST',
 			cost_center = 'Main - _GST',
-			posting_date = '2019-03-10',
 			item = "Milk",
 			do_not_save=1
 		)
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js
index dcb9ed1..388605d 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.js
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.js
@@ -234,15 +234,20 @@
 				this.update_item_in_frm(item, field, value)
 					.then(() => {
 						frappe.dom.unfreeze();
-						let items = this.frm.doc.items.map(item => item.idx);
-						if (items && items.length > 0 && items.indexOf(item.idx)) {
-							this.frm.doc.items.forEach(item_row => {
-								// update cart
-								this.on_qty_change(item_row);
-							});
-						} else {
-							this.on_qty_change(item);
-						}
+						frappe.run_serially([
+							() => {
+								let items = this.frm.doc.items.map(item => item.name);
+								if (items && items.length > 0 && items.includes(item.name)) {
+									this.frm.doc.items.forEach(item_row => {
+										// update cart
+										this.on_qty_change(item_row);
+									});
+								} else {
+									this.on_qty_change(item);
+								}
+							},
+							() => this.post_qty_change(item)
+						]);
 					});
 			}
 			return;
@@ -263,9 +268,20 @@
 					.then(() => {
 						this.frm.script_manager.trigger('qty', item.doctype, item.name)
 							.then(() => {
-								this.frm.doc.items.forEach(item => {
-									this.update_cart_data(item);
-								});
+								frappe.run_serially([
+									() => {
+										let items = this.frm.doc.items.map(i => i.name);
+										if (items && items.length > 0 && items.includes(item.name)) {
+											this.frm.doc.items.forEach(item_row => {
+												// update cart
+												this.on_qty_change(item_row);
+											});
+										} else {
+											this.on_qty_change(item);
+										}
+									},
+									() => this.post_qty_change(item)
+								]);
 							});
 					});
 			},
@@ -286,10 +302,17 @@
 	on_qty_change(item) {
 		frappe.run_serially([
 			() => this.update_cart_data(item),
-			() => this.set_form_action()
 		]);
 	}
 
+	post_qty_change(item) {
+		this.cart.update_taxes_and_totals();
+		this.cart.update_grand_total();
+		this.cart.update_qty_total();
+		this.cart.scroll_to_item(item.item_code);
+		this.set_form_action();
+	}
+
 	select_batch_and_serial_no(row) {
 		frappe.dom.unfreeze();
 
@@ -304,7 +327,8 @@
 									frappe.model.clear_doc(item.doctype, item.name);
 								}
 							},
-							() => this.update_cart_data(item)
+							() => this.update_cart_data(item),
+							() => this.post_qty_change(item)
 						]);
 					});
 			})
@@ -321,9 +345,6 @@
 
 	update_cart_data(item) {
 		this.cart.add_item(item);
-		this.cart.update_taxes_and_totals();
-		this.cart.update_grand_total();
-		this.cart.update_qty_total();
 		frappe.dom.unfreeze();
 	}
 
@@ -974,7 +995,6 @@
 			$item.appendTo(this.$cart_items);
 		}
 		this.highlight_item(item.item_code);
-		this.scroll_to_item(item.item_code);
 	}
 
 	update_item(item) {