klydekushy commited on
Commit
3660169
·
verified ·
1 Parent(s): 3bcf74e

Update src/modules/loans_engine.py

Browse files
Files changed (1) hide show
  1. src/modules/loans_engine.py +22 -1
src/modules/loans_engine.py CHANGED
@@ -689,7 +689,26 @@ def show_loans_engine(client, sheet_name):
689
  # 7. VALIDATION & DOCUMENTS
690
  with st.form("valid_pret"):
691
  submit = st.form_submit_button("OCTROYER & GÉNÉRER DOCS")
 
 
 
 
 
 
 
692
 
 
 
 
 
 
 
 
 
 
 
 
 
693
  if submit:
694
  # 7a. SAUVEGARDE GOOGLE SHEETS
695
  ws_prets = sh.worksheet("Prets_Master")
@@ -707,6 +726,7 @@ def show_loans_engine(client, sheet_name):
707
  motif, # Motif
708
  montant, # Montant_Capital
709
  taux_hebdo, # Taux_Hebdo
 
710
  duree_semaines, # Duree_Semaines
711
  round(montant_versement), # Montant_Versement
712
  round(montant_total), # Montant_Total
@@ -730,7 +750,8 @@ def show_loans_engine(client, sheet_name):
730
  "ID_Pret": new_id,
731
  "Montant_Capital": montant,
732
  "Montant_Total": montant_total,
733
- "Taux_Hebdo": taux_hebdo,
 
734
  "Duree_Semaines": duree_semaines,
735
  "Motif": motif,
736
  "Date_Deblocage": date_debut.strftime("%d/%m/%Y"),
 
689
  # 7. VALIDATION & DOCUMENTS
690
  with st.form("valid_pret"):
691
  submit = st.form_submit_button("OCTROYER & GÉNÉRER DOCS")
692
+
693
+
694
+
695
+ # ============================================================================
696
+ # CALCUL DU TAUX D'ENDETTEMENT AVANT VALIDATION
697
+ # ============================================================================
698
+ from Analytics.AnalyseFinance import calculer_taux_endettement
699
 
700
+ taux_endettement = calculer_taux_endettement(
701
+ type_code,
702
+ montant_versement,
703
+ nb_versements,
704
+ duree_semaines,
705
+ client_info['Revenus_Mensuels']
706
+ )
707
+
708
+ # Affichage pour information (optionnel)
709
+ st.info(f"📊 **Taux d'endettement calculé** : {taux_endettement:.2f}%")
710
+
711
+
712
  if submit:
713
  # 7a. SAUVEGARDE GOOGLE SHEETS
714
  ws_prets = sh.worksheet("Prets_Master")
 
726
  motif, # Motif
727
  montant, # Montant_Capital
728
  taux_hebdo, # Taux_Hebdo
729
+ taux_endettement, # Taux_endettement
730
  duree_semaines, # Duree_Semaines
731
  round(montant_versement), # Montant_Versement
732
  round(montant_total), # Montant_Total
 
750
  "ID_Pret": new_id,
751
  "Montant_Capital": montant,
752
  "Montant_Total": montant_total,
753
+ "Taux_Hebdo": taux_hebdo,
754
+ "Taux_Endettement": taux_endettement, # ✅ AJOUT
755
  "Duree_Semaines": duree_semaines,
756
  "Motif": motif,
757
  "Date_Deblocage": date_debut.strftime("%d/%m/%Y"),