Skip to content

Commit

Permalink
Merge pull request #2927 from resilient-tech/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
ljain112 authored Jan 6, 2025
2 parents 3ff886a + bba95e4 commit 2e796bc
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 14 deletions.
2 changes: 2 additions & 0 deletions india_compliance/gst_india/api_classes/e_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class EInvoiceAPI(BaseAPI):
# Cancel IRN errors
"9999": "Invoice is not active",
"4002": "EwayBill is already generated for this IRN",
# IRN Generated in different Portal
"2148": "Requested IRN data is not available",
# Invalid GSTIN error
"3028": "GSTIN is invalid",
"3029": "GSTIN is not active",
Expand Down
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
41 changes: 41 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 _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,45 @@ 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)
args = {
"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(
args, 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
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def get_return_status(self):
self.gstin,
self.return_period,
)
self.filing_status = status
self.db_set("filing_status", status)

return status

Expand Down
17 changes: 7 additions & 10 deletions india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,11 +1012,12 @@ def get_gst_details(party_details, doctype, company, *, update_place_of_supply=F
gst_details.update(party_gst_details)

# POS
gst_details.place_of_supply = (
party_details.place_of_supply
if (not update_place_of_supply and party_details.place_of_supply)
else get_place_of_supply(party_details, doctype)
)
if not update_place_of_supply and party_details.place_of_supply:
gst_details.place_of_supply = party_details.place_of_supply
else:
place_of_supply = get_place_of_supply(party_details, doctype)
gst_details.place_of_supply = place_of_supply
party_details.place_of_supply = place_of_supply

# set is_reverse_charge as per party_gst_details if not set
if not is_sales_transaction and "is_reverse_charge" not in party_details:
Expand Down Expand Up @@ -1091,11 +1092,7 @@ def get_gst_details(party_details, doctype, company, *, update_place_of_supply=F
if default_tax := get_tax_template(
master_doctype,
company,
is_inter_state_supply(
party_details.copy().update(
doctype=doctype, place_of_supply=gst_details.place_of_supply
),
),
is_inter_state_supply(frappe._dict({**party_details, "doctype": doctype})),
party_details.get(company_gstin_field)[:2],
party_details.is_reverse_charge,
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ def get_columns(filters):

columns.extend(
[
{
"label": _("Item Qty"),
"fieldname": "qty",
"fieldtype": "Data",
"width": 100,
},
{
"label": _("HSN Code"),
"fieldname": "gst_hsn_code",
Expand Down
5 changes: 5 additions & 0 deletions india_compliance/gst_india/utils/e_waybill.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ def _generate_e_waybill(doc, throw=True, force=False):
if result.error_code == "4002":
result = api(doc).get_e_waybill_by_irn(doc.get("irn"))

if result.error_code == "2148":
with_irn = False
data = EWaybillData(doc).get_data(with_irn=with_irn)
result = EWaybillAPI(doc).generate_e_waybill(data)

except GSPServerError as e:
handle_server_errors(settings, doc, "e-Waybill", e)
return
Expand Down
1 change: 1 addition & 0 deletions india_compliance/gst_india/utils/gstr_1/gstr_1_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ def get_invoices_for_hsn_wise_summary(self):
frappe.qb.from_(query)
.select(
"*",
Sum(query.qty).as_("qty"),
Sum(query.taxable_value).as_("taxable_value"),
Sum(query.cgst_amount).as_("cgst_amount"),
Sum(query.sgst_amount).as_("sgst_amount"),
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 2e796bc

Please sign in to comment.