From af4aa713b9eae6d81e3e6d57baaff4814f30f6eb Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 30 Aug 2026 07:21:37 +0100 Subject: [PATCH] Package runtime migrations and branding assets --- .gitignore | 1 + alembic.ini | 2 +- docs/CURRENT_STATE.md | 8 +++++-- docs/HANDOFF.md | 21 ++++++++++++------- docs/PROJECT_OVERVIEW.md | 3 ++- docs/TASKS.md | 19 +++++++++++++++-- docs/design/DOCUMENT_DESIGN.md | 3 ++- docs/design/HANDOFF.md | 5 +++-- pyproject.toml | 8 +++++++ .../assets}/branding/logo-dark.svg | 0 .../assets}/branding/logo-light.svg | 0 src/roborto_accounting/cli/main.py | 5 +++-- src/roborto_accounting/config.py | 5 +++-- src/roborto_accounting/migrations/__init__.py | 1 + .../roborto_accounting/migrations}/env.py | 0 .../migrations}/script.py.mako | 0 .../migrations}/versions/0001_initial.py | 0 .../versions/0002_settings_accounts.py | 0 .../migrations}/versions/0003_journals.py | 0 .../migrations}/versions/0004_audit_events.py | 0 .../migrations}/versions/0005_clients.py | 0 .../migrations}/versions/0006_suppliers.py | 0 .../versions/0007_projects_rates.py | 0 .../migrations}/versions/0008_expenses.py | 0 .../migrations}/versions/0009_attachments.py | 0 .../migrations}/versions/0010_tags.py | 0 .../migrations}/versions/0011_quotations.py | 0 .../migrations}/versions/0012_invoices.py | 0 .../versions/0013_client_payments.py | 0 .../versions/0014_credits_writeoffs.py | 0 .../migrations}/versions/0015_payables.py | 0 .../migrations}/versions/0016_time_entries.py | 0 .../versions/0017_rechargeable_expenses.py | 0 .../versions/0018_recurring_definitions.py | 0 .../migrations}/versions/0019_bank_imports.py | 0 .../versions/0020_reconciliation.py | 0 .../versions/0021_currency_snapshots.py | 0 .../migrations}/versions/0022_tax_details.py | 0 .../migrations}/versions/0023_assets.py | 0 .../migrations}/versions/0024_periods.py | 0 .../versions/0025_document_settings.py | 0 .../versions/0026_invoice_accounting.py | 0 .../versions/0027_invoice_voids.py | 0 .../versions/0028_business_letters.py | 0 .../migrations/versions/__init__.py | 1 + tests/test_controls_cli.py | 2 +- tests/test_document_theme.py | 3 ++- tests/test_financial_documents.py | 4 ++-- tests/test_letters.py | 4 ++-- tests/test_sales_cli.py | 2 +- tests/test_sales_documents.py | 4 ++-- 51 files changed, 72 insertions(+), 29 deletions(-) rename {assets => src/roborto_accounting/assets}/branding/logo-dark.svg (100%) rename {assets => src/roborto_accounting/assets}/branding/logo-light.svg (100%) create mode 100644 src/roborto_accounting/migrations/__init__.py rename {alembic => src/roborto_accounting/migrations}/env.py (100%) rename {alembic => src/roborto_accounting/migrations}/script.py.mako (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0001_initial.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0002_settings_accounts.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0003_journals.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0004_audit_events.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0005_clients.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0006_suppliers.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0007_projects_rates.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0008_expenses.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0009_attachments.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0010_tags.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0011_quotations.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0012_invoices.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0013_client_payments.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0014_credits_writeoffs.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0015_payables.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0016_time_entries.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0017_rechargeable_expenses.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0018_recurring_definitions.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0019_bank_imports.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0020_reconciliation.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0021_currency_snapshots.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0022_tax_details.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0023_assets.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0024_periods.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0025_document_settings.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0026_invoice_accounting.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0027_invoice_voids.py (100%) rename {alembic => src/roborto_accounting/migrations}/versions/0028_business_letters.py (100%) create mode 100644 src/roborto_accounting/migrations/versions/__init__.py diff --git a/.gitignore b/.gitignore index 9a406f1..eaacf35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .venv/ .pytest_cache/ +build/ __pycache__/ *.py[cod] accounts.db diff --git a/alembic.ini b/alembic.ini index 2dafd12..bffec92 100644 --- a/alembic.ini +++ b/alembic.ini @@ -1,5 +1,5 @@ [alembic] -script_location = %(here)s/alembic +script_location = %(here)s/src/roborto_accounting/migrations prepend_sys_path = . path_separator = os sqlalchemy.url = sqlite:///accounts.db diff --git a/docs/CURRENT_STATE.md b/docs/CURRENT_STATE.md index cda398c..35bd79b 100644 --- a/docs/CURRENT_STATE.md +++ b/docs/CURRENT_STATE.md @@ -1,6 +1,7 @@ # Current State -- Development stage: approved v1 and business-letter workflow implemented; no active task. +- Development stage: approved v1, business-letter workflow, and deployable wheel + packaging implemented; no active task. - Implemented: persistence/migrations, exact money, chart/settings, balanced journals, audit, all core records and sales/payables workflows, recurring definitions, bank import/reconciliation, currency/VAT/tax records, assets, period locks/backups, @@ -21,7 +22,10 @@ and P&L were generated and visually inspected against `docs/design/references/`; multi-page invoice and ledger/report pagination was checked. - Missing approved functionality: none identified by the completed requirements audit. -- Known problems: no known failing test or migration. +- Packaging: migrations and branding resources are included in the wheel. A wheel + installed into an isolated target outside the checkout initialized revision 0028 + and generated all five branded sample PDFs. +- Known problems: no known failing test, migration, or packaging defect. - Repository baseline: the completed implementation is captured in the initial Git commit; generated runtime/test artifacts remain ignored. - Current active task: none. diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index 5934e4d..09bd6d6 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -7,9 +7,9 @@ a pre-trading sole-trader software business. SQLite is authoritative. ## 2. Repository state -The accounting/service layers and full backlog are implemented and captured in the -initial Git baseline. `.venv`, caches, generated databases, bytecode, and package -metadata are ignored. +The accounting/service layers and full approved backlog are implemented. The initial +Git baseline exists; a follow-up packaging change makes wheels self-contained. `.venv`, +caches, generated databases, bytecode, build output, and package metadata are ignored. ## 3. Current application state @@ -34,15 +34,18 @@ approval, XDG runtime locations, and ReportLab/svglib shared A4 rendering. Completed the full backlog, including migrations 0014–0028, all controls and reports, CLI/runtime paths, PDF renderers, managed generated-document metadata, and deterministic visual samples. Corrected migration 0017 to use SQLite batch mode. +PKG-001 moved migrations and branding resources into the installable package and +validated initialization/document generation from a wheel outside the checkout. ## 7. Current task -No active approved task. The final audit tasks and `DOC-FUTURE-001` business-letter -draft/finalize/archive workflow are complete. `DOC-006` added the root operator guide. +No active approved task. The final audit tasks, business-letter workflow, operator +guide, and self-contained wheel deployment task are complete. ## 8. Important code locations -- Models/migrations: `src/roborto_accounting/persistence/`, `alembic/versions/` +- Models/migrations: `src/roborto_accounting/persistence/`, + `src/roborto_accounting/migrations/versions/` - Services: `src/roborto_accounting/services/` - Reports/documents: `src/roborto_accounting/reporting/` - CLI/runtime paths: `src/roborto_accounting/cli/`, `src/roborto_accounting/config.py` @@ -55,6 +58,9 @@ draft/finalize/archive workflow are complete. `DOC-006` added the root operator - `.venv/bin/alembic -c upgrade head` — fresh SQLite through 0028 - `.venv/bin/accounts --help` - `.venv/bin/accounts document-samples --output ` +- `.venv/bin/pip wheel . --no-deps --no-build-isolation --wheel-dir ` +- wheel installed to an isolated target outside the checkout: initialization through + 0028 and five sample PDFs succeeded - `git diff --check` ## 10. Environment variables by NAME ONLY @@ -64,7 +70,8 @@ draft/finalize/archive workflow are complete. `DOC-006` added the root operator ## 11. Testing/quality status 60 isolated tests pass. Fresh migration through 0028 has no SQLite foreign-key -violations. Representative A4 invoice, quotation, Cash Flow, and P&L PDFs were +violations. The built wheel contains migrations and both brand SVGs and works outside +the checkout. Representative A4 invoice, quotation, Cash Flow, and P&L PDFs were visually inspected; multi-page headers, wrapping, totals, footers, and page numbering were checked. diff --git a/docs/PROJECT_OVERVIEW.md b/docs/PROJECT_OVERVIEW.md index ab3c4cc..f639678 100644 --- a/docs/PROJECT_OVERVIEW.md +++ b/docs/PROJECT_OVERVIEW.md @@ -73,7 +73,8 @@ documents, and backups in `~/.local/share/roborto-accounting`, and state in - `src/roborto_accounting/`: package and separated layers - `tests/`: isolated automated tests -- `alembic/`: migrations +- `src/roborto_accounting/migrations/`: packaged Alembic migrations +- `src/roborto_accounting/assets/branding/`: packaged document-branding resources - `docs/`: maintained context - `AGENTS.md`: working instructions diff --git a/docs/TASKS.md b/docs/TASKS.md index c74b02e..28d0f65 100644 --- a/docs/TASKS.md +++ b/docs/TASKS.md @@ -31,7 +31,7 @@ major task is `IN PROGRESS`. - Objective: Establish migrations and exact `Decimal` storage policy. - Scope: Alembic environment, initial migration workflow, SQLite encoding/scale/rounding. - Acceptance criteria: upgrade/downgrade works; monetary round-trip proves no floats. -- Relevant code: `alembic/`, persistence money type, tests. +- Relevant code: `src/roborto_accounting/migrations/`, persistence money type, tests. - Validation: migration and arithmetic tests. - Dependencies: FND-002. Non-goals: business tables. Open questions: exact encoding is proposed. @@ -468,7 +468,7 @@ major task is `IN PROGRESS`. - Objective: Implement the approved reusable light-mode Roborto document identity. - Scope: rendering-library selection, deterministic A4 output, margins, typography, `logo-light.svg`, colour tokens, headings, tables, totals, footer/page numbering, wrapping and page breaks. - Acceptance criteria: one UI-independent theme serves every renderer; output is print-safe, greyscale-legible, deterministic, and contains no accounting logic. -- Relevant code: future `reporting/documents/`, `assets/branding/`, `docs/design/`. +- Relevant code: `reporting/documents/`, packaged branding assets, `docs/design/`. - Validation: unit/layout tests plus generated representative multi-page PDF inspection. - Dependencies: DOC-001. Non-goals: per-document themes, dashboards, gradients, shadows, proprietary fonts, Flask/React. Open questions: rendering library. @@ -523,6 +523,21 @@ major task is `IN PROGRESS`. - Dependencies: CLI-006, DOC-FUTURE-001. Non-goals: deployment automation or invented workflows. Open questions: none. +### PKG-001 — Self-contained wheel deployment +- Priority: P0; Status: COMPLETE +- Objective: Make a normal wheel installation independent of the source checkout. +- Scope: package Alembic migrations and brand SVG resources, resolve them from the + installed package, and retain the repository Alembic developer workflow. +- Acceptance criteria: a built wheel contains every migration and branding asset; + code installed from that wheel can initialize a new database and generate branded + document samples while running outside the repository. +- Relevant code: `pyproject.toml`, packaged migrations/assets, runtime configuration, + CLI initialization, deployment tests. +- Validation: full tests, clean wheel inspection, external-location database + initialization and PDF sample generation. +- Dependencies: FND-002, DOC-005. Non-goals: system-wide installation automation, + cloud deployment, or changing the XDG runtime-storage policy. Open questions: none. + ## Backlog review The approved specification is represented by tasks, acceptance criteria, decisions, or diff --git a/docs/design/DOCUMENT_DESIGN.md b/docs/design/DOCUMENT_DESIGN.md index 2c5d7ec..4b7fc8d 100644 --- a/docs/design/DOCUMENT_DESIGN.md +++ b/docs/design/DOCUMENT_DESIGN.md @@ -14,7 +14,8 @@ Profit & Loss statements, transaction/accounting/year-end reports, and other professional A4 output. Do not independently style each renderer. - A4 portrait by default, white/light background, generous margins and whitespace. -- Use `assets/branding/logo-light.svg`; never put the dark logo panel on light pages. +- Use the packaged `src/roborto_accounting/assets/branding/logo-light.svg`; never put + the dark logo panel on light pages. - Roborto green `#7ee787`; Roborto dark `#0b0f14`; dark body text and light rules. - Clean, non-proprietary sans-serif typography; monospace only sparingly. - Strong dark titles with a short thin green accent, not full-width colour banners. diff --git a/docs/design/HANDOFF.md b/docs/design/HANDOFF.md index 3ffc042..aed7138 100644 --- a/docs/design/HANDOFF.md +++ b/docs/design/HANDOFF.md @@ -19,8 +19,9 @@ Never infer business data or reproduce text errors from it. ## Assets and references -- `assets/branding/logo-light.svg`: required light-document logo. -- `assets/branding/logo-dark.svg`: retained dark-mode asset, not for white A4 pages. +- `src/roborto_accounting/assets/branding/logo-light.svg`: required light-document logo. +- `src/roborto_accounting/assets/branding/logo-dark.svg`: retained dark-mode asset, + not for white A4 pages. - `docs/design/references/invoice-reference.png`: canonical visual direction. - Other PNGs: quotation, letter, Cash Flow, and Profit & Loss adaptations. diff --git a/pyproject.toml b/pyproject.toml index 901d102..b9bc343 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,14 @@ accounts = "roborto_accounting.cli.main:main" [tool.setuptools.packages.find] where = ["src"] +[tool.setuptools.package-data] +roborto_accounting = [ + "assets/branding/*.svg", + "migrations/*.py", + "migrations/*.mako", + "migrations/versions/*.py", +] + [tool.pytest.ini_options] testpaths = ["tests"] addopts = "-ra" diff --git a/assets/branding/logo-dark.svg b/src/roborto_accounting/assets/branding/logo-dark.svg similarity index 100% rename from assets/branding/logo-dark.svg rename to src/roborto_accounting/assets/branding/logo-dark.svg diff --git a/assets/branding/logo-light.svg b/src/roborto_accounting/assets/branding/logo-light.svg similarity index 100% rename from assets/branding/logo-light.svg rename to src/roborto_accounting/assets/branding/logo-light.svg diff --git a/src/roborto_accounting/cli/main.py b/src/roborto_accounting/cli/main.py index d72ccaf..52fa918 100644 --- a/src/roborto_accounting/cli/main.py +++ b/src/roborto_accounting/cli/main.py @@ -3,6 +3,7 @@ import argparse import json from datetime import date from decimal import Decimal,InvalidOperation +from importlib.resources import files from pathlib import Path from alembic import command from alembic.config import Config @@ -100,8 +101,8 @@ def build_parser()->argparse.ArgumentParser: def _upgrade_database(path:Path)->None: path.parent.mkdir(parents=True,exist_ok=True) - project_root=Path(__file__).resolve().parents[3] - config=Config(str(project_root/"alembic.ini"));config.set_main_option("script_location",str(project_root/"alembic")) + migration_path=files("roborto_accounting").joinpath("migrations") + config=Config();config.set_main_option("script_location",str(migration_path)) config.set_main_option("sqlalchemy.url",sqlite_url(path));command.upgrade(config,"head") def _account_id(session,code:str)->int: diff --git a/src/roborto_accounting/config.py b/src/roborto_accounting/config.py index 89c78e8..46c334c 100644 --- a/src/roborto_accounting/config.py +++ b/src/roborto_accounting/config.py @@ -1,6 +1,7 @@ """Location-independent runtime paths following XDG conventions.""" import os from dataclasses import dataclass +from importlib.resources import files from pathlib import Path @dataclass(frozen=True) @@ -24,5 +25,5 @@ def runtime_paths(environ:dict[str,str]|None=None)->RuntimePaths: return RuntimePaths(config,data,state) def default_logo_path()->Path: - """Resolve the checked-in brand asset independently of the current directory.""" - return Path(__file__).resolve().parents[2]/"assets"/"branding"/"logo-light.svg" + """Resolve the packaged brand asset independently of the current directory.""" + return Path(str(files("roborto_accounting").joinpath("assets/branding/logo-light.svg"))) diff --git a/src/roborto_accounting/migrations/__init__.py b/src/roborto_accounting/migrations/__init__.py new file mode 100644 index 0000000..8318cfe --- /dev/null +++ b/src/roborto_accounting/migrations/__init__.py @@ -0,0 +1 @@ +"""Packaged Alembic migration resources.""" diff --git a/alembic/env.py b/src/roborto_accounting/migrations/env.py similarity index 100% rename from alembic/env.py rename to src/roborto_accounting/migrations/env.py diff --git a/alembic/script.py.mako b/src/roborto_accounting/migrations/script.py.mako similarity index 100% rename from alembic/script.py.mako rename to src/roborto_accounting/migrations/script.py.mako diff --git a/alembic/versions/0001_initial.py b/src/roborto_accounting/migrations/versions/0001_initial.py similarity index 100% rename from alembic/versions/0001_initial.py rename to src/roborto_accounting/migrations/versions/0001_initial.py diff --git a/alembic/versions/0002_settings_accounts.py b/src/roborto_accounting/migrations/versions/0002_settings_accounts.py similarity index 100% rename from alembic/versions/0002_settings_accounts.py rename to src/roborto_accounting/migrations/versions/0002_settings_accounts.py diff --git a/alembic/versions/0003_journals.py b/src/roborto_accounting/migrations/versions/0003_journals.py similarity index 100% rename from alembic/versions/0003_journals.py rename to src/roborto_accounting/migrations/versions/0003_journals.py diff --git a/alembic/versions/0004_audit_events.py b/src/roborto_accounting/migrations/versions/0004_audit_events.py similarity index 100% rename from alembic/versions/0004_audit_events.py rename to src/roborto_accounting/migrations/versions/0004_audit_events.py diff --git a/alembic/versions/0005_clients.py b/src/roborto_accounting/migrations/versions/0005_clients.py similarity index 100% rename from alembic/versions/0005_clients.py rename to src/roborto_accounting/migrations/versions/0005_clients.py diff --git a/alembic/versions/0006_suppliers.py b/src/roborto_accounting/migrations/versions/0006_suppliers.py similarity index 100% rename from alembic/versions/0006_suppliers.py rename to src/roborto_accounting/migrations/versions/0006_suppliers.py diff --git a/alembic/versions/0007_projects_rates.py b/src/roborto_accounting/migrations/versions/0007_projects_rates.py similarity index 100% rename from alembic/versions/0007_projects_rates.py rename to src/roborto_accounting/migrations/versions/0007_projects_rates.py diff --git a/alembic/versions/0008_expenses.py b/src/roborto_accounting/migrations/versions/0008_expenses.py similarity index 100% rename from alembic/versions/0008_expenses.py rename to src/roborto_accounting/migrations/versions/0008_expenses.py diff --git a/alembic/versions/0009_attachments.py b/src/roborto_accounting/migrations/versions/0009_attachments.py similarity index 100% rename from alembic/versions/0009_attachments.py rename to src/roborto_accounting/migrations/versions/0009_attachments.py diff --git a/alembic/versions/0010_tags.py b/src/roborto_accounting/migrations/versions/0010_tags.py similarity index 100% rename from alembic/versions/0010_tags.py rename to src/roborto_accounting/migrations/versions/0010_tags.py diff --git a/alembic/versions/0011_quotations.py b/src/roborto_accounting/migrations/versions/0011_quotations.py similarity index 100% rename from alembic/versions/0011_quotations.py rename to src/roborto_accounting/migrations/versions/0011_quotations.py diff --git a/alembic/versions/0012_invoices.py b/src/roborto_accounting/migrations/versions/0012_invoices.py similarity index 100% rename from alembic/versions/0012_invoices.py rename to src/roborto_accounting/migrations/versions/0012_invoices.py diff --git a/alembic/versions/0013_client_payments.py b/src/roborto_accounting/migrations/versions/0013_client_payments.py similarity index 100% rename from alembic/versions/0013_client_payments.py rename to src/roborto_accounting/migrations/versions/0013_client_payments.py diff --git a/alembic/versions/0014_credits_writeoffs.py b/src/roborto_accounting/migrations/versions/0014_credits_writeoffs.py similarity index 100% rename from alembic/versions/0014_credits_writeoffs.py rename to src/roborto_accounting/migrations/versions/0014_credits_writeoffs.py diff --git a/alembic/versions/0015_payables.py b/src/roborto_accounting/migrations/versions/0015_payables.py similarity index 100% rename from alembic/versions/0015_payables.py rename to src/roborto_accounting/migrations/versions/0015_payables.py diff --git a/alembic/versions/0016_time_entries.py b/src/roborto_accounting/migrations/versions/0016_time_entries.py similarity index 100% rename from alembic/versions/0016_time_entries.py rename to src/roborto_accounting/migrations/versions/0016_time_entries.py diff --git a/alembic/versions/0017_rechargeable_expenses.py b/src/roborto_accounting/migrations/versions/0017_rechargeable_expenses.py similarity index 100% rename from alembic/versions/0017_rechargeable_expenses.py rename to src/roborto_accounting/migrations/versions/0017_rechargeable_expenses.py diff --git a/alembic/versions/0018_recurring_definitions.py b/src/roborto_accounting/migrations/versions/0018_recurring_definitions.py similarity index 100% rename from alembic/versions/0018_recurring_definitions.py rename to src/roborto_accounting/migrations/versions/0018_recurring_definitions.py diff --git a/alembic/versions/0019_bank_imports.py b/src/roborto_accounting/migrations/versions/0019_bank_imports.py similarity index 100% rename from alembic/versions/0019_bank_imports.py rename to src/roborto_accounting/migrations/versions/0019_bank_imports.py diff --git a/alembic/versions/0020_reconciliation.py b/src/roborto_accounting/migrations/versions/0020_reconciliation.py similarity index 100% rename from alembic/versions/0020_reconciliation.py rename to src/roborto_accounting/migrations/versions/0020_reconciliation.py diff --git a/alembic/versions/0021_currency_snapshots.py b/src/roborto_accounting/migrations/versions/0021_currency_snapshots.py similarity index 100% rename from alembic/versions/0021_currency_snapshots.py rename to src/roborto_accounting/migrations/versions/0021_currency_snapshots.py diff --git a/alembic/versions/0022_tax_details.py b/src/roborto_accounting/migrations/versions/0022_tax_details.py similarity index 100% rename from alembic/versions/0022_tax_details.py rename to src/roborto_accounting/migrations/versions/0022_tax_details.py diff --git a/alembic/versions/0023_assets.py b/src/roborto_accounting/migrations/versions/0023_assets.py similarity index 100% rename from alembic/versions/0023_assets.py rename to src/roborto_accounting/migrations/versions/0023_assets.py diff --git a/alembic/versions/0024_periods.py b/src/roborto_accounting/migrations/versions/0024_periods.py similarity index 100% rename from alembic/versions/0024_periods.py rename to src/roborto_accounting/migrations/versions/0024_periods.py diff --git a/alembic/versions/0025_document_settings.py b/src/roborto_accounting/migrations/versions/0025_document_settings.py similarity index 100% rename from alembic/versions/0025_document_settings.py rename to src/roborto_accounting/migrations/versions/0025_document_settings.py diff --git a/alembic/versions/0026_invoice_accounting.py b/src/roborto_accounting/migrations/versions/0026_invoice_accounting.py similarity index 100% rename from alembic/versions/0026_invoice_accounting.py rename to src/roborto_accounting/migrations/versions/0026_invoice_accounting.py diff --git a/alembic/versions/0027_invoice_voids.py b/src/roborto_accounting/migrations/versions/0027_invoice_voids.py similarity index 100% rename from alembic/versions/0027_invoice_voids.py rename to src/roborto_accounting/migrations/versions/0027_invoice_voids.py diff --git a/alembic/versions/0028_business_letters.py b/src/roborto_accounting/migrations/versions/0028_business_letters.py similarity index 100% rename from alembic/versions/0028_business_letters.py rename to src/roborto_accounting/migrations/versions/0028_business_letters.py diff --git a/src/roborto_accounting/migrations/versions/__init__.py b/src/roborto_accounting/migrations/versions/__init__.py new file mode 100644 index 0000000..2c4e0ce --- /dev/null +++ b/src/roborto_accounting/migrations/versions/__init__.py @@ -0,0 +1 @@ +"""Roborto accounting schema revisions.""" diff --git a/tests/test_controls_cli.py b/tests/test_controls_cli.py index 3a2035c..8e3bbf2 100644 --- a/tests/test_controls_cli.py +++ b/tests/test_controls_cli.py @@ -32,5 +32,5 @@ def test_controls_reports_and_exports_cli(tmp_path,capsys): assert "account_code=1000" in _run(prefix,["report","ledger",*period],capsys) csv_out=tmp_path/"trial.csv";_run(prefix,["report","trial-balance",*period,"--format","csv","--output",str(csv_out)],capsys);assert csv_out.is_file() ods_out=tmp_path/"pl.ods";_run(prefix,["report","profit-loss",*period,"--format","ods","--output",str(ods_out)],capsys);assert ods_out.is_file() - pdf_out=tmp_path/"cash.pdf";_run(prefix,["report","cash-flow",*period,"--format","pdf","--output",str(pdf_out),"--logo","assets/branding/logo-light.svg"],capsys);assert pdf_out.stat().st_size>1000 + pdf_out=tmp_path/"cash.pdf";_run(prefix,["report","cash-flow",*period,"--format","pdf","--output",str(pdf_out)],capsys);assert pdf_out.stat().st_size>1000 assert "tax_classification=REVIEW" in _run(prefix,["report","tax-review"],capsys) diff --git a/tests/test_document_theme.py b/tests/test_document_theme.py index 160a29d..9fa36c0 100644 --- a/tests/test_document_theme.py +++ b/tests/test_document_theme.py @@ -1,8 +1,9 @@ +from roborto_accounting.config import default_logo_path from roborto_accounting.reporting.documents.theme import DocumentTheme from reportlab.platypus import Paragraph def test_shared_theme_generates_deterministic_a4_pdf(tmp_path): - logo=__import__("pathlib").Path("assets/branding/logo-light.svg") + logo=default_logo_path() theme=DocumentTheme(logo);story=theme.header(["accounts@roborto.net"])+theme.heading("INVOICE") story.append(Paragraph("Correct accounting content",theme.body)) first=theme.build(tmp_path/"first.pdf",story) diff --git a/tests/test_financial_documents.py b/tests/test_financial_documents.py index d33f7b9..4608f4a 100644 --- a/tests/test_financial_documents.py +++ b/tests/test_financial_documents.py @@ -1,6 +1,6 @@ from datetime import date from decimal import Decimal -from pathlib import Path +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 @@ -11,7 +11,7 @@ from roborto_accounting.reporting.ledgers import LedgerRow,TrialBalanceRow,Trial def test_financial_report_pdfs_render_supplied_values_and_paginate(tmp_path): settings = BusinessSettings(trading_name="roborto", general_email="hello@roborto.net") - theme = DocumentTheme(Path("assets/branding/logo-light.svg")) + 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) diff --git a/tests/test_letters.py b/tests/test_letters.py index 3fbec09..0ccf05c 100644 --- a/tests/test_letters.py +++ b/tests/test_letters.py @@ -1,5 +1,5 @@ from datetime import date -from pathlib import Path +from roborto_accounting.config import default_logo_path import pytest @@ -16,7 +16,7 @@ def test_letter_render_is_deterministic_and_finalization_is_stable(tmp_path): engine=make_engine("sqlite://");Base.metadata.create_all(engine);session=make_session_factory(engine)() settings=BusinessSettings(trading_name="roborto",business_descriptor="Software Development",general_email="hello@roborto.net") letter=create_letter(session,letter_date=date(2026,8,29),recipient_name="Client",recipient_address="Address\nDublin",recipient_email="client@example.invalid",reference="REF-1",subject="Project follow-up",body_text="Hello,\n\n"+("A long representative paragraph for wrapping and pagination. "*180)) - theme=DocumentTheme(Path("assets/branding/logo-light.svg"));first=render_letter_pdf(tmp_path/"first.pdf",letter=letter,settings=settings,theme=theme);second=render_letter_pdf(tmp_path/"second.pdf",letter=letter,settings=settings,theme=theme) + theme=DocumentTheme(default_logo_path());first=render_letter_pdf(tmp_path/"first.pdf",letter=letter,settings=settings,theme=theme);second=render_letter_pdf(tmp_path/"second.pdf",letter=letter,settings=settings,theme=theme) assert first.read_bytes()==second.read_bytes() and first.stat().st_size>2000 attachment=finalize_letter(session,letter=letter,settings=settings,archive_root=tmp_path/"archive",theme=theme) assert letter.status=="FINALIZED" and (tmp_path/"archive"/attachment.stored_relative_path).is_file() diff --git a/tests/test_sales_cli.py b/tests/test_sales_cli.py index a0c37ff..d23d0d1 100644 --- a/tests/test_sales_cli.py +++ b/tests/test_sales_cli.py @@ -20,7 +20,7 @@ def test_sales_and_payables_cli_workflow(tmp_path,capsys): payment=int(_run(prefix,["invoice-payment",str(invoice),"--date","2026-08-10","--amount","125","--financial-account","1000"],capsys)) assert payment>0 and "PAID" in _run(prefix,["invoice-list"],capsys) archive=tmp_path/"archive" - generated=int(_run(prefix,["sales-document-generate","invoice",str(invoice),"--archive",str(archive),"--logo","assets/branding/logo-light.svg"],capsys)) + generated=int(_run(prefix,["sales-document-generate","invoice",str(invoice),"--archive",str(archive)],capsys)) assert generated>0 and len(list(archive.rglob("*.pdf")))==1 bill=int(_run(prefix,["supplier-bill-add","--supplier-id",str(supplier),"--date","2026-08-03","--description","Subscription","--amount","60","--expense-account","5020"],capsys)) diff --git a/tests/test_sales_documents.py b/tests/test_sales_documents.py index 957b785..d9bc8a7 100644 --- a/tests/test_sales_documents.py +++ b/tests/test_sales_documents.py @@ -1,6 +1,6 @@ from datetime import date from decimal import Decimal -from pathlib import Path +from roborto_accounting.config import default_logo_path from roborto_accounting.persistence.base import Base from roborto_accounting.persistence.db import make_engine,make_session_factory from roborto_accounting.persistence.models import Account,AccountClass,BusinessSettings,Client @@ -17,7 +17,7 @@ def test_issued_sales_documents_render_from_snapshots(tmp_path): line={"description":"Development","quantity":Decimal("2"),"unit":"hours","unit_price":Decimal("50"),"vat_amount":Decimal("0"),"income_account_id":income.id} invoice=create_invoice(s,settings=settings,client=client,invoice_date=date(2026,1,1),lines=[line]);issue_invoice(s,invoice,client,receivables_account_id=ar.id) quote=create_quotation(s,client=client,quotation_date=date(2026,1,1),lines=[line]);issue_quotation(s,quote,client) - theme=DocumentTheme(Path("assets/branding/logo-light.svg")) + theme=DocumentTheme(default_logo_path()) assert render_invoice_pdf(tmp_path/"invoice.pdf",invoice=invoice,settings=settings,theme=theme).stat().st_size>1000 assert render_quotation_pdf(tmp_path/"quote.pdf",quotation=quote,settings=settings,theme=theme).stat().st_size>1000 invoice_attachment=generate_invoice_document(s,invoice=invoice,settings=settings,archive_root=tmp_path/"archive",theme=theme)