From 210f4984f7cda64941262dddfc7eb35e82b1f51b Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 3 Oct 2018 15:55:51 +0530 Subject: [PATCH] [Fix] Payment request not working --- .../doctype/purchase_invoice/purchase_invoice.js | 5 +++-- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 9 +++++---- erpnext/public/js/controllers/transaction.js | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index c37fd15ab9..3da54f0611 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -77,8 +77,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ } if (doc.outstanding_amount > 0 && !cint(doc.is_return)) { - cur_frm.add_custom_button(__('Payment Request'), - this.make_payment_request, __("Make")); + cur_frm.add_custom_button(__('Payment Request'), function() { + me.make_payment_request() + }, __("Make")); } if(doc.docstatus===0) { diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index ca74d4da15..b8ea205d48 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -35,6 +35,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }, refresh: function(doc, dt, dn) { + const me = this; this._super(); if(cur_frm.msgbox && cur_frm.msgbox.$wrapper.is(":visible")) { // hide new msgbox @@ -82,9 +83,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } } - if(doc.outstanding_amount>0 && !cint(doc.is_return)) { - cur_frm.add_custom_button(__('Payment Request'), - this.make_payment_request, __("Make")); + if (doc.outstanding_amount>0 && !cint(doc.is_return)) { + cur_frm.add_custom_button(__('Payment Request'), function() { + me.make_payment_request(); + }, __("Make")); } if(!doc.auto_repeat) { @@ -102,7 +104,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } this.set_default_print_format(); - var me = this; if (doc.docstatus == 1 && !doc.inter_company_invoice_reference) { frappe.model.with_doc("Customer", me.frm.doc.customer, function() { var customer = frappe.model.get_doc("Customer", me.frm.doc.customer); diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 3b6f169d36..a27161f012 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -211,8 +211,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }, make_payment_request: function() { - const me = this; - const payment_request_type = (in_list(['Sales Order', 'Sales Invoice'], me.frm.doc.doctype)) + var me = this; + const payment_request_type = (in_list(['Sales Order', 'Sales Invoice'], this.frm.doc.doctype)) ? "Inward" : "Outward"; frappe.call({