[Fix] Discount in offline POS is enabled even is it's disabled in POS Profile (#13233)

This commit is contained in:
rohitwaghchaure 2018-03-08 16:21:13 +05:30 committed by Nabin Hait
parent a3a63177a1
commit a32e57ae82
3 changed files with 20 additions and 16 deletions

View File

@ -393,7 +393,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.frm = {} this.frm = {}
this.frm.doc = this.doc this.frm.doc = this.doc
this.set_transaction_defaults("Customer"); this.set_transaction_defaults("Customer");
this.frm.doc["allow_user_to_edit_rate"] = this.pos_profile_data["allow_user_to_edit_rate"] ? true : false, this.frm.doc["allow_user_to_edit_rate"] = this.pos_profile_data["allow_user_to_edit_rate"] ? true : false;
this.frm.doc["allow_user_to_edit_discount"] = this.pos_profile_data["allow_user_to_edit_discount"] ? true : false;
this.wrapper.html(frappe.render_template("pos", this.frm.doc)); this.wrapper.html(frappe.render_template("pos", this.frm.doc));
this.make_search(); this.make_search();
this.make_customer(); this.make_customer();
@ -1256,6 +1257,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
$(this.wrapper).find('.selected-item').empty(); $(this.wrapper).find('.selected-item').empty();
if(this.child_doc.length) { if(this.child_doc.length) {
this.child_doc[0]["allow_user_to_edit_rate"] = this.pos_profile_data["allow_user_to_edit_rate"] ? true : false, this.child_doc[0]["allow_user_to_edit_rate"] = this.pos_profile_data["allow_user_to_edit_rate"] ? true : false,
this.child_doc[0]["allow_user_to_edit_discount"] = this.pos_profile_data["allow_user_to_edit_discount"] ? true : false;
this.selected_row = $(frappe.render_template("pos_selected_item", this.child_doc[0])) this.selected_row = $(frappe.render_template("pos_selected_item", this.child_doc[0]))
$(this.wrapper).find('.selected-item').html(this.selected_row) $(this.wrapper).find('.selected-item').html(this.selected_row)
} }
@ -1683,7 +1685,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
setInterval(function () { setInterval(function () {
me.freeze_screen = false; me.freeze_screen = false;
me.sync_sales_invoice() me.sync_sales_invoice()
}, 60000) }, 180000)
}, },
sync_sales_invoice: function () { sync_sales_invoice: function () {

View File

@ -37,20 +37,22 @@
<div class="cell price-cell text-right tax-table"> <div class="cell price-cell text-right tax-table">
</div> </div>
</div> </div>
<div class="pos-list-row discount-amount-area"> {% if(allow_user_to_edit_discount) { %}
<div class="cell"></div> <div class="pos-list-row discount-amount-area">
<div class="cell text-right">{%= __("Discount") %}</div> <div class="cell"></div>
<div class="cell price-cell discount-field-col"> <div class="cell text-right">{%= __("Discount") %}</div>
<div class="input-group input-group-sm"> <div class="cell price-cell discount-field-col">
<span class="input-group-addon">%</span> <div class="input-group input-group-sm">
<input type="text" class="form-control discount-percentage text-right"> <span class="input-group-addon">%</span>
</div> <input type="text" class="form-control discount-percentage text-right">
<div class="input-group input-group-sm"> </div>
<span class="input-group-addon">{%= get_currency_symbol(currency) %}</span> <div class="input-group input-group-sm">
<input type="text" class="form-control discount-amount text-right" placeholder="{%= 0.00 %}"> <span class="input-group-addon">{%= get_currency_symbol(currency) %}</span>
<input type="text" class="form-control discount-amount text-right" placeholder="{%= 0.00 %}">
</div>
</div> </div>
</div> </div>
</div> {% } %}
<div class="pos-list-row grand-total-area collapse-btn" style="border-bottom:1px solid #d1d8dd;"> <div class="pos-list-row grand-total-area collapse-btn" style="border-bottom:1px solid #d1d8dd;">
<div class="cell"> <div class="cell">
<a class=""> <a class="">
@ -71,7 +73,7 @@
{% for(var j=i*3; j {% for(var j=i*3; j
<(i+1)*3; j++) { %} <button type="button" class="btn btn-default numeric-keypad" val="{{j+1}}">{{j+1}}</button> <(i+1)*3; j++) { %} <button type="button" class="btn btn-default numeric-keypad" val="{{j+1}}">{{j+1}}</button>
{% } %} {% } %}
<button type="button" {% if(!allow_user_to_edit_rate && chartData[i] == __("Price")) { %} disabled {% } %} id="pos-item-{{ chartData[i].toLowerCase() }}" class="btn text-center btn-default numeric-keypad pos-operation">{{ __(chartData[i]) }}</button> <button type="button" {% if((!allow_user_to_edit_rate && chartData[i] == __("Price")) || (!allow_user_to_edit_discount && chartData[i] == __("Disc"))) { %} disabled {% } %} id="pos-item-{{ chartData[i].toLowerCase() }}" class="btn text-center btn-default numeric-keypad pos-operation">{{ __(chartData[i]) }}</button>
</div> </div>
{% } %} {% } %}
<div class="row text-right"> <div class="row text-right">

View File

@ -9,7 +9,7 @@
</div> </div>
<div class="pos-list-row"> <div class="pos-list-row">
<div class="cell">{{ __("Discount") }}: %</div> <div class="cell">{{ __("Discount") }}: %</div>
<input type="tel" class="form-control cell pos-item-disc" value="{%= discount_percentage %}"> <input type="tel" class="form-control cell pos-item-disc" {% if !allow_user_to_edit_discount %} disabled {% endif %} value="{%= discount_percentage %}">
</div> </div>
<div class="pos-list-row"> <div class="pos-list-row">
<div class="cell">{{ __("Price") }}:</div> <div class="cell">{{ __("Price") }}:</div>