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:
commit
9866acc0f8
2 changed files with 14 additions and 1 deletions
|
@ -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 }
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue