22 lines
761 B
Python
22 lines
761 B
Python
from pydantic import BaseModel, ConfigDict
|
|
from typing import List, Optional
|
|
from decimal import Decimal
|
|
|
|
class UserCostShare(BaseModel):
|
|
user_id: int
|
|
user_identifier: str # Name or email
|
|
items_added_value: Decimal = Decimal("0.00") # Total value of items this user added
|
|
amount_due: Decimal # The user's share of the total cost (for equal split, this is total_cost / num_users)
|
|
balance: Decimal # items_added_value - amount_due
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
class ListCostSummary(BaseModel):
|
|
list_id: int
|
|
list_name: str
|
|
total_list_cost: Decimal
|
|
num_participating_users: int
|
|
equal_share_per_user: Decimal
|
|
user_balances: List[UserCostShare]
|
|
|
|
model_config = ConfigDict(from_attributes=True) |