fix: Remove advance_payment_status uses
(cherry picked from commit 907e3af1b0)
This commit is contained in:
committed by
Mergify
parent
ef52be2f17
commit
36b4f68566
@@ -206,9 +206,6 @@ class PaymentRequest(Document):
|
|||||||
self.send_email()
|
self.send_email()
|
||||||
self.make_communication_entry()
|
self.make_communication_entry()
|
||||||
|
|
||||||
def on_submit(self):
|
|
||||||
self.update_reference_advance_payment_status()
|
|
||||||
|
|
||||||
def request_phone_payment(self):
|
def request_phone_payment(self):
|
||||||
controller = _get_payment_gateway_controller(self.payment_gateway)
|
controller = _get_payment_gateway_controller(self.payment_gateway)
|
||||||
request_amount = self.get_request_amount()
|
request_amount = self.get_request_amount()
|
||||||
@@ -493,14 +490,6 @@ class PaymentRequest(Document):
|
|||||||
if payment_provider == "stripe":
|
if payment_provider == "stripe":
|
||||||
return create_stripe_subscription(gateway_controller, data)
|
return create_stripe_subscription(gateway_controller, data)
|
||||||
|
|
||||||
def update_reference_advance_payment_status(self):
|
|
||||||
advance_payment_doctypes = frappe.get_hooks("advance_payment_receivable_doctypes") + frappe.get_hooks(
|
|
||||||
"advance_payment_payable_doctypes"
|
|
||||||
)
|
|
||||||
if self.reference_doctype in advance_payment_doctypes:
|
|
||||||
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
|
|
||||||
ref_doc.set_advance_payment_status()
|
|
||||||
|
|
||||||
def _allocate_payment_request_to_pe_references(self, references):
|
def _allocate_payment_request_to_pe_references(self, references):
|
||||||
"""
|
"""
|
||||||
Allocate the Payment Request to the Payment Entry references based on\n
|
Allocate the Payment Request to the Payment Entry references based on\n
|
||||||
|
|||||||
@@ -284,8 +284,6 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
def test_multiple_payment_if_partially_paid_for_same_currency(self):
|
def test_multiple_payment_if_partially_paid_for_same_currency(self):
|
||||||
so = make_sales_order(currency="INR", qty=1, rate=1000)
|
so = make_sales_order(currency="INR", qty=1, rate=1000)
|
||||||
|
|
||||||
self.assertEqual(so.advance_payment_status, "Not Requested")
|
|
||||||
|
|
||||||
pr = make_payment_request(
|
pr = make_payment_request(
|
||||||
dt="Sales Order",
|
dt="Sales Order",
|
||||||
dn=so.name,
|
dn=so.name,
|
||||||
@@ -300,7 +298,6 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
self.assertEqual(pr.status, "Requested")
|
self.assertEqual(pr.status, "Requested")
|
||||||
|
|
||||||
so.load_from_db()
|
so.load_from_db()
|
||||||
self.assertEqual(so.advance_payment_status, "Requested")
|
|
||||||
|
|
||||||
# to make partial payment
|
# to make partial payment
|
||||||
pe = pr.create_payment_entry(submit=False)
|
pe = pr.create_payment_entry(submit=False)
|
||||||
@@ -311,7 +308,6 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
self.assertEqual(pe.references[0].payment_request, pr.name)
|
self.assertEqual(pe.references[0].payment_request, pr.name)
|
||||||
|
|
||||||
so.load_from_db()
|
so.load_from_db()
|
||||||
self.assertEqual(so.advance_payment_status, "Partially Paid")
|
|
||||||
|
|
||||||
pr.load_from_db()
|
pr.load_from_db()
|
||||||
self.assertEqual(pr.status, "Partially Paid")
|
self.assertEqual(pr.status, "Partially Paid")
|
||||||
@@ -327,7 +323,6 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
self.assertEqual(pe.references[0].payment_request, pr.name)
|
self.assertEqual(pe.references[0].payment_request, pr.name)
|
||||||
|
|
||||||
so.load_from_db()
|
so.load_from_db()
|
||||||
self.assertEqual(so.advance_payment_status, "Fully Paid")
|
|
||||||
|
|
||||||
pr.load_from_db()
|
pr.load_from_db()
|
||||||
self.assertEqual(pr.status, "Paid")
|
self.assertEqual(pr.status, "Paid")
|
||||||
@@ -409,8 +404,6 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
po.save()
|
po.save()
|
||||||
po.submit()
|
po.submit()
|
||||||
|
|
||||||
self.assertEqual(po.advance_payment_status, "Not Initiated")
|
|
||||||
|
|
||||||
pr = make_payment_request(
|
pr = make_payment_request(
|
||||||
dt="Purchase Order",
|
dt="Purchase Order",
|
||||||
dn=po.name,
|
dn=po.name,
|
||||||
@@ -425,7 +418,6 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
self.assertEqual(pr.status, "Initiated")
|
self.assertEqual(pr.status, "Initiated")
|
||||||
|
|
||||||
po.load_from_db()
|
po.load_from_db()
|
||||||
self.assertEqual(po.advance_payment_status, "Initiated")
|
|
||||||
|
|
||||||
pe = pr.create_payment_entry()
|
pe = pr.create_payment_entry()
|
||||||
|
|
||||||
@@ -441,7 +433,6 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
self.assertEqual(pe.references[1].payment_request, pr.name)
|
self.assertEqual(pe.references[1].payment_request, pr.name)
|
||||||
|
|
||||||
po.load_from_db()
|
po.load_from_db()
|
||||||
self.assertEqual(po.advance_payment_status, "Fully Paid")
|
|
||||||
|
|
||||||
pr.load_from_db()
|
pr.load_from_db()
|
||||||
self.assertEqual(pr.status, "Paid")
|
self.assertEqual(pr.status, "Paid")
|
||||||
@@ -491,7 +482,6 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
|
|
||||||
def test_payment_cancel_process(self):
|
def test_payment_cancel_process(self):
|
||||||
so = make_sales_order(currency="INR", qty=1, rate=1000)
|
so = make_sales_order(currency="INR", qty=1, rate=1000)
|
||||||
self.assertEqual(so.advance_payment_status, "Not Requested")
|
|
||||||
|
|
||||||
pr = make_payment_request(
|
pr = make_payment_request(
|
||||||
dt="Sales Order",
|
dt="Sales Order",
|
||||||
@@ -506,7 +496,6 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
self.assertEqual(pr.outstanding_amount, pr.grand_total)
|
self.assertEqual(pr.outstanding_amount, pr.grand_total)
|
||||||
|
|
||||||
so.load_from_db()
|
so.load_from_db()
|
||||||
self.assertEqual(so.advance_payment_status, "Requested")
|
|
||||||
|
|
||||||
pe = pr.create_payment_entry(submit=False)
|
pe = pr.create_payment_entry(submit=False)
|
||||||
pe.paid_amount = 800
|
pe.paid_amount = 800
|
||||||
@@ -516,7 +505,6 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
self.assertEqual(pe.references[0].payment_request, pr.name)
|
self.assertEqual(pe.references[0].payment_request, pr.name)
|
||||||
|
|
||||||
so.load_from_db()
|
so.load_from_db()
|
||||||
self.assertEqual(so.advance_payment_status, "Partially Paid")
|
|
||||||
|
|
||||||
pr.load_from_db()
|
pr.load_from_db()
|
||||||
self.assertEqual(pr.status, "Partially Paid")
|
self.assertEqual(pr.status, "Partially Paid")
|
||||||
@@ -532,4 +520,3 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
self.assertEqual(pr.grand_total, 1000)
|
self.assertEqual(pr.grand_total, 1000)
|
||||||
|
|
||||||
so.load_from_db()
|
so.load_from_db()
|
||||||
self.assertEqual(so.advance_payment_status, "Requested")
|
|
||||||
|
|||||||
@@ -1846,37 +1846,6 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
self.db_set("advance_paid", advance_paid)
|
self.db_set("advance_paid", advance_paid)
|
||||||
|
|
||||||
self.set_advance_payment_status()
|
|
||||||
|
|
||||||
def set_advance_payment_status(self):
|
|
||||||
new_status = None
|
|
||||||
|
|
||||||
paid_amount = frappe.get_value(
|
|
||||||
doctype="Payment Request",
|
|
||||||
filters={
|
|
||||||
"reference_doctype": self.doctype,
|
|
||||||
"reference_name": self.name,
|
|
||||||
"docstatus": 1,
|
|
||||||
},
|
|
||||||
fieldname="sum(grand_total - outstanding_amount)",
|
|
||||||
)
|
|
||||||
|
|
||||||
if not paid_amount:
|
|
||||||
if self.doctype in frappe.get_hooks("advance_payment_receivable_doctypes"):
|
|
||||||
new_status = "Not Requested" if paid_amount is None else "Requested"
|
|
||||||
elif self.doctype in frappe.get_hooks("advance_payment_payable_doctypes"):
|
|
||||||
new_status = "Not Initiated" if paid_amount is None else "Initiated"
|
|
||||||
else:
|
|
||||||
total_amount = self.get("rounded_total") or self.get("grand_total")
|
|
||||||
new_status = "Fully Paid" if paid_amount == total_amount else "Partially Paid"
|
|
||||||
|
|
||||||
if new_status == self.advance_payment_status:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.db_set("advance_payment_status", new_status, update_modified=False)
|
|
||||||
self.set_status(update=True)
|
|
||||||
self.notify_update()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def company_abbr(self):
|
def company_abbr(self):
|
||||||
if not hasattr(self, "_abbr"):
|
if not hasattr(self, "_abbr"):
|
||||||
|
|||||||
@@ -354,7 +354,6 @@ doc_events = {
|
|||||||
"Payment Entry": {
|
"Payment Entry": {
|
||||||
"on_submit": [
|
"on_submit": [
|
||||||
"erpnext.regional.create_transaction_log",
|
"erpnext.regional.create_transaction_log",
|
||||||
"erpnext.accounts.doctype.payment_request.payment_request.update_payment_req_status",
|
|
||||||
"erpnext.accounts.doctype.dunning.dunning.resolve_dunning",
|
"erpnext.accounts.doctype.dunning.dunning.resolve_dunning",
|
||||||
],
|
],
|
||||||
"on_trash": "erpnext.regional.check_deletion_permission",
|
"on_trash": "erpnext.regional.check_deletion_permission",
|
||||||
|
|||||||
Reference in New Issue
Block a user