added event on numeric keypad
This commit is contained in:
parent
e30f83a8af
commit
f0c7ba4b1f
@ -303,6 +303,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
this.make_list_customers();
|
this.make_list_customers();
|
||||||
this.make_customer();
|
this.make_customer();
|
||||||
this.make_item_list();
|
this.make_item_list();
|
||||||
|
this.bind_numeric_keypad();
|
||||||
this.make_discount_field()
|
this.make_discount_field()
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -403,6 +404,40 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
me.set_focus();
|
me.set_focus();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
bind_numeric_keypad: function() {
|
||||||
|
var me = this;
|
||||||
|
$(this.numeric_keypad).find('.pos-operation').on('click', function(){
|
||||||
|
me.numeric_val = '';
|
||||||
|
})
|
||||||
|
|
||||||
|
$(this.numeric_keypad).find('.numeric-keypad').on('click', function(){
|
||||||
|
me.numeric_id = $(this).attr("id") || me.numeric_id;
|
||||||
|
me.val = $(this).attr("val")
|
||||||
|
if(me.val && me.numeric_id) {
|
||||||
|
me.selected_field = $(me.wrapper).find('.selected-item').find('.' + me.numeric_id)
|
||||||
|
me.numeric_val += me.val;
|
||||||
|
me.selected_field.val(flt(me.numeric_val))
|
||||||
|
me.selected_field.trigger("change")
|
||||||
|
me.render_selected_item()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
$(this.numeric_keypad).find('.numeric-del').click(function(){
|
||||||
|
me.selected_field = $(me.wrapper).find('.selected-item').find('.' + me.numeric_id)
|
||||||
|
me.numeric_val = cstr(flt(me.selected_field.val())).slice(0, -1);
|
||||||
|
me.selected_field.val(me.numeric_val);
|
||||||
|
me.selected_field.trigger("change")
|
||||||
|
me.render_selected_item()
|
||||||
|
})
|
||||||
|
|
||||||
|
$(this.numeric_keypad).find('.pos-pay').click(function(){
|
||||||
|
me.validate();
|
||||||
|
me.update_paid_amount_status(true);
|
||||||
|
me.create_invoice();
|
||||||
|
me.make_payment();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
render_list_customers: function () {
|
render_list_customers: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
@ -797,11 +832,24 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
bind_items_event: function() {
|
||||||
|
var me = this;
|
||||||
|
$(this.wrapper).find(".pos-bill-item").click(function() {
|
||||||
|
me.numeric_val = "";
|
||||||
|
me.numeric_id = ""
|
||||||
|
me.item_code = $(this).attr("data-item-code");
|
||||||
|
me.render_selected_item()
|
||||||
|
me.bind_qty_event()
|
||||||
|
me.update_rate()
|
||||||
|
$(me.wrapper).find(".selected-item").scrollTop(1000);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
bind_qty_event: function () {
|
bind_qty_event: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
$(this.wrapper).find(".pos-item-qty").on("change", function () {
|
$(this.wrapper).on("change", ".pos-item-qty", function () {
|
||||||
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
||||||
var qty = $(this).val();
|
var qty = $(this).val();
|
||||||
me.update_qty(item_code, qty)
|
me.update_qty(item_code, qty)
|
||||||
@ -818,8 +866,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) - 1;
|
var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) - 1;
|
||||||
me.update_qty(item_code, qty)
|
me.update_qty(item_code, qty)
|
||||||
})
|
})
|
||||||
|
|
||||||
$(this.wrapper).find(".pos-item-discount").on("change", function () {
|
$(this.wrapper).on("change", ".pos-item-disc", function () {
|
||||||
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
||||||
var discount = $(this).val();
|
var discount = $(this).val();
|
||||||
me.update_discount(item_code, discount)
|
me.update_discount(item_code, discount)
|
||||||
@ -841,20 +889,20 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
|
|
||||||
update_rate: function () {
|
update_rate: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
$(this.wrapper).on("change", ".pos-item-price", function () {
|
||||||
$(this.wrapper).find(".pos-bill-item").click(function() {
|
|
||||||
var item_code = $(this).attr("data-item-code");
|
|
||||||
doc = me.get_child_item(item_code);
|
|
||||||
html_data = frappe.render_template("pos_selected_item", doc[0])
|
|
||||||
$(me.wrapper).find('.selected-item').html(html_data)
|
|
||||||
me.bind_qty_event()
|
|
||||||
})
|
|
||||||
|
|
||||||
$(this.wrapper).find(".pos-item-rate").on("change", function () {
|
|
||||||
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
|
||||||
me.set_item_details(item_code, "rate", $(this).val());
|
me.set_item_details(item_code, "rate", $(this).val());
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
render_selected_item: function() {
|
||||||
|
doc = this.get_child_item(this.item_code);
|
||||||
|
$(this.wrapper).find('.selected-item').empty();
|
||||||
|
if(doc.length) {
|
||||||
|
this.selected_row = frappe.render_template("pos_selected_item", doc[0])
|
||||||
|
$(this.wrapper).find('.selected-item').html(this.selected_row)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
get_child_item: function(item_code) {
|
get_child_item: function(item_code) {
|
||||||
var me = this;
|
var me = this;
|
||||||
@ -1011,8 +1059,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
refresh: function (update_paid_amount) {
|
refresh: function (update_paid_amount) {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.refresh_fields(update_paid_amount);
|
this.refresh_fields(update_paid_amount);
|
||||||
this.bind_qty_event();
|
this.bind_items_event();
|
||||||
this.update_rate();
|
|
||||||
this.set_primary_action();
|
this.set_primary_action();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1056,11 +1103,11 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
$(this).select();
|
$(this).select();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wrapper.find("input.pos-item-discount").on("focus", function () {
|
this.wrapper.find("input.pos-item-disc").on("focus", function () {
|
||||||
$(this).select();
|
$(this).select();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wrapper.find("input.pos-item-rate").on("focus", function () {
|
this.wrapper.find("input.pos-item-price").on("focus", function () {
|
||||||
$(this).select();
|
$(this).select();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -1375,13 +1422,18 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
item.price_list_rate = pricing_rule[0].price || item.price_list_rate;
|
item.price_list_rate = pricing_rule[0].price || item.price_list_rate;
|
||||||
item.margin_rate_or_amount = pricing_rule[0].margin_rate_or_amount;
|
item.margin_rate_or_amount = pricing_rule[0].margin_rate_or_amount;
|
||||||
item.discount_percentage = pricing_rule[0].discount_percentage || 0.0;
|
item.discount_percentage = pricing_rule[0].discount_percentage || 0.0;
|
||||||
} else if ((item.discount_percentage > 0 || item.margin_rate_or_amount > 0) && item.pricing_rule) {
|
me.apply_pricing_rule_on_item(item)
|
||||||
|
} else if (item.pricing_rule) {
|
||||||
|
item.price_list_rate = me.price_list_data[item.item_code]
|
||||||
item.margin_rate_or_amount = 0.0;
|
item.margin_rate_or_amount = 0.0;
|
||||||
item.discount_percentage = 0.0;
|
item.discount_percentage = 0.0;
|
||||||
item.pricing_rule = null;
|
item.pricing_rule = null;
|
||||||
|
me.apply_pricing_rule_on_item(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item.discount_percentage > 0) {
|
||||||
|
me.apply_pricing_rule_on_item(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
me.apply_pricing_rule_on_item(item)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -85,12 +85,13 @@
|
|||||||
}
|
}
|
||||||
.item-cart {
|
.item-cart {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
height: calc(100vh - 60vh);
|
height: calc(100vh - 72vh);
|
||||||
}
|
}
|
||||||
.edit-pos-item {
|
.edit-pos-item {
|
||||||
height: 40px;
|
height: 50px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
border-top: 1px solid #d1d8dd;
|
border-top: 1px solid #d1d8dd;
|
||||||
|
padding-top: 12px;
|
||||||
}
|
}
|
||||||
.pos-bill-item:hover {
|
.pos-bill-item:hover {
|
||||||
background-color: #f5f7fa;
|
background-color: #f5f7fa;
|
||||||
@ -170,6 +171,16 @@
|
|||||||
}
|
}
|
||||||
.pos-keyboard-key,
|
.pos-keyboard-key,
|
||||||
.delete-btn {
|
.delete-btn {
|
||||||
|
border: 1px solid #d1d8dd;
|
||||||
|
height: 85px;
|
||||||
|
width: 85px;
|
||||||
|
margin: 10px 10px;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 200;
|
||||||
|
background-color: #FDFDFD;
|
||||||
|
border-color: #e8e8e8;
|
||||||
|
}
|
||||||
|
.numeric-keypad {
|
||||||
border: 1px solid #d1d8dd;
|
border: 1px solid #d1d8dd;
|
||||||
height: 69px;
|
height: 69px;
|
||||||
width: 69px;
|
width: 69px;
|
||||||
|
|||||||
@ -73,15 +73,15 @@
|
|||||||
{% for(var i=0; i<3; i++) { %}
|
{% for(var i=0; i<3; i++) { %}
|
||||||
<div class="row text-right">
|
<div class="row text-right">
|
||||||
{% for(var j=i*3; j<(i+1)*3; j++) { %}
|
{% for(var j=i*3; j<(i+1)*3; j++) { %}
|
||||||
<button type="button" class="btn btn-default pos-keyboard-key">{{j+1}}</button>
|
<button type="button" class="btn btn-default numeric-keypad" val="{{j+1}}">{{j+1}}</button>
|
||||||
{% } %}
|
{% } %}
|
||||||
<button type="button" class="btn text-center btn-default pos-keyboard-key">{{ chartData[i] }}</button>
|
<button type="button" 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">
|
||||||
<button type="button" class="btn btn-default delete-btn">Del</button>
|
<button type="button" class="btn btn-default numeric-keypad numeric-del">Del</button>
|
||||||
<button type="button" class="btn btn-default pos-keyboard-key">0</button>
|
<button type="button" class="btn btn-default numeric-keypad" val="0">0</button>
|
||||||
<button type="button" class="btn btn-default pos-keyboard-key">.</button>
|
<button type="button" class="btn btn-default numeric-keypad" val=".">.</button>
|
||||||
<button type="button" class="btn btn-primary pos-pay">Pay</button>
|
<button type="button" class="btn btn-primary pos-pay">Pay</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -18,13 +18,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-xs-2 text-right">
|
<div class="col-xs-2 text-right">
|
||||||
<div class="row input-sm">
|
<div class="row input-sm">
|
||||||
<input type="tel" value="{%= discount_percentage %}" class="form-control text-right pos-item-discount">
|
<input type="tel" value="{%= discount_percentage %}" class="form-control text-right pos-item-disc">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-3 text-right">
|
<div class="col-xs-3 text-right">
|
||||||
<div class="text-muted" style="margin-top: 5px;">
|
<div class="text-muted" style="margin-top: 5px;">
|
||||||
{% if(enabled) { %}
|
{% if(enabled) { %}
|
||||||
<input type="tel" value="{%= rate %}" class="form-control input-sm pos-item-rate text-right">
|
<input type="tel" value="{%= rate %}" class="form-control input-sm pos-item-price text-right">
|
||||||
{% } else { %}
|
{% } else { %}
|
||||||
<h6>{%= format_currency(rate) %}</h6>
|
<h6>{%= format_currency(rate) %}</h6>
|
||||||
{% } %}
|
{% } %}
|
||||||
|
|||||||
@ -3,25 +3,25 @@
|
|||||||
<div class="form-group edit-pos-item">
|
<div class="form-group edit-pos-item">
|
||||||
<label class=" text-left col-xs-4">Price:</label>
|
<label class=" text-left col-xs-4">Price:</label>
|
||||||
<div class="col-xs-8">
|
<div class="col-xs-8">
|
||||||
<input class="form-control text-right" value="{%= rate %}">
|
<input class="form-control text-right pos-item-price" disabled value="{%= rate %}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group edit-pos-item">
|
<div class="form-group edit-pos-item">
|
||||||
<label class=" text-left col-xs-4">Qty:</label>
|
<label class=" text-left col-xs-4">Qty:</label>
|
||||||
<div class="col-xs-8">
|
<div class="col-xs-8">
|
||||||
<input class="form-control text-right pos-item-qty" value="{%= qty %}">
|
<input class="form-control text-right pos-item-qty" disabled value="{%= qty %}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group edit-pos-item">
|
<div class="form-group edit-pos-item">
|
||||||
<label class=" text-left col-xs-4">Discount:</label>
|
<label class=" text-left col-xs-4">Discount:</label>
|
||||||
<div class="col-xs-8">
|
<div class="col-xs-8">
|
||||||
<input class="form-control text-right" value="{%= discount_percentage %}">
|
<input class="form-control text-right pos-item-disc" disabled value="{%= discount_percentage %}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group edit-pos-item">
|
<div class="form-group edit-pos-item">
|
||||||
<label class=" text-left col-xs-4">Amount:</label>
|
<label class=" text-left col-xs-4">Amount:</label>
|
||||||
<div class="col-xs-8">
|
<div class="col-xs-8">
|
||||||
<input class="form-control text-right " value="{%= amount %}">
|
<input class="form-control text-right " disabled value="{%= amount %}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -104,13 +104,14 @@
|
|||||||
|
|
||||||
.item-cart {
|
.item-cart {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
height: ~"calc(100vh - 60vh)";
|
height: ~"calc(100vh - 72vh)";
|
||||||
}
|
}
|
||||||
|
|
||||||
.edit-pos-item {
|
.edit-pos-item {
|
||||||
height: 40px;
|
height: 50px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
border-top: 1px solid @border-color;
|
border-top: 1px solid @border-color;
|
||||||
|
padding-top: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pos-bill-item:hover {
|
.pos-bill-item:hover {
|
||||||
@ -212,6 +213,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.pos-keyboard-key, .delete-btn {
|
.pos-keyboard-key, .delete-btn {
|
||||||
|
border: 1px solid #d1d8dd;
|
||||||
|
height:85px;
|
||||||
|
width:85px;
|
||||||
|
margin:10px 10px;
|
||||||
|
font-size:24px;
|
||||||
|
font-weight:200;
|
||||||
|
background-color: #FDFDFD;
|
||||||
|
border-color: #e8e8e8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.numeric-keypad {
|
||||||
border: 1px solid #d1d8dd;
|
border: 1px solid #d1d8dd;
|
||||||
height:69px;
|
height:69px;
|
||||||
width:69px;
|
width:69px;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user