stop exporting bills with export_template
This commit is contained in:
parent
33244f6d70
commit
f973c59c9a
2 changed files with 17 additions and 7 deletions
|
@ -5,25 +5,23 @@ class PiecesJustificativesService
|
||||||
end
|
end
|
||||||
|
|
||||||
def liste_documents(dossiers)
|
def liste_documents(dossiers)
|
||||||
bill_ids = []
|
|
||||||
|
|
||||||
docs = pjs_for_champs(dossiers) +
|
docs = pjs_for_champs(dossiers) +
|
||||||
pjs_for_commentaires(dossiers) +
|
pjs_for_commentaires(dossiers) +
|
||||||
pjs_for_dossier(dossiers) +
|
pjs_for_dossier(dossiers) +
|
||||||
pjs_for_avis(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
|
# some bills are shared among operations
|
||||||
# so first, all the bill_ids are fetched
|
# so first, all the bill_ids are fetched
|
||||||
operation_logs, some_bill_ids = operation_logs_and_signature_ids(dossiers)
|
operation_logs, some_bill_ids = operation_logs_and_signature_ids(dossiers)
|
||||||
|
|
||||||
docs += operation_logs
|
docs += operation_logs
|
||||||
bill_ids += some_bill_ids
|
|
||||||
end
|
|
||||||
|
|
||||||
if liste_documents_allows?(:with_bills)
|
|
||||||
# then the bills are retrieved without duplication
|
# then the bills are retrieved without duplication
|
||||||
docs += signatures(bill_ids.uniq)
|
docs += signatures(some_bill_ids.uniq)
|
||||||
end
|
end
|
||||||
|
|
||||||
docs.filter { |_attachment, path| path.present? }
|
docs.filter { |_attachment, path| path.present? }
|
||||||
|
|
|
@ -312,6 +312,12 @@ describe PiecesJustificativesService do
|
||||||
expect(subject).to match_array([dossier_bs.serialized.attachment, dossier_bs.signature.attachment])
|
expect(subject).to match_array([dossier_bs.serialized.attachment, dossier_bs.signature.attachment])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with export_template' do
|
||||||
|
let(:export_template) { default_export_template }
|
||||||
|
|
||||||
|
it { expect(subject).to be_empty }
|
||||||
|
end
|
||||||
|
|
||||||
context 'with a dol' do
|
context 'with a dol' do
|
||||||
let(:dol) { create(:dossier_operation_log, dossier: dossier) }
|
let(:dol) { create(:dossier_operation_log, dossier: dossier) }
|
||||||
let(:witness_dol) { create(:dossier_operation_log, dossier: witness) }
|
let(:witness_dol) { create(:dossier_operation_log, dossier: witness) }
|
||||||
|
@ -322,6 +328,12 @@ describe PiecesJustificativesService do
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(subject).to include(dol.serialized.attachment) }
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue