From 675f79920e99013917bb271415c230f3baf4a534 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Fri, 23 Oct 2020 15:41:05 +0530 Subject: [PATCH] fix: consider the existing paid payment request for phone payment channel --- .../accounts/doctype/payment_request/payment_request.py | 8 +++++++- .../doctype/payment_request/test_payment_request.py | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index cb58f89dfb..1b97050eb1 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -393,6 +393,10 @@ def get_amount(ref_doc, payment_account=None): frappe.throw(_("Payment Entry is already created")) def get_existing_payment_request_amount(ref_dt, ref_dn): + """ + Get the existing payment request which are unpaid or partially paid for payment channel other than Phone + and get the summation of existing paid payment request for Phone payment channel. + """ existing_payment_request_amount = frappe.db.sql(""" select sum(grand_total) from `tabPayment Request` @@ -400,7 +404,9 @@ def get_existing_payment_request_amount(ref_dt, ref_dn): reference_doctype = %s and reference_name = %s and docstatus = 1 - and status = 'Paid' + and (status != 'Paid' + or (payment_channel = 'Phone' + and status = 'Paid')) """, (ref_dt, ref_dn)) return flt(existing_payment_request_amount[0][0]) if existing_payment_request_amount else 0 diff --git a/erpnext/accounts/doctype/payment_request/test_payment_request.py b/erpnext/accounts/doctype/payment_request/test_payment_request.py index 747bad8bb5..8a10e2cbd9 100644 --- a/erpnext/accounts/doctype/payment_request/test_payment_request.py +++ b/erpnext/accounts/doctype/payment_request/test_payment_request.py @@ -127,7 +127,6 @@ class TestPaymentRequest(unittest.TestCase): recipient_id="nabin@erpnext.com", return_doc=1) pr1.grand_total = 200 pr1.submit() - pr1.set_as_paid() # Make a 2nd Payment Request pr2 = make_payment_request(dt="Sales Order", dn=so.name,