From cc9aa80395658e97aa75b219c1b2f5e5f87bdfc4 Mon Sep 17 00:00:00 2001 From: Geethu K Date: Wed, 21 Feb 2024 14:44:25 +0530 Subject: [PATCH] feat:jewellery_receipt_has_stone --- .../jewellery_item_receipt.json | 59 +++++----- .../jewellery_receipt/jewellery_receipt.js | 42 +++++-- .../jewellery_receipt/jewellery_receipt.py | 1 + .../purchase_item_details.json | 106 ------------------ 4 files changed, 66 insertions(+), 142 deletions(-) delete mode 100644 aumms/aumms/doctype/purchase_item_details/purchase_item_details.json diff --git a/aumms/aumms/doctype/jewellery_item_receipt/jewellery_item_receipt.json b/aumms/aumms/doctype/jewellery_item_receipt/jewellery_item_receipt.json index 9a379fea..1574813b 100644 --- a/aumms/aumms/doctype/jewellery_item_receipt/jewellery_item_receipt.json +++ b/aumms/aumms/doctype/jewellery_item_receipt/jewellery_item_receipt.json @@ -16,7 +16,8 @@ "stone", "stone_charge", "making_charge", - "amount" + "amount", + "has_stone" ], "fields": [ { @@ -24,6 +25,21 @@ "fieldtype": "Column Break", "label": "Item Details " }, + { + "fieldname": "item_code", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Item Code", + "read_only": 1 + }, + { + "fieldname": "uom", + "fieldtype": "Link", + "in_list_view": 1, + "label": "UOM", + "options": "UOM", + "reqd": 1 + }, { "fieldname": "gold_weight", "fieldtype": "Float", @@ -32,17 +48,17 @@ "reqd": 1 }, { - "fieldname": "net_weight", + "depends_on": "eval:doc.stone", + "fieldname": "stone_weight", "fieldtype": "Float", "in_list_view": 1, - "label": "Net Weight", - "read_only": 1 + "label": "Stone Weight" }, { - "fieldname": "amount", + "fieldname": "net_weight", "fieldtype": "Float", "in_list_view": 1, - "label": "Amount", + "label": "Net Weight", "read_only": 1 }, { @@ -56,13 +72,6 @@ "label": "Stone", "read_only": 1 }, - { - "depends_on": "eval:doc.stone", - "fieldname": "stone_weight", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Stone Weight" - }, { "depends_on": "eval:doc.stone", "fieldname": "stone_charge", @@ -71,32 +80,30 @@ "label": "Stone Charge" }, { - "fieldname": "uom", - "fieldtype": "Link", + "fieldname": "making_charge", + "fieldtype": "Currency", "in_list_view": 1, - "label": "UOM", - "options": "UOM", + "label": "Making Charge", "reqd": 1 }, { - "fieldname": "item_code", - "fieldtype": "Data", + "fieldname": "amount", + "fieldtype": "Float", "in_list_view": 1, - "label": "Item Code", + "label": "Amount", "read_only": 1 }, { - "fieldname": "making_charge", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Making Charge", - "reqd": 1 + "default": "0", + "fieldname": "has_stone", + "fieldtype": "Check", + "label": "has Stone" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-02-19 12:22:43.830822", + "modified": "2024-02-21 12:54:33.716315", "modified_by": "Administrator", "module": "AuMMS", "name": "Jewellery Item Receipt", diff --git a/aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.js b/aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.js index 4de034f2..f94eb2c5 100644 --- a/aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.js +++ b/aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.js @@ -3,17 +3,35 @@ frappe.ui.form.on("Jewellery Receipt", { refresh:function(frm) { - // show only customers whose territory is set to India frm.set_query('stone', () => { - return { - filters: { - is_stone_item: 1 - } + return { + filters: { + is_stone_item: 1 } + } }) - }, + has_stone: function (frm) { + if(!frm.doc.has_stone){ + frm.set_value('stone', ); + } + frm.fields_dict.item_details.grid.toggle_enable('has_stone', frm.doc.has_stone); + frm.refresh_fields(); + frm.trigger('update_item_details'); + }, + stone: function(frm){ + frm.trigger('update_item_details'); + }, + update_item_details: function(frm){ + if(frm.doc.item_details){ + frm.doc.item_details.forEach(function(item){ + frappe.model.set_value(item.doctype, item.name, 'has_stone', frm.doc.has_stone); + frappe.model.set_value(item.doctype, item.name, 'stone', frm.doc.stone); + }); + } + frm.refresh_fields(); + } }); frappe.ui.form.on("Jewellery Item Receipt", { @@ -22,13 +40,20 @@ frappe.ui.form.on("Jewellery Item Receipt", { if (frm.doc.stone) { frappe.model.set_value(child.doctype, child.name, 'stone', frm.doc.stone); } + if (frm.doc.has_stone) { + frappe.model.set_value(child.doctype, child.name, 'has_stone', frm.doc.has_stone); + frm.refresh_fields(); + } + else{ + frappe.model.set_value(child.doctype, child.name, 'has_stone', 0); + } }, stone_weight: function(frm, cdt, cdn) { let d = locals[cdt][cdn]; if (frm.doc.has_stone) { let net_weight = d.gold_weight + d.stone_weight; frappe.model.set_value(cdt, cdn, 'net_weight', net_weight); - } + }frm.fields_dict.item_details.grid.toggle_enable('has_stone', frm.doc.has_stone);frm.fields_dict.item_details.grid.toggle_enable('has_stone', frm.doc.has_stone); }, gold_weight: function(frm, cdt, cdn) { let d = locals[cdt][cdn]; @@ -49,6 +74,3 @@ frappe.ui.form.on("Jewellery Item Receipt", { } } }); -frappe.ui.form.on("Jewellery Item Receipt", { - -}); diff --git a/aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.py b/aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.py index b348df57..3295daee 100644 --- a/aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.py +++ b/aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.py @@ -48,6 +48,7 @@ def create_item(self): aumms_item.weight_per_unit = item_detail.net_weight aumms_item.weight_uom = item_detail.uom aumms_item.has_stone = self.has_stone + aumms_item.gold_weight = item_detail.gold_weight # If has_stone is checked, fetch stone details from item_detail if self.has_stone: aumms_item.append('stone_details', { diff --git a/aumms/aumms/doctype/purchase_item_details/purchase_item_details.json b/aumms/aumms/doctype/purchase_item_details/purchase_item_details.json deleted file mode 100644 index 03d9ba27..00000000 --- a/aumms/aumms/doctype/purchase_item_details/purchase_item_details.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "actions": [], - "allow_rename": 1, - "creation": "2024-02-12 23:46:19.937061", - "doctype": "DocType", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "item_details_column", - "item_code", - "gold_weight", - "net_weight", - "uom", - "column_break_juco", - "stone", - "stone_weight", - "stone_charge", - "purity", - "amount" - ], - "fields": [ - { - "fieldname": "item_details_column", - "fieldtype": "Column Break", - "label": "Item Details " - }, - { - "fieldname": "gold_weight", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Gold Weight" - }, - { - "fieldname": "net_weight", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Net Weight", - "read_only": 1 - }, - { - "fieldname": "amount", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Amount", - "read_only": 1 - }, - { - "fieldname": "column_break_juco", - "fieldtype": "Column Break" - }, - { - "fieldname": "stone", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Stone", - "read_only": 1 - }, - { - "depends_on": "eval:doc.stone", - "fieldname": "stone_weight", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Stone Weight" - }, - { - "depends_on": "eval:doc.stone", - "fieldname": "stone_charge", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Stone Charge" - }, - { - "fieldname": "purity", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Purity", - "options": "Purity" - }, - { - "fieldname": "uom", - "fieldtype": "Link", - "in_list_view": 1, - "label": "UOM", - "options": "UOM" - }, - { - "fieldname": "item_code", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Item Code", - "read_only": 1 - } - ], - "index_web_pages_for_search": 1, - "istable": 1, - "links": [], - "modified": "2024-02-16 15:46:24.566785", - "modified_by": "Administrator", - "module": "AuMMS", - "name": "Purchase Item Details", - "owner": "Administrator", - "permissions": [], - "sort_field": "modified", - "sort_order": "DESC", - "states": [] -}