fix(accounts): fetch deferred invoice docs on non-empty sales_docs or purchase_docs in repost accounting ledger (backport #57753) (#57756)

Co-authored-by: Diptanil Saha <diptanil@frappe.io>
This commit is contained in:
mergify[bot]
2026-08-03 12:33:56 +00:00
committed by GitHub
parent 0b08129b40
commit ee4e296ce6

View File

@@ -473,19 +473,24 @@ def get_child_docs(doc: list) -> list:
def validate_docs_for_deferred_accounting(sales_docs, purchase_docs): def validate_docs_for_deferred_accounting(sales_docs, purchase_docs):
docs_with_deferred_revenue = frappe.db.get_all( docs_with_deferred_revenue = ()
"Sales Invoice Item", docs_with_deferred_expense = ()
filters={"parent": ["in", sales_docs], "docstatus": 1, "enable_deferred_revenue": True},
fields=["parent"],
as_list=1,
)
docs_with_deferred_expense = frappe.db.get_all( if sales_docs:
"Purchase Invoice Item", docs_with_deferred_revenue = frappe.db.get_all(
filters={"parent": ["in", purchase_docs], "docstatus": 1, "enable_deferred_expense": 1}, "Sales Invoice Item",
fields=["parent"], filters={"parent": ["in", sales_docs], "docstatus": 1, "enable_deferred_revenue": True},
as_list=1, fields=["parent"],
) as_list=1,
)
if purchase_docs:
docs_with_deferred_expense = frappe.db.get_all(
"Purchase Invoice Item",
filters={"parent": ["in", purchase_docs], "docstatus": 1, "enable_deferred_expense": 1},
fields=["parent"],
as_list=1,
)
if docs_with_deferred_revenue or docs_with_deferred_expense: if docs_with_deferred_revenue or docs_with_deferred_expense:
frappe.throw( frappe.throw(