Skip to content

Commit

Permalink
feat:Calculation of amount in customer jewellery Order
Browse files Browse the repository at this point in the history
  • Loading branch information
G-eethu committed May 14, 2024
1 parent 9a03758 commit 92fa4c4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function calculate_amount(frm, cdt, cdn){
frappe.model.set_value(cdt, cdn, 'amount_without_making_charge', 0);
}
if(child.making_chargein_percentage && child.amount_without_making_charge){
frappe.model.set_value(cdt, cdn, 'amount', child.amount_without_making_charge * (child.making_chargein_percentage/100));
frappe.model.set_value(cdt, cdn, 'amount', child.amount_without_making_charge + (child.making_chargein_percentage/100));
}
else{
frappe.model.set_value(cdt, cdn, 'amount', 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ frappe.ui.form.on("Jewellery Order", {
}
}
});
if (!frm.doc.weight_of_available_item)
{
frm.toggle_display("weight_of_available_item", false);
}
limit_item_details(frm)
calculate_weight(frm)
},
quantity: function(frm) {
limit_item_details(frm)
Expand All @@ -37,33 +42,11 @@ frappe.ui.form.on("Jewellery Order", {

frappe.ui.form.on("Jewellery Order Item", {
weight: function(frm, cdt, cdn) {
let weight_of_available_item = 0;
let total_weight = 0;
if(frm.doc.jewellery_order_items){
frm.doc.jewellery_order_items.forEach(function(d) {
if (d.is_available) {
weight_of_available_item += d.weight || 0;
}
total_weight += d.weight || 0;
});
}
frm.set_value('weight_of_available_item', weight_of_available_item);
frm.set_value('total_weight', total_weight);
calculate_weight(frm);
},

jewellery_order_items_remove: function(frm) {
let total_weightage = 0;
let total_weight = 0;
if(frm.doc.jewellery_order_items){
frm.doc.jewellery_order_items.forEach(function(d) {
if (d.is_available) {
total_weightage += d.weight || 0;
}
total_weight += d.weight || 0;
});
}
frm.set_value('weight_of_available_item', total_weightage);
frm.set_value('total_weight', total_weight);
calculate_weight(frm);
update_available_item_quantity(frm);
check_finished(frm);
},
Expand Down Expand Up @@ -159,3 +142,18 @@ function check_finished(frm) {
}
frm.set_value('finished', all_available ? 1 : 0);
}

function calculate_weight(frm, cdt,cdn) {
let weight_of_available_item = 0;
let total_weight = 0;
if(frm.doc.jewellery_order_items){
frm.doc.jewellery_order_items.forEach(function(d) {
if (d.is_available) {
weight_of_available_item += d.weight || 0;
}
total_weight += d.weight || 0;
});
}
frm.set_value('weight_of_available_item', weight_of_available_item);
frm.set_value('total_weight', total_weight);
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"read_only": 1
},
{
"depends_on": "eval:doc.previous_stage_completed == 1",
"depends_on": "eval:doc.previous_stage_completed == 1 && doc.is_first_stage == 0",
"fieldname": "previous_stage_weight",
"fieldtype": "Float",
"label": "Previous Stage Weight",
Expand All @@ -189,7 +189,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-05-10 13:01:39.150002",
"modified": "2024-05-10 16:15:36.511365",
"modified_by": "Administrator",
"module": "AuMMS Manufacturing",
"name": "Manufacturing Stage",
Expand Down

0 comments on commit 92fa4c4

Please sign in to comment.