
- Created project structure with FastAPI framework - Set up SQLite database with SQLAlchemy ORM - Implemented models: User, Item, Supplier, Transaction - Created CRUD operations for all models - Added API endpoints for all resources - Implemented JWT authentication and authorization - Added Alembic migration scripts - Created health endpoint - Updated documentation generated with BackendIM... (backend.im)
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
from typing import Optional
|
|
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
from app.models.transaction import TransactionType
|
|
|
|
|
|
# Shared properties
|
|
class TransactionBase(BaseModel):
|
|
transaction_type: TransactionType
|
|
quantity: int
|
|
price_per_unit: float
|
|
reference_number: Optional[str] = None
|
|
notes: Optional[str] = None
|
|
item_id: int
|
|
user_id: Optional[int] = None
|
|
transaction_date: Optional[datetime] = None
|
|
|
|
|
|
# Properties to receive on transaction creation
|
|
class TransactionCreate(TransactionBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on transaction update
|
|
class TransactionUpdate(TransactionBase):
|
|
transaction_type: Optional[TransactionType] = None
|
|
quantity: Optional[int] = None
|
|
price_per_unit: Optional[float] = None
|
|
item_id: Optional[int] = None
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class TransactionInDBBase(TransactionBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Transaction(TransactionInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class TransactionInDB(TransactionInDBBase):
|
|
pass |