From f973c59c9ac0e7eff2e9dced5bcfbd7fd9c0b003 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 23 Jul 2024 17:09:28 +0200 Subject: [PATCH] stop exporting bills with export_template --- app/services/pieces_justificatives_service.rb | 12 +++++------- spec/services/pieces_justificatives_service_spec.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index e3972d67a..acdc9b459 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -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? } diff --git a/spec/services/pieces_justificatives_service_spec.rb b/spec/services/pieces_justificatives_service_spec.rb index 900c12a05..9c999588c 100644 --- a/spec/services/pieces_justificatives_service_spec.rb +++ b/spec/services/pieces_justificatives_service_spec.rb @@ -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