Files
TimeTracker/app/models/invoice_template.py
Dries Peeters db82068dfd feat(reporting,invoices): scaffold reporting + invoicing extensions
- Add data models:
  - Reporting: SavedReportView, ReportEmailSchedule
  - Currency/FX: Currency, ExchangeRate
  - Tax: TaxRule (flexible rules with date ranges; client/project scoping)
  - Invoices: InvoiceTemplate, Payment, CreditNote, InvoiceReminderSchedule
- Extend Invoice:
  - Add currency_code and template_id
  - Add relationships: payments, credits, reminder_schedules
  - Compute outstanding by subtracting credits; helper to apply matching TaxRule
- Register new models in app/models/__init__.py
- DB: add Alembic migration 017 to create new tables and alter invoices

Notes:
- Requires database migration (alembic upgrade head).
- Follow-ups: FX fetching + scheduler, report builder UI/CRUD, utilization dashboard,
  email schedules/reminders, invoice themes in UI, partial payments and credit notes in routes/templates
2025-10-06 13:51:24 +02:00

24 lines
811 B
Python

from datetime import datetime
from app import db
class InvoiceTemplate(db.Model):
"""Reusable invoice templates/themes with customizable HTML and CSS."""
__tablename__ = 'invoice_templates'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), nullable=False, unique=True, index=True)
description = db.Column(db.String(255), nullable=True)
html = db.Column(db.Text, nullable=True)
css = db.Column(db.Text, nullable=True)
is_default = db.Column(db.Boolean, default=False, nullable=False)
created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
def __repr__(self):
return f"<InvoiceTemplate {self.name}>"