Skip to content

Commit

Permalink
fix: use base_tax_amount_after_discount_amount instead of tax_amount (#…
Browse files Browse the repository at this point in the history
…2144)

Closes: #2143 

Tax difference was calculated on document currency but taxes were set on the basis of company currency.
![image](https://github.com/resilient-tech/india-compliance/assets/108322669/77d4c0b4-e3e0-494f-b604-73d6b944b5af)
  • Loading branch information
ljain112 authored May 25, 2024
1 parent 239dc6d commit d77848f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
13 changes: 7 additions & 6 deletions india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
):
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion india_compliance/gst_india/utils/test_e_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
10 changes: 8 additions & 2 deletions india_compliance/gst_india/utils/transaction_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d77848f

Please sign in to comment.