Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amelioration(dossier.pdf): pour les champs de type Champs::AddressChamp, ajoute le code insee de la commune sous l'adresse complete #9624

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/champs/address_champ.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def departement_name
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 }
Expand Down
11 changes: 10 additions & 1 deletion app/views/dossiers/show.pdf.prawn
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down