Skip to content

Commit

Permalink
fix: test for repost accounting in JVs
Browse files Browse the repository at this point in the history
  • Loading branch information
GursheenK committed Mar 3, 2024
1 parent 4b57126 commit 1634955
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions erpnext/accounts/doctype/journal_entry/test_journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,18 @@ def test_jv_account_and_party_balance_with_cost_centre(self):
def test_repost_accounting_entries(self):
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center

# Configure Repost Accounting Ledger for JVs
settings = frappe.get_doc("Repost Accounting Ledger Settings")
if not [x for x in settings.allowed_types if x.document_type == "Journal Entry"]:
settings.append("allowed_types", {"document_type": "Journal Entry", "allowed": True})
settings.save()

# Create JV with defaut cost center - _Test Cost Center
jv = make_journal_entry("_Test Cash - _TC", "_Test Bank - _TC", 100, save=False)
jv.multi_currency = 0
jv.submit()

# Check GL entries before reposting
self.voucher_no = jv.name

self.fields = [
Expand All @@ -448,33 +456,18 @@ def test_repost_accounting_entries(self):

self.check_gl_entries()

cost_center = "_Test Cost Center for BS Account - _TC"
# 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[0].account = "_Test Bank - _TC"
jv.accounts[0].cost_center = "_Test Cost Center for BS Account - _TC"
jv.accounts[1].account = "_Test Cash - _TC"

jv.accounts[1].cost_center = "_Test Cost Center for BS Account - _TC"
jv.save()
jv.load_from_db()

# Check if repost flag gets set on update after submit
self.assertTrue(jv.repost_required)
jv.repost_accounting_entries()

self.expected_gle = [
{
"account": "_Test Bank - _TC",
"debit_in_account_currency": 100,
"credit_in_account_currency": 0,
"cost_center": "_Test Cost Center for BS Account - _TC",
},
{
"account": "_Test Cash - _TC",
"debit_in_account_currency": 0,
"credit_in_account_currency": 100,
"cost_center": "_Test Cost Center - _TC",
},
]

# Check GL entries after reposting
jv.load_from_db()
self.expected_gle[0]["cost_center"] = "_Test Cost Center for BS Account - _TC"
self.check_gl_entries()

def check_gl_entries(self):
Expand Down

0 comments on commit 1634955

Please sign in to comment.