From 7a78fdc9131cb4de85028aa4efe33a74cc7afc6c Mon Sep 17 00:00:00 2001 From: mfo Date: Fri, 13 Sep 2024 11:19:05 +0200 Subject: [PATCH] fix(normalized_address): should not raise an error for addresses without code postal --- app/models/address_proxy.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/models/address_proxy.rb b/app/models/address_proxy.rb index 0a2fb3392..efc3767f4 100644 --- a/app/models/address_proxy.rb +++ b/app/models/address_proxy.rb @@ -32,10 +32,14 @@ class AddressProxy @city_name = etablissement.localite @postal_code = etablissement.code_postal @city_code = etablissement.code_insee_localite - @departement_name = APIGeoService.departement_name_by_postal_code(@postal_code) - @departement_code = APIGeoService.departement_code(@departement_name) - @region_code = APIGeoService.region_code_by_departement(@departement_code) - @region_name = APIGeoService.region_name(@region_code) + if @postal_code + @departement_name = APIGeoService.departement_name_by_postal_code(@postal_code) + @departement_code = APIGeoService.departement_code(@departement_name) + @region_code = APIGeoService.region_code_by_departement(@departement_code) + @region_name = APIGeoService.region_name(@region_code) + else # adresse without postal_code, ex: + @departement_name, @departement_code, @region_code, @region_name = nil + end end end