Skip to content

Commit

Permalink
fix: Separate on_submit and before_submit of PR
Browse files Browse the repository at this point in the history
(cherry picked from commit dbd7b83)
  • Loading branch information
Abdeali099 authored and mergify[bot] committed Oct 7, 2024
1 parent 677aadd commit d828ea6
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions erpnext/accounts/doctype/payment_request/payment_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,28 @@ def before_submit(self):
else:
self.outstanding_amount = self.grand_total

def on_submit(self):
if self.payment_request_type == "Outward":
self.status = "Initiated"
self.db_set("status", "Initiated")
return
elif self.payment_request_type == "Inward":
self.status = "Requested"
self.db_set("status", "Requested")

if self.payment_request_type == "Inward":
if self.payment_channel == "Phone":
self.request_phone_payment()
else:
self.set_payment_request_url()
if not (self.mute_email or self.flags.mute_email):
self.send_email()
self.make_communication_entry()
send_mail = self.payment_gateway_validation() if self.payment_gateway else None
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)

if (
hasattr(ref_doc, "order_type") and ref_doc.order_type == "Shopping Cart"
) or self.flags.mute_email:
send_mail = False

if send_mail and self.payment_channel != "Phone":
self.set_payment_request_url()
self.send_email()
self.make_communication_entry()

elif self.payment_channel == "Phone":
self.request_phone_payment()

def request_phone_payment(self):
controller = _get_payment_gateway_controller(self.payment_gateway)
Expand Down

0 comments on commit d828ea6

Please sign in to comment.