Skip to content

Commit

Permalink
feat: suggest default HSN in item from item group (#2361)
Browse files Browse the repository at this point in the history
fetch `HSN Code` in Item from Item Group.
closes: #234
  • Loading branch information
Sanket322 authored Jul 12, 2024
1 parent d9818bd commit c28ea60
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions india_compliance/gst_india/constants/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,8 @@
"fieldtype": "Link",
"options": "GST HSN Code",
"insert_after": "item_group",
"fetch_from": "item_group.gst_hsn_code",
"fetch_if_empty": 1,
"allow_in_quick_entry": 1,
"mandatory_depends_on": "eval:gst_settings.validate_hsn_code && doc.is_sales_item",
"description": "You can search code by the description of the category.",
Expand All @@ -926,6 +928,16 @@
"insert_after": "item_tax_section_break",
},
],
"Item Group": [
{
"fieldname": "gst_hsn_code",
"label": "HSN/SAC",
"fieldtype": "Link",
"options": "GST HSN Code",
"insert_after": "defaults",
"description": "You can search code by the description of the category.",
},
],
"Item Tax Template": [
{
"fieldname": "gst_treatment",
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() #50
execute:from india_compliance.gst_india.setup import create_custom_fields; create_custom_fields() #51
execute:from india_compliance.gst_india.setup import create_property_setters; create_property_setters() #7
execute:from india_compliance.income_tax_india.setup import create_custom_fields; create_custom_fields() #1
india_compliance.patches.post_install.remove_old_fields #1
Expand Down
15 changes: 15 additions & 0 deletions india_compliance/public/js/quick_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,21 @@ class ItemQuickEntryForm extends frappe.ui.form.QuickEntryForm {
render_dialog() {
super.render_dialog();
india_compliance.set_hsn_code_query(this.dialog.get_field("gst_hsn_code"));

this.set_hsn_from_item_group();
}

set_hsn_from_item_group() {
let item_group_field = this.dialog.fields_dict.item_group;

item_group_field.df.onchange = async () => {
const { message } = await frappe.db.get_value(
"Item Group",
item_group_field.value,
"gst_hsn_code"
);
this.dialog.set_value("gst_hsn_code", message.gst_hsn_code);
};
}
}

Expand Down

0 comments on commit c28ea60

Please sign in to comment.