From 4668a2d7d825450818e04a1b785deb61d861ed29 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 12 Jul 2024 10:04:54 +0530 Subject: [PATCH] refactor: make reposting implicit (cherry picked from commit 722ef9232484df34b8a3cbcc817cdc47bc9e442d) # Conflicts: # erpnext/accounts/doctype/journal_entry/journal_entry.py --- .../doctype/journal_entry/journal_entry.py | 14 ++++++++++++++ .../doctype/purchase_invoice/purchase_invoice.py | 1 + .../doctype/sales_invoice/sales_invoice.py | 1 + 3 files changed, 16 insertions(+) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index b4fb13e42c3..a90a3c1d6b8 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -99,6 +99,20 @@ class JournalEntry(AccountsController): self.update_asset_value() self.update_inter_company_jv() self.update_invoice_discounting() +<<<<<<< HEAD +======= + self.update_booked_depreciation() + + def on_update_after_submit(self): + if hasattr(self, "repost_required"): + self.needs_repost = self.check_if_fields_updated( + fields_to_check=[], child_tables={"accounts": []} + ) + if self.needs_repost: + self.validate_for_repost() + self.db_set("repost_required", self.needs_repost) + self.repost_accounting_entries() +>>>>>>> 722ef92324 (refactor: make reposting implicit) def on_cancel(self): # References for this Journal are removed on the `on_cancel` event in accounts_controller diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 2015dd1b634..fd018309282 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -601,6 +601,7 @@ class PurchaseInvoice(BuyingController): if self.needs_repost: self.validate_for_repost() self.db_set("repost_required", self.needs_repost) + self.repost_accounting_entries() def make_gl_entries(self, gl_entries=None, from_repost=False): update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes" diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 009c48a385c..d01e494e60d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -549,6 +549,7 @@ class SalesInvoice(SellingController): if self.needs_repost: self.validate_for_repost() self.db_set("repost_required", self.needs_repost) + self.repost_accounting_entries() def set_paid_amount(self): paid_amount = 0.0