Skip to content

Commit

Permalink
fix: update existing unit tests to handle company validation of accou…
Browse files Browse the repository at this point in the history
…nting dimension
  • Loading branch information
Sugesh393 committed Dec 27, 2024
1 parent a42fd93 commit 70b9cc0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
5 changes: 4 additions & 1 deletion erpnext/accounts/doctype/budget/test_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ def test_monthly_budget_against_main_cost_center(self):

def set_total_expense_zero(posting_date, budget_against_field=None, budget_against_CC=None):
if budget_against_field == "project":
budget_against = frappe.db.get_value("Project", {"project_name": "_Test Project"})
project = frappe.get_doc("Project", {"project_name": "_Test Project"})
project.company = "_Test Company"
project.save()
budget_against = project.name
else:
budget_against = budget_against_CC or "_Test Cost Center - _TC"

Expand Down
30 changes: 15 additions & 15 deletions erpnext/controllers/tests/test_accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1472,32 +1472,32 @@ def test_90_dimensions_filter(self):

# Invoices
si1 = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_submit=True)
si1.department = "Management"
si1.department = "Management - _TC"
si1.save().submit()

si2 = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_submit=True)
si2.department = "Operations"
si2.department = "Operations - _TC"
si2.save().submit()

# Payments
cr_note1 = self.create_sales_invoice(qty=-1, conversion_rate=75, rate=1, do_not_save=True)
cr_note1.department = "Management"
cr_note1.department = "Management - _TC"
cr_note1.is_return = 1
cr_note1.save().submit()

cr_note2 = self.create_sales_invoice(qty=-1, conversion_rate=75, rate=1, do_not_save=True)
cr_note2.department = "Legal"
cr_note2.department = "Legal - _TC"
cr_note2.is_return = 1
cr_note2.save().submit()

pe1 = get_payment_entry(si1.doctype, si1.name)
pe1.references = []
pe1.department = "Research & Development"
pe1.department = "Research & Development - _TC"
pe1.save().submit()

pe2 = get_payment_entry(si1.doctype, si1.name)
pe2.references = []
pe2.department = "Management"
pe2.department = "Management - _TC"
pe2.save().submit()

je1 = self.create_journal_entry(
Expand All @@ -1510,7 +1510,7 @@ def test_90_dimensions_filter(self):
)
je1.accounts[0].party_type = "Customer"
je1.accounts[0].party = self.customer
je1.accounts[0].department = "Management"
je1.accounts[0].department = "Management - _TC"
je1.save().submit()

# assert dimension filter's result
Expand All @@ -1519,17 +1519,17 @@ def test_90_dimensions_filter(self):
self.assertEqual(len(pr.invoices), 2)
self.assertEqual(len(pr.payments), 5)

pr.department = "Legal"
pr.department = "Legal - _TC"
pr.get_unreconciled_entries()
self.assertEqual(len(pr.invoices), 0)
self.assertEqual(len(pr.payments), 1)

pr.department = "Management"
pr.department = "Management - _TC"
pr.get_unreconciled_entries()
self.assertEqual(len(pr.invoices), 1)
self.assertEqual(len(pr.payments), 3)

pr.department = "Research & Development"
pr.department = "Research & Development - _TC"
pr.get_unreconciled_entries()
self.assertEqual(len(pr.invoices), 0)
self.assertEqual(len(pr.payments), 1)
Expand All @@ -1540,17 +1540,17 @@ def test_91_cr_note_should_inherit_dimension(self):

# Invoice
si = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_submit=True)
si.department = "Management"
si.department = "Management - _TC"
si.save().submit()

# Payment
cr_note = self.create_sales_invoice(qty=-1, conversion_rate=75, rate=1, do_not_save=True)
cr_note.department = "Management"
cr_note.department = "Management - _TC"
cr_note.is_return = 1
cr_note.save().submit()

pr = self.create_payment_reconciliation()
pr.department = "Management"
pr.department = "Management - _TC"
pr.get_unreconciled_entries()
self.assertEqual(len(pr.invoices), 1)
self.assertEqual(len(pr.payments), 1)
Expand Down Expand Up @@ -1582,7 +1582,7 @@ def test_92_dimension_inhertiance_exc_gain_loss(self):
# Sales Invoice in Foreign Currency
self.setup_dimensions()
rate_in_account_currency = 1
dpt = "Research & Development"
dpt = "Research & Development - _TC"

si = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_save=True)
si.department = dpt
Expand Down Expand Up @@ -1617,7 +1617,7 @@ def test_92_dimension_inhertiance_exc_gain_loss(self):

def test_93_dimension_inheritance_on_advance(self):
self.setup_dimensions()
dpt = "Research & Development"
dpt = "Research & Development - _TC"

adv = self.create_payment_entry(amount=1, source_exc_rate=85)
adv.department = dpt
Expand Down

0 comments on commit 70b9cc0

Please sign in to comment.