refactor: submit and make JV through background job
This commit is contained in:
parent
6644311c8b
commit
4f51c5a433
@ -93,6 +93,12 @@ class ExchangeRateRevaluation(Document):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def fetch_and_calculate_accounts_data(self):
|
||||||
|
accounts = self.get_accounts_data()
|
||||||
|
if accounts:
|
||||||
|
for acc in accounts:
|
||||||
|
self.append("accounts", acc)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_accounts_data(self):
|
def get_accounts_data(self):
|
||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
|
@ -1408,6 +1408,50 @@ def check_and_delete_linked_reports(report):
|
|||||||
frappe.delete_doc("Desktop Icon", icon)
|
frappe.delete_doc("Desktop Icon", icon)
|
||||||
|
|
||||||
|
|
||||||
|
def create_err_and_its_journals(companies: list = None) -> None:
|
||||||
|
if companies:
|
||||||
|
for company in companies:
|
||||||
|
err = frappe.new_doc("Exchange Rate Revaluation")
|
||||||
|
err.company = company.name
|
||||||
|
err.posting_date = nowdate()
|
||||||
|
err.rounding_loss_allowance = 0.0
|
||||||
|
|
||||||
|
err.fetch_and_calculate_accounts_data()
|
||||||
|
if err.accounts:
|
||||||
|
err.save().submit()
|
||||||
|
response = err.make_jv_entries()
|
||||||
|
|
||||||
|
if company.submit_err_jv:
|
||||||
|
jv = response.get("revaluation_jv", None)
|
||||||
|
jv and frappe.get_doc("Journal Entry", jv).submit()
|
||||||
|
jv = response.get("zero_balance_jv", None)
|
||||||
|
jv and frappe.get_doc("Journal Entry", jv).submit()
|
||||||
|
|
||||||
|
|
||||||
|
def auto_create_exchange_rate_revaluation_daily() -> None:
|
||||||
|
"""
|
||||||
|
Executed by background job
|
||||||
|
"""
|
||||||
|
companies = frappe.db.get_all(
|
||||||
|
"Company",
|
||||||
|
filters={"auto_exchange_rate_revaluation": 1, "auto_err_frequency": "Daily"},
|
||||||
|
fields=["name", "submit_err_jv"],
|
||||||
|
)
|
||||||
|
create_err_and_its_journals(companies)
|
||||||
|
|
||||||
|
|
||||||
|
def auto_create_exchange_rate_revaluation_weekly() -> None:
|
||||||
|
"""
|
||||||
|
Executed by background job
|
||||||
|
"""
|
||||||
|
companies = frappe.db.get_all(
|
||||||
|
"Company",
|
||||||
|
filters={"auto_exchange_rate_revaluation": 1, "auto_err_frequency": "Weekly"},
|
||||||
|
fields=["name", "submit_err_jv"],
|
||||||
|
)
|
||||||
|
create_err_and_its_journals(companies)
|
||||||
|
|
||||||
|
|
||||||
def get_payment_ledger_entries(gl_entries, cancel=0):
|
def get_payment_ledger_entries(gl_entries, cancel=0):
|
||||||
ple_map = []
|
ple_map = []
|
||||||
if gl_entries:
|
if gl_entries:
|
||||||
|
@ -415,6 +415,10 @@ scheduler_events = {
|
|||||||
"erpnext.selling.doctype.quotation.quotation.set_expired_status",
|
"erpnext.selling.doctype.quotation.quotation.set_expired_status",
|
||||||
"erpnext.buying.doctype.supplier_quotation.supplier_quotation.set_expired_status",
|
"erpnext.buying.doctype.supplier_quotation.supplier_quotation.set_expired_status",
|
||||||
"erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.send_auto_email",
|
"erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.send_auto_email",
|
||||||
|
"erpnext.accounts.utils.auto_create_exchange_rate_revaluation_daily",
|
||||||
|
],
|
||||||
|
"weekly": [
|
||||||
|
"erpnext.accounts.utils.auto_create_exchange_rate_revaluation_weekly",
|
||||||
],
|
],
|
||||||
"daily_long": [
|
"daily_long": [
|
||||||
"erpnext.setup.doctype.email_digest.email_digest.send",
|
"erpnext.setup.doctype.email_digest.email_digest.send",
|
||||||
|
@ -98,6 +98,7 @@
|
|||||||
"exchange_rate_revaluation_settings_section",
|
"exchange_rate_revaluation_settings_section",
|
||||||
"auto_exchange_rate_revaluation",
|
"auto_exchange_rate_revaluation",
|
||||||
"auto_err_frequency",
|
"auto_err_frequency",
|
||||||
|
"submit_err_jv",
|
||||||
"budget_detail",
|
"budget_detail",
|
||||||
"exception_budget_approver_role",
|
"exception_budget_approver_role",
|
||||||
"registration_info",
|
"registration_info",
|
||||||
@ -751,6 +752,12 @@
|
|||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Frequency",
|
"label": "Frequency",
|
||||||
"options": "Daily\nWeekly"
|
"options": "Daily\nWeekly"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "submit_err_jv",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Submit ERR Journals?"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-building",
|
"icon": "fa fa-building",
|
||||||
@ -758,7 +765,7 @@
|
|||||||
"image_field": "company_logo",
|
"image_field": "company_logo",
|
||||||
"is_tree": 1,
|
"is_tree": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-07-03 14:29:56.262188",
|
"modified": "2023-07-07 05:41:41.537256",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Company",
|
"name": "Company",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user