feat: button to get Scrap Items
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js
index 94a2589..3824853 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js
@@ -204,6 +204,10 @@
rate(frm) {
set_missing_values(frm);
},
+
+ items_remove: function(frm) {
+ set_missing_values(frm);
+ }
});
frappe.ui.form.on('Subcontracting Receipt Supplied Item', {
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json
index 4b3cc83..95fe087 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json
@@ -40,6 +40,7 @@
"col_break_warehouse",
"supplier_warehouse",
"items_section",
+ "get_scrap_items",
"items",
"section_break0",
"total_qty",
@@ -626,12 +627,18 @@
"fieldtype": "Check",
"label": "Edit Posting Date and Time",
"print_hide": 1
+ },
+ {
+ "fieldname": "get_scrap_items",
+ "fieldtype": "Button",
+ "label": "Get Scrap Items",
+ "options": "get_scrap_items"
}
],
"in_create": 1,
"is_submittable": 1,
"links": [],
- "modified": "2023-07-06 18:43:16.171842",
+ "modified": "2023-08-25 10:02:11.546559",
"modified_by": "Administrator",
"module": "Subcontracting",
"name": "Subcontracting Receipt",
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
index 36be4d1..5f64ab1 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
@@ -147,6 +147,7 @@
):
self.supplied_items = []
+ @frappe.whitelist()
def get_scrap_items(self):
if (
frappe.db.get_single_value("Buying Settings", "backflush_raw_materials_of_subcontract_based_on")
@@ -176,11 +177,16 @@
"recalculate_rate": 0,
},
)
+ else:
+ self.calculate_additional_costs()
+ self.calculate_items_qty_and_amount()
def remove_scrap_items(self):
for item in list(self.items):
if item.is_scrap_item:
self.remove(item)
+ else:
+ item.scrap_cost_per_qty = 0
@frappe.whitelist()
def set_missing_values(self):
@@ -239,6 +245,8 @@
scrap_cost_map[item.reference_name] += item.amount
else:
scrap_cost_map[item.reference_name] = item.amount
+ else:
+ item.scrap_cost_per_qty = 0
total_qty = total_amount = 0
for item in self.items: