55 lines
2.2 KiB
Python
55 lines
2.2 KiB
Python
"""Integration tests for balance sheet + trial balance."""
|
|
|
|
from datetime import date
|
|
|
|
from odoo.tests.common import TransactionCase, tagged
|
|
|
|
from odoo.addons.fusion_accounting_reports.services.date_periods import Period
|
|
|
|
|
|
@tagged('post_install', '-at_install', 'integration')
|
|
class TestBalanceSheetIntegration(TransactionCase):
|
|
|
|
def test_balance_sheet_includes_total_assets(self):
|
|
result = self.env['fusion.report.engine'].compute_balance_sheet(
|
|
date(2026, 12, 31), company_id=self.env.company.id)
|
|
labels = [r['label'] for r in result['rows']]
|
|
self.assertIn('TOTAL ASSETS', labels)
|
|
self.assertIn('TOTAL LIABILITIES', labels)
|
|
self.assertIn('TOTAL EQUITY', labels)
|
|
|
|
def test_balance_sheet_total_assets_is_subtotal(self):
|
|
result = self.env['fusion.report.engine'].compute_balance_sheet(
|
|
date(2026, 12, 31), company_id=self.env.company.id)
|
|
ta = next(
|
|
(r for r in result['rows'] if r['label'] == 'TOTAL ASSETS'),
|
|
None,
|
|
)
|
|
self.assertIsNotNone(ta)
|
|
self.assertTrue(ta['is_subtotal'])
|
|
|
|
def test_balance_sheet_returns_period(self):
|
|
result = self.env['fusion.report.engine'].compute_balance_sheet(
|
|
date(2026, 4, 19), company_id=self.env.company.id)
|
|
self.assertEqual(result['period']['date_to'], '2026-04-19')
|
|
|
|
|
|
@tagged('post_install', '-at_install', 'integration')
|
|
class TestTrialBalanceIntegration(TransactionCase):
|
|
|
|
def test_trial_balance_returns_all_5_groups(self):
|
|
period = Period(date(2026, 1, 1), date(2026, 12, 31), 'Test 2026')
|
|
result = self.env['fusion.report.engine'].compute_trial_balance(
|
|
period, company_id=self.env.company.id)
|
|
labels = [r['label'] for r in result['rows']]
|
|
for label in ('Assets', 'Liabilities', 'Equity', 'Income', 'Expenses'):
|
|
self.assertIn(label, labels)
|
|
|
|
def test_trial_balance_has_total_subtotal(self):
|
|
period = Period(date(2026, 1, 1), date(2026, 12, 31), 'Test 2026')
|
|
result = self.env['fusion.report.engine'].compute_trial_balance(
|
|
period, company_id=self.env.company.id)
|
|
last = result['rows'][-1]
|
|
self.assertEqual(last['label'], 'Total (should be 0)')
|
|
self.assertTrue(last['is_subtotal'])
|