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 () {
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"))
}
}
})
})

View File

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