36 lines
2.3 KiB
Python
36 lines
2.3 KiB
Python
from datetime import date
|
|
from decimal import Decimal
|
|
from roborto_accounting.config import default_logo_path
|
|
|
|
from roborto_accounting.persistence.models import BusinessSettings
|
|
from roborto_accounting.reporting.documents.financial import render_cash_flow_pdf, render_profit_and_loss_pdf,render_transaction_ledger_pdf,render_trial_balance_pdf
|
|
from roborto_accounting.reporting.documents.theme import DocumentTheme
|
|
from roborto_accounting.reporting.financial import CashFlowSummary, ProfitLossRow, ProfitLossSummary
|
|
from roborto_accounting.reporting.ledgers import LedgerRow,TrialBalanceRow,TrialBalanceSummary
|
|
|
|
|
|
def test_financial_report_pdfs_render_supplied_values_and_paginate(tmp_path):
|
|
settings = BusinessSettings(trading_name="roborto", general_email="hello@roborto.net")
|
|
theme = DocumentTheme(default_logo_path())
|
|
rows = [
|
|
ProfitLossRow(str(index), f"Account {index} with a deliberately long descriptive name", "INCOME" if index % 2 else "EXPENSE", Decimal(index))
|
|
for index in range(1, 90)
|
|
]
|
|
profit_loss = render_profit_and_loss_pdf(
|
|
tmp_path / "profit-loss.pdf",
|
|
report=ProfitLossSummary(rows, Decimal("2025"), Decimal("1980"), Decimal("45")),
|
|
start=date(2026, 1, 1), end=date(2026, 12, 31), settings=settings, theme=theme
|
|
)
|
|
cash_flow = render_cash_flow_pdf(
|
|
tmp_path / "cash-flow.pdf",
|
|
summary=CashFlowSummary(Decimal("1234.56"), Decimal("234.50"), Decimal("1000.06")),
|
|
start=date(2026, 1, 1), end=date(2026, 12, 31), settings=settings, theme=theme,
|
|
)
|
|
assert profit_loss.stat().st_size > 3000
|
|
assert cash_flow.stat().st_size > 1000
|
|
ledger_rows=[LedgerRow(index,date(2026,1,1),"1000","Bank",f"Ledger description {index}",Decimal("1"),Decimal("1")) for index in range(80)]
|
|
ledger=render_transaction_ledger_pdf(tmp_path/"ledger.pdf",rows=ledger_rows,start=date(2026,1,1),end=date(2026,12,31),settings=settings,theme=theme)
|
|
tb=TrialBalanceSummary([TrialBalanceRow("1000","Bank",Decimal("10"),Decimal("0")),TrialBalanceRow("4000","Income",Decimal("0"),Decimal("10"))],Decimal("10"),Decimal("10"),True)
|
|
trial=render_trial_balance_pdf(tmp_path/"trial.pdf",report=tb,start=date(2026,1,1),end=date(2026,12,31),settings=settings,theme=theme)
|
|
assert ledger.stat().st_size>3000 and trial.stat().st_size>1000
|