diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 126b88745c..1c21fbefb6 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -160,10 +160,13 @@ erpnext.POS = Class.extend({ parent: this.wrapper.find(".barcode-area") }); this.barcode.make_input(); - this.barcode.$input.on("change", function() { - me.add_item_thru_barcode(); + this.barcode.$input.on("keypress", function() { + setTimeout(function() { me.barcode_timeout(); }, 1000); }); }, + barcode_timeout: function() { + me.add_item_thru_barcode(); + }, make_item_list: function() { var me = this; wn.call({ @@ -178,7 +181,7 @@ erpnext.POS = Class.extend({ me.wrapper.find(".item-list").empty(); $.each(r.message, function(index, obj) { if (obj.image) - image = ""; + image = ''; else image = '
'; @@ -230,7 +233,6 @@ erpnext.POS = Class.extend({ var child = wn.model.add_child(me.frm.doc, "Sales Invoice Item", "entries"); child.item_code = item_code; me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name); - //me.refresh(); } }, update_qty: function(item_code, qty) { @@ -262,7 +264,7 @@ erpnext.POS = Class.extend({ %(item_code)s%(item_name)s\ \ - %(rate)s
%(amount)s\ + %(amount)s
%(rate)s\ ', { item_code: d.item_code, @@ -297,14 +299,18 @@ erpnext.POS = Class.extend({ this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_export, cur_frm.doc.price_list_currency)); + $("input.qty").on("focus", function() { + $(this).select(); + }); + // append quantity to the respective item after change from input box $("input.qty").on("change", function() { var item_code = $(this).closest("tr")[0].id; me.update_qty(item_code, $(this).val()); }); - // on td click highlight the respective row - $("td").on("click", function() { + // on td click toggle the highlighting of row + $("#cart tbody tr td").on("click", function() { var row = $(this).closest("tr"); if (row.attr("data-selected") == "false") { row.attr("class", "warning"); @@ -319,22 +325,25 @@ erpnext.POS = Class.extend({ }); me.refresh_delete_btn(); + cur_frm.pos.barcode.$input.focus(); }, refresh_delete_btn: function() { $(".delete-items").toggle($(".item-cart .warning").length ? true : false); }, add_item_thru_barcode: function() { var me = this; + clearTimeout(); wn.call({ method: 'accounts.doctype.sales_invoice.pos.get_item_from_barcode', args: {barcode: this.barcode.$input.val()}, callback: function(r) { if (r.message) { me.add_to_cart(r.message[0].name); - me.refresh(); } else msgprint(wn._("Invalid Barcode")); + + me.refresh(); } }); }, @@ -348,9 +357,6 @@ erpnext.POS = Class.extend({ selected_items.push(row.attr("id")); } } - - if (!selected_items[0]) - msgprint(wn._("Please select any item to remove it")); var child = wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries", "Sales Invoice"); @@ -362,6 +368,7 @@ erpnext.POS = Class.extend({ } }); cur_frm.fields_dict["entries"].grid.refresh(); + cur_frm.script_manager.trigger("calculate_taxes_and_totals"); me.refresh(); }, make_payment: function() { diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 5d11ecbecb..e2eeeac309 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -97,8 +97,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte if (cint(sys_defaults.fs_pos_view)===1) cur_frm.cscript.pos_btn(); - setTimeout(function() { cur_frm.$pos_btn.click(); }, 1000); - } else { // hide shown pos for submitted records if(cur_frm.pos_active) cur_frm.cscript.toggle_pos(false);