mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-01-06 03:30:25 -06:00
- 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
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
from datetime import datetime
|
|
from app import db
|
|
|
|
|
|
class TaxRule(db.Model):
|
|
"""Flexible tax rules per country/region/client with effective date ranges."""
|
|
|
|
__tablename__ = 'tax_rules'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
name = db.Column(db.String(100), nullable=False)
|
|
country = db.Column(db.String(2), nullable=True) # ISO-3166-1 alpha-2
|
|
region = db.Column(db.String(50), nullable=True)
|
|
client_id = db.Column(db.Integer, db.ForeignKey('clients.id'), nullable=True, index=True)
|
|
project_id = db.Column(db.Integer, db.ForeignKey('projects.id'), nullable=True, index=True)
|
|
tax_code = db.Column(db.String(50), nullable=True) # e.g., VAT, GST
|
|
rate_percent = db.Column(db.Numeric(7, 4), nullable=False, default=0)
|
|
compound = db.Column(db.Boolean, default=False, nullable=False)
|
|
inclusive = db.Column(db.Boolean, default=False, nullable=False) # If true, prices include tax
|
|
start_date = db.Column(db.Date, nullable=True)
|
|
end_date = db.Column(db.Date, nullable=True)
|
|
active = db.Column(db.Boolean, default=True, 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"<TaxRule {self.name} {self.rate_percent}%>"
|
|
|
|
|