mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-01-21 20:09:57 -06:00
Add the ability to create and manage PDF invoice templates for different page sizes (A4, Letter, Legal, A3, A5, Tabloid) with independent templates for each size. Features: - Database migration to create invoice_pdf_templates table with page_size column and default templates for all supported sizes - New InvoicePDFTemplate model with helper methods for template management - Page size selector dropdown in canvas editor with dynamic canvas resizing - Size selection in invoice export view - Each page size maintains its own template (HTML, CSS, design JSON) - Preview functionality converted to full-screen modal popup PDF Generation: - Updated InvoicePDFGenerator to accept page_size parameter - Dynamic @page rule updates in CSS based on selected size - Removed conflicting @page rules from HTML inline styles when separate CSS exists - Template content preserved exactly as saved (no whitespace stripping) - Fallback logic: size-specific template → legacy Settings template → default UI/UX Improvements: - Styled page size selector to match app theme with dark mode support - Fixed canvas editor header styling and readability - Canvas correctly resizes when switching between page sizes - Unsaved changes confirmation uses app's standard modal - All editor controls properly styled for dark/light mode - Preview opens in modal instead of small side window Bug Fixes: - Fixed migration KeyError by correcting down_revision reference - Fixed DatatypeMismatch error by using boolean TRUE instead of integer - Fixed template content mismatch (logo positions) by preserving HTML - Fixed page size not being applied by ensuring @page rules are updated - Fixed f-string syntax error in _generate_css by using .format() instead - Fixed debug_print scope issue in _render_from_custom_template Debugging: - Added comprehensive debug logging to PDF generation flow - Debug output visible in Docker console for troubleshooting - Logs template retrieval, @page size updates, and final CSS content Files Changed: - migrations/versions/041_add_invoice_pdf_templates_table.py (new) - app/models/invoice_pdf_template.py (new) - app/models/__init__.py (register new model) - app/routes/admin.py (template management by size) - app/routes/invoices.py (page size parameter, debug logging) - app/utils/pdf_generator.py (page size support, debug logging) - templates/admin/pdf_layout.html (size selector, canvas resizing, modal) - app/templates/invoices/view.html (size selector for export)
79 lines
2.1 KiB
Python
79 lines
2.1 KiB
Python
from .user import User
|
|
from .project import Project
|
|
from .time_entry import TimeEntry
|
|
from .task import Task
|
|
from .settings import Settings
|
|
from .invoice import Invoice, InvoiceItem
|
|
from .invoice_template import InvoiceTemplate
|
|
from .currency import Currency, ExchangeRate
|
|
from .tax_rule import TaxRule
|
|
from .payments import Payment, CreditNote, InvoiceReminderSchedule
|
|
from .reporting import SavedReportView, ReportEmailSchedule
|
|
from .client import Client
|
|
from .task_activity import TaskActivity
|
|
from .expense_category import ExpenseCategory
|
|
from .mileage import Mileage
|
|
from .per_diem import PerDiem, PerDiemRate
|
|
from .extra_good import ExtraGood
|
|
from .comment import Comment
|
|
from .focus_session import FocusSession
|
|
from .recurring_block import RecurringBlock
|
|
from .rate_override import RateOverride
|
|
from .saved_filter import SavedFilter
|
|
from .project_cost import ProjectCost
|
|
from .kanban_column import KanbanColumn
|
|
from .time_entry_template import TimeEntryTemplate
|
|
from .activity import Activity
|
|
from .user_favorite_project import UserFavoriteProject
|
|
from .client_note import ClientNote
|
|
from .weekly_time_goal import WeeklyTimeGoal
|
|
from .expense import Expense
|
|
from .permission import Permission, Role
|
|
from .api_token import ApiToken
|
|
from .calendar_event import CalendarEvent
|
|
from .budget_alert import BudgetAlert
|
|
from .import_export import DataImport, DataExport
|
|
from .invoice_pdf_template import InvoicePDFTemplate
|
|
|
|
__all__ = [
|
|
"User",
|
|
"Project",
|
|
"TimeEntry",
|
|
"Task",
|
|
"Settings",
|
|
"Invoice",
|
|
"InvoiceItem",
|
|
"Client",
|
|
"TaskActivity",
|
|
"Comment",
|
|
"FocusSession",
|
|
"RecurringBlock",
|
|
"RateOverride",
|
|
"SavedFilter",
|
|
"ProjectCost",
|
|
"InvoiceTemplate",
|
|
"Currency",
|
|
"ExchangeRate",
|
|
"TaxRule",
|
|
"Payment",
|
|
"CreditNote",
|
|
"InvoiceReminderSchedule",
|
|
"SavedReportView",
|
|
"ReportEmailSchedule",
|
|
"KanbanColumn",
|
|
"TimeEntryTemplate",
|
|
"Activity",
|
|
"UserFavoriteProject",
|
|
"ClientNote",
|
|
"WeeklyTimeGoal",
|
|
"Expense",
|
|
"Permission",
|
|
"Role",
|
|
"ApiToken",
|
|
"CalendarEvent",
|
|
"BudgetAlert",
|
|
"DataImport",
|
|
"DataExport",
|
|
"InvoicePDFTemplate",
|
|
]
|