86 lines
2.1 KiB
Python
86 lines
2.1 KiB
Python
"""Schémas Phase 7 — Finances avancé : contributions, répartition, rapport complet."""
|
|
from pydantic import BaseModel
|
|
from datetime import date, datetime
|
|
from uuid import UUID
|
|
from typing import Optional
|
|
|
|
|
|
DESTINATIONS = ["district", "region", "bsg", "intergroupe"]
|
|
DESTINATIONS_LABELS = {
|
|
"district": "District 87-16",
|
|
"region": "Région 87",
|
|
"bsg": "BSG",
|
|
"intergroupe": "Intergroupe",
|
|
}
|
|
METHODES_CONTRIBUTION = ["DU", "VIREMENT", "CHEQUE"]
|
|
|
|
|
|
# ── M4 Envoi de contributions ──
|
|
class EnvoiContributionCreate(BaseModel):
|
|
date_envoi: date
|
|
destination: str # district, region, bsg, intergroupe
|
|
montant: float
|
|
methode: str # DU, VIREMENT, CHEQUE
|
|
resolution_id: UUID # résolution adoptée qui autorise l'envoi
|
|
|
|
|
|
class EnvoiContributionOut(BaseModel):
|
|
id: UUID
|
|
date_envoi: date
|
|
destination: str
|
|
destination_label: str
|
|
montant: float
|
|
methode: str
|
|
resolution_id: Optional[UUID] = None
|
|
engagee: bool = False
|
|
debitee: bool = False
|
|
saisi_par_prenom: Optional[str] = None
|
|
cree_le: datetime
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class CalculRepartitionIn(BaseModel):
|
|
"""Montant à répartir — le backend calcule les montants par destination."""
|
|
montant_total: float
|
|
|
|
|
|
class CalculRepartitionOut(BaseModel):
|
|
destination: str
|
|
destination_label: str
|
|
pourcentage: float
|
|
montant: float
|
|
|
|
|
|
# ── G8 Config répartition ──
|
|
class ConfigRepartitionItem(BaseModel):
|
|
destination: str
|
|
pourcentage: float
|
|
|
|
|
|
class ConfigRepartitionOut(BaseModel):
|
|
destination: str
|
|
destination_label: str
|
|
pourcentage: float
|
|
actif_depuis: date
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class ConfigRepartitionBatch(BaseModel):
|
|
"""Mettre à jour toutes les répartitions d'un coup."""
|
|
items: list[ConfigRepartitionItem]
|
|
|
|
|
|
# ── Rapport financier complet ──
|
|
class RapportFinancierComplet(BaseModel):
|
|
mois: int
|
|
annee: int
|
|
total_collectes: float
|
|
total_depenses: float
|
|
total_contributions: float
|
|
solde_mois: float
|
|
nb_collectes: int
|
|
nb_depenses: int
|
|
nb_contributions: int
|
|
depenses_impayees: float
|