diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index 4438acf8118..3e8ac1f19f8 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -55,6 +55,25 @@ frappe.ui.form.on("Stock Reconciliation", { } }, + scan_barcode: function(frm) { + const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:frm}); + barcode_scanner.process_scan(); + }, + + scan_mode: function(frm) { + if (frm.doc.scan_mode) { + frappe.show_alert({ + message: __("Scan mode enabled, existing quantity will not be fetched."), + indicator: "green" + }); + } + }, + + set_warehouse: function(frm) { + let transaction_controller = new erpnext.TransactionController({frm:frm}); + transaction_controller.autofill_warehouse(frm.doc.items, "warehouse", frm.doc.set_warehouse); + }, + get_items: function(frm) { let fields = [ { @@ -148,15 +167,18 @@ frappe.ui.form.on("Stock Reconciliation", { batch_no: d.batch_no }, callback: function(r) { - frappe.model.set_value(cdt, cdn, "qty", r.message.qty); + const row = frappe.model.get_doc(cdt, cdn); + if (!frm.doc.scan_mode) { + frappe.model.set_value(cdt, cdn, "qty", r.message.qty); + } frappe.model.set_value(cdt, cdn, "valuation_rate", r.message.rate); frappe.model.set_value(cdt, cdn, "current_qty", r.message.qty); frappe.model.set_value(cdt, cdn, "current_valuation_rate", r.message.rate); frappe.model.set_value(cdt, cdn, "current_amount", r.message.rate * r.message.qty); - frappe.model.set_value(cdt, cdn, "amount", r.message.rate * r.message.qty); + frappe.model.set_value(cdt, cdn, "amount", row.qty * row.valuation_rate); frappe.model.set_value(cdt, cdn, "current_serial_no", r.message.serial_nos); - if (frm.doc.purpose == "Stock Reconciliation") { + if (frm.doc.purpose == "Stock Reconciliation" && !frm.doc.scan_mode) { frappe.model.set_value(cdt, cdn, "serial_no", r.message.serial_nos); } } @@ -239,7 +261,14 @@ frappe.ui.form.on("Stock Reconciliation Item", { const serial_nos = child.serial_no.trim().split('\n'); frappe.model.set_value(cdt, cdn, "qty", serial_nos.length); } - } + }, + + items_add: function(frm, cdt, cdn) { + var item = frappe.get_doc(cdt, cdn); + if (!item.warehouse && frm.doc.set_warehouse) { + frappe.model.set_value(cdt, cdn, "warehouse", frm.doc.set_warehouse); + } + }, }); diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json index a882a61e5a5..e545b8ea5c3 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json @@ -14,6 +14,12 @@ "posting_date", "posting_time", "set_posting_time", + "section_break_8", + "set_warehouse", + "section_break_22", + "scan_barcode", + "column_break_12", + "scan_mode", "sb9", "items", "section_break_9", @@ -139,13 +145,44 @@ { "fieldname": "dimension_col_break", "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_8", + "fieldtype": "Section Break" + }, + { + "fieldname": "scan_barcode", + "fieldtype": "Data", + "label": "Scan Barcode", + "options": "Barcode" + }, + { + "default": "0", + "description": "Disables auto-fetching of existing quantity", + "fieldname": "scan_mode", + "fieldtype": "Check", + "label": "Scan Mode" + }, + { + "fieldname": "set_warehouse", + "fieldtype": "Link", + "label": "Default Warehouse", + "options": "Warehouse" + }, + { + "fieldname": "section_break_22", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_12", + "fieldtype": "Column Break" } ], "icon": "fa fa-upload-alt", "idx": 1, "is_submittable": 1, "links": [], - "modified": "2022-02-06 14:28:19.043905", + "modified": "2022-03-27 08:57:47.161959", "modified_by": "Administrator", "module": "Stock", "name": "Stock Reconciliation",