Skip to content

Commit

Permalink
fix: update hsn code from fee category on creation of item
Browse files Browse the repository at this point in the history
(cherry picked from commit c516f16)
  • Loading branch information
vorasmit authored and mergify[bot] committed Nov 7, 2024
1 parent eb5daee commit e458e51
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions india_compliance/gst_india/overrides/fee_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import frappe


def before_update(doc, method=None):
if doc.gst_hsn_code:
frappe.flags.category_hsn_code = doc.gst_hsn_code
12 changes: 12 additions & 0 deletions india_compliance/gst_india/overrides/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@


def validate(doc, method=None):
update_hsn_code(doc)
validate_hsn_code(doc)
set_taxes_from_hsn_code(doc)


def update_hsn_code(doc):
"""
Update HSN Code from Fee Category (education)
"""
if not frappe.flags.category_hsn_code:
return

doc.gst_hsn_code = frappe.flags.category_hsn_code
del frappe.flags.category_hsn_code


def validate_hsn_code(doc):
# HSN Code is being validated only for sales items
if not doc.is_sales_item:
Expand Down
4 changes: 4 additions & 0 deletions india_compliance/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@
"validate": "india_compliance.audit_trail.overrides.version.validate",
"on_trash": "india_compliance.audit_trail.overrides.version.on_trash",
},
"Fee Category": {
"before_insert": "india_compliance.gst_india.overrides.fee_category.before_update",
"before_validate": "india_compliance.gst_india.overrides.fee_category.before_update",
},
}


Expand Down

0 comments on commit e458e51

Please sign in to comment.