set paid amount with grand amount on invoice form
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 8ca4d5f..b73673f 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -263,6 +263,10 @@
});
}
}
+ },
+
+ amount: function(){
+ this.write_off_outstanding_amount_automatically()
}
});
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index e7485c1..fde33e8 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -549,13 +549,6 @@
if(this.frm.doc.doctype == "Sales Invoice" || this.frm.doc.doctype == "Purchase Invoice") {
frappe.model.round_floats_in(this.frm.doc, ["paid_amount"]);
- if(this.frm.doc.is_pos || this.frm.doc.is_paid) {
- if(!this.frm.doc.paid_amount || update_paid_amount===undefined || update_paid_amount) {
- this.frm.doc.paid_amount = flt(total_amount_to_pay);
- }
- } else {
- this.frm.doc.paid_amount = 0
- }
this.set_in_company_currency(this.frm.doc, ["paid_amount"]);
if(this.frm.refresh_field){
@@ -564,6 +557,7 @@
}
if(this.frm.doc.doctype == "Sales Invoice"){
+ this.set_default_payment(total_amount_to_pay, update_paid_amount)
this.calculate_paid_amount()
}
@@ -585,6 +579,19 @@
this.calculate_change_amount()
},
+ set_default_payment: function(total_amount_to_pay, update_paid_amount){
+ var me = this;
+ payment_status = true;
+ if(this.frm.doc.is_pos && (!this.frm.doc.paid_amount || update_paid_amount===undefined || update_paid_amount)){
+ $.each(this.frm.doc['payments'] || [], function(index, data){
+ if(data.type == "Cash" && payment_status) {
+ data.amount = total_amount_to_pay;
+ payment_status = false;
+ }
+ })
+ }
+ },
+
calculate_paid_amount: function(){
var me = this;
var paid_amount = base_paid_amount = 0.0;
diff --git a/erpnext/public/js/payment/payments.js b/erpnext/public/js/payment/payments.js
index dc0b026..9464f50 100644
--- a/erpnext/public/js/payment/payments.js
+++ b/erpnext/public/js/payment/payments.js
@@ -74,7 +74,7 @@
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
+ //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()