mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-29 14:48:26 +00:00
Merge pull request #56765 from frappe/chore/profitability-analysis-unique-cost-centers
test: isolate Profitability Analysis tests from shared cost centers
This commit is contained in:
@@ -46,8 +46,9 @@ class TestProfitabilityAnalysis(ERPNextTestSuite):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_income_expense_and_gross_profit(self):
|
def test_income_expense_and_gross_profit(self):
|
||||||
# bootstrap leaf cost center; clean of committed GL so exact assertions hold
|
# a dedicated leaf cost center keeps these exact assertions free of GL that
|
||||||
cc = "_Test Cost Center - _TC"
|
# other tests may book against a shared cost center in the same fiscal year
|
||||||
|
cc = self.make_cc("_Test PA Income Expense")
|
||||||
self.book_income(cc, 10000)
|
self.book_income(cc, 10000)
|
||||||
self.book_expense(cc, 4000)
|
self.book_expense(cc, 4000)
|
||||||
|
|
||||||
@@ -74,7 +75,7 @@ class TestProfitabilityAnalysis(ERPNextTestSuite):
|
|||||||
self.assertEqual(parent_row["gross_profit_loss"], 7000)
|
self.assertEqual(parent_row["gross_profit_loss"], 7000)
|
||||||
|
|
||||||
def test_date_range_excludes_out_of_period_entries(self):
|
def test_date_range_excludes_out_of_period_entries(self):
|
||||||
cc = "_Test Cost Center 2 - _TC"
|
cc = self.make_cc("_Test PA Date Range")
|
||||||
self.book_income(cc, 10000, posting_date="2025-06-01")
|
self.book_income(cc, 10000, posting_date="2025-06-01")
|
||||||
|
|
||||||
# the 2025 income must not appear in a 2026 report (zero-value rows are dropped)
|
# the 2025 income must not appear in a 2026 report (zero-value rows are dropped)
|
||||||
@@ -97,7 +98,8 @@ class TestProfitabilityAnalysis(ERPNextTestSuite):
|
|||||||
data = self.run_report()
|
data = self.run_report()
|
||||||
# the report appends a blank separator row and a totals row at the end
|
# the report appends a blank separator row and a totals row at the end
|
||||||
total_row = data[-1]
|
total_row = data[-1]
|
||||||
self.assertEqual(total_row["account"], "'Total'")
|
# the report wraps the (possibly translated) "Total" label in single quotes
|
||||||
|
self.assertEqual(total_row["account"], "'" + frappe._("Total") + "'")
|
||||||
# total is built from direct (non-accumulated) values, so it stays internally consistent
|
# total is built from direct (non-accumulated) values, so it stays internally consistent
|
||||||
self.assertEqual(total_row["gross_profit_loss"], total_row["income"] - total_row["expense"])
|
self.assertEqual(total_row["gross_profit_loss"], total_row["income"] - total_row["expense"])
|
||||||
# and it includes this test's bookings
|
# and it includes this test's bookings
|
||||||
|
|||||||
Reference in New Issue
Block a user