Skip to content

Commit

Permalink
Merge pull request #2902 from Ninad1306/add_tax_categoy_field
Browse files Browse the repository at this point in the history
fix: Tax Category Required to Set Item Tax Template
  • Loading branch information
ljain112 authored Dec 27, 2024
2 parents 5f227b2 + 0551ae7 commit cdd0d2b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
10 changes: 9 additions & 1 deletion india_compliance/gst_india/constants/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,19 @@
},
],
("Subcontracting Order", "Subcontracting Receipt", "Stock Entry"): [
{
"fieldname": "tax_category",
"label": "Tax Category",
"fieldtype": "Link",
"insert_after": "section_break_taxes",
"options": "Tax Category",
"print_hide": 1,
},
{
"fieldname": "taxes_and_charges",
"label": "Taxes and Charges Template",
"fieldtype": "Link",
"insert_after": "section_break_taxes",
"insert_after": "tax_category",
"options": "Sales Taxes and Charges Template",
"print_hide": 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"column_break_wxlx",
"total_taxable_value",
"section_break_biay",
"tax_category",
"taxes",
"section_break_zcnz",
"total_customs_duty",
Expand Down Expand Up @@ -279,6 +280,13 @@
"options": "\nNot Applicable\nReconciled\nUnreconciled\nIgnored",
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "tax_category",
"fieldtype": "Link",
"label": "Tax Category",
"options": "Tax Category",
"print_hide": 1
}
],
"in_create": 1,
Expand All @@ -297,7 +305,7 @@
"link_fieldname": "link_name"
}
],
"modified": "2024-08-12 15:48:43.769450",
"modified": "2024-12-20 15:17:36.898844",
"modified_by": "Administrator",
"module": "GST India",
"name": "Bill of Entry",
Expand Down
43 changes: 43 additions & 0 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 @@ -11,6 +11,7 @@
import erpnext
from erpnext.accounts.general_ledger import make_gl_entries, make_reverse_gl_entries
from erpnext.controllers.accounts_controller import AccountsController
from erpnext.stock.get_item_details import ItemDetailsCtx, _get_item_tax_template

from india_compliance.gst_india.overrides.ineligible_itc import (
update_landed_cost_voucher_for_gst_expense,
Expand Down Expand Up @@ -114,6 +115,7 @@ def set_default_accounts(self):
self.customs_payable_account = company.default_customs_payable_account

def set_taxes_and_totals(self):
self.validate_item_tax_template()
self.taxes_controller = CustomTaxController(self)

self.taxes_controller.set_item_wise_tax_rates()
Expand Down Expand Up @@ -234,6 +236,47 @@ def validate_taxes(self):
).format(row.idx, tax.tax_amount, column)
)

def validate_item_tax_template(self):
for item in self.items:
if item.item_code and item.get("item_tax_template"):
item_doc = frappe.get_cached_doc("Item", item.item_code)
item_details = ItemDetailsCtx(
{
"net_rate": item.get("taxable_value"),
"base_net_rate": item.get("taxable_value"),
"tax_category": self.get("tax_category"),
"bill_date": self.bill_of_entry_date,
"company": self.get("company"),
}
)

item_group = item_doc.item_group
item_group_taxes = []

while item_group:
item_group_doc = frappe.get_cached_doc("Item Group", item_group)
item_group_taxes += item_group_doc.taxes or []
item_group = item_group_doc.parent_item_group

item_taxes = item_doc.taxes or []

if not item_group_taxes and (not item_taxes):
# No validation if no taxes in item or item group
continue

taxes = _get_item_tax_template(
item_details, item_taxes + item_group_taxes, for_validate=True
)

if taxes:
if item.item_tax_template not in taxes:
item.item_tax_template = taxes[0]
frappe.msgprint(
_(
"Row {0}: Item Tax template updated as per validity and rate applied"
).format(item.idx, frappe.bold(item.item_code))
)

def get_gl_entries(self):
# company_currency is required by get_gl_dict
# nosemgrep
Expand Down
2 changes: 1 addition & 1 deletion india_compliance/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ india_compliance.patches.v15.remove_duplicate_web_template

[post_model_sync]
india_compliance.patches.v14.set_default_for_overridden_accounts_setting
execute:from india_compliance.gst_india.setup import create_custom_fields; create_custom_fields() #60
execute:from india_compliance.gst_india.setup import create_custom_fields; create_custom_fields() #61
execute:from india_compliance.gst_india.setup import create_property_setters; create_property_setters() #10
execute:from india_compliance.income_tax_india.setup import create_custom_fields; create_custom_fields() #2
india_compliance.patches.post_install.remove_old_fields #2
Expand Down

0 comments on commit cdd0d2b

Please sign in to comment.