feat(fusion_accounting_reports): partner-grouped engine method

Adds engine.compute_partner_grouped(period, account_type=...) that
returns per-partner aggregations with aging buckets (current/1-30/
31-60/61-90/90+). SQL-direct for performance — single GROUP BY query
with conditional sum per bucket.

Foundation for the 3 partner-grouped reports landing in commit 3:
Aged Receivable, Aged Payable, Partner Ledger.

Made-with: Cursor
This commit is contained in:
gsinghpal
2026-04-19 23:54:32 -04:00
parent 6896c71b79
commit ff6d21a561
2 changed files with 142 additions and 1 deletions

View File

@@ -90,6 +90,23 @@ class TestFusionReportEngine(TransactionCase):
)
self.assertIsInstance(rows, list)
def test_compute_partner_grouped_receivable(self):
period = Period(date(2025, 1, 1), date(2025, 12, 31), 'Test')
result = self.env['fusion.report.engine'].compute_partner_grouped(
period, account_type='asset_receivable',
)
self.assertEqual(result['report_type'], 'partner_grouped')
self.assertEqual(result['account_type'], 'asset_receivable')
self.assertIn('rows', result)
self.assertIn('total', result)
self.assertIn('partner_count', result)
if result['rows']:
for key in (
'partner_name', 'total', 'bucket_current', 'bucket_1_30',
'bucket_31_60', 'bucket_61_90', 'bucket_90_plus',
):
self.assertIn(key, result['rows'][0])
def test_no_report_raises_validation_error(self):
period = Period(date(2026, 1, 1), date(2026, 12, 31), 'Test 2026')
# Inactivate any pre-existing GL definitions so the lookup