[Fix] batch no searching in pos

This commit is contained in:
Rohit Waghchaure 2016-07-30 16:49:48 +05:30
parent 62658fde45
commit a88dec8775
5 changed files with 24 additions and 11 deletions

View File

@ -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('<a href="#Form/POS Profile/New POS Profile">'
frappe.msgprint('<a href="#List/POS Profile">'
+ _("Welcome to POS: Create your POS Profile") + '</a>');
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)

View File

@ -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{

View File

@ -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);
}
},

View File

@ -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;

View File

@ -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{
$("<p>No payment mode selected in pos profile</p>").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();
})
},