From 88514a246b8cc00a6fa8a3e8d2397396c04c3ed7 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 19 Jul 2016 20:04:44 +0530 Subject: [PATCH] set paid amount with grand amount on invoice form --- .../doctype/sales_invoice/sales_invoice.js | 4 ++++ .../public/js/controllers/taxes_and_totals.js | 21 ++++++++++++------- erpnext/public/js/payment/payments.js | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 8ca4d5f1e5..b73673fe94 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -263,6 +263,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }); } } + }, + + 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 e7485c19d4..fde33e8415 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -549,13 +549,6 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ 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 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ } 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 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ 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 dc0b02638d..9464f50f67 100644 --- a/erpnext/public/js/payment/payments.js +++ b/erpnext/public/js/payment/payments.js @@ -74,7 +74,7 @@ erpnext.payments = erpnext.stock.StockController.extend({ 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()