Merge pull request #12816 from mntechnique/hotfix-for-#12810
Does not allow discount over 100% in POS
This commit is contained in:
		
						commit
						f1fa338999
					
				| @ -1177,8 +1177,17 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ | |||||||
| 		$(this.wrapper).on("change", ".pos-item-disc", function () { | 		$(this.wrapper).on("change", ".pos-item-disc", function () { | ||||||
| 			var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code"); | 			var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code"); | ||||||
| 			var discount = $(this).val(); | 			var discount = $(this).val(); | ||||||
| 			me.update_discount(item_code, discount) | 			if(discount > 100){ | ||||||
| 			me.update_value() | 				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")) | 			frappe.throw(__("LocalStorage is full , did not save")) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| }) | }) | ||||||
| @ -768,11 +768,19 @@ class POSCart { | |||||||
| 						return; | 						return; | ||||||
| 					} | 					} | ||||||
| 
 | 
 | ||||||
| 					const item_code = this.selected_item.attr('data-item-code'); | 					if (this.selected_item.active_field == 'discount_percentage' && this.numpad.get_value() > cint(100)) { | ||||||
| 					const field = this.selected_item.active_field; | 						frappe.show_alert({ | ||||||
| 					const value = this.numpad.get_value(); | 							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); | 				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("paid_amount", this.frm.doc.paid_amount); | ||||||
| 		this.dialog.set_value("outstanding_amount", this.frm.doc.outstanding_amount); | 		this.dialog.set_value("outstanding_amount", this.frm.doc.outstanding_amount); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user