fix(desktop): normalize optional note subcodes in detail references
davoodmehraban89 committed
Oct 31, 2026 at 21:41 UTC
58c15c04bada85cd5387758a0cedd373f1d3ea65
1 file changed
+14
-3
backend/src/aram_backend/desktop_five_statement_details.py
+14
-3
@@ -41,6 +41,16 @@ def _text(value: object, label: str, *, blank_ok: bool = False) -> str:
41
return value
42
43
44
+def _note_reference(section: object, note: object, subnote: object) -> str:
45
+ section_text = _text(section, "SECTION")
46
+ note_text = _text(note, "NOTE")
47
+ subnote_text = _text(subnote, "SUBNOTE", blank_ok=True)
48
+ parts = [section_text, "یادداشت " + note_text]
49
+ if subnote_text:
50
+ parts.append("زیرعنوان " + subnote_text)
51
+ return " / ".join(parts)
52
+
53
+
54
def _amount(value: object, label: str) -> str:
55
try:
56
return format(_money(value), ",f")
@@ -89,7 +99,7 @@ def build_preview_details(
99
for line in result.balance_sheet.lines:
100
rows.append(_row(
101
"ترازنامه", line.line_label,
92
- f"{line.statement_section} / یادداشت {line.note_number} / {line.subnote_code}",
102
+ _note_reference(line.statement_section, line.note_number, line.subnote_code),
103
line.source_closing_exposure, closing=line.presentation_amount,
104
trace=(
105
f"دسته: {line.category} | ضریب: {line.sign_multiplier} | "
@@ -123,8 +133,9 @@ def build_preview_details(
133
for line in result.equity_changes.account_movements:
134
rows.append(_row(
135
"تغییرات حقوق مالکانه", line.account_name,
126
- f"حساب {line.account_code} / {line.statement_section} / "
127
- f"یادداشت {line.note_number} / {line.subnote_code}",
136
+ f"حساب {line.account_code} / " + _note_reference(
137
+ line.statement_section, line.note_number, line.subnote_code,
138
+ ),
139
f"ردیف اکسل {line.source_excel_row} / ردیف منبع {line.source_row}",
140
opening=line.opening_balance, debit=line.debit_turnover,
141
credit=line.credit_turnover, movement=line.movement_amount,