klydekushy commited on
Commit
281774d
·
verified ·
1 Parent(s): 7a6f1fb

Update src/modules/kyc_form.py

Browse files
Files changed (1) hide show
  1. src/modules/kyc_form.py +59 -80
src/modules/kyc_form.py CHANGED
@@ -21,54 +21,26 @@ def lbl(text, mandatory=False):
21
  # Listes de référence
22
  LISTE_PROFESSIONS = ["Commerçant", "Fonctionnaire", "Agriculteur", "Etudiant", "Ouvrier", "Cadre Supérieur", "Ingénieur", "Médecin", "Autre"]
23
  LISTE_QUARTIERS = [
24
- # Dakar Plateau
25
  "Plateau", "Médina", "Fann", "Point E", "Gueule Tapée", "Colobane",
26
-
27
- # Dakar Est
28
  "Hann Maristes 1", "Hann Maristes 2", "Hann Bel-Air",
29
-
30
- # Dakar Ouest
31
  "Yoff", "Ouakam", "Ngor", "Almadies", "Mamelles",
32
-
33
- # Dakar Centre
34
  "Mermoz", "Sacré-Cœur", "Liberté 1", "Liberté 2", "Liberté 3",
35
  "Liberté 4", "Liberté 5", "Liberté 6",
36
  "HLM", "Grand Dakar", "Dieuppeul", "Derklé",
37
-
38
- # Pikine
39
  "Pikine Est", "Pikine Ouest", "Pikine Nord", "Pikine Sud",
40
  "Guinaw Rails", "Thiaroye", "Dalifort",
41
-
42
- # Guédiawaye
43
  "Guédiawaye", "Golf Sud", "Medina Gounass", "Wakhinane Nimzatt",
44
-
45
- # Rufisque
46
  "Rufisque", "Bargny", "Diamniadio", "Sébikotane",
47
-
48
- # Autres
49
  "Autre"
50
  ]
51
 
52
  LISTE_VILLES = [
53
- # Dakar & Région
54
  "Dakar", "Pikine", "Guédiawaye", "Rufisque",
55
-
56
- # Ouest
57
  "Thiès", "Mbour", "Tivaouane", "Joal-Fadiouth", "Popenguine",
58
-
59
- # Centre
60
  "Touba", "Diourbel", "Kaolack", "Fatick", "Foundiougne",
61
-
62
- # Nord
63
  "Saint-Louis", "Dagana", "Podor", "Richard-Toll",
64
-
65
- # Sud
66
  "Ziguinchor", "Oussouye", "Bignona", "Kolda", "Sédhiou",
67
-
68
- # Est
69
  "Tambacounda", "Kédougou", "Bakel", "Koumpentoum",
70
-
71
- # Autres
72
  "Autre"
73
  ]
74
 
