@davoodmehraban89 / Aram-2 Mirror · read-only / commits / 44fb0de
Fork 0

Mirrored from https://github.com/davoodmehraban89/Aram.git

Synced Dec 3, 20:45 UTC

refactor(test): use shared synthetic demo builders rather than duplicated fixtures

davoodmehraban89 committed Oct 31, 2026 at 19:02 UTC 44fb0dedfc49749b696d114e5c22d466d742f304
1 file changed +4 -198
backend/tests/test_five_statement_pipeline_integration.py
+4 -198
@@ -20,125 +20,10 @@ from aram_backend.pilot_workbook import SHEET_HEADERS
20 from aram_backend.reconciliation_review import NoteReference
21 from aram_backend.five_statement_pipeline import build_five_statement_pipeline
22 from aram_backend.five_statement_pipeline_cli import main as pipeline_cli_main
23 -
24 -
25 -COMPANY = "001"
26 -YEAR = 1404
27 -
28 -
29 -def source_workbook() -> bytes:
30 - """One debit-net balanced ledger shared by every candidate builder."""
31 - book = Workbook()
32 - book.remove(book.active)
33 - for name, headers in SHEET_HEADERS.items():
34 - book.create_sheet(name).append(list(headers))
35 -
36 - def add(sheet: str, **values: object) -> None:
37 - book[sheet].append([values.get(column) for column in SHEET_HEADERS[sheet]])
38 -
39 - add(
40 - "Company", company_code=COMPANY, company_name="Synthetic integration only",
41 - fiscal_year=YEAR, currency="IRR", unit="Rial", prepared_by="Test fixture",
42 - status="Draft",
43 - )
44 - ledger = (
45 - # code, name, opening, debit, credit, closing
46 - ("CASH", "Cash", "40", "30", "20", "50"),
47 - ("AR", "Receivables", "50", "0", "0", "50"),
48 - ("AP", "Payables", "-20", "10", "0", "-10"),
49 - ("CAP", "Share capital", "-70", "0", "0", "-70"),
50 - ("REV", "Revenue", "0", "0", "40", "-40"),
51 - ("EXP", "Cost of revenue", "0", "20", "0", "20"),
52 - )
53 - for index, (code, name, opening, debit, credit, closing) in enumerate(ledger, 101):
54 - add(
55 - "Accounts", company_code=COMPANY, fiscal_year=YEAR,
56 - general_code=code, general_name=name, account_full_code=code,
57 - account_name=name, opening=opening, debit=debit, credit=credit,
58 - closing=closing, source_row=index, row_status="Draft",
59 - closing_delta="0",
60 - )
61 -
62 - notes = (
63 - ("BS", "Current assets", "C01", "Cash"),
64 - ("BS", "Current assets", "A01", "Receivables"),
65 - ("BS", "Current liabilities", "L01", "Payables"),
66 - ("BS", "Equity", "E01", "Equity"),
67 - ("IS", "Revenue", "R01", "Revenue"),
68 - ("IS", "Cost of revenue", "X01", "Cost of revenue"),
69 - ("EQ", "Share capital", "E01", "Share capital"),
70 - ("EQ", "Current year result", "P01", "Current year result"),
71 - )
72 - for statement, section, note, title in notes:
73 - add(
74 - "Notes", company_code=COMPANY, fiscal_year=YEAR,
75 - statement=statement, statement_section=section,
76 - note_number=note, note_title=title, subnote_code="",
77 - subnote_title="",
78 - )
79 -
80 - mappings = (
81 - ("CASH", "BS", "Current assets", "C01"),
82 - ("AR", "BS", "Current assets", "A01"),
83 - ("AP", "BS", "Current liabilities", "L01"),
84 - ("CAP", "BS", "Equity", "E01"),
85 - ("CAP", "EQ", "Share capital", "E01"),
86 - ("REV", "IS", "Revenue", "R01"),
87 - ("REV", "BS", "Equity", "E01"),
88 - ("REV", "EQ", "Current year result", "P01"),
89 - ("EXP", "IS", "Cost of revenue", "X01"),
90 - ("EXP", "BS", "Equity", "E01"),
91 - ("EXP", "EQ", "Current year result", "P01"),
92 - )
93 - for index, (account, statement, section, note) in enumerate(mappings, 1):
94 - add(
95 - "Mapping", mapping_id=f"SYNTH-M-{index:02d}",
96 - company_code=COMPANY, fiscal_year=YEAR,
97 - account_full_code=account, account_level="General",
98 - general_code=account, target_statement=statement,
99 - statement_section=section, note_number=note, subnote_code="",
100 - mapping_version=1, approval_status="Approved",
101 - reviewer="Synthetic fixture only", review_date="2026-10-31",
102 - source="Synthetic test", notes="Not an authenticated approval",
103 - validation_status="Valid",
104 - )
105 -
106 - output = BytesIO()
107 - book.save(output)
108 - book.close()
109 - return output.getvalue()
110 -
111 -
112 -def references() -> tuple[NoteReference, ...]:
113 - return (
114 - NoteReference("BS", "Current assets", "C01", "", "50", "SYNTH-BS-CASH"),
115 - NoteReference("BS", "Current assets", "A01", "", "50", "SYNTH-BS-AR"),
116 - NoteReference("BS", "Current liabilities", "L01", "", "-10", "SYNTH-BS-AP"),
117 - NoteReference("BS", "Equity", "E01", "", "-90", "SYNTH-BS-EQ"),
118 - NoteReference("IS", "Revenue", "R01", "", "-40", "SYNTH-IS-REV"),
119 - NoteReference("IS", "Cost of revenue", "X01", "", "20", "SYNTH-IS-COST"),
120 - NoteReference("EQ", "Share capital", "E01", "", "-70", "SYNTH-EQ-CAP"),
121 - NoteReference("EQ", "Current year result", "P01", "", "-20", "SYNTH-EQ-PROFIT"),
122 - )
123 -
124 -
125 -def cash_transactions() -> tuple[CashFlowEntry, ...]:
126 - return (
127 - CashFlowEntry(
128 - company_code=COMPANY, fiscal_year=YEAR, line_id="CF-L1",
129 - transaction_id="CF-V1", posting_date="1404-01-01",
130 - cash_account_code="CASH", counterpart_account_code="REV",
131 - cash_debit="30", cash_credit="0", counterpart_debit="0",
132 - counterpart_credit="30", evidence_ref="SYNTH-TXN-1",
133 - ),
134 - CashFlowEntry(
135 - company_code=COMPANY, fiscal_year=YEAR, line_id="CF-L2",
136 - transaction_id="CF-V2", posting_date="1404-01-02",
137 - cash_account_code="CASH", counterpart_account_code="EXP",
138 - cash_debit="0", cash_credit="20", counterpart_debit="20",
139 - counterpart_credit="0", evidence_ref="SYNTH-TXN-2",
140 - ),
141 - )
23 +from aram_backend.synthetic_five_statement_demo import (
24 + COMPANY, YEAR, cash_transactions, pipeline_manifest,
25 + references, source_workbook,
26 +)
27
28
29 def build_pipeline(
@@ -213,85 +98,6 @@ def build_all(data: bytes | None = None, *, transactions=None):
98
99
100
216 -def pipeline_manifest(*, transactions=None):
217 - return {
218 - "schema_version": 1,
219 - "company_code": COMPANY,
220 - "fiscal_year": YEAR,
221 - "currency": "IRR",
222 - "unit": "Rial",
223 - "references": [asdict(item) for item in references()],
224 - "balance_sheet_policies": [
225 - {
226 - "statement_section": "Current assets", "note_number": "C01",
227 - "subnote_code": "", "category": "ASSETS", "sign_multiplier": 1,
228 - "line_label": "Cash and cash equivalents",
229 - "policy_evidence_ref": "SYNTH-POL-BS-CASH",
230 - },
231 - {
232 - "statement_section": "Current assets", "note_number": "A01",
233 - "subnote_code": "", "category": "ASSETS", "sign_multiplier": 1,
234 - "line_label": "Trade receivables", "policy_evidence_ref": "SYNTH-POL-BS-AR",
235 - },
236 - {
237 - "statement_section": "Current liabilities", "note_number": "L01",
238 - "subnote_code": "", "category": "LIABILITIES", "sign_multiplier": -1,
239 - "line_label": "Trade payables", "policy_evidence_ref": "SYNTH-POL-BS-AP",
240 - },
241 - {
242 - "statement_section": "Equity", "note_number": "E01",
243 - "subnote_code": "", "category": "EQUITY", "sign_multiplier": -1,
244 - "line_label": "Total equity", "policy_evidence_ref": "SYNTH-POL-BS-EQ",
245 - },
246 - ],
247 - "income_statement_policies": [
248 - {
249 - "statement_section": "Revenue", "note_number": "R01",
250 - "subnote_code": "", "category": "REVENUE", "sign_multiplier": -1,
251 - "line_label": "Revenue", "policy_evidence_ref": "SYNTH-POL-IS-REV",
252 - },
253 - {
254 - "statement_section": "Cost of revenue", "note_number": "X01",
255 - "subnote_code": "", "category": "COST_OF_REVENUE", "sign_multiplier": 1,
256 - "line_label": "Cost of revenue", "policy_evidence_ref": "SYNTH-POL-IS-COST",
257 - },
258 - ],
259 - "equity_movement_policies": [
260 - {
261 - "statement_section": "Share capital", "note_number": "E01",
262 - "subnote_code": "", "equity_component": "SHARE_CAPITAL",
263 - "movement_category": "CAPITAL_CONTRIBUTION", "sign_multiplier": -1,
264 - "line_label": "Share capital", "policy_evidence_ref": "SYNTH-POL-EQ-CAP",
265 - },
266 - {
267 - "statement_section": "Current year result", "note_number": "P01",
268 - "subnote_code": "", "equity_component": "RETAINED_EARNINGS",
269 - "movement_category": "NET_PROFIT_LOSS", "sign_multiplier": -1,
270 - "line_label": "Current year profit", "policy_evidence_ref": "SYNTH-POL-EQ-PROFIT",
271 - },
272 - ],
273 - "cash_accounts": [
274 - {"account_code": "CASH", "evidence_ref": "SYNTH-CASH-SCOPE"},
275 - ],
276 - "counterpart_policies": [
277 - {"account_code": "REV", "activity": "OPERATING", "evidence_ref": "SYNTH-REV-CLASS"},
278 - {"account_code": "EXP", "activity": "OPERATING", "evidence_ref": "SYNTH-EXP-CLASS"},
279 - ],
280 - "transactions": [
281 - asdict(item) for item in (
282 - cash_transactions() if transactions is None else transactions
283 - )
284 - ],
285 - "cash_balance_notes": [
286 - {
287 - "statement_section": "Current assets", "note_number": "C01",
288 - "subnote_code": "", "evidence_ref": "SYNTH-CASH-NOTE-SELECTION",
289 - },
290 - ],
291 - }
292 -
293 -
294 -
101 def test_all_five_real_builders_reconcile_from_one_immutable_workbook():
102 bs, income, equity, cash, trial, result = build_all()
103