amelioration(dossier.pdf): pour les champs de type Champs::AddressChamp, ajoute le code insee de la commune sous l'adresse complete, ajoute le code postal, ajoute le departemenent et son code. Pour les champs de type Champs::CommuneChamp ajoute le code postal de la commune

This commit is contained in:
Martin 2023-10-20 11:22:51 +02:00
parent 8a4299ade1
commit 2295d64300
2 changed files with 14 additions and 1 deletions

View file

@ -47,6 +47,10 @@ class Champs::AddressChamp < Champs::TextChamp
APIGeoService.departement_name(address.fetch('department_code'))
end
def departement_code_and_name
"#{address.fetch('department_code')} #{departement_name}"
end
def departement
if full_address?
{ code: address.fetch('department_code'), name: departement_name }

View file

@ -176,10 +176,19 @@ def add_single_champ(pdf, champ)
when 'Champs::NumberChamp'
value = champ.blank? ? 'Non communiqué' : number_with_delimiter(champ.to_s)
format_in_2_lines(pdf, tdc.libelle, value)
when 'Champs::AddressChamp'
value = champ.blank? ? 'Non communiqué' : champ.to_s
format_in_2_lines(pdf, tdc.libelle, value)
if champ.full_address?
format_in_2_lines(pdf, "Code INSEE :", champ.commune&.fetch(:code))
format_in_2_lines(pdf, "Code Postal :", champ.commune&.fetch(:postal_code))
format_in_2_lines(pdf, "Département :", champ.departement_code_and_name)
end
when 'Champs::CommuneChamp'
value = champ.blank? ? 'Non communiqué' : champ.to_s
format_in_2_lines(pdf, tdc.libelle, value)
pdf.text "Département : #{champ.departement_code_and_name}" if champ.departement?
format_in_2_lines(pdf, "Code Postal :", champ.code_postal) if champ.code_postal?
format_in_2_lines(pdf, "Département :", champ.departement_code_and_name) if champ.departement?
else
value = champ.blank? ? 'Non communiqué' : champ.to_s
format_in_2_lines(pdf, tdc.libelle, value)