From c6147c92d2381938015c4e8db15f452412dc076c Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 12 Jul 2024 10:04:54 +0530 Subject: [PATCH 1/4] refactor: make reposting implicit --- erpnext/accounts/doctype/journal_entry/journal_entry.py | 1 + erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py | 1 + erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 1 + 3 files changed, 3 insertions(+) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index f3a7efe9ef..a277e395cc 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -208,6 +208,7 @@ class JournalEntry(AccountsController): if self.needs_repost: self.validate_for_repost() self.db_set("repost_required", self.needs_repost) + self.repost_accounting_entries() 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 e07a7b33a4..93851b62fe 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -836,6 +836,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): if not gl_entries: diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index b300341911..2c96a17c7b 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -764,6 +764,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 -- GitLab From 9cd87749f1433405fcc703efe096919b68380e96 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 15 Jul 2024 14:21:47 +0530 Subject: [PATCH 2/4] refactor(test): no need to assert repost_required flag Reposting happens implicitly upon 'Update After Submit' --- erpnext/accounts/doctype/journal_entry/test_journal_entry.py | 4 ---- .../doctype/purchase_invoice/test_purchase_invoice.py | 2 -- 2 files changed, 6 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py index b33a7aa5f4..f2cf0c76ae 100644 --- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py @@ -462,10 +462,6 @@ class TestJournalEntry(unittest.TestCase): jv.accounts[1].cost_center = "_Test Cost Center for BS Account - _TC" jv.save() - # Check if repost flag gets set on update after submit - self.assertTrue(jv.repost_required) - jv.repost_accounting_entries() - # Check GL entries after reposting jv.load_from_db() self.expected_gle[0]["cost_center"] = "_Test Cost Center for BS Account - _TC" diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 1ee516f164..f9db813b69 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -2045,8 +2045,6 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): pi.items[0].expense_account = "Service - _TC" pi.save() pi.load_from_db() - self.assertTrue(pi.repost_required) - pi.repost_accounting_entries() expected_gle = [ ["Creditors - _TC", 0.0, 1000, nowdate()], -- GitLab From 3043c6e7993583a5985d67d110980a4efe29953d Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 15 Jul 2024 14:27:16 +0530 Subject: [PATCH 3/4] refactor(test): reposting happens implicitly --- .../accounts/doctype/sales_invoice/test_sales_invoice.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index f4dc92b150..7a6104fc56 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2902,13 +2902,9 @@ class TestSalesInvoice(FrappeTestCase): si.items[0].income_account = "Service - _TC" si.additional_discount_account = "_Test Account Sales - _TC" si.taxes[0].account_head = "TDS Payable - _TC" + # Ledger reposted implicitly upon 'Update After Submit' si.save() - si.load_from_db() - self.assertTrue(si.repost_required) - - si.repost_accounting_entries() - expected_gle = [ ["_Test Account Sales - _TC", 22.0, 0.0, nowdate()], ["Debtors - _TC", 88, 0.0, nowdate()], -- GitLab From 453e2985ebb6e4006a350ec76a92b8960d190d45 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 15 Jul 2024 14:29:07 +0530 Subject: [PATCH 4/4] chore: contextual comments --- erpnext/accounts/doctype/journal_entry/test_journal_entry.py | 1 + .../accounts/doctype/purchase_invoice/test_purchase_invoice.py | 1 + 2 files changed, 2 insertions(+) diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py index f2cf0c76ae..772393261f 100644 --- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py @@ -460,6 +460,7 @@ class TestJournalEntry(unittest.TestCase): # Change cost center for bank account - _Test Cost Center for BS Account create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company") jv.accounts[1].cost_center = "_Test Cost Center for BS Account - _TC" + # Ledger reposted implicitly upon 'Update After Submit' jv.save() # Check GL entries after reposting diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index f9db813b69..9604281afd 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -2043,6 +2043,7 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): check_gl_entries(self, pi.name, expected_gle, nowdate()) pi.items[0].expense_account = "Service - _TC" + # Ledger reposted implicitly upon 'Update After Submit' pi.save() pi.load_from_db() -- GitLab