From 67a001d87602cb589b5edb606c03be2d2130d594 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 4 Dec 2021 19:19:03 +0530 Subject: [PATCH 1/3] fix: Better Error logging fordeferred revenue/expense booking --- erpnext/accounts/deferred_revenue.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py index 5df8269f75..76c833a24e 100644 --- a/erpnext/accounts/deferred_revenue.py +++ b/erpnext/accounts/deferred_revenue.py @@ -375,11 +375,12 @@ def make_gl_entries(doc, credit_account, debit_account, against, except Exception as e: if frappe.flags.in_test: raise e + traceback = frappe.get_traceback() + frappe.log_error(title=_('Error while processing deferred accounting for Invoice {0}').format(doc.name), message=traceback) else: frappe.db.rollback() traceback = frappe.get_traceback() - frappe.log_error(message=traceback) - + frappe.log_error(title=_('Error while processing deferred accounting for Invoice {0}').format(doc.name), message=traceback) frappe.flags.deferred_accounting_error = True def send_mail(deferred_process): @@ -449,7 +450,7 @@ def book_revenue_via_journal_entry(doc, credit_account, debit_account, against, except Exception: frappe.db.rollback() traceback = frappe.get_traceback() - frappe.log_error(message=traceback) + frappe.log_error(title=_('Error while processing deferred accounting for Invoice {0}').format(doc.name), message=traceback) frappe.flags.deferred_accounting_error = True From 0ba4fcee2a6091922b452b3ca8ad9b72606b814f Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 4 Dec 2021 19:25:44 +0530 Subject: [PATCH 2/3] fix: Commit joural entries --- erpnext/accounts/deferred_revenue.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py index 76c833a24e..1afed127b2 100644 --- a/erpnext/accounts/deferred_revenue.py +++ b/erpnext/accounts/deferred_revenue.py @@ -447,6 +447,8 @@ def book_revenue_via_journal_entry(doc, credit_account, debit_account, against, if submit: journal_entry.submit() + + frappe.db.commit() except Exception: frappe.db.rollback() traceback = frappe.get_traceback() From 3c64e201cc36f309b16de1c83c1e4d27aa6a2826 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 4 Dec 2021 20:05:37 +0530 Subject: [PATCH 3/3] fix: Log error before throwing exception --- erpnext/accounts/deferred_revenue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py index 1afed127b2..22c81ddd46 100644 --- a/erpnext/accounts/deferred_revenue.py +++ b/erpnext/accounts/deferred_revenue.py @@ -374,9 +374,9 @@ def make_gl_entries(doc, credit_account, debit_account, against, frappe.db.commit() except Exception as e: if frappe.flags.in_test: - raise e traceback = frappe.get_traceback() frappe.log_error(title=_('Error while processing deferred accounting for Invoice {0}').format(doc.name), message=traceback) + raise e else: frappe.db.rollback() traceback = frappe.get_traceback()