diff --git a/.demo/exampleCandidatsCRE4.csv b/.demo/exampleCandidatsCRE4.csv index 241006257c..e207f0d4f5 100644 --- a/.demo/exampleCandidatsCRE4.csv +++ b/.demo/exampleCandidatsCRE4.csv @@ -87,9 +87,9 @@ N (AO sol)";"Codes cas (AO sol)";"Codes cas (AO sol)";Motif d'élimination;Nom projet (doublon);CP (doublon);Commune (doublon);Modifications;Statut;Notification;Commentaires -Test 1;CRE4 - Bâtiment;1;2;HISTORIQUE1;;HISTORIQUE1;1;;1;;0,5;1;;300;1;2;3;;6;;SD3B;Personne morale;;;PME;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Centrale Solaire;2;0,5;;;;5 avenue laeticia;13010;MARSEILLE;;Bouches-Du-Rhône;;;;;;;;;;;;N/A;;1;300;;;;;Silicium polycristallin;123;MODULE PV;France;360;18,26%;CELLULE PV;France;PLAQUETTE PV;France;POLYSI PV;France;CONVERT PV;France;;;;;;;;;;1820;6342;1469;01/11/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Classé;;;;;;;;;;;21/10/2020; -Test 2;CRE4 - Bâtiment;1;2;HISTORIQUE2;;HISTORIQUE2;2;01/01/2027;2;;0,5;1;;300;1;2;3;;6;;SD3B;Personne morale;;;PME;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Centrale Solaire;2;0,5;;;;1 impasse des capucins;20000;AJACCIO;;Corse;;;;;;;;;;;;N/A;;1;300;;;;;Silicium polycristallin;123;MODULE PV;France;360;18,26%;CELLULE PV;France;PLAQUETTE PV;France;POLYSI PV;France;CONVERT PV;France;;;;;;;;;;1820;6342;1469;01/11/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Classé;;;;;;;;;;;21/10/2020; -Test 3;CRE4 - Bâtiment;10;2;NON-HISTORIQUE1;;NON-HISTORIQUE1;3;;1;;1,2;1;;400;4;5;6;;15;;SD3C;Personne morale;;;Grande entreprise;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Face Nord;2;1,2;;;;2 rue de l'avenue;92800;PUTEAUX;;Ile-de-France;;;;;;;;;;;;;;1;400;;Oui;;;Silicium monocristallin;456;MODULE PV;Chine;400;19,70%;CELLULE PV;Chine;PLAQUETTE PV;Chine;POLYSI PV;Chine;CONVERT PV;Chine;;;;;;;;;;2055;5200;1585;01/12/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Favorable;;;;Classé;;;;;;;;;;;; -Test 4;CRE4 - Bâtiment;10;2;NON-HISTORIQUE2;;NON-HISTORIQUE2;1;;4;;1,2;1;;400;4;5;6;;15;;SD3C;Personne morale;;;Grande entreprise;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Face Nord;2;1,2;;;;1 rue de Bordeaux;33000 / 33100;BORDEAUX;;Nouvelle-Aquitaine;;;;;;;;;;;;;;1;400;;Oui;;;Silicium monocristallin;456;MODULE PV;Chine;400;19,70%;CELLULE PV;Chine;PLAQUETTE PV;Chine;POLYSI PV;Chine;CONVERT PV;Chine;;;;;;;;;;2055;5200;1585;01/12/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Favorable;;;;Classé;;;;;;;;;;;; -Test 5;CRE4 - Bâtiment;10;2;NON-HISTORIQUE3;;NON-HISTORIQUE3;2;01/03/2030;1;;1,2;1;;400;4;5;6;;15;;SD3C;Personne morale;;;Grande entreprise;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Face Nord;2;1,2;;;;2 rue de Bordeaux;33000 / 33200;BORDEAUX;;Nouvelle-Aquitaine;;;;;;;;;;;;;;1;400;;Oui;;;Silicium monocristallin;456;MODULE PV;Chine;400;19,70%;CELLULE PV;Chine;PLAQUETTE PV;Chine;POLYSI PV;Chine;CONVERT PV;Chine;;;;;;;;;;2055;5200;1585;01/12/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Favorable;;;;Eliminé;;;;;prix;;;;;;; +Test 1;CRE4 - Bâtiment;1;2;HISTORIQUE1;;HISTORIQUE1;;;1;;0,5;1;;300;1;2;3;;6;;SD3B;Personne morale;;;PME;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Centrale Solaire;2;0,5;;;;5 avenue laeticia;13010;MARSEILLE;;Bouches-Du-Rhône;;;;;;;;;;;;N/A;;1;300;;;;;Silicium polycristallin;123;MODULE PV;France;360;18,26%;CELLULE PV;France;PLAQUETTE PV;France;POLYSI PV;France;CONVERT PV;France;;;;;;;;;;1820;6342;1469;01/11/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Classé;;;;;;;;;;;21/10/2020; +Test 2;CRE4 - Bâtiment;1;2;HISTORIQUE2;;HISTORIQUE2;;01/01/2027;2;;0,5;1;;300;1;2;3;;6;;SD3B;Personne morale;;;PME;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Centrale Solaire;2;0,5;;;;1 impasse des capucins;20000;AJACCIO;;Corse;;;;;;;;;;;;N/A;;1;300;;;;;Silicium polycristallin;123;MODULE PV;France;360;18,26%;CELLULE PV;France;PLAQUETTE PV;France;POLYSI PV;France;CONVERT PV;France;;;;;;;;;;1820;6342;1469;01/11/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Classé;;;;;;;;;;;21/10/2020; +Test 3;CRE4 - Bâtiment;10;2;NON-HISTORIQUE1;;NON-HISTORIQUE1;;;1;;1,2;1;;400;4;5;6;;15;;SD3C;Personne morale;;;Grande entreprise;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Face Nord;2;1,2;;;;2 rue de l'avenue;92800;PUTEAUX;;Ile-de-France;;;;;;;;;;;;;;1;400;;Oui;;;Silicium monocristallin;456;MODULE PV;Chine;400;19,70%;CELLULE PV;Chine;PLAQUETTE PV;Chine;POLYSI PV;Chine;CONVERT PV;Chine;;;;;;;;;;2055;5200;1585;01/12/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Favorable;;;;Classé;;;;;;;;;;;; +Test 4;CRE4 - Bâtiment;10;2;NON-HISTORIQUE2;;NON-HISTORIQUE2;;;4;;1,2;1;;400;4;5;6;;15;;SD3C;Personne morale;;;Grande entreprise;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Face Nord;2;1,2;;;;1 rue de Bordeaux;33000 / 33100;BORDEAUX;;Nouvelle-Aquitaine;;;;;;;;;;;;;;1;400;;Oui;;;Silicium monocristallin;456;MODULE PV;Chine;400;19,70%;CELLULE PV;Chine;PLAQUETTE PV;Chine;POLYSI PV;Chine;CONVERT PV;Chine;;;;;;;;;;2055;5200;1585;01/12/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Favorable;;;;Classé;;;;;;;;;;;; +Test 5;CRE4 - Bâtiment;10;2;NON-HISTORIQUE3;;NON-HISTORIQUE3;;01/03/2030;1;;1,2;1;;400;4;5;6;;15;;SD3C;Personne morale;;;Grande entreprise;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Face Nord;2;1,2;;;;2 rue de Bordeaux;33000 / 33200;BORDEAUX;;Nouvelle-Aquitaine;;;;;;;;;;;;;;1;400;;Oui;;;Silicium monocristallin;456;MODULE PV;Chine;400;19,70%;CELLULE PV;Chine;PLAQUETTE PV;Chine;POLYSI PV;Chine;CONVERT PV;Chine;;;;;;;;;;2055;5200;1585;01/12/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Favorable;;;;Eliminé;;;;;prix;;;;;;; Test 6;Eolien;8;;EOLIEN P8 DEMANDE CHANGEMENT ACTIONNAIRE;;EOLIEN P8 DEMANDE CHANGEMENT ACTIONNAIRE;;;1;;0,5;1;;300;1;2;3;;6;;SD3B;Personne morale;;;PME;;;Valentin COGNITO;Gérant;;Valentin Cognito;Directeur du développement;1 place carpeaux;porteur@test.test;;Centrale Solaire;2;0,5;;;;5 avenue laeticia;13010;MARSEILLE;;Bouches-Du-Rhône;;;;;;;;;;;;N/A;;1;300;;;;;Silicium polycristallin;123;MODULE PV;France;360;18,26%;CELLULE PV;France;PLAQUETTE PV;France;POLYSI PV;France;CONVERT PV;France;;;;;;;;;;1820;6342;1469;01/11/2021;;;;;;;;;;;;;;;;;;Non;Non;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Classé;;;;;;;;;;;21/10/2020; diff --git a/packages/applications/ssr/src/components/pages/candidature/importer/candidature.schema.test.ts b/packages/applications/ssr/src/components/pages/candidature/importer/candidature.schema.test.ts index 32ea36a487..4c8ee5cf3e 100644 --- a/packages/applications/ssr/src/components/pages/candidature/importer/candidature.schema.test.ts +++ b/packages/applications/ssr/src/components/pages/candidature/importer/candidature.schema.test.ts @@ -406,6 +406,36 @@ describe('Schema candidature', () => { path: ['Financement collectif (Oui/Non)', 'Gouvernance partagée (Oui/Non)'], }); }); + + test('le type de GF est obligatoire pour projet classé PPE2', () => { + const result = candidatureCsvSchema.safeParse({ + ...minimumValuesClassé, + "Appel d'offres": 'PPE2 - Eolien', + "1. Garantie financière jusqu'à 6 mois après la date d'achèvement\n2. Garantie financière avec date d'échéance et à renouveler\n3. Consignation": + undefined, + }); + assert(!result.success); + expect(result.error.errors[0]).to.deep.eq({ + code: 'invalid_type', + expected: 'string', + received: 'undefined', + path: [ + "1. Garantie financière jusqu'à 6 mois après la date d'achèvement\n2. Garantie financière avec date d'échéance et à renouveler\n3. Consignation", + ], + message: + '"1. Garantie financière jusqu\'à 6 mois après la date d\'achèvement\n2. Garantie financière avec date d\'échéance et à renouveler\n3. Consignation" est requis lorsque "Classé ?" a la valeur "classé"', + }); + }); + + test("le type de GF n'est pas obligatoire pour projet classé CRE4", () => { + const result = candidatureCsvSchema.safeParse({ + ...minimumValuesClassé, + "Appel d'offres": 'Eolien', + "1. Garantie financière jusqu'à 6 mois après la date d'achèvement\n2. Garantie financière avec date d'échéance et à renouveler\n3. Consignation": + undefined, + }); + assertNoError(result); + }); }); describe('Cas particuliers', () => { diff --git a/packages/applications/ssr/src/components/pages/candidature/importer/candidature.schema.ts b/packages/applications/ssr/src/components/pages/candidature/importer/candidature.schema.ts index 7755b2acc6..0fccbec2c8 100644 --- a/packages/applications/ssr/src/components/pages/candidature/importer/candidature.schema.ts +++ b/packages/applications/ssr/src/components/pages/candidature/importer/candidature.schema.ts @@ -207,7 +207,9 @@ const candidatureCsvRowSchema = z // le type de GF est obligatoire si la candidature est classée .superRefine((obj, ctx) => { const actualStatut = statut[obj[colonnes.statut]]; - if (actualStatut === 'classé' && !obj[colonnes.typeGf]) { + const ao = obj[colonnes.appelOffre]; + const isPPE2 = ao.startsWith('PPE2'); + if (isPPE2 && actualStatut === 'classé' && !obj[colonnes.typeGf]) { ctx.addIssue(conditionalRequiredError(colonnes.typeGf, colonnes.statut, actualStatut)); } })