[Fix] Discount in offline POS is enabled even is it's disabled in POS Profile (#13233)
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index 29f27fb..fe71f28 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -393,7 +393,8 @@
this.frm = {}
this.frm.doc = this.doc
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.make_search();
this.make_customer();
@@ -1256,6 +1257,7 @@
$(this.wrapper).find('.selected-item').empty();
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_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.wrapper).find('.selected-item').html(this.selected_row)
}
@@ -1683,7 +1685,7 @@
setInterval(function () {
me.freeze_screen = false;
me.sync_sales_invoice()
- }, 60000)
+ }, 180000)
},
sync_sales_invoice: function () {
diff --git a/erpnext/public/js/pos/pos.html b/erpnext/public/js/pos/pos.html
index 1d9fd7c..af90756 100644
--- a/erpnext/public/js/pos/pos.html
+++ b/erpnext/public/js/pos/pos.html
@@ -37,20 +37,22 @@
<div class="cell price-cell text-right tax-table">
</div>
</div>
- <div class="pos-list-row discount-amount-area">
- <div class="cell"></div>
- <div class="cell text-right">{%= __("Discount") %}</div>
- <div class="cell price-cell discount-field-col">
- <div class="input-group input-group-sm">
- <span class="input-group-addon">%</span>
- <input type="text" class="form-control discount-percentage text-right">
- </div>
- <div class="input-group input-group-sm">
- <span class="input-group-addon">{%= get_currency_symbol(currency) %}</span>
- <input type="text" class="form-control discount-amount text-right" placeholder="{%= 0.00 %}">
+ {% if(allow_user_to_edit_discount) { %}
+ <div class="pos-list-row discount-amount-area">
+ <div class="cell"></div>
+ <div class="cell text-right">{%= __("Discount") %}</div>
+ <div class="cell price-cell discount-field-col">
+ <div class="input-group input-group-sm">
+ <span class="input-group-addon">%</span>
+ <input type="text" class="form-control discount-percentage text-right">
+ </div>
+ <div class="input-group input-group-sm">
+ <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 class="pos-list-row grand-total-area collapse-btn" style="border-bottom:1px solid #d1d8dd;">
<div class="cell">
<a class="">
@@ -71,7 +73,7 @@
{% 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>
{% } %}
- <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 class="row text-right">
diff --git a/erpnext/public/js/pos/pos_selected_item.html b/erpnext/public/js/pos/pos_selected_item.html
index 085e048..03c7341 100644
--- a/erpnext/public/js/pos/pos_selected_item.html
+++ b/erpnext/public/js/pos/pos_selected_item.html
@@ -9,7 +9,7 @@
</div>
<div class="pos-list-row">
<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 class="pos-list-row">
<div class="cell">{{ __("Price") }}:</div>