Merge pull request #8462 from colinux/fix-not-terminable-dossier-having-incomplete-etablissement
Fix: prévient l'instructeur lorsqu'un dossier n'est pas terminable à cause de champ SIRET incomplet
This commit is contained in:
commit
40ca336750
5 changed files with 56 additions and 13 deletions
|
@ -315,7 +315,7 @@ module Instructeurs
|
|||
def aasm_error_message(exception, target_state:)
|
||||
if exception.originating_state == target_state
|
||||
"Le dossier est déjà #{dossier_display_state(target_state, lower: true)}."
|
||||
elsif exception.failures.include?(:can_terminer?)
|
||||
elsif exception.failures.include?(:can_terminer?) && dossier.any_etablissement_as_degraded_mode?
|
||||
"Les données relatives au SIRET de ce dossier n’ont pas pu encore être vérifiées : il n’est pas possible de le passer #{dossier_display_state(target_state, lower: true)}."
|
||||
else
|
||||
"Le dossier est en ce moment #{dossier_display_state(exception.originating_state, lower: true)} : il n’est pas possible de le passer #{dossier_display_state(target_state, lower: true)}."
|
||||
|
|
|
@ -540,7 +540,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def can_terminer?
|
||||
return false if etablissement&.as_degraded_mode?
|
||||
return false if any_etablissement_as_degraded_mode?
|
||||
|
||||
true
|
||||
end
|
||||
|
@ -569,6 +569,13 @@ class Dossier < ApplicationRecord
|
|||
termine? || reason == :procedure_removed
|
||||
end
|
||||
|
||||
def any_etablissement_as_degraded_mode?
|
||||
return true if etablissement&.as_degraded_mode?
|
||||
return true if champs_public_all.any? { _1.etablissement&.as_degraded_mode? }
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def messagerie_available?
|
||||
visible_by_administration? && !hidden_by_user? && !user_deleted? && !archived
|
||||
end
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
class SerializerService
|
||||
def self.dossier(dossier)
|
||||
Sentry.with_scope do |scope|
|
||||
scope.set_tags(dossier_id: dossier.id)
|
||||
|
||||
data = execute_query('serializeDossier', { number: dossier.id })
|
||||
data && data['dossier']
|
||||
end
|
||||
end
|
||||
|
||||
def self.dossiers(procedure)
|
||||
Sentry.with_scope do |scope|
|
||||
scope.set_tags(procedure_id: procedure.id)
|
||||
|
||||
data = execute_query('serializeDossiers', { number: procedure.id })
|
||||
data && data['demarche']['dossiers']
|
||||
end
|
||||
end
|
||||
|
||||
def self.demarches_publiques(after: nil)
|
||||
data = execute_query('serializeDemarchesPubliques', { after: after })
|
||||
|
@ -20,6 +28,9 @@ class SerializerService
|
|||
end
|
||||
|
||||
def self.champ(champ)
|
||||
Sentry.with_scope do |scope|
|
||||
scope.set_tags(champ_id: champ.id)
|
||||
|
||||
if champ.private?
|
||||
data = execute_query('serializeAnnotation', { number: champ.dossier_id, id: champ.to_typed_id })
|
||||
data && data['dossier']['annotations'].first
|
||||
|
@ -28,6 +39,7 @@ class SerializerService
|
|||
data && data['dossier']['champs'].first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.execute_query(operation_name, variables)
|
||||
result = API::V2::Schema.execute(QUERY,
|
||||
|
|
|
@ -2,7 +2,16 @@
|
|||
%table.table.vertical.dossier-champs{ role: :presentation }
|
||||
%tbody
|
||||
%tr
|
||||
%td.libelle{ colspan: 2 } ⚠ LʼINSEE est indisponible, les informations sur lʼentreprise arriveront dʼici quelques heures.
|
||||
%td{ colspan: 2 }
|
||||
.fr-alert.fr-alert--warning.fr-alert--sm
|
||||
%p
|
||||
LʼINSEE est indisponible, les informations sur lʼentreprise arriveront dʼici quelques heures.
|
||||
- if profile == "instructeur"
|
||||
%br
|
||||
Il nʼest pas possible dʼaccepter ou de refuser un dossier sans cette étape.
|
||||
|
||||
|
||||
|
||||
%tr
|
||||
%td.libelle SIRET :
|
||||
%td= etablissement.siret
|
||||
|
|
|
@ -1192,6 +1192,21 @@ describe Dossier do
|
|||
expect(dossier_ok.accepter_automatiquement(instructeur:, motivation:)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context "when a SIRET champ has etablissement in degraded mode" do
|
||||
let(:dossier_incomplete) { create(:dossier, :en_instruction) }
|
||||
let(:dossier_ok) { create(:dossier, :en_instruction) }
|
||||
|
||||
before do
|
||||
dossier_incomplete.champs_public << create(:champ_siret, dossier: dossier_incomplete, etablissement: Etablissement.new(siret: build(:etablissement).siret))
|
||||
dossier_ok.champs_public << create(:champ_siret, dossier: dossier_ok)
|
||||
end
|
||||
|
||||
it "can't accepter" do
|
||||
expect(dossier_incomplete.may_accepter?(instructeur:, motivation:)).to be_falsey
|
||||
expect(dossier_ok.may_accepter?(instructeur:, motivation:)).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#check_mandatory_and_visible_champs" do
|
||||
|
|
Loading…
Reference in a new issue