Remove the mandataire_social guess

Rationale:
- is true for only 0.06% of Dossiers
- is not displayed anymore anyways
- will be a rare case for now
  * FC adoption is not insane
  * FC used more for personal than professional
    matters
  * not always the mandataires sociaux that fill
    dossiers for their companies, so not that
    relevant
- we can add it back later
This commit is contained in:
gregoirenovel 2018-03-19 16:45:43 +01:00
parent 51fff9eb17
commit d0a59058e8
11 changed files with 11 additions and 72 deletions

View file

@ -113,7 +113,6 @@ class Users::DossiersController < UsersController
etablissement = @facade.dossier.build_etablissement(etablissement_attributes) etablissement = @facade.dossier.build_etablissement(etablissement_attributes)
if etablissement.save if etablissement.save
Rails.logger.info("etablissement saved, siret: #{siret}, id: #{etablissement.id}") Rails.logger.info("etablissement saved, siret: #{siret}, id: #{etablissement.id}")
@facade.dossier.mandataire_social!(current_user.france_connect_information)
else else
Rails.logger.info("etablissement not saved, siret: #{siret}, errors: #{etablissement.errors.full_messages}") Rails.logger.info("etablissement not saved, siret: #{siret}, errors: #{etablissement.errors.full_messages}")
return errors_valid_siret return errors_valid_siret

View file

@ -292,12 +292,6 @@ class Dossier < ApplicationRecord
end end
end end
def mandataire_social!(france_connect_information)
if etablissement.mandataire_social?(france_connect_information)
update_column(:mandataire_social, true)
end
end
private private
def update_state_dates def update_state_dates

View file

@ -19,12 +19,4 @@ class Etablissement < ApplicationRecord
end end
attr_accessor :entreprise_mandataires_sociaux attr_accessor :entreprise_mandataires_sociaux
def mandataire_social?(france_connect_information)
if france_connect_information.present?
entreprise_mandataires_sociaux&.find do |mandataire|
france_connect_information.mandataire_social?(mandataire)
end
end
end
end end

View file

@ -2,10 +2,4 @@ class FranceConnectInformation < ApplicationRecord
belongs_to :user belongs_to :user
validates :france_connect_particulier_id, presence: true, allow_blank: false, allow_nil: false validates :france_connect_particulier_id, presence: true, allow_blank: false, allow_nil: false
def mandataire_social?(params)
params[:nom].casecmp(family_name).zero? &&
params[:prenom].casecmp(given_name).zero? &&
params[:date_naissance_timestamp] == birthdate.to_time.to_i
end
end end

View file

@ -4,7 +4,6 @@ class DossierSerializer < ActiveModel::Serializer
:updated_at, :updated_at,
:archived, :archived,
:email, :email,
:mandataire_social,
:state, :state,
:simplified_state, :simplified_state,
:initiated_at, :initiated_at,

View file

@ -4,7 +4,6 @@ class DossierTableExportSerializer < ActiveModel::Serializer
:updated_at, :updated_at,
:archived, :archived,
:email, :email,
:mandataire_social,
:state, :state,
:initiated_at, :initiated_at,
:received_at, :received_at,

View file

@ -55,13 +55,6 @@
- else - else
= sanitize(champ.decorate.value) = sanitize(champ.decorate.value)
- if @facade.dossier.mandataire_social && gestionnaire_signed_in?
.mandataire_social.text-success.center
%br
Il est probable que le soumissionnaire du dossier soit un des mandataire social de l'entreprise (
%b
= "#{@facade.dossier.user.given_name} #{@facade.dossier.user.family_name}"
)
.row .row
- if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.count > 0 - if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.count > 0
.col-xs-12 .col-xs-12

View file

@ -45,7 +45,6 @@
"created_at": "2008-09-01T08:05:00.000Z", "created_at": "2008-09-01T08:05:00.000Z",
"updated_at": "2008-09-01T08:05:00.000Z", "updated_at": "2008-09-01T08:05:00.000Z",
"archived": false, "archived": false,
"mandataire_social": false,
"state": "initiated", "state": "initiated",
"simplified_state": "En construction", "simplified_state": "En construction",
"initiated_at": "2017-04-11T12:00:12.000Z", "initiated_at": "2017-04-11T12:00:12.000Z",

View file

@ -130,7 +130,7 @@ describe API::V1::DossiersController do
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, motivation: "Motivation") } } let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, motivation: "Motivation") } }
let(:dossier_id) { dossier.id } let(:dossier_id) { dossier.id }
let(:body) { JSON.parse(retour.body, symbolize_names: true) } let(:body) { JSON.parse(retour.body, symbolize_names: true) }
let(:field_list) { [:id, :created_at, :updated_at, :archived, :mandataire_social, :individual, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :accompagnateurs, :invites] } let(:field_list) { [:id, :created_at, :updated_at, :archived, :individual, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :accompagnateurs, :invites] }
subject { body[:dossier] } subject { body[:dossier] }
it 'return REST code 200', :show_in_doc do it 'return REST code 200', :show_in_doc do
@ -142,7 +142,6 @@ describe API::V1::DossiersController do
it { expect(subject[:created_at]).to eq('2008-09-01T10:05:00.000Z') } it { expect(subject[:created_at]).to eq('2008-09-01T10:05:00.000Z') }
it { expect(subject[:updated_at]).to eq('2008-09-01T10:05:00.000Z') } it { expect(subject[:updated_at]).to eq('2008-09-01T10:05:00.000Z') }
it { expect(subject[:archived]).to eq(dossier.archived) } it { expect(subject[:archived]).to eq(dossier.archived) }
it { expect(subject[:mandataire_social]).to eq(dossier.mandataire_social) }
it { expect(subject.keys).to match_array(field_list) } it { expect(subject.keys).to match_array(field_list) }

