Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use base_tax_amount_after_discount_amount instead of tax_amount #2144

Merged
merged 2 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
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 @@
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

Check warning on line 188 in india_compliance/gst_india/overrides/transaction.py

View check run for this annotation

Codecov / codecov/patch

india_compliance/gst_india/overrides/transaction.py#L188

Added line #L188 was not covered by tests

else:
tds_amount += row.tax_amount
tds_amount += row.base_tax_amount_after_discount_amount

Check warning on line 191 in india_compliance/gst_india/overrides/transaction.py

View check run for this annotation

Codecov / codecov/patch

india_compliance/gst_india/overrides/transaction.py#L191

Added line #L191 was not covered by tests

return tds_amount

Expand Down Expand Up @@ -1028,7 +1029,7 @@

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 @@

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
4 changes: 2 additions & 2 deletions india_compliance/gst_india/utils/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ def get(self):
tax_type,
{
"tax_rate": flt(item.get(f"{_tax_type}_rate", 0)),
"tax_amount": 0,
"base_tax_amount_after_discount_amount": 0,
vorasmit marked this conversation as resolved.
Show resolved Hide resolved
},
)

tax_details["tax_amount"] += flt(
tax_details["base_tax_amount_after_discount_amount"] += flt(
item.get(f"{_tax_type}_amount", 0), self.precision
)

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
6 changes: 3 additions & 3 deletions india_compliance/templates/gst_breakup.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
</td>
{% else %}
<td class="text-right">
{% if value.tax_rate or not value.tax_amount %}
{% if value.tax_rate or not value.base_tax_amount_after_discount_amount %}
({{ value.tax_rate }}%)&nbsp;
{% endif %}

{% if doc.get('is_return') %}
{{ frappe.utils.fmt_money(value.tax_amount |abs, None, "INR") }}
{{ frappe.utils.fmt_money(value.base_tax_amount_after_discount_amount |abs, None, "INR") }}
{% else %}
{{ frappe.utils.fmt_money(value.tax_amount, None, "INR") }}
{{ frappe.utils.fmt_money(value.base_tax_amount_after_discount_amount, None, "INR") }}
{% endif %}
</td>
{% endif %}
Expand Down