added event on numeric keypad

This commit is contained in:
Rohit Waghchaure 2017-02-28 16:51:17 +05:30
parent e30f83a8af
commit f0c7ba4b1f
6 changed files with 111 additions and 36 deletions

View File

@ -303,6 +303,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.make_list_customers();
this.make_customer();
this.make_item_list();
this.bind_numeric_keypad();
this.make_discount_field()
},
@ -403,6 +404,40 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
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 () {
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 () {
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 qty = $(this).val();
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;
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 discount = $(this).val();
me.update_discount(item_code, discount)
@ -841,20 +889,20 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
update_rate: function () {
var me = this;
$(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 () {
$(this.wrapper).on("change", ".pos-item-price", function () {
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
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) {
var me = this;
@ -1011,8 +1059,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
refresh: function (update_paid_amount) {
var me = this;
this.refresh_fields(update_paid_amount);
this.bind_qty_event();
this.update_rate();
this.bind_items_event();
this.set_primary_action();
},
@ -1056,11 +1103,11 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
$(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.wrapper.find("input.pos-item-rate").on("focus", function () {
this.wrapper.find("input.pos-item-price").on("focus", function () {
$(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.margin_rate_or_amount = pricing_rule[0].margin_rate_or_amount;
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.discount_percentage = 0.0;
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)
})
},

View File

@ -85,12 +85,13 @@
}
.item-cart {
overflow-y: scroll;
height: calc(100vh - 60vh);
height: calc(100vh - 72vh);
}
.edit-pos-item {
height: 40px;
height: 50px;
font-size: 14px;
border-top: 1px solid #d1d8dd;
padding-top: 12px;
}
.pos-bill-item:hover {
background-color: #f5f7fa;
@ -170,6 +171,16 @@
}
.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;
height: 69px;
width: 69px;

View File

@ -73,15 +73,15 @@
{% for(var i=0; i<3; i++) { %}
<div class="row text-right">
{% 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 class="row text-right">
<button type="button" class="btn btn-default delete-btn">Del</button>
<button type="button" class="btn btn-default pos-keyboard-key">0</button>
<button type="button" class="btn btn-default pos-keyboard-key">.</button>
<button type="button" class="btn btn-default numeric-keypad numeric-del">Del</button>
<button type="button" class="btn btn-default numeric-keypad" val="0">0</button>
<button type="button" class="btn btn-default numeric-keypad" val=".">.</button>
<button type="button" class="btn btn-primary pos-pay">Pay</button>
</div>
</div>

View File

@ -18,13 +18,13 @@
</div>
<div class="col-xs-2 text-right">
<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 class="col-xs-3 text-right">
<div class="text-muted" style="margin-top: 5px;">
{% 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 { %}
<h6>{%= format_currency(rate) %}</h6>
{% } %}

View File

@ -3,25 +3,25 @@
<div class="form-group edit-pos-item">
<label class=" text-left col-xs-4">Price:</label>
<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 class="form-group edit-pos-item">
<label class=" text-left col-xs-4">Qty:</label>
<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 class="form-group edit-pos-item">
<label class=" text-left col-xs-4">Discount:</label>
<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 class="form-group edit-pos-item">
<label class=" text-left col-xs-4">Amount:</label>
<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>

View File

@ -104,13 +104,14 @@
.item-cart {
overflow-y: scroll;
height: ~"calc(100vh - 60vh)";
height: ~"calc(100vh - 72vh)";
}
.edit-pos-item {
height: 40px;
height: 50px;
font-size: 14px;
border-top: 1px solid @border-color;
padding-top: 12px;
}
.pos-bill-item:hover {
@ -212,6 +213,17 @@
}
.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;
height:69px;
width:69px;