
This commit includes the following changes: - Deleted the `package-lock.json` file to streamline dependency management. - Updated the `financials.py` endpoint to return a comprehensive user financial summary, including net balance, total group spending, debts, and credits. - Enhanced the `expense.py` CRUD operations to handle enum values and improve error handling during expense deletion. - Introduced new schemas in `financials.py` for user financial summaries and debt/credit tracking. - Refactored the costs service to improve group balance summary calculations. These changes aim to improve the application's financial tracking capabilities and maintain cleaner dependency management.
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
from pydantic import BaseModel, Field
|
|
from typing import Union, List
|
|
from .expense import ExpensePublic, SettlementPublic
|
|
from decimal import Decimal
|
|
|
|
class FinancialActivityResponse(BaseModel):
|
|
activities: List[Union[ExpensePublic, SettlementPublic]]
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
class SummaryUser(BaseModel):
|
|
"""Lightweight representation of a user for summary responses."""
|
|
id: int
|
|
name: str
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
class DebtCredit(BaseModel):
|
|
"""Represents a debt or credit entry in the user financial summary."""
|
|
user: SummaryUser
|
|
amount: float
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
class UserFinancialSummary(BaseModel):
|
|
"""Aggregated financial summary for the authenticated user across all groups."""
|
|
|
|
net_balance: float = 0.0
|
|
total_group_spending: float = 0.0
|
|
debts: List[DebtCredit] = Field(default_factory=list)
|
|
credits: List[DebtCredit] = Field(default_factory=list)
|
|
currency: str = "USD"
|
|
|
|
class Config:
|
|
orm_mode = True |