[POS] Enhancement to set default payment as cash, functionality to clear amount value, renamed doctype Payments and some fixes.
diff --git a/erpnext/public/js/payment/payment_details.html b/erpnext/public/js/payment/payment_details.html
index 00a2d93..18f9d03 100644
--- a/erpnext/public/js/payment/payment_details.html
+++ b/erpnext/public/js/payment/payment_details.html
@@ -1,9 +1,11 @@
<div class="row pos-payment-row" type="{{type}}" idx={{idx}}>
- <div class="col-xs-6"><h5 class="payment-mode text-ellipsis" idx="{{idx}}"> {{mode_of_payment}} </h5></div>
- <div class="col-xs-6 text-right">
- <input disabled data-fieldtype="Currency"
- style="cursor: pointer;"
- class="input-with-feedback form-control text-right amount"
- idx="{{idx}}" type="text" value="{{format_number(amount, 2)}}">
+ <div class="col-xs-6">{{mode_of_payment}}</div>
+ <div class="col-xs-6">
+ <div class="input-group">
+ <input disabled class="form-control text-right amount" idx="{{idx}}" type="text" value="{{format_number(amount, 2)}}">
+ <span class="input-group-btn">
+ <button type="button" class="btn btn-default clr" idx="{{idx}}" style="border:1px solid #d1d8dd">C</button>
+ </span>
</div>
+ </div>
</div>
\ No newline at end of file
diff --git a/erpnext/public/js/payment/payments.js b/erpnext/public/js/payment/payments.js
index f5527b1..4cd12f1 100644
--- a/erpnext/public/js/payment/payments.js
+++ b/erpnext/public/js/payment/payments.js
@@ -31,6 +31,7 @@
$(this.$body).html(frappe.render_template('pos_payment', this.frm.doc))
this.show_payment_details();
this.bind_keyboard_event()
+ this.clear_amount()
},
make_multimode_payment: function(){
@@ -57,11 +58,33 @@
currency: me.frm.doc.currency,
type: data.type
})).appendTo(multimode_payments)
+
+ if (data.type == 'Cash' && me.frm.doc.outstanding_amount > 0) {
+ me.idx = data.idx;
+ me.set_outstanding_amount();
+ }
})
}else{
$("<p>No payment mode selected in pos profile</p>").appendTo(multimode_payments)
}
},
+
+ set_outstanding_amount: function(){
+ this.selected_mode = $(this.$body).find(repl("input[idx='%(idx)s']",{'idx': this.idx}));
+ this.highlight_selected_row()
+ this.payment_val = 0.0
+ if(this.frm.doc.outstanding_amount > 0 && flt(this.selected_mode.val()) == 0.0){
+ //When user first tithis click on row
+ this.payment_val = flt(this.frm.doc.outstanding_amount)
+ this.selected_mode.val(format_number(this.payment_val, 2));
+ this.update_paid_amount()
+ }else if(flt(this.selected_mode.val()) > 0){
+ //If user click on existing row which has value
+ this.payment_val = flt(this.selected_mode.val());
+ }
+ this.selected_mode.select()
+ this.bind_amount_change_event();
+ },
bind_keyboard_event: function(){
var me = this;
@@ -69,28 +92,15 @@
this.bind_payment_mode_keys_event();
this.bind_keyboard_keys_event();
},
-
+
bind_payment_mode_keys_event: function(){
var me = this;
$(this.$body).find('.pos-payment-row').click(function(){
me.idx = $(this).attr("idx");
- me.selected_mode = $(me.$body).find(repl("input[idx='%(idx)s']",{'idx': me.idx}));
- me.highlight_selected_row()
- me.payment_val = 0.0
- if(me.frm.doc.outstanding_amount > 0 && flt(me.selected_mode.val()) == 0.0){
- //When user first time click on row
- me.payment_val = flt(me.frm.doc.outstanding_amount)
- me.selected_mode.val(format_number(me.payment_val, 2));
- me.update_paid_amount()
- }else if(flt(me.selected_mode.val()) > 0){
- //If user click on existing row which has value
- me.payment_val = flt(me.selected_mode.val());
- }
- me.selected_mode.select()
- me.bind_amount_change_event();
+ me.set_outstanding_amount()
})
},
-
+
highlight_selected_row: function(){
var me = this;
selected_row = $(this.$body).find(repl(".pos-payment-row[idx='%(idx)s']",{'idx': this.idx}));
@@ -127,7 +137,19 @@
me.update_paid_amount()
})
},
-
+
+ clear_amount: function(){
+ var me = this;
+ $(this.$body).find('.clr').click(function(e){
+ e.stopPropagation();
+ me.idx = $(this).attr("idx");
+ me.selected_mode = $(me.$body).find(repl("input[idx='%(idx)s']",{'idx': me.idx}));
+ me.payment_val = 0.0;
+ me.selected_mode.val(0.0);
+ me.update_paid_amount();
+ })
+ },
+
update_paid_amount: function(){
var me = this;
$.each(this.frm.doc.payments, function(index, data){