From e3978f55eb5700beeff1c6eb85ef55e73a24fe1d Mon Sep 17 00:00:00 2001
From: Nicolas ROCHE <nroche@entrouvert.com>
Date: Fri, 23 Sep 2022 17:36:08 +0200
Subject: [PATCH] toulouse_maelis: pass top level fields to updateFamily
 (#69535)

---
 passerelle/contrib/toulouse_maelis/models.py  | 28 +++++++++++++++++++
 .../data/toulouse_maelis/Q_create_person.xml  |  2 ++
 tests/data/toulouse_maelis/Q_create_rl2.xml   |  2 ++
 .../data/toulouse_maelis/Q_delete_person.xml  |  2 ++
 tests/data/toulouse_maelis/Q_update_child.xml |  2 ++
 .../data/toulouse_maelis/Q_update_person.xml  |  2 ++
 tests/data/toulouse_maelis/Q_update_rl1.xml   |  2 ++
 tests/data/toulouse_maelis/Q_update_rl2.xml   |  2 ++
 8 files changed, 42 insertions(+)

diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py
index 18eec229..c403c654 100644
--- a/passerelle/contrib/toulouse_maelis/models.py
+++ b/passerelle/contrib/toulouse_maelis/models.py
@@ -513,16 +513,20 @@ class ToulouseMaelis(BaseResource, HTTPResource):
 
         rl1 = post_data
         rl1['num'] = family['RL1']['num']
         rl1['adresse'] = family['RL1']['adresse']
         payload = {
             'dossierNumber': family_id,
             'categorie': family['category'],
             'situation': family['situation'],
+            'flagCom': family['flagCom'],
+            'nbChild': family['nbChild'],
+            'nbTotalChild': family['nbTotalChild'],
+            'nbAES': family['nbAES'],
             'rl1': rl1,
         }
         self.call('Family', 'updateFamily', **payload)
         return {'data': 'ok'}
 
     @endpoint(
         display_category='Famille',
         description='Création du RL2',
@@ -536,16 +540,20 @@ class ToulouseMaelis(BaseResource, HTTPResource):
         family = self.get_family_raw(family_id)
         if family['RL2']:
             raise APIError('RL2 already defined on family', err_code='already-rl2')
 
         payload = {
             'dossierNumber': family_id,
             'categorie': family['category'],
             'situation': family['situation'],
+            'flagCom': family['flagCom'],
+            'nbChild': family['nbChild'],
+            'nbTotalChild': family['nbTotalChild'],
+            'nbAES': family['nbAES'],
             'rl2': post_data,
         }
         self.call('Family', 'updateFamily', **payload)
         return {'data': 'ok'}
 
     @endpoint(
         display_category='Famille',
         description='Modification du RL2',
@@ -563,16 +571,20 @@ class ToulouseMaelis(BaseResource, HTTPResource):
 
         rl2 = post_data
         rl2['num'] = family['RL2']['num']
         rl2['adresse'] = family['RL2']['adresse']
         payload = {
             'dossierNumber': family_id,
             'categorie': family['category'],
             'situation': family['situation'],
+            'flagCom': family['flagCom'],
+            'nbChild': family['nbChild'],
+            'nbTotalChild': family['nbTotalChild'],
+            'nbAES': family['nbAES'],
             'rl2': rl2,
         }
         self.call('Family', 'updateFamily', **payload)
         return {'data': 'ok'}
 
     @endpoint(
         display_category='Famille',
         description="Ajout d'un enfant",
@@ -623,16 +635,20 @@ class ToulouseMaelis(BaseResource, HTTPResource):
         self.replace_null_values(post_data)
 
         child = post_data
         child['num'] = child_id
         payload = {
             'dossierNumber': family_id,
             'categorie': family['category'],
             'situation': family['situation'],
+            'flagCom': family['flagCom'],
+            'nbChild': family['nbChild'],
+            'nbTotalChild': family['nbTotalChild'],
+            'nbAES': family['nbAES'],
             'childList': [child],
         }
         self.call('Family', 'updateFamily', **payload)
         return {'data': 'ok'}
 
     @endpoint(
         display_category='Famille',
         description="Mise à jour des coordonnées d'une personne",
@@ -670,16 +686,20 @@ class ToulouseMaelis(BaseResource, HTTPResource):
         self.replace_null_values(post_data)
 
         personList = family[kind + 'PersonList']
         personList.append(post_data)
         payload = {
             'dossierNumber': family_id,
             'categorie': family['category'],
             'situation': family['situation'],
+            'flagCom': family['flagCom'],
+            'nbChild': family['nbChild'],
+            'nbTotalChild': family['nbTotalChild'],
+            'nbAES': family['nbAES'],
             kind + 'PersonList': [{'personList': personList}],
         }
         self.call('Family', 'updateFamily', **payload)
         return {'data': 'ok'}
 
     @endpoint(
         display_category='Famille',
         description="Mise à jour d'une personne autorisée à récupérer les enfants ou à prévenir en cas d'urgence",
@@ -708,16 +728,20 @@ class ToulouseMaelis(BaseResource, HTTPResource):
         else:
             raise APIError(
                 "no '%s' authorized person on '%s' family" % (person_id, family_id), err_code='not-found'
             )
         payload = {
             'dossierNumber': family_id,
             'categorie': family['category'],
             'situation': family['situation'],
+            'flagCom': family['flagCom'],
+            'nbChild': family['nbChild'],
+            'nbTotalChild': family['nbTotalChild'],
+            'nbAES': family['nbAES'],
             kind + 'PersonList': [{'personList': personList}],
         }
         self.call('Family', 'updateFamily', **payload)
         return {'data': 'ok'}
 
     @endpoint(
         display_category='Famille',
         description="Suppression d'une personne autorisée à récupérer les enfants ou à prévenir en cas d'urgence",
@@ -744,16 +768,20 @@ class ToulouseMaelis(BaseResource, HTTPResource):
         else:
             raise APIError(
                 "no '%s' authorized person on '%s' family" % (person_id, family_id), err_code='not-found'
             )
         payload = {
             'dossierNumber': family_id,
             'categorie': family['category'],
             'situation': family['situation'],
+            'flagCom': family['flagCom'],
+            'nbChild': family['nbChild'],
+            'nbTotalChild': family['nbTotalChild'],
+            'nbAES': family['nbAES'],
             kind + 'PersonList': [{'personList': personList}],
         }
         self.call('Family', 'updateFamily', **payload)
         return {'data': 'ok'}
 
     @endpoint(
         display_category='Famille',
         description="Créer ou mettre à jour le régime alimentaire d'un enfant",
diff --git a/tests/data/toulouse_maelis/Q_create_person.xml b/tests/data/toulouse_maelis/Q_create_person.xml
index 0bed61bd..87883b58 100644
--- a/tests/data/toulouse_maelis/Q_create_person.xml
+++ b/tests/data/toulouse_maelis/Q_create_person.xml
@@ -8,16 +8,18 @@
       </wsse:UsernameToken>
     </wsse:Security>
   </soap-env:Header>
   <soap-env:Body>
     <ns0:updateFamily xmlns:ns0="family.ws.maelis.sigec.com">
       <dossierNumber>1312</dossierNumber>
       <categorie>BI</categorie>
       <situation>M</situation>
+      <flagCom>true</flagCom>
+      <nbChild>2</nbChild>
       <emergencyPersonList>
         <personList>
           <numPerson>614059</numPerson>
           <civility>MME</civility>
           <firstname>KENY</firstname>
           <lastname>ARKANA</lastname>
           <dateBirth>1982-12-20T00:00:00+01:00</dateBirth>
           <quality>T</quality>
diff --git a/tests/data/toulouse_maelis/Q_create_rl2.xml b/tests/data/toulouse_maelis/Q_create_rl2.xml
index 759d68be..8f84b48d 100644
--- a/tests/data/toulouse_maelis/Q_create_rl2.xml
+++ b/tests/data/toulouse_maelis/Q_create_rl2.xml
@@ -7,16 +7,18 @@
       </wsse:UsernameToken>
     </wsse:Security>
   </soap-env:Header>
   <soap-env:Body>
     <ns0:updateFamily xmlns:ns0="family.ws.maelis.sigec.com">
       <dossierNumber>1312</dossierNumber>
       <categorie>BI</categorie>
       <situation>M</situation>
+      <flagCom>true</flagCom>
+      <nbChild>2</nbChild>
       <rl2>
         <lastname>DOE</lastname>
         <firstname>JANE</firstname>
         <quality>MERE</quality>
         <civility>MME</civility>
         <dateBirth>1940-06-22</dateBirth>
         <adresse>
           <num>170</num>
diff --git a/tests/data/toulouse_maelis/Q_delete_person.xml b/tests/data/toulouse_maelis/Q_delete_person.xml
index c9bf9ec0..24e3259f 100644
--- a/tests/data/toulouse_maelis/Q_delete_person.xml
+++ b/tests/data/toulouse_maelis/Q_delete_person.xml
@@ -8,12 +8,14 @@
       </wsse:UsernameToken>
     </wsse:Security>
   </soap-env:Header>
   <soap-env:Body>
     <ns0:updateFamily xmlns:ns0="family.ws.maelis.sigec.com">
       <dossierNumber>1312</dossierNumber>
       <categorie>BI</categorie>
       <situation>M</situation>
+      <flagCom>true</flagCom>
+      <nbChild>2</nbChild>
       <emergencyPersonList/>
     </ns0:updateFamily>
   </soap-env:Body>
 </soap-env:Envelope>
diff --git a/tests/data/toulouse_maelis/Q_update_child.xml b/tests/data/toulouse_maelis/Q_update_child.xml
index fb3a0021..9a2c1e08 100644
--- a/tests/data/toulouse_maelis/Q_update_child.xml
+++ b/tests/data/toulouse_maelis/Q_update_child.xml
@@ -7,16 +7,18 @@
       </wsse:UsernameToken>
     </wsse:Security>
   </soap-env:Header>
   <soap-env:Body>
     <ns0:updateFamily xmlns:ns0="family.ws.maelis.sigec.com">
       <dossierNumber>1312</dossierNumber>
       <categorie>BI</categorie>
       <situation>M</situation>
+      <flagCom>true</flagCom>
+      <nbChild>2</nbChild>
       <childList>
         <num>613880</num>
         <lastname>DOE</lastname>
         <firstname>JANNIS</firstname>
         <sexe>F</sexe>
         <birth>
           <dateBirth>1943-01-19</dateBirth>
           <place>Port Arthur</place>
diff --git a/tests/data/toulouse_maelis/Q_update_person.xml b/tests/data/toulouse_maelis/Q_update_person.xml
index 80e219f7..ea48b4a0 100644
--- a/tests/data/toulouse_maelis/Q_update_person.xml
+++ b/tests/data/toulouse_maelis/Q_update_person.xml
@@ -8,16 +8,18 @@
       </wsse:UsernameToken>
     </wsse:Security>
   </soap-env:Header>
   <soap-env:Body>
     <ns0:updateFamily xmlns:ns0="family.ws.maelis.sigec.com">
       <dossierNumber>1312</dossierNumber>
       <categorie>BI</categorie>
       <situation>M</situation>
+      <flagCom>true</flagCom>
+      <nbChild>2</nbChild>
       <emergencyPersonList>
         <personList>
           <numPerson>614059</numPerson>
           <civility/>
           <firstname>Mathias</firstname>
           <lastname>Cassel</lastname>
           <dateBirth>1972-01-01</dateBirth>
           <quality>O</quality>
diff --git a/tests/data/toulouse_maelis/Q_update_rl1.xml b/tests/data/toulouse_maelis/Q_update_rl1.xml
index bafdc62e..677d6d99 100644
--- a/tests/data/toulouse_maelis/Q_update_rl1.xml
+++ b/tests/data/toulouse_maelis/Q_update_rl1.xml
@@ -8,16 +8,18 @@
       </wsse:UsernameToken>
     </wsse:Security>
   </soap-env:Header>
   <soap-env:Body>
     <ns0:updateFamily xmlns:ns0="family.ws.maelis.sigec.com">
       <dossierNumber>1312</dossierNumber>
       <categorie>BI</categorie>
       <situation>M</situation>
+      <flagCom>true</flagCom>
+      <nbChild>2</nbChild>
       <rl1>
         <num>613878</num>
         <lastname>Doe</lastname>
         <firstname>Jhonny</firstname>
         <quality>PERE</quality>
         <civility>M.</civility>
         <dateBirth>1943-06-15</dateBirth>
         <adresse>
diff --git a/tests/data/toulouse_maelis/Q_update_rl2.xml b/tests/data/toulouse_maelis/Q_update_rl2.xml
index 4bec07e9..ee64b404 100644
--- a/tests/data/toulouse_maelis/Q_update_rl2.xml
+++ b/tests/data/toulouse_maelis/Q_update_rl2.xml
@@ -7,16 +7,18 @@
       </wsse:UsernameToken>
     </wsse:Security>
   </soap-env:Header>
   <soap-env:Body>
     <ns0:updateFamily xmlns:ns0="family.ws.maelis.sigec.com">
       <dossierNumber>1312</dossierNumber>
       <categorie>BI</categorie>
       <situation>M</situation>
+      <flagCom>true</flagCom>
+      <nbChild>2</nbChild>
       <rl2>
         <num>613879</num>
         <lastname>DOE</lastname>
         <firstname>JANE</firstname>
         <quality>MERE</quality>
         <civility>MME</civility>
         <dateBirth>1940-06-22</dateBirth>
         <adresse>
-- 
2.30.2

