Merge pull request #9737 from demarches-simplifiees/9670-export-rnf

En tant qu'instructeur, je peux exporter les données RNF des dossiers
This commit is contained in:
mfo 2023-11-23 08:19:00 +00:00 committed by GitHub
commit 78f9a2aa1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 0 deletions

View file

@ -20,4 +20,12 @@ class Champs::RNFChamp < Champ
def blank?
rnf_id.blank?
end
def for_export
if data
[rnf_id, data['title'], data.dig('address', 'label'), data.dig('address', 'cityCode'), "#{data['department']} - #{APIGeoService.departement_name(data['department'])}"]
else
[rnf_id, nil, nil, nil, nil]
end
end
end

View file

@ -1,2 +1,5 @@
class TypesDeChamp::RNFTypeDeChamp < TypesDeChamp::TextTypeDeChamp
def libelle_for_export(index)
[libelle, "#{libelle} (Nom)", "#{libelle} (Adresse)", "#{libelle} (Code insee Ville)", "#{libelle} (Département)"][index]
end
end

View file

@ -73,4 +73,11 @@ describe Champs::RNFChamp, type: :model do
}
end
end
describe 'for_export' do
let(:champ) { build(:champ_rnf, external_id:, data: JSON.parse(body)) }
it do
expect(champ.for_export).to eq(['075-FDD-00003-01', 'Fondation SFR', '16 Rue du Général de Boissieu 75015 Paris', '75115', '75 - Paris'])
end
end
end

View file

@ -92,6 +92,10 @@ describe ProcedureExportService do
"cojo",
"expression_reguliere",
"rnf",
"rnf (Nom)",
"rnf (Adresse)",
"rnf (Code insee Ville)",
"rnf (Département)",
"engagement_juridique"
]
end
@ -221,6 +225,10 @@ describe ProcedureExportService do
"cojo",
"expression_reguliere",
"rnf",
"rnf (Nom)",
"rnf (Adresse)",
"rnf (Code insee Ville)",
"rnf (Département)",
"engagement_juridique"
]
end
@ -318,6 +326,10 @@ describe ProcedureExportService do
"cojo",
"expression_reguliere",
"rnf",
"rnf (Nom)",
"rnf (Adresse)",
"rnf (Code insee Ville)",
"rnf (Département)",
"engagement_juridique"
]
end