diff --git a/india_compliance/gst_india/overrides/transaction.py b/india_compliance/gst_india/overrides/transaction.py index 8e5c50063..90b72865b 100644 --- a/india_compliance/gst_india/overrides/transaction.py +++ b/india_compliance/gst_india/overrides/transaction.py @@ -68,13 +68,14 @@ def update_taxable_values(doc, valid_accounts): if any( row for row in doc.taxes - if row.tax_amount and row.account_head in valid_accounts + if row.base_tax_amount_after_discount_amount + and row.account_head in valid_accounts ): reference_row_index = next( ( cint(row.row_id) - 1 for row in doc.taxes - if row.tax_amount + if row.base_tax_amount_after_discount_amount and row.charge_type == "On Previous Row Total" and row.account_head in valid_accounts ), @@ -184,10 +185,10 @@ def get_tds_amount(doc): continue if row.get("add_deduct_tax") and row.add_deduct_tax == "Deduct": - tds_amount -= row.tax_amount + tds_amount -= row.base_tax_amount_after_discount_amount else: - tds_amount += row.tax_amount + tds_amount += row.base_tax_amount_after_discount_amount return tds_amount @@ -1028,7 +1029,7 @@ def set_item_wise_tax_details(self): for row in self.doc.taxes: if ( - not row.tax_amount + not row.base_tax_amount_after_discount_amount or not row.item_wise_tax_detail or row.account_head not in self.gst_account_map ): @@ -1041,7 +1042,7 @@ def set_item_wise_tax_details(self): old = json.loads(row.item_wise_tax_detail) - tax_difference = row.tax_amount + tax_difference = row.base_tax_amount_after_discount_amount # update item taxes for item_name in old: diff --git a/india_compliance/gst_india/utils/test_e_invoice.py b/india_compliance/gst_india/utils/test_e_invoice.py index ce0ad94bf..09e83d88e 100644 --- a/india_compliance/gst_india/utils/test_e_invoice.py +++ b/india_compliance/gst_india/utils/test_e_invoice.py @@ -173,7 +173,7 @@ def test_progressive_item_tax_amount(self): total_item_wise_cgst = sum(row["CgstAmt"] for row in e_invoice_data.item_list) self.assertEqual( - si.taxes[0].tax_amount, + si.taxes[0].base_tax_amount_after_discount_amount, total_item_wise_cgst, ) diff --git a/india_compliance/gst_india/utils/transaction_data.py b/india_compliance/gst_india/utils/transaction_data.py index ac1bfe96e..6c18bb99a 100644 --- a/india_compliance/gst_india/utils/transaction_data.py +++ b/india_compliance/gst_india/utils/transaction_data.py @@ -121,7 +121,10 @@ def update_transaction_tax_details(self): self.transaction_details[key] = 0 for row in self.doc.taxes: - if not row.tax_amount or row.account_head not in self.gst_accounts: + if ( + not row.base_tax_amount_after_discount_amount + or row.account_head not in self.gst_accounts + ): continue tax = self.gst_accounts[row.account_head][:-8] @@ -326,7 +329,10 @@ def update_item_tax_details(self, item_details, item): item_details.update({f"{tax}_amount": 0, f"{tax}_rate": 0}) for row in self.doc.taxes: - if not row.tax_amount or row.account_head not in self.gst_accounts: + if ( + not row.base_tax_amount_after_discount_amount + or row.account_head not in self.gst_accounts + ): continue # Remove '_account' from 'cgst_account' diff --git a/india_compliance/patches/post_install/improve_item_tax_template.py b/india_compliance/patches/post_install/improve_item_tax_template.py index 7ccbffa98..36baa6ca2 100644 --- a/india_compliance/patches/post_install/improve_item_tax_template.py +++ b/india_compliance/patches/post_install/improve_item_tax_template.py @@ -378,7 +378,7 @@ def get_taxes_for_docs(docs, doctype, is_sales_doctype): return ( frappe.qb.from_(taxes) .select( - taxes.tax_amount, + taxes.base_tax_amount_after_discount_amount, taxes.account_head, taxes.parent, taxes.item_wise_tax_detail,