add data from rnf field to export

This commit is contained in:
Christophe Robillard 2023-11-21 11:02:33 +01:00
parent a6f4ae3ee4
commit daa4c28af7
4 changed files with 30 additions and 0 deletions

View file

@ -20,4 +20,12 @@ class Champs::RNFChamp < Champ
def blank? def blank?
rnf_id.blank? rnf_id.blank?
end 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 end

View file

@ -1,2 +1,5 @@
class TypesDeChamp::RNFTypeDeChamp < TypesDeChamp::TextTypeDeChamp 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 end

View file

@ -73,4 +73,11 @@ describe Champs::RNFChamp, type: :model do
} }
end end
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 end

View file

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