Skip to content

Commit

Permalink
fix: check type for reference name
Browse files Browse the repository at this point in the history
(cherry picked from commit b06345a)
  • Loading branch information
sagarvora authored and mergify[bot] committed Nov 13, 2022
1 parent 3614584 commit a305793
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions erpnext/accounts/doctype/bank_guarantee/bank_guarantee.py
Expand Up @@ -22,15 +22,18 @@ def on_submit(self):


@frappe.whitelist()
def get_voucher_details(bank_guarantee_type, reference_name):
fields_to_fetch = ["grand_total"]
def get_voucher_details(bank_guarantee_type: str, reference_name: str):
if not isinstance(reference_name, str):
raise TypeError("reference_name must be a string")

doctype = "Sales Order" if bank_guarantee_type == "Receiving" else "Purchase Order"
fields_to_fetch = ["grand_total"]

if doctype == "Sales Order":
if bank_guarantee_type == "Receiving":
doctype = "Sales Order"
fields_to_fetch.append("customer")
fields_to_fetch.append("project")
else:
doctype = "Purchase Order"
fields_to_fetch.append("supplier")

return frappe.db.get_value(doctype, reference_name, fields_to_fetch, as_dict=True)

0 comments on commit a305793

Please sign in to comment.