Skip to content

Commit

Permalink
feat:add validation for Item Wise Stone Details
Browse files Browse the repository at this point in the history
  • Loading branch information
avishna-avi committed Feb 13, 2025
1 parent 3c2b884 commit 3a95465
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"options": "AuMMS Item"
},
{
"default": "Gram",
"fieldname": "uom",
"fieldtype": "Link",
"in_list_view": 1,
Expand Down Expand Up @@ -56,7 +57,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-08-20 10:07:11.991708",
"modified": "2025-02-13 15:16:58.071888",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Item Wise Stone Details",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@
"fieldname": "stone_weight_gold_weight_uom",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Stone Weight (Gold Weight UOM)"
"label": "Stone Weight (Gold Weight UOM)",
"read_only": 1
},
{
"default": "Gram",
Expand Down Expand Up @@ -233,7 +234,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2025-01-20 12:56:15.072112",
"modified": "2025-02-13 15:11:59.142367",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Jewellery Item Receipt",
Expand Down
28 changes: 22 additions & 6 deletions aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ frappe.ui.form.on("Jewellery Receipt", {
});
set_sub_category_filter(frm);
},
onload: function (frm) {
frm.fields_dict["item_wise_stone_details"].grid.cannot_add_rows = true;
frm.refresh_field("item_wise_stone_details");
},
item_sub_category: function (frm) {
frm.events.update_item_details_table(frm);
},
Expand Down Expand Up @@ -202,15 +206,27 @@ frappe.ui.form.on("Jewellery Item Receipt", {
},
add_stone: function (frm, cdt, cdn) {
let row = locals[cdt][cdn];
if (row.has_stone) {
if (!row.stone || !row.stone_uom || !row.stone_weight || !row.rate) {
frappe.msgprint(__(
'Please ensure all stone details are filled before adding.'));
return;
}

frm.add_child("item_wise_stone_details", {
reference: row.idx,
stone: row.stone,
uom: row.stone_uom,
stone_weight: row.stone_weight,
rate: row.rate,
amount: row.rate * row.stone_weight,
reference: row.idx,
stone: row.stone,
uom: row.stone_uom,
stone_weight: row.stone_weight,
rate: row.rate,
amount: row.rate * row.stone_weight,
});

frm.refresh_field("item_wise_stone_details");
} else {
frappe.msgprint(__('Has Stone must be checked to add a stone.'));
}

if (row.stone_weight_gold_weight_uom)
row.stone_weight_gold_weight_uom += row.stone_weight;
else row.stone_weight_gold_weight_uom = row.stone_weight;
Expand Down
5 changes: 2 additions & 3 deletions aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@
"fieldname": "item_wise_stone_details",
"fieldtype": "Table",
"label": "Item Wise Stone Details",
"options": "Item Wise Stone Details",
"read_only": 1
"options": "Item Wise Stone Details"
},
{
"fieldname": "item_sub_category",
Expand All @@ -135,7 +134,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2025-01-20 14:25:31.637164",
"modified": "2025-02-13 15:28:43.982739",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Jewellery Receipt",
Expand Down

0 comments on commit 3a95465

Please sign in to comment.