Skip to content

Commit

Permalink
fix: sets field even when no default method (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
HKuz committed May 14, 2024
1 parent e383190 commit 08b387b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions electronic_payments/www/payments/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def get_context(context):
discount_amount = get_discount_amount(context.doc, data)
party = context.doc.customer if context.doc.customer else context.doc.supplier
payment_methods = []
has_default = False
for pm in frappe.get_all("Portal Payment Method", {"parent": party}, order_by="`default` DESC"):
payment_method = frappe.get_doc("Portal Payment Method", pm.name)
fees = payment_method.calculate_payment_method_fees(
Expand Down Expand Up @@ -59,7 +60,12 @@ def get_context(context):
context.doc.grand_total_with_service_charge = fmt_money(
payment_method.total, frappe.get_precision(context.doc.doctype, "grand_total")
)
has_default = True
payment_methods.append(payment_method)
if not has_default:
context.doc.grand_total_with_service_charge = fmt_money(
payment_methods[0].total, frappe.get_precision(context.doc.doctype, "grand_total")
)
context.payment_methods = payment_methods

# get customer configured payment methods
Expand Down

0 comments on commit 08b387b

Please sign in to comment.