From 37def88629751bc8cf566fd81676b9336c2bce65 Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Mon, 23 Dec 2024 12:50:00 +0530 Subject: [PATCH 1/3] fix: tax category required to set item tax template --- india_compliance/gst_india/constants/custom_fields.py | 10 +++++++++- .../gst_india/doctype/bill_of_entry/bill_of_entry.json | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/india_compliance/gst_india/constants/custom_fields.py b/india_compliance/gst_india/constants/custom_fields.py index f451ee7ccf..08c0150fd7 100644 --- a/india_compliance/gst_india/constants/custom_fields.py +++ b/india_compliance/gst_india/constants/custom_fields.py @@ -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, }, diff --git a/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.json b/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.json index a30beee11a..316e143e6a 100644 --- a/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.json +++ b/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.json @@ -43,6 +43,7 @@ "column_break_wxlx", "total_taxable_value", "section_break_biay", + "tax_category", "taxes", "section_break_zcnz", "total_customs_duty", @@ -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, @@ -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", From 03656c47b16a82cbc904aa25dab4c704732e054f Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Thu, 26 Dec 2024 17:31:36 +0530 Subject: [PATCH 2/3] fix: validate item tax template based on tax category --- .../doctype/bill_of_entry/bill_of_entry.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.py b/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.py index aba4d59f59..ec270d2c91 100644 --- a/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.py +++ b/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.py @@ -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, @@ -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() @@ -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 From 0551ae7baf07a71e9b43d16254dc8071be52e1d0 Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Thu, 26 Dec 2024 17:31:54 +0530 Subject: [PATCH 3/3] fix: update patch number --- india_compliance/patches.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/india_compliance/patches.txt b/india_compliance/patches.txt index 328e89de8a..f40bf933b2 100644 --- a/india_compliance/patches.txt +++ b/india_compliance/patches.txt @@ -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