refactor: handle 'no data' situation in patch

(cherry picked from commit 8e3bf7dc09)
This commit is contained in:
ruthra kumar
2024-10-22 16:07:14 +05:30
committed by Mergify
parent 063cef576c
commit 164d7cc896

View File

@@ -10,6 +10,7 @@ def get_advance_doctypes() -> list:
def get_payments_with_so_po_reference() -> list: def get_payments_with_so_po_reference() -> list:
advance_payment_entries = []
advance_doctypes = get_advance_doctypes() advance_doctypes = get_advance_doctypes()
per = qb.DocType("Payment Entry Reference") per = qb.DocType("Payment Entry Reference")
payments_with_reference = ( payments_with_reference = (
@@ -19,6 +20,7 @@ def get_payments_with_so_po_reference() -> list:
.where(per.reference_doctype.isin(advance_doctypes) & per.docstatus.eq(1)) .where(per.reference_doctype.isin(advance_doctypes) & per.docstatus.eq(1))
.run() .run()
) )
if payments_with_reference:
pe = qb.DocType("Payment Entry") pe = qb.DocType("Payment Entry")
advance_payment_entries = ( advance_payment_entries = (
qb.from_(pe) qb.from_(pe)
@@ -32,6 +34,7 @@ def get_payments_with_so_po_reference() -> list:
def get_journals_with_so_po_reference() -> list: def get_journals_with_so_po_reference() -> list:
advance_journal_entries = []
advance_doctypes = get_advance_doctypes() advance_doctypes = get_advance_doctypes()
jea = qb.DocType("Journal Entry Account") jea = qb.DocType("Journal Entry Account")
journals_with_reference = ( journals_with_reference = (
@@ -41,8 +44,9 @@ def get_journals_with_so_po_reference() -> list:
.where(jea.reference_type.isin(advance_doctypes) & jea.docstatus.eq(1)) .where(jea.reference_type.isin(advance_doctypes) & jea.docstatus.eq(1))
.run() .run()
) )
if journals_with_reference:
je = qb.DocType("Journal Entry") je = qb.DocType("Journal Entry")
advance_payment_entries = ( advance_journal_entries = (
qb.from_(je) qb.from_(je)
.select(ConstantColumn("Journal Entry").as_("doctype")) .select(ConstantColumn("Journal Entry").as_("doctype"))
.select(je.name) .select(je.name)
@@ -50,7 +54,7 @@ def get_journals_with_so_po_reference() -> list:
.run(as_dict=True) .run(as_dict=True)
) )
return advance_payment_entries return advance_journal_entries
def make_advance_ledger_entries(vouchers: list): def make_advance_ledger_entries(vouchers: list):