Merge pull request #9624 from mfo/US/dossier.export.pdf

amelioration(dossier.pdf): pour les champs de type Champs::AddressChamp, ajoute le code insee de la commune sous l'adresse complete
This commit is contained in:
mfo 2023-10-26 06:34:30 +00:00 committed by GitHub
commit 9866acc0f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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')) APIGeoService.departement_name(address.fetch('department_code'))
end end
def departement_code_and_name
"#{address.fetch('department_code')} #{departement_name}"
end
def departement def departement
if full_address? if full_address?
{ code: address.fetch('department_code'), name: departement_name } { code: address.fetch('department_code'), name: departement_name }

View file

@ -176,10 +176,19 @@ def add_single_champ(pdf, champ)
when 'Champs::NumberChamp' when 'Champs::NumberChamp'
value = champ.blank? ? 'Non communiqué' : number_with_delimiter(champ.to_s) value = champ.blank? ? 'Non communiqué' : number_with_delimiter(champ.to_s)
format_in_2_lines(pdf, tdc.libelle, value) 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' when 'Champs::CommuneChamp'
value = champ.blank? ? 'Non communiqué' : champ.to_s value = champ.blank? ? 'Non communiqué' : champ.to_s
format_in_2_lines(pdf, tdc.libelle, value) 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 else
value = champ.blank? ? 'Non communiqué' : champ.to_s value = champ.blank? ? 'Non communiqué' : champ.to_s
format_in_2_lines(pdf, tdc.libelle, value) format_in_2_lines(pdf, tdc.libelle, value)