Spaces:
Running
Running
Update src/modules/loans_engine.py
Browse files- src/modules/loans_engine.py +20 -6
src/modules/loans_engine.py
CHANGED
|
@@ -380,6 +380,12 @@ def show_loans_engine(client, sheet_name):
|
|
| 380 |
# Récupération de la ligne complète
|
| 381 |
client_info = df_clients[df_clients['search_label'] == selected_client_label].iloc[0]
|
| 382 |
client_id = client_info['ID_Client']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
|
| 384 |
st.info(f"♦️Cible Détectée : **{client_info['Nom_Complet']}**")
|
| 385 |
|
|
@@ -404,6 +410,11 @@ def show_loans_engine(client, sheet_name):
|
|
| 404 |
|
| 405 |
st.markdown(f"**Profession :** {client_info['Statut_Pro']} | **Ville :** {client_info['Ville']}")
|
| 406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
# ============================================================================
|
| 408 |
# 3. SÉLECTION GARANT (Optionnel)
|
| 409 |
# ============================================================================
|
|
@@ -446,8 +457,8 @@ def show_loans_engine(client, sheet_name):
|
|
| 446 |
"Commerce / Achat de stock",
|
| 447 |
"Investissement",
|
| 448 |
"Trésorerie professionnelle",
|
| 449 |
-
"Lancement d
|
| 450 |
-
"Développement d
|
| 451 |
"Agriculture / Élevage",
|
| 452 |
"Transport / Logistique",
|
| 453 |
"Urgence médicale",
|
|
@@ -457,7 +468,7 @@ def show_loans_engine(client, sheet_name):
|
|
| 457 |
"Événements familiaux",
|
| 458 |
"Voyage / Déplacement",
|
| 459 |
"Consommation",
|
| 460 |
-
"Achat d
|
| 461 |
"Projet personnel",
|
| 462 |
"Autre"
|
| 463 |
]
|
|
@@ -657,10 +668,11 @@ def show_loans_engine(client, sheet_name):
|
|
| 657 |
# ====================================================================
|
| 658 |
|
| 659 |
# 5. APPEL CERVEAU ANALYTIQUE (AUTO-TRIGGER)
|
| 660 |
-
#
|
| 661 |
analyse = analyser_capacite(
|
| 662 |
type_code, montant, taux_hebdo, duree_semaines, montant_versement, nb_versements,
|
| 663 |
-
client_info['Revenus_Mensuels'], client_info.get('Charges_Estimees', 0), montant_total
|
|
|
|
| 664 |
)
|
| 665 |
|
| 666 |
# AFFICHAGE ANALYSE
|
|
@@ -702,6 +714,7 @@ def show_loans_engine(client, sheet_name):
|
|
| 702 |
|
| 703 |
# ============================================================================
|
| 704 |
# CALCUL DU TAUX D'ENDETTEMENT AVANT VALIDATION
|
|
|
|
| 705 |
# ============================================================================
|
| 706 |
from Analytics.AnalyseFinance import calculer_taux_endettement
|
| 707 |
|
|
@@ -710,7 +723,8 @@ def show_loans_engine(client, sheet_name):
|
|
| 710 |
montant_versement,
|
| 711 |
nb_versements,
|
| 712 |
duree_semaines,
|
| 713 |
-
client_info['Revenus_Mensuels']
|
|
|
|
| 714 |
)
|
| 715 |
|
| 716 |
# Affichage pour information (optionnel)
|
|
|
|
| 380 |
# Récupération de la ligne complète
|
| 381 |
client_info = df_clients[df_clients['search_label'] == selected_client_label].iloc[0]
|
| 382 |
client_id = client_info['ID_Client']
|
| 383 |
+
|
| 384 |
+
# ✅ Lecture du nombre de personnes à charge depuis le KYC
|
| 385 |
+
try:
|
| 386 |
+
pers_charge = int(client_info.get('Pers_Charge', 0))
|
| 387 |
+
except (ValueError, TypeError):
|
| 388 |
+
pers_charge = 0
|
| 389 |
|
| 390 |
st.info(f"♦️Cible Détectée : **{client_info['Nom_Complet']}**")
|
| 391 |
|
|
|
|
| 410 |
|
| 411 |
st.markdown(f"**Profession :** {client_info['Statut_Pro']} | **Ville :** {client_info['Ville']}")
|
| 412 |
|
| 413 |
+
# ✅ Affichage IPF si le client a des personnes à charge
|
| 414 |
+
if pers_charge >= 1:
|
| 415 |
+
ipf = rev / (1 + pers_charge)
|
| 416 |
+
st.info(f"📊 **IPF (Indice de Pression Familiale)** : {int(ipf):,} XOF — base de calcul ajustée ({pers_charge} pers. à charge)".replace(",", " "))
|
| 417 |
+
|
| 418 |
# ============================================================================
|
| 419 |
# 3. SÉLECTION GARANT (Optionnel)
|
| 420 |
# ============================================================================
|
|
|
|
| 457 |
"Commerce / Achat de stock",
|
| 458 |
"Investissement",
|
| 459 |
"Trésorerie professionnelle",
|
| 460 |
+
"Lancement d'activité",
|
| 461 |
+
"Développement d'activité",
|
| 462 |
"Agriculture / Élevage",
|
| 463 |
"Transport / Logistique",
|
| 464 |
"Urgence médicale",
|
|
|
|
| 468 |
"Événements familiaux",
|
| 469 |
"Voyage / Déplacement",
|
| 470 |
"Consommation",
|
| 471 |
+
"Achat d'équipement personnel",
|
| 472 |
"Projet personnel",
|
| 473 |
"Autre"
|
| 474 |
]
|
|
|
|
| 668 |
# ====================================================================
|
| 669 |
|
| 670 |
# 5. APPEL CERVEAU ANALYTIQUE (AUTO-TRIGGER)
|
| 671 |
+
# ✅ MODIFIÉ : passage de pers_charge pour activer l'IPF si nécessaire
|
| 672 |
analyse = analyser_capacite(
|
| 673 |
type_code, montant, taux_hebdo, duree_semaines, montant_versement, nb_versements,
|
| 674 |
+
client_info['Revenus_Mensuels'], client_info.get('Charges_Estimees', 0), montant_total,
|
| 675 |
+
pers_charge=pers_charge
|
| 676 |
)
|
| 677 |
|
| 678 |
# AFFICHAGE ANALYSE
|
|
|
|
| 714 |
|
| 715 |
# ============================================================================
|
| 716 |
# CALCUL DU TAUX D'ENDETTEMENT AVANT VALIDATION
|
| 717 |
+
# ✅ MODIFIÉ : passage de pers_charge pour activer l'IPF si nécessaire
|
| 718 |
# ============================================================================
|
| 719 |
from Analytics.AnalyseFinance import calculer_taux_endettement
|
| 720 |
|
|
|
|
| 723 |
montant_versement,
|
| 724 |
nb_versements,
|
| 725 |
duree_semaines,
|
| 726 |
+
client_info['Revenus_Mensuels'],
|
| 727 |
+
pers_charge=pers_charge
|
| 728 |
)
|
| 729 |
|
| 730 |
# Affichage pour information (optionnel)
|