modify pj service
This commit is contained in:
parent
6ef5b5d474
commit
0bd879ec9b
1 changed files with 18 additions and 13 deletions
|
@ -1,8 +1,8 @@
|
||||||
class PiecesJustificativesService
|
class PiecesJustificativesService
|
||||||
def self.liste_documents(dossier)
|
def self.liste_documents(dossier, for_expert)
|
||||||
pjs_champs = pjs_for_champs(dossier)
|
pjs_champs = pjs_for_champs(dossier, for_expert)
|
||||||
pjs_commentaires = pjs_for_commentaires(dossier)
|
pjs_commentaires = pjs_for_commentaires(dossier)
|
||||||
pjs_dossier = pjs_for_dossier(dossier)
|
pjs_dossier = pjs_for_dossier(dossier, for_expert)
|
||||||
|
|
||||||
(pjs_champs + pjs_commentaires + pjs_dossier)
|
(pjs_champs + pjs_commentaires + pjs_dossier)
|
||||||
.filter(&:attached?)
|
.filter(&:attached?)
|
||||||
|
@ -120,8 +120,8 @@ class PiecesJustificativesService
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def self.pjs_for_champs(dossier)
|
def self.pjs_for_champs(dossier, for_expert = false)
|
||||||
allowed_champs = dossier.champs + dossier.champs_private
|
allowed_champs = for_expert ? dossier.champs : dossier.champs + dossier.champs_private
|
||||||
|
|
||||||
allowed_child_champs = allowed_champs
|
allowed_child_champs = allowed_champs
|
||||||
.filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:repetition) }
|
.filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:repetition) }
|
||||||
|
@ -138,17 +138,22 @@ class PiecesJustificativesService
|
||||||
.map(&:piece_jointe)
|
.map(&:piece_jointe)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.pjs_for_dossier(dossier)
|
def self.pjs_for_dossier(dossier, for_expert = false)
|
||||||
bill_signatures = dossier.dossier_operation_logs.filter_map(&:bill_signature).uniq
|
pjs = [
|
||||||
|
|
||||||
[
|
|
||||||
dossier.justificatif_motivation,
|
dossier.justificatif_motivation,
|
||||||
dossier.attestation&.pdf,
|
dossier.attestation&.pdf,
|
||||||
dossier.etablissement&.entreprise_attestation_sociale,
|
dossier.etablissement&.entreprise_attestation_sociale,
|
||||||
dossier.etablissement&.entreprise_attestation_fiscale,
|
dossier.etablissement&.entreprise_attestation_fiscale
|
||||||
dossier.dossier_operation_logs.map(&:serialized),
|
|
||||||
bill_signatures.map(&:serialized),
|
|
||||||
bill_signatures.map(&:signature)
|
|
||||||
].flatten.compact
|
].flatten.compact
|
||||||
|
|
||||||
|
if !for_expert
|
||||||
|
bill_signatures = dossier.dossier_operation_logs.filter_map(&:bill_signature).uniq
|
||||||
|
pjs += [
|
||||||
|
dossier.dossier_operation_logs.map(&:serialized),
|
||||||
|
bill_signatures.map(&:serialized),
|
||||||
|
bill_signatures.map(&:signature)
|
||||||
|
].flatten.compact
|
||||||
|
end
|
||||||
|
pjs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue