Skip to content

Commit

Permalink
Merge pull request #10015 from mfo/US/feat-export-include-mandataire
Browse files Browse the repository at this point in the history
ETQ instructeur, ETQ API les exports contiennent plus de donnée (mandataire & info de france connection france connect)
  • Loading branch information
colinux authored Feb 22, 2024
2 parents 3492bf3 + 77927e4 commit bacfc0c
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
3 changes: 3 additions & 0 deletions app/graphql/api/v2/stored_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ def self.get(query_id)
usager {
email
}
prenomMandataire
nomMandataire
deposeParUnTiers
connectionUsager
groupeInstructeur {
...GroupeInstructeurFragment
Expand Down
3 changes: 3 additions & 0 deletions app/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@ type Dossier {
dateTraitementSVASVR: ISO8601DateTime
demandeur: Demandeur!
demarche: DemarcheDescriptor!
deposeParUnTiers: Boolean

"""
L’URL du GeoJSON contenant les données cartographiques du dossier.
Expand All @@ -1427,6 +1428,7 @@ type Dossier {
messages(id: ID): [Message!]!
motivation: String
motivationAttachment: File
nomMandataire: String

"""
Le numero du dossier.
Expand All @@ -1438,6 +1440,7 @@ type Dossier {
"""
pdf: File
prefilled: Boolean!
prenomMandataire: String
revision: Revision! @deprecated(reason: "Utilisez le champ `demarche.revision` à la place.")

"""
Expand Down
8 changes: 6 additions & 2 deletions app/graphql/types/dossier_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ class ConnectionUsager < Types::BaseEnum
field :attestation, Types::File, "L’URL de l’attestation au format PDF.", null: true

field :usager, Types::ProfileType, "Profile de l'usager déposant le dossier", null: false

field :groupe_instructeur, Types::GroupeInstructeurType, null: false
field :revision, Types::RevisionType, null: false, deprecation_reason: 'Utilisez le champ `demarche.revision` à la place.'

field :demandeur, Types::DemandeurType, null: false
field :prenom_mandataire, String, null: true, method: :mandataire_first_name
field :nom_mandataire, String, null: true, method: :mandataire_last_name
field :depose_par_un_tiers, Boolean, method: :for_tiers

field :instructeurs, [Types::ProfileType], null: false

Expand Down Expand Up @@ -89,8 +93,8 @@ def connection_usager
if object.user_deleted?
:deleted
else
user_loader.then do |user|
if user.france_connect_information.present?
user_loader.then do |_user|
if object.user_from_france_connect?
:france_connect
else
:password
Expand Down
12 changes: 10 additions & 2 deletions app/models/dossier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1192,14 +1192,18 @@ def spreadsheet_columns_ods(types_de_champ:)
def spreadsheet_columns(with_etablissement: false, types_de_champ:)
columns = [
['ID', id.to_s],
['Email', user_email_for(:display)]
['Email', user_email_for(:display)],
['FranceConnect ?', user_from_france_connect?]
]

if procedure.for_individual?
columns += [
['Civilité', individual&.gender],
['Nom', individual&.nom],
['Prénom', individual&.prenom]
['Prénom', individual&.prenom],
['Dépot pour un tier', :for_tiers],
['Nom du mandataire', :mandataire_last_name],
['Prénom du mandataire', :mandataire_first_name]
]
if procedure.ask_birthday
columns += [['Date de naissance', individual&.birthdate]]
Expand Down Expand Up @@ -1382,6 +1386,10 @@ def mandataire_full_name
"#{mandataire_first_name} #{mandataire_last_name}"
end

def user_from_france_connect?
user.france_connect_information.present?
end

private

def create_missing_traitemets
Expand Down
21 changes: 19 additions & 2 deletions spec/models/dossier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2126,16 +2126,33 @@
describe "#spreadsheet_columns" do
let(:dossier) { create(:dossier) }

context 'user france connected' do
let(:dossier) { build(:dossier, user: build(:user, france_connect_information: build(:france_connect_information))) }
it { expect(dossier.spreadsheet_columns(types_de_champ: [])).to include(["FranceConnect ?", true]) }
end

context 'user not france connected' do
let(:dossier) { build(:dossier) }
it { expect(dossier.spreadsheet_columns(types_de_champ: [])).to include(["FranceConnect ?", false]) }
end

context 'for_individual' do
let(:dossier) { create(:dossier, procedure: create(:procedure, :for_individual)) }
it { expect(dossier.spreadsheet_columns(types_de_champ: [])).to include(["Dépot pour un tier", :for_tiers]) }
it { expect(dossier.spreadsheet_columns(types_de_champ: [])).to include(['Nom du mandataire', :mandataire_last_name]) }
it { expect(dossier.spreadsheet_columns(types_de_champ: [])).to include(['Prénom du mandataire', :mandataire_first_name]) }
end

it { expect(dossier.spreadsheet_columns(types_de_champ: [])).to include(["État du dossier", "Brouillon"]) }

context 'procedure sva' do
let(:dossier) { create(:dossier, :en_instruction, procedure: create(:procedure, :sva)) }
let(:dossier) { build(:dossier, :en_instruction, procedure: create(:procedure, :sva)) }

it { expect(dossier.spreadsheet_columns(types_de_champ: [])).to include(["Date décision SVA", :sva_svr_decision_on]) }
end

context 'procedure svr' do
let(:dossier) { create(:dossier, :en_instruction, procedure: create(:procedure, :svr)) }
let(:dossier) { build(:dossier, :en_instruction, procedure: create(:procedure, :svr)) }

it { expect(dossier.spreadsheet_columns(types_de_champ: [])).to include(["Date décision SVR", :sva_svr_decision_on]) }
end
Expand Down
10 changes: 8 additions & 2 deletions spec/services/procedure_export_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@
[
"ID",
"Email",
"FranceConnect ?",
"Civilité",
"Nom",
"Prénom",
"Dépot pour un tier",
"Nom du mandataire",
"Prénom du mandataire",
"Archivé",
"État du dossier",
"Dernière mise à jour le",
Expand Down Expand Up @@ -111,8 +115,8 @@

# SimpleXlsxReader is transforming datetimes in utc... It is only used in test so we just hack around.
offset = dossier.depose_at.utc_offset
depose_at = Time.zone.at(dossiers_sheet.data[0][8] - offset.seconds)
en_instruction_at = Time.zone.at(dossiers_sheet.data[0][9] - offset.seconds)
depose_at = Time.zone.at(dossiers_sheet.data[0][12] - offset.seconds)
en_instruction_at = Time.zone.at(dossiers_sheet.data[0][13] - offset.seconds)
expect(dossiers_sheet.data.first.size).to eq(nominal_headers.size)
expect(depose_at).to eq(dossier.depose_at.round)
expect(en_instruction_at).to eq(dossier.en_instruction_at.round)
Expand Down Expand Up @@ -174,6 +178,7 @@
[
"ID",
"Email",
"FranceConnect ?",
"Entreprise raison sociale",
"Archivé",
"État du dossier",
Expand Down Expand Up @@ -245,6 +250,7 @@
[
"ID",
"Email",
"FranceConnect ?",
"Établissement SIRET",
"Établissement siège social",
"Établissement NAF",
Expand Down

0 comments on commit bacfc0c

Please sign in to comment.