Merge branch 'develop' into e-commerce-refactor-develop
diff --git a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
index 8434970..0720d9b 100644
--- a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
+++ b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
@@ -110,9 +110,15 @@
 
 	def merge_pos_invoice_into(self, invoice, data):
 		items, payments, taxes = [], [], []
+
 		loyalty_amount_sum, loyalty_points_sum = 0, 0
+
 		rounding_adjustment, base_rounding_adjustment = 0, 0
 		rounded_total, base_rounded_total = 0, 0
+
+		loyalty_amount_sum, loyalty_points_sum, idx = 0, 0, 1
+
+
 		for doc in data:
 			map_doc(doc, invoice, table_map={ "doctype": invoice.doctype })
 
@@ -146,6 +152,8 @@
 						found = True
 				if not found:
 					tax.charge_type = 'Actual'
+					tax.idx = idx
+					idx += 1
 					tax.included_in_print_rate = 0
 					tax.tax_amount = tax.tax_amount_after_discount_amount
 					tax.base_tax_amount = tax.base_tax_amount_after_discount_amount
@@ -163,8 +171,8 @@
 					payments.append(payment)
 			rounding_adjustment += doc.rounding_adjustment
 			rounded_total += doc.rounded_total
-			base_rounding_adjustment += doc.rounding_adjustment
-			base_rounded_total += doc.rounded_total
+			base_rounding_adjustment += doc.base_rounding_adjustment
+			base_rounded_total += doc.base_rounded_total
 
 
 		if loyalty_points_sum:
@@ -176,9 +184,9 @@
 		invoice.set('payments', payments)
 		invoice.set('taxes', taxes)
 		invoice.set('rounding_adjustment',rounding_adjustment)
-		invoice.set('rounding_adjustment',base_rounding_adjustment)
-		invoice.set('base_rounded_total',base_rounded_total)
+		invoice.set('base_rounding_adjustment',base_rounding_adjustment)
 		invoice.set('rounded_total',rounded_total)
+		invoice.set('base_rounded_total',base_rounded_total)
 		invoice.additional_discount_percentage = 0
 		invoice.discount_amount = 0.0
 		invoice.taxes_and_charges = None