mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
Merge pull request #6039 from rohitwaghchaure/allow_to_edit_change_amount
Allow to edit change amount
This commit is contained in:
@@ -138,12 +138,14 @@
|
||||
font-size: 15px;
|
||||
}
|
||||
.pos-payment-row .col-xs-6 {
|
||||
padding: 10px;
|
||||
padding: 15px;
|
||||
}
|
||||
.pos-payment-row {
|
||||
border-bottom: 1px solid #d1d8dd;
|
||||
margin: 2px 0px 5px 0px;
|
||||
height: 60px;
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.pos-payment-row:hover,
|
||||
.pos-keyboard-key:hover {
|
||||
@@ -203,3 +205,8 @@ body[data-route="pos"] .modal-dialog {
|
||||
.pos-invoice-list {
|
||||
padding: 15px 10px;
|
||||
}
|
||||
.write_off_amount,
|
||||
.change_amount {
|
||||
margin: 15px;
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
@@ -615,4 +615,18 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
||||
this.frm.doc.base_change_amount = flt(this.frm.doc.change_amount * this.frm.doc.conversion_rate,
|
||||
precision("base_change_amount"));
|
||||
},
|
||||
|
||||
calculate_write_off_amount: function(){
|
||||
if(this.frm.doc.paid_amount > this.frm.doc.grand_total){
|
||||
this.frm.doc.write_off_amount = flt(this.frm.doc.grand_total - this.frm.doc.paid_amount + this.frm.doc.change_amount,
|
||||
precision("write_off_amount"))
|
||||
|
||||
this.frm.doc.base_write_off_amount = flt(this.frm.doc.write_off_amount * this.frm.doc.conversion_rate,
|
||||
precision("base_write_off_amount"));
|
||||
}else{
|
||||
this.frm.doc.paid_amount = 0.0
|
||||
}
|
||||
|
||||
this.calculate_outstanding_amount(false)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="row pos-payment-row" type="{{type}}" idx={{idx}}>
|
||||
<div class="col-xs-6">{{mode_of_payment}}</div>
|
||||
<div class="col-xs-6" style="padding:20px">{{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)}}">
|
||||
|
||||
@@ -13,6 +13,14 @@ erpnext.payments = erpnext.stock.StockController.extend({
|
||||
this.$body = this.dialog.body;
|
||||
this.set_payment_primary_action();
|
||||
this.make_keyboard();
|
||||
this.select_text()
|
||||
},
|
||||
|
||||
select_text: function(){
|
||||
var me = this;
|
||||
$(this.$body).find('.form-control').click(function(){
|
||||
$(this).select();
|
||||
})
|
||||
},
|
||||
|
||||
set_payment_primary_action: function(){
|
||||
@@ -20,7 +28,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
|
||||
|
||||
this.dialog.set_primary_action(__("Submit"), function() {
|
||||
me.dialog.hide()
|
||||
me.write_off_amount()
|
||||
me.submit_invoice()
|
||||
})
|
||||
},
|
||||
|
||||
@@ -78,7 +86,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
|
||||
//When user first time 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()
|
||||
this.update_payment_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());
|
||||
@@ -90,17 +98,29 @@ erpnext.payments = erpnext.stock.StockController.extend({
|
||||
bind_keyboard_event: function(){
|
||||
var me = this;
|
||||
this.payment_val = '';
|
||||
this.bind_payment_mode_keys_event();
|
||||
this.bind_keyboard_keys_event();
|
||||
this.bind_form_control_event();
|
||||
this.bind_numeric_keys_event();
|
||||
},
|
||||
|
||||
bind_payment_mode_keys_event: function(){
|
||||
bind_form_control_event: function(){
|
||||
var me = this;
|
||||
$(this.$body).find('.pos-payment-row').click(function(){
|
||||
if(me.frm.doc.outstanding_amount > 0){
|
||||
me.idx = $(this).attr("idx");
|
||||
me.set_outstanding_amount()
|
||||
}
|
||||
me.idx = $(this).attr("idx");
|
||||
me.set_outstanding_amount()
|
||||
})
|
||||
|
||||
$(this.$body).find('.form-control').click(function(){
|
||||
me.idx = $(this).attr("idx");
|
||||
me.set_outstanding_amount();
|
||||
me.update_paid_amount();
|
||||
})
|
||||
|
||||
$(this.$body).find('.write_off_amount').change(function(){
|
||||
me.write_off_amount(flt($(this).val()));
|
||||
})
|
||||
|
||||
$(this.$body).find('.change_amount').change(function(){
|
||||
me.change_amount(flt($(this).val()));
|
||||
})
|
||||
},
|
||||
|
||||
@@ -113,13 +133,13 @@ erpnext.payments = erpnext.stock.StockController.extend({
|
||||
this.selected_mode.attr('disabled', false);
|
||||
},
|
||||
|
||||
bind_keyboard_keys_event: function(){
|
||||
bind_numeric_keys_event: function(){
|
||||
var me = this;
|
||||
$(this.$body).find('.pos-keyboard-key').click(function(){
|
||||
me.payment_val += $(this).text();
|
||||
me.selected_mode.val(format_number(me.payment_val, 2))
|
||||
me.idx = me.selected_mode.attr("idx")
|
||||
me.update_paid_amount()
|
||||
me.selected_mode.change()
|
||||
})
|
||||
|
||||
$(this.$body).find('.delete-btn').click(function(){
|
||||
@@ -137,15 +157,11 @@ erpnext.payments = erpnext.stock.StockController.extend({
|
||||
me.payment_val = flt($(this).val()) || 0.0;
|
||||
me.selected_mode.val(format_number(me.payment_val, 2))
|
||||
me.idx = me.selected_mode.attr("idx")
|
||||
me.update_paid_amount()
|
||||
})
|
||||
|
||||
this.selected_mode.click(function(){
|
||||
me.selected_mode.select();
|
||||
me.update_payment_amount()
|
||||
})
|
||||
},
|
||||
|
||||
clear_amount: function(){
|
||||
clear_amount: function() {
|
||||
var me = this;
|
||||
$(this.$body).find('.clr').click(function(e){
|
||||
e.stopPropagation();
|
||||
@@ -154,25 +170,65 @@ erpnext.payments = erpnext.stock.StockController.extend({
|
||||
me.payment_val = 0.0;
|
||||
me.selected_mode.val(0.0);
|
||||
me.highlight_selected_row();
|
||||
me.update_paid_amount();
|
||||
me.update_payment_amount();
|
||||
})
|
||||
},
|
||||
|
||||
update_paid_amount: function(){
|
||||
write_off_amount: function(write_off_amount) {
|
||||
var me = this;
|
||||
|
||||
if(this.frm.doc.paid_amount > 0){
|
||||
this.frm.doc.write_off_amount = write_off_amount;
|
||||
this.frm.doc.base_write_off_amount = flt(this.frm.doc.write_off_amount * this.frm.doc.conversion_rate,
|
||||
precision("base_write_off_amount"));
|
||||
this.calculate_outstanding_amount(false)
|
||||
this.show_amounts()
|
||||
}
|
||||
},
|
||||
|
||||
change_amount: function(change_amount) {
|
||||
var me = this;
|
||||
|
||||
this.frm.doc.change_amount = change_amount;
|
||||
this.calculate_write_off_amount()
|
||||
this.show_amounts()
|
||||
},
|
||||
|
||||
update_paid_amount: function() {
|
||||
var me = this;
|
||||
if(in_list(['change_amount', 'write_off_amount'], this.idx)){
|
||||
value = flt(me.selected_mode.val(), 2)
|
||||
if(me.idx == 'change_amount'){
|
||||
me.change_amount(value)
|
||||
} else{
|
||||
if(value == 0) {
|
||||
value = me.frm.doc.outstanding_amount;
|
||||
}
|
||||
me.write_off_amount(value)
|
||||
}
|
||||
}else{
|
||||
this.update_payment_amount()
|
||||
}
|
||||
},
|
||||
|
||||
update_payment_amount: function(){
|
||||
var me = this;
|
||||
|
||||
$.each(this.frm.doc.payments, function(index, data){
|
||||
if(cint(me.idx) == cint(data.idx)){
|
||||
data.amount = flt(me.selected_mode.val(), 2)
|
||||
}
|
||||
})
|
||||
|
||||
this.calculate_outstanding_amount(false);
|
||||
this.show_amounts();
|
||||
},
|
||||
|
||||
|
||||
show_amounts: function(){
|
||||
var me = this;
|
||||
$(this.$body).find(".write_off_amount").val(format_number(this.frm.doc.write_off_amount, 2));
|
||||
$(this.$body).find('.paid_amount').text(format_currency(this.frm.doc.paid_amount, this.frm.doc.currency));
|
||||
$(this.$body).find('.change_amount').text(format_currency(this.frm.doc.change_amount, this.frm.doc.currency))
|
||||
$(this.$body).find('.change_amount').val(format_number(this.frm.doc.change_amount, 2))
|
||||
$(this.$body).find('.outstanding_amount').text(format_currency(this.frm.doc.outstanding_amount, this.frm.doc.currency))
|
||||
this.update_invoice();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<div class="pos_payment row">
|
||||
<div class="row" style="padding: 0px 30px;">
|
||||
<h3>Total Amount: <span class="label label-default" style="font-size:20px;padding:5px">{%= format_currency(grand_total, currency) %}</span></h3>
|
||||
</div>
|
||||
<div class="row amount-row">
|
||||
<div class="col-xs-6 col-sm-3 text-center">
|
||||
<p class="amount-label"> Total <h3>{%= format_currency(grand_total, currency) %} </h3></p>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-3 text-center">
|
||||
<p class="amount-label"> Paid <h3 class="paid_amount">{%= format_currency(paid_amount, currency) %}</h3></p>
|
||||
</div>
|
||||
@@ -10,13 +10,19 @@
|
||||
<p class="amount-label"> Outstanding <h3 class="outstanding_amount">{%= format_currency(outstanding_amount, currency) %} </h3></p>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-3 text-center">
|
||||
<p class="amount-label"> Change <h3 class="change_amount">{%= format_currency(change_amount, currency) %}</h3>
|
||||
<p class="amount-label"> Change <input class="form-control text-right change_amount bold" type="text" idx="change_amount" value="{{format_number(change_amount, 2)}}">
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-3 text-center">
|
||||
<p class="amount-label"> Write off <input class="form-control text-right write_off_amount bold" type="text" idx="write_off_amount" value="{{format_number(write_off_amount, 2)}}">
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 multimode-payments">
|
||||
<div class="col-sm-6 ">
|
||||
<div class ="row multimode-payments">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 payment-toolbar">
|
||||
{% for(var i=0; i<3; i++) { %}
|
||||
|
||||
@@ -176,13 +176,15 @@
|
||||
}
|
||||
|
||||
.pos-payment-row .col-xs-6 {
|
||||
padding :10px;
|
||||
padding :15px;
|
||||
}
|
||||
|
||||
.pos-payment-row {
|
||||
border-bottom:1px solid #d1d8dd;
|
||||
margin: 2px 0px 5px 0px;
|
||||
height: 60px;
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.pos-payment-row:hover, .pos-keyboard-key:hover{
|
||||
@@ -248,3 +250,8 @@ body[data-route="pos"] .modal-dialog {
|
||||
.pos-invoice-list {
|
||||
padding: 15px 10px;
|
||||
}
|
||||
|
||||
.write_off_amount, .change_amount {
|
||||
margin: 15px;
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user