Skip to content

Commit

Permalink
chore: Update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
deepeshgarg007 committed Dec 20, 2022
1 parent dc17898 commit e25b98b
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions erpnext/accounts/doctype/payment_request/payment_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,44 +411,44 @@ def make_payment_request(**args):
else ""
)

existing_payment_request = frappe.db.get_value(
draft_payment_request = frappe.db.get_value(
"Payment Request",
{"reference_doctype": args.dt, "reference_name": args.dn, "docstatus": ("!=", 2)},
{"reference_doctype": args.dt, "reference_name": args.dn, "docstatus": 0},
)

if existing_payment_request:
existing_payment_request_amount = get_existing_payment_request_amount(args.dt, args.dn)

if existing_payment_request_amount:
grand_total -= existing_payment_request_amount

if draft_payment_request:
frappe.db.set_value(
"Payment Request", existing_payment_request, "grand_total", grand_total, update_modified=False
"Payment Request", draft_payment_request, "grand_total", grand_total, update_modified=False
)
pr = frappe.get_doc("Payment Request", existing_payment_request)
pr = frappe.get_doc("Payment Request", draft_payment_request)
else:
if args.order_type != "Shopping Cart":
existing_payment_request_amount = get_existing_payment_request_amount(args.dt, args.dn)

if existing_payment_request_amount:
grand_total -= existing_payment_request_amount

pr = frappe.new_doc("Payment Request")
pr.update(
{
"payment_gateway_account": gateway_account.get("name"),
"payment_gateway": gateway_account.get("payment_gateway"),
"payment_account": gateway_account.get("payment_account"),
"payment_channel": gateway_account.get("payment_channel"),
"payment_request_type": args.get("payment_request_type"),
"currency": ref_doc.currency,
"grand_total": grand_total,
"mode_of_payment": args.mode_of_payment,
"email_to": args.recipient_id or ref_doc.owner,
"subject": _("Payment Request for {0}").format(args.dn),
"message": gateway_account.get("message") or get_dummy_message(ref_doc),
"reference_doctype": args.dt,
"reference_name": args.dn,
"party_type": args.get("party_type") or "Customer",
"party": args.get("party") or ref_doc.get("customer"),
"bank_account": bank_account,
}
)
pr = frappe.new_doc("Payment Request")
pr.update(
{
"payment_gateway_account": gateway_account.get("name"),
"payment_gateway": gateway_account.get("payment_gateway"),
"payment_account": gateway_account.get("payment_account"),
"payment_channel": gateway_account.get("payment_channel"),
"payment_request_type": args.get("payment_request_type"),
"currency": ref_doc.currency,
"grand_total": grand_total,
"mode_of_payment": args.mode_of_payment,
"email_to": args.recipient_id or ref_doc.owner,
"subject": _("Payment Request for {0}").format(args.dn),
"message": gateway_account.get("message") or get_dummy_message(ref_doc),
"reference_doctype": args.dt,
"reference_name": args.dn,
"party_type": args.get("party_type") or "Customer",
"party": args.get("party") or ref_doc.get("customer"),
"bank_account": bank_account,
}
)

if args.order_type == "Shopping Cart" or args.mute_email:
pr.flags.mute_email = True
Expand Down

0 comments on commit e25b98b

Please sign in to comment.