From a1807a2f98984a6474bc6d2bbb43052cd38eed36 Mon Sep 17 00:00:00 2001 From: Subin Tom <36098155+nemesis189@users.noreply.github.com> Date: Tue, 16 Nov 2021 17:46:26 +0530 Subject: [PATCH] fix: POS idx issue in taxes table while merging (#28389) --- .../pos_invoice_merge_log.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 843497019d..0720d9b2e9 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 @@ class POSInvoiceMergeLog(Document): 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 @@ class POSInvoiceMergeLog(Document): 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 @@ class POSInvoiceMergeLog(Document): 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 @@ class POSInvoiceMergeLog(Document): 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