POS batch fixes (#12005)
This commit is contained in:
parent
ee7b4f00f8
commit
2b95a5438b
@ -1225,7 +1225,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
erpnext.show_serial_batch_selector = function(frm, d, callback, show_dialog) {
|
erpnext.show_serial_batch_selector = function(frm, d, callback, on_close, show_dialog) {
|
||||||
frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js", function() {
|
frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js", function() {
|
||||||
new erpnext.SerialNoBatchSelector({
|
new erpnext.SerialNoBatchSelector({
|
||||||
frm: frm,
|
frm: frm,
|
||||||
@ -1234,7 +1234,8 @@ erpnext.show_serial_batch_selector = function(frm, d, callback, show_dialog) {
|
|||||||
type: "Warehouse",
|
type: "Warehouse",
|
||||||
name: d.warehouse
|
name: d.warehouse
|
||||||
},
|
},
|
||||||
callback: callback
|
callback: callback,
|
||||||
|
on_close: on_close
|
||||||
}, show_dialog);
|
}, show_dialog);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ erpnext.SerialNoBatchSelector = Class.extend({
|
|||||||
this.item_code = this.item.item_code;
|
this.item_code = this.item.item_code;
|
||||||
this.qty = this.item.qty;
|
this.qty = this.item.qty;
|
||||||
this.make_dialog();
|
this.make_dialog();
|
||||||
|
this.on_close_dialog();
|
||||||
},
|
},
|
||||||
|
|
||||||
make_dialog: function() {
|
make_dialog: function() {
|
||||||
@ -115,6 +116,12 @@ erpnext.SerialNoBatchSelector = Class.extend({
|
|||||||
this.dialog.show();
|
this.dialog.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
on_close_dialog: function() {
|
||||||
|
this.dialog.get_close_btn().on('click', () => {
|
||||||
|
this.on_close && this.on_close(this.item);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
validate: function() {
|
validate: function() {
|
||||||
let values = this.values;
|
let values = this.values;
|
||||||
if(!values.warehouse) {
|
if(!values.warehouse) {
|
||||||
|
@ -170,8 +170,10 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
|
|
||||||
// if actual_batch_qty and actual_qty if there is only one batch. In such
|
// if actual_batch_qty and actual_qty if there is only one batch. In such
|
||||||
// a case, no point showing the dialog
|
// a case, no point showing the dialog
|
||||||
if(field === 'qty' && (item.serial_no || item.batch_no)
|
const show_dialog = item.has_serial_no || item.has_batch_no;
|
||||||
&& (item.actual_batch_qty != item.actual_qty)) {
|
|
||||||
|
if (show_dialog && field == 'qty' && ((!item.batch_no && item.has_batch_no) ||
|
||||||
|
(item.has_serial_no) || (item.actual_batch_qty != item.actual_qty)) ) {
|
||||||
this.select_batch_and_serial_no(item);
|
this.select_batch_and_serial_no(item);
|
||||||
} else {
|
} else {
|
||||||
this.update_item_in_frm(item, field, value)
|
this.update_item_in_frm(item, field, value)
|
||||||
@ -198,7 +200,8 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
|
|
||||||
// if actual_batch_qty and actual_qty if then there is only one batch. In such
|
// if actual_batch_qty and actual_qty if then there is only one batch. In such
|
||||||
// a case, no point showing the dialog
|
// a case, no point showing the dialog
|
||||||
if (show_dialog && field == 'qty' && (item.actual_batch_qty != item.actual_qty)) {
|
if (show_dialog && field == 'qty' && ((!item.batch_no && item.has_batch_no) ||
|
||||||
|
(item.has_serial_no) || (item.actual_batch_qty != item.actual_qty)) ) {
|
||||||
// check has serial no/batch no and update cart
|
// check has serial no/batch no and update cart
|
||||||
this.select_batch_and_serial_no(item);
|
this.select_batch_and_serial_no(item);
|
||||||
} else {
|
} else {
|
||||||
@ -209,18 +212,32 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select_batch_and_serial_no(item) {
|
select_batch_and_serial_no(item) {
|
||||||
|
frappe.dom.unfreeze();
|
||||||
|
|
||||||
erpnext.show_serial_batch_selector(this.frm, item, () => {
|
erpnext.show_serial_batch_selector(this.frm, item, () => {
|
||||||
this.update_item_in_frm(item, 'qty', item.qty)
|
this.update_item_in_frm(item, 'qty', item.qty)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// update cart
|
// update cart
|
||||||
if (item.qty === 0) {
|
frappe.run_serially([
|
||||||
frappe.model.clear_doc(item.doctype, item.name);
|
() => {
|
||||||
}
|
if (item.qty === 0) {
|
||||||
this.update_cart_data(item);
|
frappe.model.clear_doc(item.doctype, item.name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
() => this.update_cart_data(item)
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
}, () => {
|
||||||
|
this.on_close(item);
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
on_close(item) {
|
||||||
|
if (!this.cart.exists(item.item_code) && item.qty) {
|
||||||
|
frappe.model.clear_doc(item.doctype, item.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
update_cart_data(item) {
|
update_cart_data(item) {
|
||||||
this.cart.add_item(item);
|
this.cart.add_item(item);
|
||||||
this.cart.update_taxes_and_totals();
|
this.cart.update_taxes_and_totals();
|
||||||
@ -735,7 +752,7 @@ class POSCart {
|
|||||||
if (this.exists(item.item_code)) {
|
if (this.exists(item.item_code)) {
|
||||||
// update quantity
|
// update quantity
|
||||||
this.update_item(item);
|
this.update_item(item);
|
||||||
} else {
|
} else if (flt(item.qty) > 0.0) {
|
||||||
// add to cart
|
// add to cart
|
||||||
const $item = $(this.get_item_html(item));
|
const $item = $(this.get_item_html(item));
|
||||||
$item.appendTo(this.$cart_items);
|
$item.appendTo(this.$cart_items);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user