Skip to content

Commit

Permalink
fix: cancel cost center allocation and journal entry after test
Browse files Browse the repository at this point in the history
(cherry picked from commit 3c65b98)
  • Loading branch information
venkat102 authored and mergify[bot] committed Sep 18, 2024
1 parent 52a161f commit 3d29007
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def setUp(self):
cost_centers = [
"Main Cost Center 1",
"Main Cost Center 2",
"Main Cost Center 3",
"Sub Cost Center 1",
"Sub Cost Center 2",
"Sub Cost Center 3",
Expand All @@ -37,7 +38,7 @@ def test_gle_based_on_cost_center_allocation(self):
)

jv = make_journal_entry(
"_Test Cash - _TC", "Sales - _TC", 100, cost_center="Main Cost Center 1 - _TC", submit=True
"Cash - _TC", "Sales - _TC", 100, cost_center="Main Cost Center 1 - _TC", submit=True
)

expected_values = [["Sub Cost Center 1 - _TC", 0.0, 60], ["Sub Cost Center 2 - _TC", 0.0, 40]]
Expand Down Expand Up @@ -121,7 +122,7 @@ def test_total_percentage(self):
def test_valid_from_based_on_existing_gle(self):
# GLE posted against Sub Cost Center 1 on today
jv = make_journal_entry(
"_Test Cash - _TC",
"Cash - _TC",
"Sales - _TC",
100,
cost_center="Main Cost Center 1 - _TC",
Expand All @@ -143,16 +144,16 @@ def test_valid_from_based_on_existing_gle(self):
jv.cancel()

def test_multiple_cost_center_allocation_on_same_main_cost_center(self):
create_cost_center_allocation(
coa1 = create_cost_center_allocation(
"_Test Company",
"Main Cost Center 1 - _TC",
"Main Cost Center 3 - _TC",
{"Sub Cost Center 1 - _TC": 30, "Sub Cost Center 2 - _TC": 30, "Sub Cost Center 3 - _TC": 40},
valid_from=add_days(today(), -5),
)

create_cost_center_allocation(
coa2 = create_cost_center_allocation(
"_Test Company",
"Main Cost Center 1 - _TC",
"Main Cost Center 3 - _TC",
{"Sub Cost Center 1 - _TC": 50, "Sub Cost Center 2 - _TC": 50},
valid_from=add_days(today(), -1),
)
Expand All @@ -161,7 +162,7 @@ def test_multiple_cost_center_allocation_on_same_main_cost_center(self):
"Cash - _TC",
"Sales - _TC",
100,
cost_center="Main Cost Center 1 - _TC",
cost_center="Main Cost Center 3 - _TC",
posting_date=today(),
submit=True,
)
Expand All @@ -185,6 +186,10 @@ def test_multiple_cost_center_allocation_on_same_main_cost_center(self):
self.assertEqual(gle.debit, 0)
self.assertEqual(gle.credit, expected_values[gle.cost_center])

coa1.cancel()
coa2.cancel()
jv.cancel()


def create_cost_center_allocation(
company,
Expand Down

0 comments on commit 3d29007

Please sign in to comment.