test(fusion_accounting_reports): balance sheet + trial balance integration

Made-with: Cursor
This commit is contained in:
gsinghpal
2026-04-19 15:52:01 -04:00
parent 16db299145
commit 0f575dd523
3 changed files with 56 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
{
'name': 'Fusion Accounting Reports',
'version': '19.0.1.0.18',
'version': '19.0.1.0.19',
'category': 'Accounting/Accounting',
'summary': 'AI-augmented financial reports (P&L, balance sheet, trial balance, GL).',
'description': """

View File

@@ -15,3 +15,4 @@ from . import test_reports_adapter
from . import test_fusion_report_tools
from . import test_engine_property
from . import test_pnl_integration
from . import test_bs_tb_integration

View File

@@ -0,0 +1,54 @@
"""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'])