From 056c1709c6b60aebd623c293b2b92fceb7aaa709 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Thu, 8 Feb 2018 00:22:53 +0530 Subject: [PATCH 1/2] Fixes #12810 --- .../page/point_of_sale/point_of_sale.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js index 1d884cc136..9484dc7029 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -768,11 +768,19 @@ class POSCart { return; } - const item_code = this.selected_item.attr('data-item-code'); - const field = this.selected_item.active_field; - const value = this.numpad.get_value(); + if (this.selected_item.active_field == 'discount_percentage' && this.numpad.get_value() > cint(100)) { + frappe.show_alert({ + indicator: 'red', + message: __('Discount amount cannot be greater than 100%') + }); + this.numpad.reset_value(); + } else { + const item_code = this.selected_item.attr('data-item-code'); + const field = this.selected_item.active_field; + const value = this.numpad.get_value(); - this.events.on_field_change(item_code, field, value); + this.events.on_field_change(item_code, field, value); + } } this.events.on_numpad(btn_value); @@ -1588,4 +1596,4 @@ class Payment { this.dialog.set_value("paid_amount", this.frm.doc.paid_amount); this.dialog.set_value("outstanding_amount", this.frm.doc.outstanding_amount); } -} +} \ No newline at end of file From 1a4d77a962dd21b2e977554a873e38855f0ee6fa Mon Sep 17 00:00:00 2001 From: Saurabh Date: Thu, 8 Feb 2018 01:32:48 +0530 Subject: [PATCH 2/2] Fixes #12810 for Offline POS --- erpnext/accounts/page/pos/pos.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index d779de0da0..29f27fb70c 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -1177,8 +1177,17 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ $(this.wrapper).on("change", ".pos-item-disc", function () { var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code"); var discount = $(this).val(); - me.update_discount(item_code, discount) - me.update_value() + if(discount > 100){ + discount = $(this).val(''); + frappe.show_alert({ + indicator: 'red', + message: __('Discount amount cannot be greater than 100%') + }); + me.update_discount(item_code, discount); + }else{ + me.update_discount(item_code, discount); + me.update_value(); + } }) }, @@ -2006,4 +2015,4 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ frappe.throw(__("LocalStorage is full , did not save")) } } -}) +}) \ No newline at end of file