mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
feat: Validity for Item taxes (#20136)
* feat: Validity for Item taxes * fix: Add HSN wise taxes * fix: Sort taxes based on validity * fix: Validation for item tax template and filters based on validity * fix: Add missing semicolon * fix: Validate tax template only if item code available * fix: Do not validate or filter item tax template if no item taxes applied * fix: Consider item group for validating taxes * fix: Test cases for item tax validation * fix: Item tax template filtering fixes * fix: Add missing semicolon * fix: Remove unnecessary query
This commit is contained in:
@@ -3,6 +3,26 @@
|
||||
|
||||
frappe.ui.form.on('GST HSN Code', {
|
||||
refresh: function(frm) {
|
||||
|
||||
if(! frm.doc.__islocal && frm.doc.taxes.length){
|
||||
frm.add_custom_button(__('Update Taxes for Items'), function(){
|
||||
frappe.confirm(
|
||||
'Are you sure? It will overwrite taxes for all items with HSN Code <b>'+frm.doc.name+'</b>.',
|
||||
function(){
|
||||
frappe.call({
|
||||
args:{
|
||||
taxes: frm.doc.taxes,
|
||||
hsn_code: frm.doc.name
|
||||
},
|
||||
method: 'erpnext.regional.doctype.gst_hsn_code.gst_hsn_code.update_taxes_in_item_master',
|
||||
callback: function(r) {
|
||||
if(r.message){
|
||||
frappe.show_alert(__('Item taxes updated'));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,104 +1,48 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"autoname": "field:hsn_code",
|
||||
"beta": 0,
|
||||
"creation": "2017-06-21 10:48:56.422086",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"actions": [],
|
||||
"autoname": "field:hsn_code",
|
||||
"creation": "2017-06-21 10:48:56.422086",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"hsn_code",
|
||||
"description",
|
||||
"taxes"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "hsn_code",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "HSN Code",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
"fieldname": "hsn_code",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "HSN Code",
|
||||
"reqd": 1,
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Description",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"in_list_view": 1,
|
||||
"label": "Description"
|
||||
},
|
||||
{
|
||||
"fieldname": "taxes",
|
||||
"fieldtype": "Table",
|
||||
"label": "Taxes",
|
||||
"options": "Item Tax"
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 0,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-09-29 14:38:52.220743",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Regional",
|
||||
"name": "GST HSN Code",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"quick_entry": 1,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"search_fields": "hsn_code, description",
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"title_field": "hsn_code",
|
||||
"track_changes": 1,
|
||||
"track_seen": 0
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2019-12-29 11:32:06.849631",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Regional",
|
||||
"name": "GST HSN Code",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"quick_entry": 1,
|
||||
"search_fields": "hsn_code, description",
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"title_field": "hsn_code",
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -8,3 +8,26 @@ from frappe.model.document import Document
|
||||
|
||||
class GSTHSNCode(Document):
|
||||
pass
|
||||
|
||||
@frappe.whitelist()
|
||||
def update_taxes_in_item_master(taxes, hsn_code):
|
||||
items = frappe.get_list("Item", filters={
|
||||
'gst_hsn_code': hsn_code
|
||||
})
|
||||
|
||||
taxes = frappe.parse_json(taxes)
|
||||
frappe.enqueue(update_item_document, items=items, taxes=taxes)
|
||||
return 1
|
||||
|
||||
def update_item_document(items, taxes):
|
||||
for item in items:
|
||||
item_to_be_updated=frappe.get_doc("Item", item.name)
|
||||
item_to_be_updated.taxes = []
|
||||
for tax in taxes:
|
||||
tax = frappe._dict(tax)
|
||||
item_to_be_updated.append("taxes", {
|
||||
'item_tax_template': tax.item_tax_template,
|
||||
'tax_category': tax.tax_category,
|
||||
'valid_from': tax.valid_from
|
||||
})
|
||||
item_to_be_updated.save()
|
||||
|
||||
Reference in New Issue
Block a user