diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index d3fa8990b..b6522f620 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -46,13 +46,15 @@ class PiecesJustificativesService def self.serialize_champs_as_pjs(dossier) dossier.champs_public.filter { |champ| champ.type_de_champ.old_pj }.map do |champ| - { - created_at: champ.created_at&.in_time_zone('UTC'), - type_de_piece_justificative_id: champ.type_de_champ.old_pj[:stable_id], - content_url: champ.for_api, - user: champ.dossier.user - } - end + champ.for_api&.map do |content_url| + { + created_at: champ.created_at&.in_time_zone('UTC'), + type_de_piece_justificative_id: champ.type_de_champ.old_pj[:stable_id], + content_url:, + user: champ.dossier.user + } + end + end.flatten end def self.clone_attachments(original, kopy)