From 219310e817d22144dd1f9ffca50db5c14d90d602 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jul 2024 18:13:30 +0530 Subject: [PATCH 1/2] refactor: provision for monthly re-evaluation (cherry picked from commit ce2b9e0f1a69a652ed797453ba04d30e4857c0eb) --- erpnext/setup/doctype/company/company.json | 4 ++-- erpnext/setup/doctype/company/company.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 787b0826f01..284bd2b7f22 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -754,7 +754,7 @@ "fieldname": "auto_err_frequency", "fieldtype": "Select", "label": "Frequency", - "options": "Daily\nWeekly" + "options": "Daily\nWeekly\nMonthly" }, { "default": "0", @@ -808,7 +808,7 @@ "image_field": "company_logo", "is_tree": 1, "links": [], - "modified": "2024-06-21 17:46:25.567565", + "modified": "2024-07-24 18:17:56.413971", "modified_by": "Administrator", "module": "Setup", "name": "Company", diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 87d14e3c6b4..f79ea60f5c4 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -31,7 +31,7 @@ class Company(NestedSet): accumulated_depreciation_account: DF.Link | None allow_account_creation_against_child_company: DF.Check asset_received_but_not_billed: DF.Link | None - auto_err_frequency: DF.Literal["Daily", "Weekly"] + auto_err_frequency: DF.Literal["Daily", "Weekly", "Monthly"] auto_exchange_rate_revaluation: DF.Check book_advance_payments_in_separate_party_account: DF.Check capital_work_in_progress_account: DF.Link | None From 7b3a78e04e3b28a4effdb3a1a25163bd256dce31 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jul 2024 18:16:20 +0530 Subject: [PATCH 2/2] refactor: hooks for monthly re-evaluation jobs (cherry picked from commit fc4e5f165c9628171189a1c080793507e21e0500) --- erpnext/accounts/utils.py | 12 ++++++++++++ erpnext/hooks.py | 1 + 2 files changed, 13 insertions(+) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 2558e976bea..0450221222d 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1598,6 +1598,18 @@ def auto_create_exchange_rate_revaluation_weekly() -> None: create_err_and_its_journals(companies) +def auto_create_exchange_rate_revaluation_monthly() -> None: + """ + Executed by background job + """ + companies = frappe.db.get_all( + "Company", + filters={"auto_exchange_rate_revaluation": 1, "auto_err_frequency": "Montly"}, + fields=["name", "submit_err_jv"], + ) + create_err_and_its_journals(companies) + + def get_payment_ledger_entries(gl_entries, cancel=0): ple_map = [] if gl_entries: diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 028acc9cb11..527be6ab337 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -456,6 +456,7 @@ scheduler_events = { ], "monthly_long": [ "erpnext.accounts.deferred_revenue.process_deferred_accounting", + "erpnext.accounts.utils.auto_create_exchange_rate_revaluation_monthly", ], }