Improve CarPass product UX and service flows
This commit is contained in:
@@ -2,7 +2,7 @@ import enum
|
||||
from datetime import date, datetime
|
||||
from decimal import Decimal
|
||||
|
||||
from sqlalchemy import Date, DateTime, Enum, ForeignKey, Numeric, String, Text, func
|
||||
from sqlalchemy import Boolean, Date, DateTime, Enum, ForeignKey, Numeric, String, Text, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.db.base import Base
|
||||
@@ -19,6 +19,29 @@ class ServiceType(str, enum.Enum):
|
||||
other = "other"
|
||||
|
||||
|
||||
class ExpenseCategory(str, enum.Enum):
|
||||
insurance = "insurance"
|
||||
tax = "tax"
|
||||
fine = "fine"
|
||||
parking = "parking"
|
||||
car_wash = "car_wash"
|
||||
toll = "toll"
|
||||
tires = "tires"
|
||||
wheels = "wheels"
|
||||
battery = "battery"
|
||||
parts = "parts"
|
||||
repair = "repair"
|
||||
maintenance = "maintenance"
|
||||
diagnostics = "diagnostics"
|
||||
towing = "towing"
|
||||
loan_payment = "loan_payment"
|
||||
loan_interest = "loan_interest"
|
||||
state_fee = "state_fee"
|
||||
registration = "registration"
|
||||
inspection = "inspection"
|
||||
other = "other"
|
||||
|
||||
|
||||
class FuelEntry(Base):
|
||||
__tablename__ = "fuel_entries"
|
||||
|
||||
@@ -56,3 +79,25 @@ class ServiceEntry(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
car = relationship("Car", back_populates="service_entries")
|
||||
|
||||
|
||||
class ExpenseEntry(Base):
|
||||
__tablename__ = "expense_entries"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
car_id: Mapped[int] = mapped_column(ForeignKey("cars.id", ondelete="CASCADE"), index=True)
|
||||
entry_date: Mapped[date] = mapped_column(Date, index=True)
|
||||
category: Mapped[ExpenseCategory] = mapped_column(Enum(ExpenseCategory), index=True)
|
||||
title: Mapped[str] = mapped_column(String(180))
|
||||
vendor: Mapped[str | None] = mapped_column(String(160))
|
||||
total_cost: Mapped[Decimal] = mapped_column(Numeric(12, 2))
|
||||
currency: Mapped[str] = mapped_column(String(3), default="RUB", server_default="RUB")
|
||||
odometer: Mapped[int | None]
|
||||
period_start: Mapped[date | None] = mapped_column(Date)
|
||||
period_end: Mapped[date | None] = mapped_column(Date)
|
||||
period_months: Mapped[int | None]
|
||||
is_recurring: Mapped[bool] = mapped_column(Boolean, default=False, server_default="false")
|
||||
notes: Mapped[str | None] = mapped_column(Text)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
car = relationship("Car", back_populates="expense_entries")
|
||||
|
||||
Reference in New Issue
Block a user