refactor: ignore system generated cr / dr notes on general ledger

(cherry picked from commit bb8c9b5a58)
This commit is contained in:
ruthra kumar
2024-08-02 15:47:27 +05:30
committed by Mergify
parent b20b15af74
commit 0a83c8b00c

View File

@@ -234,6 +234,20 @@ def get_conditions(filters):
if err_journals:
filters.update({"voucher_no_not_in": [x[0] for x in err_journals]})
if filters.get("ignore_cr_dr_notes"):
system_generated_cr_dr_journals = frappe.db.get_all(
"Journal Entry",
filters={
"company": filters.get("company"),
"docstatus": 1,
"voucher_type": ("in", ["Credit Note", "Debit Note"]),
"is_system_generated": 1,
},
as_list=True,
)
if system_generated_cr_dr_journals:
filters.update({"voucher_no_not_in": [x[0] for x in system_generated_cr_dr_journals]})
if filters.get("voucher_no_not_in"):
conditions.append("voucher_no not in %(voucher_no_not_in)s")