Skip to content

Commit

Permalink
chore: fix type, less nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
vorasmit committed Apr 11, 2024
1 parent 1f971dd commit 00a72e5
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,42 +280,43 @@ def validate_taxes(self):
[input_accounts.cess_non_advol_account], tax
)

if tax.charge_type == "Actual":

item_wise_tax_rates = json.loads(tax.item_wise_tax_rates)
if not item_wise_tax_rates:
frappe.throw(
_(
"Tax Row #{0}: Charge Type is set to Actual. However, this would"
" not compute item taxes, and your further reporting will be affected."
).format(tax.idx),
title=_("Invalid Charge Type"),
)
if tax.charge_type != "Actual":
continue

# validating total tax
total_tax = 0
is_non_cess_advol = (
tax.account_head == input_accounts.cess_non_advol_account
item_wise_tax_rates = json.loads(tax.item_wise_tax_rates)
if not item_wise_tax_rates:
frappe.throw(
_(
"Tax Row #{0}: Charge Type is set to Actual. However, this would"
" not compute item taxes, and your further reporting will be affected."
).format(tax.idx),
title=_("Invalid Charge Type"),
)

for item, rate in item_wise_tax_rates.items():
multiplier = (
item_qty_map.get(item, 0)
if is_non_cess_advol
else taxable_value_map.get(item, 0) / 100
)
total_tax += multiplier * rate
# validating total tax
total_tax = 0
is_non_cess_advol = (
tax.account_head == input_accounts.cess_non_advol_account
)

tax_difference = abs(total_tax - tax.tax_amount)
for item, rate in item_wise_tax_rates.items():
multiplier = (
item_qty_map.get(item, 0)
if is_non_cess_advol
else taxable_value_map.get(item, 0) / 100
)
total_tax += multiplier * rate

if tax_difference > 1:
column = "On Item Quantity" if is_non_cess_advol else "Net Total"
frappe.throw(
_(
"Tax Row #{0}: Charge Type is set to Actual. However, Tax Amount {1}"
" is incorrect. Try setting the Charge Type to On {2}."
).format(row.idx, tax.tax_amount, column)
)
tax_difference = abs(total_tax - tax.tax_amount)

if tax_difference > 1:
column = "On Item Quantity" if is_non_cess_advol else "On Net Total"
frappe.throw(
_(
"Tax Row #{0}: Charge Type is set to Actual. However, Tax Amount {1}"
" is incorrect. Try setting the Charge Type to {2}."
).format(row.idx, tax.tax_amount, column)
)

def get_gl_entries(self):
# company_currency is required by get_gl_dict
Expand Down

0 comments on commit 00a72e5

Please sign in to comment.