Skip to content

Commit

Permalink
Merge pull request #42338 from frappe/mergify/bp/version-15-hotfix/pr…
Browse files Browse the repository at this point in the history
…-42294

refactor: make reposting implicit (backport #42294)
  • Loading branch information
ruthra-kumar authored Jul 15, 2024
2 parents 609a0b8 + 4968395 commit 2915865
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 11 deletions.
1 change: 1 addition & 0 deletions erpnext/accounts/doctype/journal_entry/journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def on_update_after_submit(self):
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
Expand Down
5 changes: 1 addition & 4 deletions erpnext/accounts/doctype/journal_entry/test_journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,9 @@ def test_repost_accounting_entries(self):
# 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 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ def on_update_after_submit(self):
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2005,10 +2005,9 @@ def test_repost_accounting_entries(self):
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()
self.assertTrue(pi.repost_required)
pi.repost_accounting_entries()

expected_gle = [
["Creditors - _TC", 0.0, 1000, nowdate()],
Expand Down
1 change: 1 addition & 0 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ def on_update_after_submit(self):
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
Expand Down
6 changes: 1 addition & 5 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2940,13 +2940,9 @@ def test_additional_discount_for_sales_invoice_with_discount_accounting_enabled(
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()],
Expand Down

0 comments on commit 2915865

Please sign in to comment.