Watch
1
0
Fork
You've already forked arc
0
forked from hesabix/arc
arc/hesabixAPI/tests/test_business_print_settings_resolver.py
Babak Alizadeh f7e158a1c8 Fix invoice PDF currency symbols when the general print setting is on.
Per-type rows were keeping the default off flag, and CSS ::after on table cells did not render on line items.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-27 19:15:20 +03:30

44 lines
1.6 KiB
Python

from __future__ import annotations
from app.services.business_print_settings_resolver import (
default_print_settings_dict,
pick_print_settings,
)
from app.services.print_tax_discount_display import DISPLAY_ALWAYS
class _FakeRow:
def __init__(self, document_type: str, **kwargs):
self.document_type = document_type
defaults = default_print_settings_dict()
for key, value in defaults.items():
setattr(self, key, value)
for key, value in kwargs.items():
setattr(self, key, value)
def test_pick_print_settings_merges_per_type():
rows = [
_FakeRow("all", show_share_qr=False, line_tax_display="smart"),
_FakeRow("invoice_sales", show_share_qr=True, line_tax_display=DISPLAY_ALWAYS),
]
merged = pick_print_settings(rows, "invoice_sales")
assert merged["show_share_qr"] is True
assert merged["line_tax_display"] == DISPLAY_ALWAYS
def test_pick_print_settings_falls_back_to_all():
rows = [_FakeRow("all", summary_tax_display=DISPLAY_ALWAYS)]
merged = pick_print_settings(rows, "invoice_purchase")
assert merged["summary_tax_display"] == DISPLAY_ALWAYS
def test_pick_print_settings_per_type_overrides_currency_symbol_flag():
rows = [
_FakeRow("all", show_currency_symbol=True),
_FakeRow("invoice_sales", show_currency_symbol=False),
]
sales = pick_print_settings(rows, "invoice_sales")
purchase = pick_print_settings(rows, "invoice_purchase")
assert sales["show_currency_symbol"] is False
assert purchase["show_currency_symbol"] is True