feat(fusion_accounting_reports): drill_down_resolver service
Pure-Python helper that, given an account_id and a date range, fetches posted account.move.line records and returns a flat list of dicts ready for the drill-down OWL dialog. Used by the engine's drill_down() method. 3 new tests, 35 total passing. Made-with: Cursor
This commit is contained in:
@@ -2,3 +2,4 @@ from . import test_services_unit
|
||||
from . import test_currency_conversion
|
||||
from . import test_fusion_report
|
||||
from . import test_line_resolver
|
||||
from . import test_drill_down_resolver
|
||||
|
||||
60
fusion_accounting_reports/tests/test_drill_down_resolver.py
Normal file
60
fusion_accounting_reports/tests/test_drill_down_resolver.py
Normal file
@@ -0,0 +1,60 @@
|
||||
"""Tests for drill_down_resolver."""
|
||||
|
||||
from datetime import date, timedelta
|
||||
|
||||
from odoo.tests.common import TransactionCase, tagged
|
||||
from odoo.addons.fusion_accounting_reports.services.drill_down_resolver import (
|
||||
fetch_drill_down,
|
||||
)
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestDrillDownResolver(TransactionCase):
|
||||
|
||||
def test_returns_empty_for_account_with_no_lines(self):
|
||||
account = self.env['account.account'].search([
|
||||
('company_ids', 'in', self.env.company.id),
|
||||
], limit=1)
|
||||
if not account:
|
||||
self.skipTest("No accounts in DB")
|
||||
rows = fetch_drill_down(
|
||||
self.env,
|
||||
account_id=account.id,
|
||||
date_from=date(2099, 1, 1),
|
||||
date_to=date(2099, 12, 31),
|
||||
company_id=self.env.company.id,
|
||||
)
|
||||
self.assertEqual(rows, [])
|
||||
|
||||
def test_returns_lines_for_account_with_data(self):
|
||||
line = self.env['account.move.line'].search([
|
||||
('parent_state', '=', 'posted'),
|
||||
], limit=1)
|
||||
if not line:
|
||||
self.skipTest("No posted move lines in DB")
|
||||
rows = fetch_drill_down(
|
||||
self.env,
|
||||
account_id=line.account_id.id,
|
||||
date_from=line.date - timedelta(days=1),
|
||||
date_to=line.date + timedelta(days=1),
|
||||
company_id=line.company_id.id,
|
||||
)
|
||||
self.assertGreater(len(rows), 0)
|
||||
ids = [r['move_line_id'] for r in rows]
|
||||
self.assertIn(line.id, ids)
|
||||
|
||||
def test_respects_limit(self):
|
||||
line = self.env['account.move.line'].search([
|
||||
('parent_state', '=', 'posted'),
|
||||
], limit=1)
|
||||
if not line:
|
||||
self.skipTest("No posted move lines in DB")
|
||||
rows = fetch_drill_down(
|
||||
self.env,
|
||||
account_id=line.account_id.id,
|
||||
date_from=date(2000, 1, 1),
|
||||
date_to=date(2099, 12, 31),
|
||||
company_id=line.company_id.id,
|
||||
limit=2,
|
||||
)
|
||||
self.assertLessEqual(len(rows), 2)
|
||||
Reference in New Issue
Block a user