stop exporting bills with export_template

This commit is contained in:
simon lehericey 2024-07-23 17:09:28 +02:00
parent 33244f6d70
commit f973c59c9a
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 17 additions and 7 deletions

View file

@ -5,25 +5,23 @@ class PiecesJustificativesService
end
def liste_documents(dossiers)
bill_ids = []
docs = pjs_for_champs(dossiers) +
pjs_for_commentaires(dossiers) +
pjs_for_dossier(dossiers) +
pjs_for_avis(dossiers)
if liste_documents_allows?(:with_bills)
# we do not export bills no more with the new export system
# the bills have never been properly understood by the users
# their export is now deprecated
if liste_documents_allows?(:with_bills) && @export_template.nil?
# some bills are shared among operations
# so first, all the bill_ids are fetched
operation_logs, some_bill_ids = operation_logs_and_signature_ids(dossiers)
docs += operation_logs
bill_ids += some_bill_ids
end
if liste_documents_allows?(:with_bills)
# then the bills are retrieved without duplication
docs += signatures(bill_ids.uniq)
docs += signatures(some_bill_ids.uniq)
end
docs.filter { |_attachment, path| path.present? }

View file

@ -312,6 +312,12 @@ describe PiecesJustificativesService do
expect(subject).to match_array([dossier_bs.serialized.attachment, dossier_bs.signature.attachment])
end
context 'with export_template' do
let(:export_template) { default_export_template }
it { expect(subject).to be_empty }
end
context 'with a dol' do
let(:dol) { create(:dossier_operation_log, dossier: dossier) }
let(:witness_dol) { create(:dossier_operation_log, dossier: witness) }
@ -322,6 +328,12 @@ describe PiecesJustificativesService do
end
it { expect(subject).to include(dol.serialized.attachment) }
context 'with export_template' do
let(:export_template) { default_export_template }
it { expect(subject).to be_empty }
end
end
end