Merge pull request #11147 from rohitwaghchaure/total_amount_and_barcode_issue_pos

[Fix] Barcode and total amount issue in online POS
This commit is contained in:
rohitwaghchaure
2017-10-11 11:13:30 +05:30
committed by GitHub
2 changed files with 21 additions and 19 deletions

View File

@@ -101,16 +101,13 @@ erpnext.pos.PointOfSale = class PointOfSale {
if (!this.payment) { if (!this.payment) {
this.make_payment_modal(); this.make_payment_modal();
} else { } else {
const mop_field = this.payment.default_mop;
let amount = 0.0;
this.frm.doc.payments.map(p => { this.frm.doc.payments.map(p => {
if (p.mode_of_payment == mop_field) { if (p.amount) {
amount = p.amount; this.payment.dialog.set_value(p.mode_of_payment, p.amount);
return;
} }
}); });
this.payment.dialog.set_value(mop_field, flt(amount)); this.payment.set_title();
} }
this.payment.open_modal(); this.payment.open_modal();
} }
@@ -1185,12 +1182,7 @@ class Payment {
make() { make() {
this.set_flag(); this.set_flag();
let title = __('Total Amount {0}',
[format_currency(this.frm.doc.grand_total, this.frm.doc.currency)]);
this.dialog = new frappe.ui.Dialog({ this.dialog = new frappe.ui.Dialog({
title: title,
fields: this.get_fields(), fields: this.get_fields(),
width: 800 width: 800
}); });
@@ -1213,6 +1205,13 @@ class Payment {
}); });
} }
set_title() {
let title = __('Total Amount {0}',
[format_currency(this.frm.doc.grand_total, this.frm.doc.currency)]);
this.dialog.set_title(title);
}
bind_events() { bind_events() {
var me = this; var me = this;
$(this.dialog.body).find('.input-with-feedback').focusin(function() { $(this.dialog.body).find('.input-with-feedback').focusin(function() {
@@ -1234,10 +1233,6 @@ class Payment {
const me = this; const me = this;
let fields = this.frm.doc.payments.map(p => { let fields = this.frm.doc.payments.map(p => {
if (p.default) {
this.default_mop = p.mode_of_payment;
}
return { return {
fieldtype: 'Currency', fieldtype: 'Currency',
label: __(p.mode_of_payment), label: __(p.mode_of_payment),

View File

@@ -9,6 +9,8 @@ from frappe.utils.nestedset import get_root_of
def get_items(start, page_length, price_list, item_group, search_value=""): def get_items(start, page_length, price_list, item_group, search_value=""):
serial_no = "" serial_no = ""
batch_no = "" batch_no = ""
barcode = ""
item_code = search_value item_code = search_value
if not frappe.db.exists('Item Group', item_group): if not frappe.db.exists('Item Group', item_group):
item_group = get_root_of('Item Group') item_group = get_root_of('Item Group')
@@ -24,7 +26,12 @@ def get_items(start, page_length, price_list, item_group, search_value=""):
if batch_no_data: if batch_no_data:
batch_no, item_code = batch_no_data batch_no, item_code = batch_no_data
item_code, condition = get_conditions(item_code, serial_no, batch_no) if not serial_no and not batch_no:
barcode_data = frappe.db.get_value('Item', {'barcode': search_value}, ['name', 'barcode'])
if barcode_data:
item_code, barcode = barcode_data
item_code, condition = get_conditions(item_code, serial_no, batch_no, barcode)
lft, rgt = frappe.db.get_value('Item Group', item_group, ['lft', 'rgt']) lft, rgt = frappe.db.get_value('Item Group', item_group, ['lft', 'rgt'])
# locate function is used to sort by closest match from the beginning of the value # locate function is used to sort by closest match from the beginning of the value
@@ -62,12 +69,12 @@ def get_items(start, page_length, price_list, item_group, search_value=""):
return res return res
def get_conditions(item_code, serial_no, batch_no): def get_conditions(item_code, serial_no, batch_no, barcode):
if serial_no or batch_no: if serial_no or batch_no or barcode:
return frappe.db.escape(item_code), "i.item_code = %(item_code)s" return frappe.db.escape(item_code), "i.item_code = %(item_code)s"
condition = """(i.item_code like %(item_code)s condition = """(i.item_code like %(item_code)s
or i.item_name like %(item_code)s or i.barcode like %(item_code)s)""" or i.item_name like %(item_code)s)"""
return '%%%s%%'%(frappe.db.escape(item_code)), condition return '%%%s%%'%(frappe.db.escape(item_code)), condition