View file

@ -259,31 +259,6 @@ describe Users::DossiersController, type: :controller do
expect(Dossier.last.state).to eq('brouillon') expect(Dossier.last.state).to eq('brouillon')
end end
describe 'Mandataires Sociaux' do
let(:france_connect_information) { create(:france_connect_information, given_name: given_name, family_name: family_name, birthdate: birthdate, france_connect_particulier_id: '1234567') }
let(:user) { create(:user, france_connect_information: france_connect_information) }
before do
subject
end
context 'when user is present in mandataires sociaux' do
let(:given_name) { 'GERARD' }
let(:family_name) { 'DEGONSE' }
let(:birthdate) { '1947-07-03' }
it { expect(Dossier.last.mandataire_social).to be_truthy }
end
context 'when user is not present in mandataires sociaux' do
let(:given_name) { 'plop' }
let(:family_name) { 'plip' }
let(:birthdate) { '1965-01-27' }
it { expect(Dossier.last.mandataire_social).to be_falsey }
end
end
describe 'get rna informations' do describe 'get rna informations' do
context 'when siren have not rna informations' do context 'when siren have not rna informations' do
let(:rna_status) { 404 } let(:rna_status) { 404 }

View file

@ -149,14 +149,12 @@ describe Dossier do
it { expect(dossier_serialized_attributes[:created_at]).to be_a(Time) } it { expect(dossier_serialized_attributes[:created_at]).to be_a(Time) }
it { expect(dossier_serialized_attributes[:updated_at]).to be_a(Time) } it { expect(dossier_serialized_attributes[:updated_at]).to be_a(Time) }
it { expect(dossier_serialized_attributes[:archived]).to be_in([true, false]) } it { expect(dossier_serialized_attributes[:archived]).to be_in([true, false]) }
it { expect(dossier_serialized_attributes[:mandataire_social]).to be_in([true, false]) }
it { expect(dossier_serialized_attributes[:state]).to be_a(String) } it { expect(dossier_serialized_attributes[:state]).to be_a(String) }
it { expect(subject[:id]).to be_a(String) } it { expect(subject[:id]).to be_a(String) }
it { expect(subject[:created_at]).to be_a(Time) } it { expect(subject[:created_at]).to be_a(Time) }
it { expect(subject[:updated_at]).to be_a(Time) } it { expect(subject[:updated_at]).to be_a(Time) }
it { expect(subject[:archived]).to be_a(String) } it { expect(subject[:archived]).to be_a(String) }
it { expect(subject[:mandataire_social]).to be_a(String) }
it { expect(subject[:state]).to be_a(String) } it { expect(subject[:state]).to be_a(String) }
end end
@ -227,18 +225,17 @@ describe Dossier do
it { expect(subject[2]).to be_a_kind_of(Time) } it { expect(subject[2]).to be_a_kind_of(Time) }
it { expect(subject[3]).to be_in([true, false]) } it { expect(subject[3]).to be_in([true, false]) }
it { expect(subject[4]).to eq(dossier.user.email) } it { expect(subject[4]).to eq(dossier.user.email) }
it { expect(subject[5]).to be_in([true, false]) } it { expect(subject[5]).to eq("brouillon") }
it { expect(subject[6]).to eq("brouillon") } it { expect(subject[6]).to eq(date1) }
it { expect(subject[7]).to eq(date1) } it { expect(subject[7]).to eq(date2) }
it { expect(subject[8]).to eq(date2) } it { expect(subject[8]).to eq(date3) }
it { expect(subject[9]).to eq(date3) } it { expect(subject[9]).to be_a_kind_of(String) }
it { expect(subject[10]).to be_a_kind_of(String) } it { expect(subject[10]).to be_a_kind_of(String) }
it { expect(subject[11]).to be_a_kind_of(String) } it { expect(subject[11]).to be_nil }
it { expect(subject[12]).to be_nil } it { expect(subject[12]).to be_nil }
it { expect(subject[13]).to be_nil } it { expect(subject[13]).to be_nil }
it { expect(subject[14]).to be_nil } it { expect(subject[14]).to be_nil }
it { expect(subject[15]).to be_nil } it { expect(subject[15]).to be_nil }
it { expect(subject[16]).to be_nil }
it do it do
expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count + expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count +
dossier.procedure.types_de_champ.count + dossier.procedure.types_de_champ.count +
@ -251,10 +248,10 @@ describe Dossier do
subject { dossier_with_individual.to_sorted_values } subject { dossier_with_individual.to_sorted_values }
it { expect(subject[12]).to eq(dossier_with_individual.individual.gender) } it { expect(subject[11]).to eq(dossier_with_individual.individual.gender) }
it { expect(subject[13]).to eq(dossier_with_individual.individual.prenom) } it { expect(subject[12]).to eq(dossier_with_individual.individual.prenom) }
it { expect(subject[14]).to eq(dossier_with_individual.individual.nom) } it { expect(subject[13]).to eq(dossier_with_individual.individual.nom) }
it { expect(subject[15]).to eq(dossier_with_individual.individual.birthdate) } it { expect(subject[14]).to eq(dossier_with_individual.individual.birthdate) }
end end
end end
@ -266,7 +263,6 @@ describe Dossier do
dossier.updated_at, dossier.updated_at,
"false", "false",
dossier.user.email, dossier.user.email,
"false",
"brouillon", "brouillon",
dossier.en_construction_at, dossier.en_construction_at,
dossier.en_instruction_at, dossier.en_instruction_at,