* fix: fetching of item tax from hsn code
(cherry picked from commit 3a50490c04)
Co-authored-by: Saqib <nextchamp.saqib@gmail.com>
This commit is contained in:
@@ -430,7 +430,8 @@ regional_overrides = {
|
|||||||
'erpnext.hr.utils.calculate_annual_eligible_hra_exemption': 'erpnext.regional.india.utils.calculate_annual_eligible_hra_exemption',
|
'erpnext.hr.utils.calculate_annual_eligible_hra_exemption': 'erpnext.regional.india.utils.calculate_annual_eligible_hra_exemption',
|
||||||
'erpnext.hr.utils.calculate_hra_exemption_for_period': 'erpnext.regional.india.utils.calculate_hra_exemption_for_period',
|
'erpnext.hr.utils.calculate_hra_exemption_for_period': 'erpnext.regional.india.utils.calculate_hra_exemption_for_period',
|
||||||
'erpnext.controllers.accounts_controller.validate_einvoice_fields': 'erpnext.regional.india.e_invoice.utils.validate_einvoice_fields',
|
'erpnext.controllers.accounts_controller.validate_einvoice_fields': 'erpnext.regional.india.e_invoice.utils.validate_einvoice_fields',
|
||||||
'erpnext.assets.doctype.asset.asset.get_depreciation_amount': 'erpnext.regional.india.utils.get_depreciation_amount'
|
'erpnext.assets.doctype.asset.asset.get_depreciation_amount': 'erpnext.regional.india.utils.get_depreciation_amount',
|
||||||
|
'erpnext.stock.doctype.item.item.set_item_tax_from_hsn_code': 'erpnext.regional.india.utils.set_item_tax_from_hsn_code'
|
||||||
},
|
},
|
||||||
'United Arab Emirates': {
|
'United Arab Emirates': {
|
||||||
'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.united_arab_emirates.utils.update_itemised_tax_data',
|
'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.united_arab_emirates.utils.update_itemised_tax_data',
|
||||||
|
|||||||
@@ -852,3 +852,14 @@ def get_depreciation_amount(asset, depreciable_value, row):
|
|||||||
depreciation_amount = flt(depreciable_value * (flt(rate_of_depreciation) / 100))
|
depreciation_amount = flt(depreciable_value * (flt(rate_of_depreciation) / 100))
|
||||||
|
|
||||||
return depreciation_amount
|
return depreciation_amount
|
||||||
|
|
||||||
|
def set_item_tax_from_hsn_code(item):
|
||||||
|
if not item.taxes and item.gst_hsn_code:
|
||||||
|
hsn_doc = frappe.get_doc("GST HSN Code", item.gst_hsn_code)
|
||||||
|
|
||||||
|
for tax in hsn_doc.taxes:
|
||||||
|
item.append('taxes', {
|
||||||
|
'item_tax_template': tax.item_tax_template,
|
||||||
|
'tax_category': tax.tax_category,
|
||||||
|
'valid_from': tax.valid_from
|
||||||
|
})
|
||||||
@@ -138,20 +138,6 @@ frappe.ui.form.on("Item", {
|
|||||||
frm.toggle_reqd('customer', frm.doc.is_customer_provided_item ? 1:0);
|
frm.toggle_reqd('customer', frm.doc.is_customer_provided_item ? 1:0);
|
||||||
},
|
},
|
||||||
|
|
||||||
gst_hsn_code: function(frm) {
|
|
||||||
if((!frm.doc.taxes || !frm.doc.taxes.length) && frm.doc.gst_hsn_code) {
|
|
||||||
frappe.db.get_doc("GST HSN Code", frm.doc.gst_hsn_code).then(hsn_doc => {
|
|
||||||
$.each(hsn_doc.taxes || [], function(i, tax) {
|
|
||||||
let a = frappe.model.add_child(cur_frm.doc, 'Item Tax', 'taxes');
|
|
||||||
a.item_tax_template = tax.item_tax_template;
|
|
||||||
a.tax_category = tax.tax_category;
|
|
||||||
a.valid_from = tax.valid_from;
|
|
||||||
frm.refresh_field('taxes');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
is_fixed_asset: function(frm) {
|
is_fixed_asset: function(frm) {
|
||||||
// set serial no to false & toggles its visibility
|
// set serial no to false & toggles its visibility
|
||||||
frm.set_value('has_serial_no', 0);
|
frm.set_value('has_serial_no', 0);
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ class Item(WebsiteGenerator):
|
|||||||
self.cant_change()
|
self.cant_change()
|
||||||
self.update_show_in_website()
|
self.update_show_in_website()
|
||||||
self.validate_item_tax_net_rate_range()
|
self.validate_item_tax_net_rate_range()
|
||||||
|
set_item_tax_from_hsn_code(self)
|
||||||
|
|
||||||
if not self.is_new():
|
if not self.is_new():
|
||||||
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
|
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
|
||||||
@@ -1305,3 +1306,7 @@ def update_variants(variants, template, publish_progress=True):
|
|||||||
def on_doctype_update():
|
def on_doctype_update():
|
||||||
# since route is a Text column, it needs a length for indexing
|
# since route is a Text column, it needs a length for indexing
|
||||||
frappe.db.add_index("Item", ["route(500)"])
|
frappe.db.add_index("Item", ["route(500)"])
|
||||||
|
|
||||||
|
@erpnext.allow_regional
|
||||||
|
def set_item_tax_from_hsn_code(item):
|
||||||
|
pass
|
||||||
15
erpnext/stock/doctype/item/regional/india.js
Normal file
15
erpnext/stock/doctype/item/regional/india.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
frappe.ui.form.on('Item', {
|
||||||
|
gst_hsn_code: function(frm) {
|
||||||
|
if ((!frm.doc.taxes || !frm.doc.taxes.length) && frm.doc.gst_hsn_code) {
|
||||||
|
frappe.db.get_doc("GST HSN Code", frm.doc.gst_hsn_code).then(hsn_doc => {
|
||||||
|
$.each(hsn_doc.taxes || [], function(i, tax) {
|
||||||
|
let a = frappe.model.add_child(cur_frm.doc, 'Item Tax', 'taxes');
|
||||||
|
a.item_tax_template = tax.item_tax_template;
|
||||||
|
a.tax_category = tax.tax_category;
|
||||||
|
a.valid_from = tax.valid_from;
|
||||||
|
frm.refresh_field('taxes');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user