Does not allow discount over 100% in POS
This commit is contained in:
rohitwaghchaure 2018-02-08 11:42:08 +05:30 committed by GitHub
commit f1fa338999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 8 deletions

View File

@ -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();
}
}) })
}, },

View File

@ -768,12 +768,20 @@ class POSCart {
return; return;
} }
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 item_code = this.selected_item.attr('data-item-code');
const field = this.selected_item.active_field; const field = this.selected_item.active_field;
const value = this.numpad.get_value(); 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);
} }