refactor: only run checks on specified companies

This commit is contained in:
ruthra kumar
2024-03-27 10:10:55 +05:30
parent 704925549b
commit 00eeacd06a

View File

@@ -2115,32 +2115,32 @@ def run_ledger_health_checks():
# Debit-Credit mismatch report # Debit-Credit mismatch report
if health_monitor_settings.debit_credit_mismatch: if health_monitor_settings.debit_credit_mismatch:
voucher_wise = frappe.get_doc("Report", "Voucher-wise Balance") for x in health_monitor_settings.companies:
filters = {"company": "நுண்ணறி", "from_date": period_start, "to_date": period_end} filters = {"company": x.company, "from_date": period_start, "to_date": period_end}
voucher_wise = frappe.get_doc("Report", "Voucher-wise Balance")
res = voucher_wise.execute_script_report(filters=filters) res = voucher_wise.execute_script_report(filters=filters)
for x in res[1]: for x in res[1]:
doc = frappe.new_doc("Ledger Health") doc = frappe.new_doc("Ledger Health")
doc.voucher_type = x.voucher_type doc.voucher_type = x.voucher_type
doc.voucher_no = x.voucher_no doc.voucher_no = x.voucher_no
doc.debit_credit_mismatch = True doc.debit_credit_mismatch = True
doc.checked_on = run_date doc.checked_on = run_date
doc.save() doc.save()
# General Ledger and Payment Ledger discrepancy # General Ledger and Payment Ledger discrepancy
if health_monitor_settings.general_and_payment_ledger_mismatch: if health_monitor_settings.general_and_payment_ledger_mismatch:
gl_pl_comparison = frappe.get_doc("Report", "General and Payment Ledger Comparison") for x in health_monitor_settings.companies:
filters = { filters = {
"company": "நுண்ணறி", "company": x.company,
"period_start_date": period_start, "period_start_date": period_start,
"period_end_date": period_end, "period_end_date": period_end,
} }
res = gl_pl_comparison.execute_script_report(filters=filters) gl_pl_comparison = frappe.get_doc("Report", "General and Payment Ledger Comparison")
res = gl_pl_comparison.execute_script_report(filters=filters)
for x in res[1]: for x in res[1]:
doc = frappe.new_doc("Ledger Health") doc = frappe.new_doc("Ledger Health")
doc.voucher_type = x.voucher_type doc.voucher_type = x.voucher_type
doc.voucher_no = x.voucher_no doc.voucher_no = x.voucher_no
doc.general_and_payment_ledger_mismatch = True doc.general_and_payment_ledger_mismatch = True
doc.checked_on = run_date doc.checked_on = run_date
doc.save() doc.save()