@@ -77,24 +49,29 @@ LISTE_PAYS = ["Sénégal", "France", "Côte d'Ivoire", "Mali", "États-Unis", "A
77
  # --- FONCTION PRINCIPALE APPELÉE PAR L'APP ---
78
  def show_kyc_form(client, sheet_name, generate_id_func):
79
  """
80
- Affiche le formulaire KYC.
81
- Args:
82
- client: La connexion gspread active (passée depuis main).
83
- sheet_name: Le nom du fichier Google Sheet.
84
- generate_id_func: La fonction pour générer l'ID (passée depuis main).
85
  """
86
- # inject_pulsing_css()
87
 
88
- st.header("ENTITÉ : NOUVEL OBJET CLIENT")
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
- # Appel de la fonction parente pour l'ID
91
- new_id = generate_id_func("CLI", "Clients_KYC")
92
  st.caption(f"Système ID : {new_id}")
93
 
94
- type_personne = st.radio("Nature", ["Personne Physique", "Personne Morale"], horizontal=True)
95
- if type_personne == "Personne Morale":
96
- st.warning("⚠️ Module Personne Morale en construction.")
97
-
98
  with st.form("kyc_form_module", clear_on_submit=False):
99
  # --- BLOC 1 : IDENTITÉ ---
100
  st.markdown("### IDENTITÉ & CONTACT")
@@ -229,9 +206,11 @@ def show_kyc_form(client, sheet_name, generate_id_func):
229
  lbl("Commentaires / Notes", False)
230
  notes = st.text_area("Notes", label_visibility="collapsed")
231
 
232
- submit_btn = st.form_submit_button("VÉRIFIER ET ENREGISTRER")
 
 
233
 
234
-
235
  # --- LOGIQUE DE VALIDATION ET ENVOI ---
236
  if submit_btn:
237
  errors = []
@@ -262,49 +241,49 @@ def show_kyc_form(client, sheet_name, generate_id_func):
262
 
263
  # Préparation de la ligne DANS L'ORDRE EXACT DES COLONNES GOOGLE SHEET
264
  row_to_add = [
265
- new_id, # ID_Client
266
- nom.upper(), # Nom_Complet
267
- date_naiss.strftime("%d-%m-%Y"),# Date_Naissance
268
- adresse, # Adresse
269
- telephone, # Telephone
270
- email, # Email
271
- type_id, # Type_Piece_Identite
272
- id_officiel.upper(), # ID_Officiel
273
  date_exp_id.strftime("%d-%m-%Y"),# Date_Expiration_ID
274
- etat_civil, # Etat_Civil
275
- pers_charge, # Pers_Charge
276
- prof_val, # Profession (calculé ci-dessus)
277
- statut_pro, # Statut_Pro
278
- employeur.upper(), # Employeur
279
- secteur, # Secteur_Activite
280
- anciennete_emploi, # Anciennete_Emploi
281
- revenus, # Revenus_Mensuels
282
- autres_rev, # Autres_Revenus
283
- anciennete_revenu, # Anciennete_Revenu
284
- autres_sources, # Autres_Sources_Revenu
285
- charges, # Charges_Estimees
286
- patrimoine, # Patrimoine_Declare
287
- statut_log, # Statut_Logement
288
- quartier_val, # Quartier (calculé ci-dessus)
289
- ville_val, # Ville (calculé ci-dessus)
290
- pays_residence_val, # Pays_Residence (calculé ci-dessus)
291
- transfert, # Moyen_Transfert
292
- entite_financiere.upper(), # Entite_Financiere
293
- n_fiscal, # Numero_Fiscal
294
- pays_naissance_val, # Pays_Naissance (calculé ci-dessus)
295
- aml, # Verification_AML
296
- origine, # Origine_Fonds
297
- reseaux_sociaux, # Reseau_sociaux
298
- notes # Commentaires_Notes
299
  ]
300
 
301
  # ÉCRITURE VIA LA CONNEXION PASSÉE EN ARGUMENT
302
  sh = client.open(sheet_name)
303
- worksheet = sh.worksheet("Clients_KYC")
 
304
  worksheet.append_row(row_to_add)
305
 
306
- st.success(f"🟢 CLIENT {new_id} VALIDÉ ET ENREGISTRÉ !")
307
 
308
  except Exception as e:
309
- st.error(f"🔴 Erreur technique module KYC : {e}")
310
-
 
21
  # Listes de référence
22
  LISTE_PROFESSIONS = ["Commerçant", "Fonctionnaire", "Agriculteur", "Etudiant", "Ouvrier", "Cadre Supérieur", "Ingénieur", "Médecin", "Autre"]
23
  LISTE_QUARTIERS = [
 
24
  "Plateau", "Médina", "Fann", "Point E", "Gueule Tapée", "Colobane",
 
 
25
  "Hann Maristes 1", "Hann Maristes 2", "Hann Bel-Air",
 
 
26
  "Yoff", "Ouakam", "Ngor", "Almadies", "Mamelles",
 
 
27
  "Mermoz", "Sacré-Cœur", "Liberté 1", "Liberté 2", "Liberté 3",
28
  "Liberté 4", "Liberté 5", "Liberté 6",
29
  "HLM", "Grand Dakar", "Dieuppeul", "Derklé",
 
 
30
  "Pikine Est", "Pikine Ouest", "Pikine Nord", "Pikine Sud",
31
  "Guinaw Rails", "Thiaroye", "Dalifort",
 
 
32
  "Guédiawaye", "Golf Sud", "Medina Gounass", "Wakhinane Nimzatt",
 
 
33
  "Rufisque", "Bargny", "Diamniadio", "Sébikotane",
 
 
34
  "Autre"
35
  ]
36
 
37
  LISTE_VILLES = [
 
38
  "Dakar", "Pikine", "Guédiawaye", "Rufisque",
 
 
39
  "Thiès", "Mbour", "Tivaouane", "Joal-Fadiouth", "Popenguine",
 
 
40
  "Touba", "Diourbel", "Kaolack", "Fatick", "Foundiougne",
 
 
41
  "Saint-Louis", "Dagana", "Podor", "Richard-Toll",
 
 
42
  "Ziguinchor", "Oussouye", "Bignona", "Kolda", "Sédhiou",
 
 
43
  "Tambacounda", "Kédougou", "Bakel", "Koumpentoum",
 
 
44
  "Autre"
45
  ]
46
 
 
49
  # --- FONCTION PRINCIPALE APPELÉE PAR L'APP ---
50
  def show_kyc_form(client, sheet_name, generate_id_func):
51
  """
52
+ Affiche le formulaire KYC (Client ou Garant).
 
 
 
 
53
  """
54
+ # inject_pulsing_css() # Décommenter si le CSS n'est pas chargé ailleurs
55
 
56
+ # Sélecteur de Type (Client ou Garant)
57
+ type_entite = st.radio("Type d'enregistrement", ["Client Physique", "Garant Physique"], horizontal=True)
58
+
59
+ # Configuration dynamique selon le choix
60
+ if type_entite == "Client Physique":
61
+ prefix_id = "CLI"
62
+ target_sheet = "Clients_KYC"
63
+ header_title = "ENTITÉ : NOUVEAU CLIENT"
64
+ else:
65
+ prefix_id = "GAR"
66
+ target_sheet = "Garants_KYC"
67
+ header_title = "ENTITÉ : NOUVEAU GARANT"
68
+
69
+ st.header(header_title)
70
 
71
+ # Appel de la fonction parente pour l'ID avec les bons paramètres
72
+ new_id = generate_id_func(prefix_id, target_sheet)
73
  st.caption(f"Système ID : {new_id}")
74
 
 
 
 
 
75
  with st.form("kyc_form_module", clear_on_submit=False):
76
  # --- BLOC 1 : IDENTITÉ ---
77
  st.markdown("### IDENTITÉ & CONTACT")
 
206
  lbl("Commentaires / Notes", False)
207
  notes = st.text_area("Notes", label_visibility="collapsed")
208
 
209
+ # Bouton dynamique selon le type
210
+ label_btn = f"VÉRIFIER ET ENREGISTRER LE {prefix_id}"
211
+ submit_btn = st.form_submit_button(label_btn)
212
 
213
+
214
  # --- LOGIQUE DE VALIDATION ET ENVOI ---
215
  if submit_btn:
216
  errors = []
 
241
 
242
  # Préparation de la ligne DANS L'ORDRE EXACT DES COLONNES GOOGLE SHEET
243
  row_to_add = [
244
+ new_id, # ID_Client ou ID_Garant
245
+ nom.upper(), # Nom_Complet
246
+ date_naiss.strftime("%d-%m-%Y"), # Date_Naissance
247
+ adresse, # Adresse
248
+ telephone, # Telephone
249
+ email, # Email
250
+ type_id, # Type_Piece_Identite
251
+ id_officiel.upper(), # ID_Officiel
252
  date_exp_id.strftime("%d-%m-%Y"),# Date_Expiration_ID
253
+ etat_civil, # Etat_Civil
254
+ pers_charge, # Pers_Charge
255
+ prof_val, # Profession
256
+ statut_pro, # Statut_Pro
257
+ employeur.upper(), # Employeur
258
+ secteur, # Secteur_Activite
259
+ anciennete_emploi, # Anciennete_Emploi
260
+ revenus, # Revenus_Mensuels
261
+ autres_rev, # Autres_Revenus
262
+ anciennete_revenu, # Anciennete_Revenu
263
+ autres_sources, # Autres_Sources_Revenu
264
+ charges, # Charges_Estimees
265
+ patrimoine, # Patrimoine_Declare
266
+ statut_log, # Statut_Logement
267
+ quartier_val, # Quartier
268
+ ville_val, # Ville
269
+ pays_residence_val, # Pays_Residence
270
+ transfert, # Moyen_Transfert
271
+ entite_financiere.upper(), # Entite_Financiere
272
+ n_fiscal, # Numero_Fiscal
273
+ pays_naissance_val, # Pays_Naissance
274
+ aml, # Verification_AML
275
+ origine, # Origine_Fonds
276
+ reseaux_sociaux, # Reseau_sociaux
277
+ notes # Commentaires_Notes
278
  ]
279
 
280
  # ÉCRITURE VIA LA CONNEXION PASSÉE EN ARGUMENT
281
  sh = client.open(sheet_name)
282
+ # On cible la feuille dynamiquement selon le type
283
+ worksheet = sh.worksheet(target_sheet)
284
  worksheet.append_row(row_to_add)
285
 
286
+ st.success(f"🟢 {prefix_id} {new_id} VALIDÉ ET ENREGISTRÉ DANS {target_sheet} !")
287
 
288
  except Exception as e:
289
+ st.error(f"🔴 Erreur technique module KYC : {e}")