refactor: control monitoring through settings page

(cherry picked from commit a42482ce35)
This commit is contained in:
ruthra kumar
2024-03-27 10:01:03 +05:30
committed by Mergify
parent 9fbb4f676b
commit 9bae5e37cd

View File

@@ -2102,16 +2102,16 @@ def get_party_types_from_account_type(account_type):
def run_ledger_health_checks(): def run_ledger_health_checks():
# run for last 1 month health_monitor_settings = frappe.get_doc("Ledger Health Monitor")
if health_monitor_settings.enable_health_monitor:
period_end = getdate() period_end = getdate()
period_start = add_days(period_end, -100) period_start = add_days(period_end, -abs(health_monitor_settings.monitor_for_last_x_days))
run_date = get_datetime() run_date = get_datetime()
# Debit-Credit mismatch report # Debit-Credit mismatch report
if health_monitor_settings.debit_credit_mismatch:
voucher_wise = frappe.get_doc("Report", "Voucher-wise Balance") voucher_wise = frappe.get_doc("Report", "Voucher-wise Balance")
# todo: company and dates should be configurable
filters = {"company": "நுண்ணறி", "from_date": period_start, "to_date": period_end} filters = {"company": "நுண்ணறி", "from_date": period_start, "to_date": period_end}
res = voucher_wise.execute_script_report(filters=filters) res = voucher_wise.execute_script_report(filters=filters)
@@ -2124,9 +2124,13 @@ def run_ledger_health_checks():
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:
gl_pl_comparison = frappe.get_doc("Report", "General and Payment Ledger Comparison") gl_pl_comparison = frappe.get_doc("Report", "General and Payment Ledger Comparison")
# todo: company and dates should be configurable filters = {
filters = {"company": "நுண்ணறி", "period_start_date": period_start, "period_end_date": period_end} "company": "நுண்ணறி",
"period_start_date": period_start,
"period_end_date": period_end,
}
res = gl_pl_comparison.execute_script_report(filters=filters) res = gl_pl_comparison.execute_script_report(filters=filters)
for x in res[1]: for x in res[1]: