From a88dec8775f582670cbd719c1447bae7962f89c6 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Sat, 30 Jul 2016 16:49:48 +0530 Subject: [PATCH] [Fix] batch no searching in pos --- erpnext/accounts/doctype/sales_invoice/pos.py | 4 ++-- erpnext/accounts/page/pos/pos.js | 8 ++++---- .../projects/doctype/timesheet/timesheet.js | 1 - .../public/js/controllers/taxes_and_totals.js | 2 +- erpnext/public/js/payment/payments.js | 20 ++++++++++++++++--- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index 605bf097f7c..9f64e075d63 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -20,7 +20,7 @@ def get_pos_data(): if pos_profile.get('name'): pos_profile = frappe.get_doc('POS Profile', pos_profile.get('name')) else: - frappe.msgprint('' + frappe.msgprint('' + _("Welcome to POS: Create your POS Profile") + ''); update_pos_profile_data(doc, pos_profile) @@ -115,7 +115,7 @@ def get_items(doc, pos_profile): item.actual_qty = frappe.db.get_value('Bin', {'item_code': item.name, 'warehouse': item.default_warehouse}, 'actual_qty') or 0 item.serial_nos = get_serial_nos(item, pos_profile) - item.batch_nos = frappe.db.sql_list("""select name from `tabBatch` where expiry_date > curdate() + item.batch_nos = frappe.db.sql_list("""select name from `tabBatch` where ifnull(expiry_date, '4000-10-10') > curdate() and item = %(item_code)s""", {'item_code': item.item_code}) item_list.append(item) diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index a89f40e0ba7..183010387ce 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -423,16 +423,16 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ if(key){ return $.grep(window.items, function(item){ - if( (item.item_code.toLowerCase().match(key)) || - (item.item_name.toLowerCase().match(key)) || (item.item_group.toLowerCase().match(key)) ){ + if(in_list(item.batch_nos, me.search.$input.val())){ + return me.item_batch_no[item.item_code] = me.search.$input.val() + } else if((item.item_code.toLowerCase().match(key)) || + (item.item_name.toLowerCase().match(key)) || (item.item_group.toLowerCase().match(key))){ return true }else if(item.barcode == me.search.$input.val()){ return item.barcode == me.search.$input.val(); } else if (in_list(Object.keys(item.serial_nos), me.search.$input.val())){ me.item_serial_no[item.item_code] = [me.search.$input.val(), item.serial_nos[me.search.$input.val()]] return true - } else if(in_list(item.batch_nos, me.search.$input.val())){ - return me.item_batch_no[item.item_code] = me.search.$input.val() } }) }else{ diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index f3dfefa7d0c..e2e6459b0a1 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -31,7 +31,6 @@ frappe.ui.form.on("Timesheet", { onload: function(frm){ if (frm.doc.__islocal && frm.doc.time_logs) { - frm.set_value("employee", "") calculate_time_and_amount(frm); } }, diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 8405e3d3c99..34c4557813f 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -582,7 +582,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ set_default_payment: function(total_amount_to_pay, update_paid_amount){ var me = this; payment_status = true; - if(this.frm.doc.is_pos && (!this.frm.doc.paid_amount || update_paid_amount===undefined || update_paid_amount)){ + if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)){ $.each(this.frm.doc['payments'] || [], function(index, data){ if(data.type == "Cash" && payment_status) { data.amount = total_amount_to_pay; diff --git a/erpnext/public/js/payment/payments.js b/erpnext/public/js/payment/payments.js index 0638b84ffa8..7437f2a648d 100644 --- a/erpnext/public/js/payment/payments.js +++ b/erpnext/public/js/payment/payments.js @@ -57,6 +57,13 @@ erpnext.payments = erpnext.stock.StockController.extend({ currency: me.frm.doc.currency, type: data.type })).appendTo(multimode_payments) + + if (data.type == 'Cash' && data.amount == me.frm.doc.paid_amount) { + me.idx = data.idx; + me.selected_mode = $(me.$body).find(repl("input[idx='%(idx)s']",{'idx': me.idx})); + me.highlight_selected_row(); + me.bind_amount_change_event(); + } }) }else{ $("

No payment mode selected in pos profile

").appendTo(multimode_payments) @@ -90,8 +97,10 @@ erpnext.payments = erpnext.stock.StockController.extend({ bind_payment_mode_keys_event: function(){ var me = this; $(this.$body).find('.pos-payment-row').click(function(){ - me.idx = $(this).attr("idx"); - me.set_outstanding_amount() + if(me.frm.doc.outstanding_amount > 0){ + me.idx = $(this).attr("idx"); + me.set_outstanding_amount() + } }) }, @@ -124,12 +133,16 @@ erpnext.payments = erpnext.stock.StockController.extend({ bind_amount_change_event: function(){ var me = this; - me.selected_mode.change(function(){ + this.selected_mode.change(function(){ me.payment_val = flt($(this).val()) || 0.0; me.selected_mode.val(format_number(me.payment_val, 2)) me.idx = me.selected_mode.attr("idx") me.update_paid_amount() }) + + this.selected_mode.click(function(){ + me.selected_mode.select(); + }) }, clear_amount: function(){ @@ -140,6 +153,7 @@ erpnext.payments = erpnext.stock.StockController.extend({ me.selected_mode = $(me.$body).find(repl("input[idx='%(idx)s']",{'idx': me.idx})); me.payment_val = 0.0; me.selected_mode.val(0.0); + me.highlight_selected_row(); me.update_paid_amount(); }) },