[Fix] POS issue for serialized items
This commit is contained in:
parent
ffcf0ca3a6
commit
dd58d537d5
@ -476,26 +476,34 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
update_qty: function() {
|
bind_qty_event: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
$(this.wrapper).find(".pos-item-qty").on("change", function(){
|
$(this.wrapper).find(".pos-item-qty").on("change", function(){
|
||||||
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
||||||
me.update_qty_rate_against_item_code(item_code, "qty", $(this).val());
|
var qty = $(this).val();
|
||||||
|
me.update_qty(item_code, qty)
|
||||||
})
|
})
|
||||||
|
|
||||||
$(this.wrapper).find("[data-action='increase-qty']").on("click", function(){
|
$(this.wrapper).find("[data-action='increase-qty']").on("click", function(){
|
||||||
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
||||||
var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) + 1;
|
var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) + 1;
|
||||||
me.update_qty_rate_against_item_code(item_code, "qty", qty);
|
me.update_qty(item_code, qty)
|
||||||
})
|
})
|
||||||
|
|
||||||
$(this.wrapper).find("[data-action='decrease-qty']").on("click", function(){
|
$(this.wrapper).find("[data-action='decrease-qty']").on("click", function(){
|
||||||
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
||||||
var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) - 1;
|
var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) - 1;
|
||||||
me.update_qty_rate_against_item_code(item_code, "qty", qty);
|
me.update_qty(item_code, qty)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
update_qty: function(item_code, qty) {
|
||||||
|
var me = this;
|
||||||
|
this.items = this.get_items(item_code);
|
||||||
|
this.validate_serial_no()
|
||||||
|
this.update_qty_rate_against_item_code(item_code, "qty", qty);
|
||||||
|
},
|
||||||
|
|
||||||
update_rate: function() {
|
update_rate: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
@ -650,7 +658,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
refresh: function(update_paid_amount) {
|
refresh: function(update_paid_amount) {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.refresh_fields(update_paid_amount);
|
this.refresh_fields(update_paid_amount);
|
||||||
this.update_qty();
|
this.bind_qty_event();
|
||||||
this.update_rate();
|
this.update_rate();
|
||||||
this.set_primary_action();
|
this.set_primary_action();
|
||||||
},
|
},
|
||||||
@ -946,6 +954,13 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
serial_no = me.item_serial_no[key][0];
|
serial_no = me.item_serial_no[key][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.items[0].has_serial_no && serial_no == ""){
|
||||||
|
this.refresh();
|
||||||
|
frappe.throw(__(repl("Error: Serial no is mandatory for item %(item)s", {
|
||||||
|
'item': this.items[0].item_code
|
||||||
|
})))
|
||||||
|
}
|
||||||
|
|
||||||
if(item_code && serial_no){
|
if(item_code && serial_no){
|
||||||
$.each(this.frm.doc.items, function(index, data){
|
$.each(this.frm.doc.items, function(index, data){
|
||||||
if(data.item_code == item_code){
|
if(data.item_code == item_code){
|
||||||
@ -957,12 +972,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.items[0].has_serial_no && serial_no == ""){
|
|
||||||
frappe.throw(__(repl("Error: Serial no is mandatory for item %(item)s", {
|
|
||||||
'item': this.items[0].item_code
|
|
||||||
})))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
validate_serial_no_qty: function(args, item_code, field, value){
|
validate_serial_no_qty: function(args, item_code, field, value){
|
||||||
@ -974,11 +983,13 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
frappe.throw(__("Serial no item cannot be a fraction"))
|
frappe.throw(__("Serial no item cannot be a fraction"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.serial_no && args.serial_no.split('\n').length != cint(value)){
|
if(args.item_code == item_code && args.serial_no && args.serial_no.split('\n').length != cint(value)){
|
||||||
args.qty = 0.0;
|
args.qty = 0.0;
|
||||||
args.serial_no = ''
|
args.serial_no = ''
|
||||||
this.refresh();
|
this.refresh();
|
||||||
frappe.throw(__("Total nos of serial no is not equal to quantity."))
|
frappe.throw(__(repl("Total nos of serial no is not equal to quantity for item %(item)s.", {
|
||||||
|
'item': item_code
|
||||||
|
})))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user