mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-02-05 11:48:45 -06:00
- Normalize line endings from CRLF to LF across all files to match .editorconfig - Standardize quote style from single quotes to double quotes - Normalize whitespace and formatting throughout codebase - Apply consistent code style across 372 files including: * Application code (models, routes, services, utils) * Test files * Configuration files * CI/CD workflows This ensures consistency with the project's .editorconfig settings and improves code maintainability.
41 lines
1.7 KiB
Python
41 lines
1.7 KiB
Python
from datetime import datetime
|
|
from app import db
|
|
|
|
|
|
class Currency(db.Model):
|
|
"""Supported currencies and display metadata."""
|
|
|
|
__tablename__ = "currencies"
|
|
|
|
code = db.Column(db.String(3), primary_key=True) # e.g., EUR, USD
|
|
name = db.Column(db.String(64), nullable=False)
|
|
symbol = db.Column(db.String(8), nullable=True) # e.g., €, $
|
|
decimal_places = db.Column(db.Integer, default=2, nullable=False)
|
|
is_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"<Currency {self.code}>"
|
|
|
|
|
|
class ExchangeRate(db.Model):
|
|
"""Daily exchange rates between currency pairs."""
|
|
|
|
__tablename__ = "exchange_rates"
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
base_code = db.Column(db.String(3), db.ForeignKey("currencies.code"), nullable=False, index=True)
|
|
quote_code = db.Column(db.String(3), db.ForeignKey("currencies.code"), nullable=False, index=True)
|
|
rate = db.Column(db.Numeric(18, 8), nullable=False)
|
|
date = db.Column(db.Date, nullable=False, index=True)
|
|
source = db.Column(db.String(50), nullable=True) # e.g., ECB, exchangerate.host
|
|
|
|
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)
|
|
|
|
__table_args__ = (db.UniqueConstraint("base_code", "quote_code", "date", name="uq_exchange_rate_day"),)
|
|
|
|
def __repr__(self):
|
|
return f"<ExchangeRate {self.base_code}/{self.quote_code} {self.date} {self.rate}>"
|