align columns naming and order for filter and add for export
Co-authored-by: mfo <mfo@users.noreply.github.com>
This commit is contained in:
parent
0e589fc7ad
commit
df71c6a689
11 changed files with 338 additions and 79 deletions
|
@ -25,49 +25,97 @@ module ColumnsConcern
|
|||
columns.concat(standard_columns)
|
||||
columns.concat(individual_columns) if for_individual
|
||||
columns.concat(moral_columns) if !for_individual
|
||||
columns.concat(chorus_columns)
|
||||
columns.concat(types_de_champ_columns)
|
||||
end
|
||||
end
|
||||
|
||||
def chorus_columns
|
||||
if chorusable? && chorus_configuration.complete?
|
||||
['domaine_fonctionnel', 'referentiel_prog', 'centre_de_cout']
|
||||
.map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) }
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def all_usager_columns_for_export
|
||||
common = [
|
||||
dossier_id_column,
|
||||
Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false),
|
||||
Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false)
|
||||
]
|
||||
|
||||
individual_or_moral_columns = for_individual? ? individual_columns : moral_columns
|
||||
|
||||
[common, individual_or_moral_columns, chorus_columns].flatten.compact
|
||||
end
|
||||
|
||||
def all_dossier_columns_for_export
|
||||
states = [dossier_state_column]
|
||||
|
||||
for_export_before_date = ['archived']
|
||||
.map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) }
|
||||
for_export_after_date = ['motivation']
|
||||
.map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) }
|
||||
routing =
|
||||
if self.routing_enabled?
|
||||
[Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id')]
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
||||
instructeurs = [Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email')]
|
||||
|
||||
[states, for_export_before_date, dossier_dates_columns, for_export_after_date, sva_svr_columns(for_export: true), routing, instructeurs].flatten.compact
|
||||
end
|
||||
|
||||
def dossier_id_column
|
||||
Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'id', type: :number)
|
||||
Column.new(procedure_id: id, table: 'self', column: 'id', type: :number)
|
||||
end
|
||||
|
||||
def dossier_state_column
|
||||
Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false)
|
||||
Column.new(procedure_id: id, table: 'self', column: 'state', label: I18n.t('activerecord.attributes.procedure_presentation.fields.self.state'), type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false)
|
||||
end
|
||||
|
||||
def notifications_column
|
||||
Columns::DossierColumn.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false)
|
||||
Column.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false)
|
||||
end
|
||||
|
||||
def dossier_columns
|
||||
common = [dossier_id_column, notifications_column]
|
||||
|
||||
dates = ['created_at', 'updated_at', 'depose_at', 'en_construction_at', 'en_instruction_at', 'processed_at']
|
||||
.map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:, type: :date) }
|
||||
|
||||
non_displayable_dates = ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since']
|
||||
.map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) }
|
||||
|
||||
states = [dossier_state_column]
|
||||
|
||||
[common, dates, sva_svr_columns, non_displayable_dates, states].flatten.compact
|
||||
non_displayable_dates = ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since']
|
||||
.map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) }
|
||||
|
||||
for_export_before_date = ['archived']
|
||||
.map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) }
|
||||
for_export_after_date = ['motivation']
|
||||
.map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) }
|
||||
|
||||
[common, states, for_export_before_date, dossier_dates_columns, for_export_after_date, sva_svr_columns(for_export: false), non_displayable_dates].flatten.compact
|
||||
end
|
||||
|
||||
def sva_svr_columns
|
||||
def dossier_dates_columns
|
||||
['created_at', 'updated_at', 'last_champ_updated_at', 'depose_at', 'en_construction_at', 'en_instruction_at', 'processed_at']
|
||||
.map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date) }
|
||||
end
|
||||
|
||||
def sva_svr_columns(for_export: false)
|
||||
return if !sva_svr_enabled?
|
||||
|
||||
scope = [:activerecord, :attributes, :procedure_presentation, :fields, :self]
|
||||
|
||||
columns = [
|
||||
Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_on', type: :date,
|
||||
label: I18n.t("#{sva_svr_decision}_decision_on", scope:))
|
||||
Column.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_on', type: :date,
|
||||
label: I18n.t("#{sva_svr_decision}_decision_on", scope:, type: sva_svr_configuration.human_decision))
|
||||
]
|
||||
|
||||
columns << Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_before', type: :date, displayable: false,
|
||||
if !for_export
|
||||
columns << Column.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_before', type: :date, displayable: false,
|
||||
label: I18n.t("#{sva_svr_decision}_decision_before", scope:))
|
||||
|
||||
end
|
||||
columns
|
||||
end
|
||||
|
||||
|
@ -80,31 +128,38 @@ module ColumnsConcern
|
|||
private
|
||||
|
||||
def email_column
|
||||
Columns::DossierColumn.new(procedure_id: id, table: 'user', column: 'email')
|
||||
Column.new(procedure_id: id, table: 'user', column: 'email')
|
||||
end
|
||||
|
||||
def standard_columns
|
||||
[
|
||||
email_column,
|
||||
Columns::DossierColumn.new(procedure_id: id, table: 'followers_instructeurs', column: 'email'),
|
||||
Columns::DossierColumn.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum),
|
||||
Columns::DossierColumn.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false) # not filterable ?
|
||||
Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false),
|
||||
Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email'),
|
||||
Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum),
|
||||
Column.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false),
|
||||
Column.new(procedure_id: id, table: 'user', column: 'id', filterable: false, displayable: false),
|
||||
Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false)
|
||||
]
|
||||
end
|
||||
|
||||
def individual_columns
|
||||
['nom', 'prenom', 'gender'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'individual', column:) }
|
||||
['gender', 'nom', 'prenom'].map { |column| Column.new(procedure_id: id, table: 'individual', column:) }
|
||||
.concat ['for_tiers', 'mandataire_last_name', 'mandataire_first_name'].map { |column| Column.new(procedure_id: id, table: 'self', column:) }
|
||||
end
|
||||
|
||||
def moral_columns
|
||||
etablissements = ['entreprise_siren', 'entreprise_forme_juridique', 'entreprise_nom_commercial', 'entreprise_raison_sociale', 'entreprise_siret_siege_social']
|
||||
.map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:) }
|
||||
etablissements = ['entreprise_forme_juridique', 'entreprise_siren', 'entreprise_nom_commercial', 'entreprise_raison_sociale', 'entreprise_siret_siege_social']
|
||||
.map { |column| Column.new(procedure_id: id, table: 'etablissement', column:) }
|
||||
|
||||
etablissement_dates = ['entreprise_date_creation'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:, type: :date) }
|
||||
etablissement_dates = ['entreprise_date_creation'].map { |column| Column.new(procedure_id: id, table: 'etablissement', column:, type: :date) }
|
||||
|
||||
other = ['siret', 'libelle_naf', 'code_postal'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:) }
|
||||
for_export = ["siege_social", "naf", "adresse", "numero_voie", "type_voie", "nom_voie", "complement_adresse", "localite", "code_insee_localite", "entreprise_siren", "entreprise_capital_social", "entreprise_numero_tva_intracommunautaire", "entreprise_forme_juridique_code", "entreprise_code_effectif_entreprise", "entreprise_etat_administratif", "entreprise_nom", "entreprise_prenom", "association_rna", "association_titre", "association_objet", "association_date_creation", "association_date_declaration", "association_date_publication"]
|
||||
.map { |column| Column.new(procedure_id: id, table: 'etablissement', column:, displayable: false, filterable: false) }
|
||||
|
||||
[etablissements, etablissement_dates, other].flatten
|
||||
other = ['siret', 'libelle_naf', 'code_postal'].map { |column| Column.new(procedure_id: id, table: 'etablissement', column:) }
|
||||
|
||||
[etablissements, etablissement_dates, other, for_export].flatten
|
||||
end
|
||||
|
||||
def types_de_champ_columns
|
||||
|
|
|
@ -450,6 +450,10 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def user_email_for_display
|
||||
user_email_for(:display)
|
||||
end
|
||||
|
||||
def expiration_started?
|
||||
[
|
||||
brouillon_close_to_expiration_notice_sent_at,
|
||||
|
|
|
@ -5,24 +5,34 @@ en:
|
|||
fields:
|
||||
self:
|
||||
id: File Nº
|
||||
user_email_for_display: Email
|
||||
state: State
|
||||
created_at: Created on
|
||||
updated_at: Updated on
|
||||
depose_at: First submission on
|
||||
en_construction_at: Submitted on
|
||||
en_instruction_at: En instruction on
|
||||
en_instruction_at: Instructed on
|
||||
processed_at: Done on
|
||||
depose_since: First Submission since
|
||||
updated_since: Updated since
|
||||
en_construction_since: Submitted since
|
||||
en_instruction_since: Instructed since
|
||||
processed_since: Finished since
|
||||
sva_decision_on: SVA decision date
|
||||
sva_decision_on: Date décision %{type}
|
||||
sva_decision_before: SVA decision date before
|
||||
svr_decision_on: SVR decision date
|
||||
svr_decision_on: Date décision %{type}
|
||||
svr_decision_before: SVR decision date before
|
||||
user_from_france_connect?: "FranceConnect ?"
|
||||
for_tiers: "For tiers"
|
||||
mandataire_last_name: "Tier last name"
|
||||
mandataire_first_name: "Tier first name"
|
||||
user:
|
||||
id: User Id
|
||||
email: Requester
|
||||
procedure:
|
||||
domaine_fonctionnel: Domaine Fonctionnel
|
||||
referentiel_prog: Référentiel De Programmation
|
||||
centre_de_cout: Centre De Coût
|
||||
followers_instructeurs:
|
||||
email: Email instructeur
|
||||
groupe_instructeur:
|
||||
|
@ -36,12 +46,38 @@ en:
|
|||
answer: Opinion
|
||||
question_answer: Opinion yes/no
|
||||
etablissement:
|
||||
entreprise_siren: SIREN
|
||||
entreprise_etat_administratif: 'Entreprise état administratif'
|
||||
entreprise_forme_juridique: Forme juridique
|
||||
entreprise_nom_commercial: Commercial name
|
||||
entreprise_raison_sociale: Raison sociale
|
||||
entreprise_siret_siege_social: SIRET siège social
|
||||
entreprise_date_creation: Creation date
|
||||
siret: SIRET
|
||||
entreprise_date_creation: Entreprise date de création
|
||||
siret: Établissement SIRET
|
||||
libelle_naf: Libellé NAF
|
||||
code_postal: Postal code
|
||||
siege_social: "Établissement siège social"
|
||||
naf: "Établissement NAF"
|
||||
adresse: "Établissement Adresse"
|
||||
numero_voie: "Établissement numero voie"
|
||||
type_voie: "Établissement type voie"
|
||||
nom_voie: "Établissement nom voie"
|
||||
complement_adresse: "Établissement complément adresse"
|
||||
code_postal: "Établissement code postal"
|
||||
localite: "Établissement localité"
|
||||
code_insee_localite: "Établissement code INSEE localité"
|
||||
entreprise_siren: SIREN
|
||||
entreprise_capital_social: "Entreprise capital social"
|
||||
entreprise_numero_tva_intracommunautaire: "Entreprise numero TVA intracommunautaire"
|
||||
entreprise_forme_juridique: "Entreprise forme juridique"
|
||||
entreprise_forme_juridique_code: "Entreprise forme juridique code"
|
||||
entreprise_nom_commercial: "Entreprise nom commercial"
|
||||
entreprise_raison_sociale: "Entreprise raison sociale"
|
||||
entreprise_siret_siege_social: "Entreprise SIRET siège social"
|
||||
entreprise_code_effectif_entreprise: "Entreprise code effectif entreprise"
|
||||
entreprise_nom: 'Entreprise nom'
|
||||
entreprise_prenom: 'Entreprise prénom'
|
||||
association_rna: 'Association RNA'
|
||||
association_titre: 'Association titre'
|
||||
association_objet: 'Association objet'
|
||||
association_date_creation: 'Association date de création'
|
||||
association_date_declaration: 'Association date de déclaration'
|
||||
association_date_publication: 'Association date de publication'
|
||||
|
|
|
@ -5,26 +5,40 @@ fr:
|
|||
fields:
|
||||
self:
|
||||
id: Nº dossier
|
||||
state: Statut
|
||||
user_email_for_display: Email
|
||||
state: État du dossier
|
||||
created_at: Créé le
|
||||
updated_at: Mis à jour le
|
||||
updated_at: Dernière mise à jour le
|
||||
depose_at: Déposé le
|
||||
en_construction_at: En construction le
|
||||
en_instruction_at: En instruction le
|
||||
processed_at: Terminé le
|
||||
en_construction_at: Passé en construction le
|
||||
en_instruction_at: Passé en instruction le
|
||||
processed_at: Traité le
|
||||
updated_since: Mis à jour depuis
|
||||
depose_since: Déposé depuis
|
||||
en_construction_since: En construction depuis
|
||||
en_instruction_since: En instruction depuis
|
||||
processed_since: Terminé depuis
|
||||
sva_decision_on: Date décision SVA
|
||||
sva_decision_on: Date décision %{type}
|
||||
sva_decision_before: Date décision SVA avant
|
||||
svr_decision_on: Date décision SVR
|
||||
svr_decision_on: Date décision %{type}
|
||||
svr_decision_before: Date décision SVR avant
|
||||
user_from_france_connect?: "FranceConnect ?"
|
||||
for_tiers: "Dépôt pour un tiers"
|
||||
mandataire_last_name: "Nom du mandataire"
|
||||
mandataire_first_name: "Prénom du mandataire"
|
||||
archived: 'Archivé'
|
||||
dossier_state: 'État du dossier'
|
||||
last_champ_updated_at: 'Dernière mise à jour du dossier le'
|
||||
motivation: 'Motivation de la décision'
|
||||
user:
|
||||
id: Identifiant du demandeur
|
||||
email: Demandeur
|
||||
procedure:
|
||||
domaine_fonctionnel: Domaine Fonctionnel
|
||||
referentiel_prog: Référentiel De Programmation
|
||||
centre_de_cout: Centre De Coût
|
||||
followers_instructeurs:
|
||||
email: Email instructeur
|
||||
email: Instructeurs
|
||||
groupe_instructeur:
|
||||
id: Groupe instructeur
|
||||
label: Groupe instructeur
|
||||
|
@ -36,12 +50,38 @@ fr:
|
|||
answer: Avis
|
||||
question_answer: Avis oui/non
|
||||
etablissement:
|
||||
entreprise_siren: SIREN
|
||||
entreprise_etat_administratif: 'Entreprise état administratif'
|
||||
entreprise_forme_juridique: Forme juridique
|
||||
entreprise_nom_commercial: Nom commercial
|
||||
entreprise_raison_sociale: Raison sociale
|
||||
entreprise_siret_siege_social: SIRET siège social
|
||||
entreprise_date_creation: Date de création
|
||||
siret: SIRET
|
||||
entreprise_date_creation: Entreprise date de création
|
||||
siret: Établissement SIRET
|
||||
libelle_naf: Libellé NAF
|
||||
code_postal: Code postal
|
||||
siege_social: "Établissement siège social"
|
||||
naf: "Établissement NAF"
|
||||
adresse: "Établissement Adresse"
|
||||
numero_voie: "Établissement numero voie"
|
||||
type_voie: "Établissement type voie"
|
||||
nom_voie: "Établissement nom voie"
|
||||
complement_adresse: "Établissement complément adresse"
|
||||
code_postal: "Établissement code postal"
|
||||
localite: "Établissement localité"
|
||||
code_insee_localite: "Établissement code INSEE localité"
|
||||
entreprise_siren: "Entreprise SIREN"
|
||||
entreprise_capital_social: "Entreprise capital social"
|
||||
entreprise_numero_tva_intracommunautaire: "Entreprise numero TVA intracommunautaire"
|
||||
entreprise_forme_juridique: "Entreprise forme juridique"
|
||||
entreprise_forme_juridique_code: "Entreprise forme juridique code"
|
||||
entreprise_nom_commercial: "Entreprise nom commercial"
|
||||
entreprise_raison_sociale: "Entreprise raison sociale"
|
||||
entreprise_siret_siege_social: "Entreprise SIRET siège social"
|
||||
entreprise_code_effectif_entreprise: "Entreprise code effectif entreprise"
|
||||
entreprise_nom: 'Entreprise nom'
|
||||
entreprise_prenom: 'Entreprise prénom'
|
||||
association_rna: 'Association RNA'
|
||||
association_titre: 'Association titre'
|
||||
association_objet: 'Association objet'
|
||||
association_date_creation: 'Association date de création'
|
||||
association_date_declaration: 'Association date de déclaration'
|
||||
association_date_publication: 'Association date de publication'
|
||||
|
|
|
@ -38,7 +38,7 @@ describe '20240920130741_migrate_procedure_presentation_to_columns.rake' do
|
|||
it 'populates the columns' do
|
||||
procedure_id = procedure.id
|
||||
|
||||
expect(procedure_presentation.displayed_columns.map(&:label)).to eq(["Raison sociale", procedure.active_revision.types_de_champ.first.libelle])
|
||||
expect(procedure_presentation.displayed_columns.map(&:label)).to eq(["Entreprise raison sociale", procedure.active_revision.types_de_champ.first.libelle])
|
||||
|
||||
order, column_id = procedure_presentation
|
||||
.sorted_column
|
||||
|
|
|
@ -29,7 +29,7 @@ describe ColumnsConcern do
|
|||
let(:tdc_private_2) { procedure.active_revision.types_de_champ_private[1] }
|
||||
let(:expected) {
|
||||
[
|
||||
{ label: 'Nº dossier', table: 'self', column: 'id', displayable: true, type: :number, scope: '', value_column: :value, filterable: true },
|
||||
{ label: 'Dossier ID', table: 'self', column: 'id', displayable: true, type: :number, scope: '', value_column: :value, filterable: true },
|
||||
{ label: 'notifications', table: 'notifications', column: 'notifications', displayable: true, type: :text, scope: '', value_column: :value, filterable: false },
|
||||
{ label: 'Créé le', table: 'self', column: 'created_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true },
|
||||
{ label: 'Mis à jour le', table: 'self', column: 'updated_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true },
|
||||
|
@ -43,10 +43,15 @@ describe ColumnsConcern do
|
|||
{ label: "En instruction depuis", table: "self", column: "en_instruction_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true },
|
||||
{ label: "Terminé depuis", table: "self", column: "processed_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true },
|
||||
{ label: "Statut", table: "self", column: "state", displayable: false, scope: 'instructeurs.dossiers.filterable_state', type: :enum, value_column: :value, filterable: true },
|
||||
{ label: "Archivé", table: "self", column: "archived", displayable: false, scope: '', type: :text, value_column: :value, filterable: false },
|
||||
{ label: "Motivation de la décision", table: "self", column: "motivation", displayable: false, scope: '', type: :text, value_column: :value, filterable: false },
|
||||
{ label: "Dernière mise à jour du dossier le", table: "self", column: "last_champ_updated_at", displayable: false, scope: '', type: :text, value_column: :value, filterable: false },
|
||||
{ label: 'Demandeur', table: 'user', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
||||
{ label: 'Email instructeur', table: 'followers_instructeurs', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
||||
{ label: 'Groupe instructeur', table: 'groupe_instructeur', column: 'id', displayable: true, type: :enum, scope: '', value_column: :value, filterable: true },
|
||||
{ label: 'Avis oui/non', table: 'avis', column: 'question_answer', displayable: true, type: :text, scope: '', value_column: :value, filterable: false },
|
||||
{ label: 'Identifiant du demandeur', table: 'user', column: 'id', displayable: false, type: :text, scope: '', value_column: :value, filterable: false },
|
||||
{ label: 'FranceConnect ?', table: 'self', column: 'user_from_france_connect?', displayable: false, type: :text, scope: '', value_column: :value, filterable: false },
|
||||
{ label: 'SIREN', table: 'etablissement', column: 'entreprise_siren', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
||||
{ label: 'Forme juridique', table: 'etablissement', column: 'entreprise_forme_juridique', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
||||
{ label: 'Nom commercial', table: 'etablissement', column: 'entreprise_nom_commercial', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
||||
|
@ -73,7 +78,11 @@ describe ColumnsConcern do
|
|||
procedure.active_revision.types_de_champ_private[3].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:explication))
|
||||
end
|
||||
|
||||
it { expect(subject).to eq(expected) }
|
||||
it {
|
||||
expected.each do |expected|
|
||||
expect(subject).to include(expected)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
context 'with rna' do
|
||||
|
@ -125,4 +134,119 @@ describe ColumnsConcern do
|
|||
it { is_expected.to include(decision_on, decision_before_field) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'export' do
|
||||
let(:procedure) { create(:procedure_with_dossiers, :published, types_de_champ_public:, for_individual:) }
|
||||
let(:for_individual) { true }
|
||||
let(:types_de_champ_public) do
|
||||
[
|
||||
{ type: :text, libelle: "Ca va ?", mandatory: true, stable_id: 1 },
|
||||
{ type: :communes, libelle: "Commune", mandatory: true, stable_id: 17 },
|
||||
{ type: :siret, libelle: 'siret', stable_id: 20 },
|
||||
{ type: :repetition, mandatory: true, stable_id: 7, libelle: "Champ répétable", children: [{ type: 'text', libelle: 'Qqchose à rajouter?', stable_id: 8 }] }
|
||||
]
|
||||
end
|
||||
|
||||
describe '#all_usager_columns_for_export' do
|
||||
context 'for individual procedure' do
|
||||
let(:for_individual) { true }
|
||||
|
||||
it "returns all usager columns" do
|
||||
expected = [
|
||||
procedure.find_column(label: "Nº dossier"),
|
||||
procedure.find_column(label: "Email"),
|
||||
procedure.find_column(label: "FranceConnect ?"),
|
||||
procedure.find_column(label: "Civilité"),
|
||||
procedure.find_column(label: "Nom"),
|
||||
procedure.find_column(label: "Prénom"),
|
||||
procedure.find_column(label: "Dépôt pour un tiers"),
|
||||
procedure.find_column(label: "Nom du mandataire"),
|
||||
procedure.find_column(label: "Prénom du mandataire")
|
||||
]
|
||||
actuals = procedure.all_usager_columns_for_export.map(&:h_id)
|
||||
expected.each do |expected_col|
|
||||
expect(actuals).to include(expected_col.h_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'for entreprise procedure' do
|
||||
let(:for_individual) { false }
|
||||
|
||||
it "returns all usager columns" do
|
||||
expected = [
|
||||
procedure.find_column(label: "Nº dossier"),
|
||||
procedure.find_column(label: "Email"),
|
||||
procedure.find_column(label: "FranceConnect ?"),
|
||||
procedure.find_column(label: "Établissement SIRET"),
|
||||
procedure.find_column(label: "Établissement siège social"),
|
||||
procedure.find_column(label: "Établissement NAF"),
|
||||
procedure.find_column(label: "Libellé NAF"),
|
||||
procedure.find_column(label: "Établissement Adresse"),
|
||||
procedure.find_column(label: "Établissement numero voie"),
|
||||
procedure.find_column(label: "Établissement type voie"),
|
||||
procedure.find_column(label: "Établissement nom voie"),
|
||||
procedure.find_column(label: "Établissement complément adresse"),
|
||||
procedure.find_column(label: "Établissement code postal"),
|
||||
procedure.find_column(label: "Établissement localité"),
|
||||
procedure.find_column(label: "Établissement code INSEE localité"),
|
||||
procedure.find_column(label: "Entreprise SIREN"),
|
||||
procedure.find_column(label: "Entreprise capital social"),
|
||||
procedure.find_column(label: "Entreprise numero TVA intracommunautaire"),
|
||||
procedure.find_column(label: "Entreprise forme juridique"),
|
||||
procedure.find_column(label: "Entreprise forme juridique code"),
|
||||
procedure.find_column(label: "Entreprise nom commercial"),
|
||||
procedure.find_column(label: "Entreprise raison sociale"),
|
||||
procedure.find_column(label: "Entreprise SIRET siège social"),
|
||||
procedure.find_column(label: "Entreprise code effectif entreprise")
|
||||
]
|
||||
actuals = procedure.all_usager_columns_for_export
|
||||
expected.each do |expected_col|
|
||||
expect(actuals.map(&:h_id)).to include(expected_col.h_id)
|
||||
end
|
||||
|
||||
expect(actuals.any? { _1.label == "Nom" }).to eq false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when procedure chorusable' do
|
||||
let(:procedure) { create(:procedure_with_dossiers, :filled_chorus, types_de_champ_public:) }
|
||||
it 'returns specific chorus columns' do
|
||||
allow_any_instance_of(Procedure).to receive(:chorusable?).and_return(true)
|
||||
expected = [
|
||||
procedure.find_column(label: "Domaine Fonctionnel"),
|
||||
procedure.find_column(label: "Référentiel De Programmation"),
|
||||
procedure.find_column(label: "Centre De Coût")
|
||||
]
|
||||
actuals = procedure.all_usager_columns_for_export.map(&:h_id)
|
||||
expected.each do |expected_col|
|
||||
expect(actuals).to include(expected_col.h_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#all_dossier_columns_for_export' do
|
||||
let(:procedure) { create(:procedure_with_dossiers, :routee, :published, types_de_champ_public:, for_individual:) }
|
||||
|
||||
it "returns all dossier columns" do
|
||||
expected = [
|
||||
procedure.find_column(label: "Archivé"),
|
||||
procedure.find_column(label: "État du dossier"),
|
||||
procedure.find_column(label: "Dernière mise à jour le"),
|
||||
procedure.find_column(label: "Dernière mise à jour du dossier le"),
|
||||
procedure.find_column(label: "Déposé le"),
|
||||
procedure.find_column(label: "Passé en instruction le"),
|
||||
procedure.find_column(label: "Traité le"),
|
||||
procedure.find_column(label: "Motivation de la décision"),
|
||||
procedure.find_column(label: "Instructeurs"),
|
||||
procedure.find_column(label: "Groupe instructeur")
|
||||
]
|
||||
actuals = procedure.all_dossier_columns_for_export.map(&:h_id)
|
||||
expected.each do |expected_col|
|
||||
expect(actuals).to include(expected_col.h_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -95,7 +95,7 @@ RSpec.describe Export, type: :model do
|
|||
expect { Export.find_or_create_fresh_export(:zip, [gi_1], instructeur, time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) }
|
||||
.to change { Export.count }.by(1)
|
||||
|
||||
update_at_column = FilteredColumn.new(column: procedure.find_column(label: 'Mis à jour le'), filter: '10/12/2021')
|
||||
update_at_column = FilteredColumn.new(column: procedure.find_column(label: 'Dernière mise à jour le'), filter: '10/12/2021')
|
||||
pp.update(tous_filters: [created_at_column, update_at_column])
|
||||
|
||||
expect { Export.find_or_create_fresh_export(:zip, [gi_1], instructeur, time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) }
|
||||
|
@ -181,7 +181,7 @@ RSpec.describe Export, type: :model do
|
|||
let(:statut) { 'tous' }
|
||||
|
||||
let(:procedure_presentation) do
|
||||
statut_column = procedure.find_column(label: 'Statut')
|
||||
statut_column = procedure.find_column(label: 'État du dossier')
|
||||
en_construction_filter = FilteredColumn.new(column: statut_column, filter: 'en_construction')
|
||||
create(:procedure_presentation,
|
||||
procedure:,
|
||||
|
|
|
@ -77,7 +77,7 @@ describe ProcedurePresentation do
|
|||
end
|
||||
|
||||
context 'when filter is state' do
|
||||
let(:filtered_column) { to_filter(['Statut', "en_construction"]) }
|
||||
let(:filtered_column) { to_filter(['État du dossier', "en_construction"]) }
|
||||
|
||||
it 'should get i18n value' do
|
||||
expect(subject).to eq("En construction")
|
||||
|
@ -94,8 +94,8 @@ describe ProcedurePresentation do
|
|||
end
|
||||
|
||||
describe '#update_displayed_fields' do
|
||||
let(:en_construction_column) { procedure.find_column(label: 'En construction le') }
|
||||
let(:mise_a_jour_column) { procedure.find_column(label: 'Mis à jour le') }
|
||||
let(:en_construction_column) { procedure.find_column(label: 'Passé en construction le') }
|
||||
let(:mise_a_jour_column) { procedure.find_column(label: 'Dernière mise à jour le') }
|
||||
|
||||
let(:procedure_presentation) do
|
||||
create(:procedure_presentation, assign_to:).tap do |pp|
|
||||
|
|
|
@ -41,7 +41,7 @@ describe DossierFilterService do
|
|||
|
||||
context 'when a filter is present' do
|
||||
let(:filtered_ids) { [dossier_1, dossier_2, dossier_3].map(&:id) }
|
||||
let(:filters) { [to_filter(['Statut', 'en_construction'])] }
|
||||
let(:filters) { [to_filter(['État du dossier', 'en_construction'])] }
|
||||
|
||||
before do
|
||||
expect(described_class).to receive(:filtered_ids).and_return(filtered_ids)
|
||||
|
@ -110,7 +110,7 @@ describe DossierFilterService do
|
|||
end
|
||||
|
||||
context 'for en_construction_at column' do
|
||||
let!(:column) { procedure.find_column(label: 'En construction le') }
|
||||
let!(:column) { procedure.find_column(label: 'Passé en construction le') }
|
||||
let!(:recent_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) }
|
||||
let!(:older_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2013, 1, 1)) }
|
||||
|
||||
|
@ -118,7 +118,7 @@ describe DossierFilterService do
|
|||
end
|
||||
|
||||
context 'for updated_at column' do
|
||||
let(:column) { procedure.find_column(label: 'Mis à jour le') }
|
||||
let(:column) { procedure.find_column(label: 'Dernière mise à jour le') }
|
||||
let(:recent_dossier) { create(:dossier, procedure:) }
|
||||
let(:older_dossier) { create(:dossier, procedure:) }
|
||||
|
||||
|
@ -251,7 +251,7 @@ describe DossierFilterService do
|
|||
end
|
||||
|
||||
context 'for email column' do
|
||||
let(:column) { procedure.find_column(label: 'Email instructeur') }
|
||||
let(:column) { procedure.find_column(label: 'Instructeurs') }
|
||||
|
||||
it { is_expected.to eq([dossier_a, dossier_z, dossier_without_instructeur].map(&:id)) }
|
||||
end
|
||||
|
@ -275,7 +275,7 @@ describe DossierFilterService do
|
|||
|
||||
context 'for other tables' do
|
||||
# All other columns and tables work the same so it’s ok to test only one
|
||||
let(:column) { procedure.find_column(label: 'Code postal') }
|
||||
let(:column) { procedure.find_column(label: 'Établissement code postal') }
|
||||
let(:order) { 'asc' } # Desc works the same, no extra test required
|
||||
|
||||
let!(:huitieme_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75008')) }
|
||||
|
@ -306,7 +306,7 @@ describe DossierFilterService do
|
|||
end
|
||||
|
||||
context 'for en_construction_at column' do
|
||||
let(:filter) { ['En construction le', '17/10/2018'] }
|
||||
let(:filter) { ['Passé en construction le', '17/10/2018'] }
|
||||
|
||||
let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) }
|
||||
let!(:discarded_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2013, 1, 1)) }
|
||||
|
@ -315,7 +315,7 @@ describe DossierFilterService do
|
|||
end
|
||||
|
||||
context 'for updated_at column' do
|
||||
let(:filter) { ['Mis à jour le', '18/9/2018'] }
|
||||
let(:filter) { ['Dernière mise à jour le', '18/9/2018'] }
|
||||
|
||||
let(:kept_dossier) { create(:dossier, procedure:) }
|
||||
let(:discarded_dossier) { create(:dossier, procedure:) }
|
||||
|
@ -362,7 +362,7 @@ describe DossierFilterService do
|
|||
end
|
||||
|
||||
context 'ignore time of day' do
|
||||
let(:filter) { ['En construction le', '17/10/2018 19:30'] }
|
||||
let(:filter) { ['Passé en construction le', '17/10/2018 19:30'] }
|
||||
|
||||
let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17, 15, 56)) }
|
||||
let!(:discarded_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 18, 5, 42)) }
|
||||
|
@ -372,20 +372,20 @@ describe DossierFilterService do
|
|||
|
||||
context 'for a malformed date' do
|
||||
context 'when its a string' do
|
||||
let(:filter) { ['Mis à jour le', 'malformed date'] }
|
||||
let(:filter) { ['Dernière mise à jour le', 'malformed date'] }
|
||||
|
||||
it { is_expected.to match([]) }
|
||||
end
|
||||
|
||||
context 'when its a number' do
|
||||
let(:filter) { ['Mis à jour le', '177500'] }
|
||||
let(:filter) { ['Dernière mise à jour le', '177500'] }
|
||||
|
||||
it { is_expected.to match([]) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'with multiple search values' do
|
||||
let(:filters) { [['En construction le', '17/10/2018'], ['En construction le', '19/10/2018']] }
|
||||
let(:filters) { [['Passé en construction le', '17/10/2018'], ['Passé en construction le', '19/10/2018']] }
|
||||
|
||||
let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) }
|
||||
let!(:other_kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 19)) }
|
||||
|
@ -397,7 +397,7 @@ describe DossierFilterService do
|
|||
end
|
||||
|
||||
context 'with multiple state filters' do
|
||||
let(:filters) { [['Statut', 'en_construction'], ['Statut', 'en_instruction']] }
|
||||
let(:filters) { [['État du dossier', 'en_construction'], ['État du dossier', 'en_instruction']] }
|
||||
|
||||
let!(:kept_dossier) { create(:dossier, :en_construction, procedure:) }
|
||||
let!(:other_kept_dossier) { create(:dossier, :en_instruction, procedure:) }
|
||||
|
@ -409,7 +409,7 @@ describe DossierFilterService do
|
|||
end
|
||||
|
||||
context 'with en_construction state filters' do
|
||||
let(:filter) { ['Statut', 'en_construction'] }
|
||||
let(:filter) { ['État du dossier', 'en_construction'] }
|
||||
|
||||
let!(:en_construction) { create(:dossier, :en_construction, procedure:) }
|
||||
let!(:en_construction_with_correction) { create(:dossier, :en_construction, procedure:) }
|
||||
|
@ -580,7 +580,7 @@ describe DossierFilterService do
|
|||
|
||||
context 'for etablissement table' do
|
||||
context 'for entreprise_date_creation column' do
|
||||
let(:filter) { ['Date de création', '21/6/2018'] }
|
||||
let(:filter) { ['Entreprise date de création', '21/6/2018'] }
|
||||
|
||||
let!(:kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2018, 6, 21))) }
|
||||
let!(:discarded_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2008, 6, 21))) }
|
||||
|
@ -588,7 +588,7 @@ describe DossierFilterService do
|
|||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||
|
||||
context 'with multiple search values' do
|
||||
let(:filters) { [['Date de création', '21/6/2016'], ['Date de création', '21/6/2018']] }
|
||||
let(:filters) { [['Entreprise date de création', '21/6/2016'], ['Entreprise date de création', '21/6/2018']] }
|
||||
|
||||
let!(:other_kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2016, 6, 21))) }
|
||||
|
||||
|
@ -601,7 +601,7 @@ describe DossierFilterService do
|
|||
context 'for code_postal column' do
|
||||
# All columns except entreprise_date_creation work exacly the same, just testing one
|
||||
|
||||
let(:filter) { ['Code postal', '75017'] }
|
||||
let(:filter) { ['Établissement code postal', '75017'] }
|
||||
|
||||
let!(:kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75017')) }
|
||||
let!(:discarded_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '25000')) }
|
||||
|
@ -609,7 +609,7 @@ describe DossierFilterService do
|
|||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||
|
||||
context 'with multiple search values' do
|
||||
let(:filters) { [['Code postal', '75017'], ['Code postal', '88100']] }
|
||||
let(:filters) { [['Établissement code postal', '75017'], ['Établissement code postal', '88100']] }
|
||||
|
||||
let!(:other_kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '88100')) }
|
||||
|
||||
|
@ -674,7 +674,7 @@ describe DossierFilterService do
|
|||
end
|
||||
|
||||
context 'for followers_instructeurs table' do
|
||||
let(:filter) { ['Email instructeur', 'keepmail'] }
|
||||
let(:filter) { ['Instructeurs', 'keepmail'] }
|
||||
|
||||
let!(:kept_dossier) { create(:dossier, procedure:) }
|
||||
let!(:discarded_dossier) { create(:dossier, procedure:) }
|
||||
|
@ -687,7 +687,7 @@ describe DossierFilterService do
|
|||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||
|
||||
context 'with multiple search values' do
|
||||
let(:filters) { [['Email instructeur', 'keepmail'], ['Email instructeur', 'beta.gouv.fr']] }
|
||||
let(:filters) { [['Instructeurs', 'keepmail'], ['Instructeurs', 'beta.gouv.fr']] }
|
||||
|
||||
let(:other_kept_dossier) { create(:dossier, procedure:) }
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ describe DossierProjectionService do
|
|||
end
|
||||
|
||||
context 'for en_construction_at column' do
|
||||
let(:label) { 'En construction le' }
|
||||
let(:label) { 'Passé en construction le' }
|
||||
let(:dossier) { create(:dossier, :en_construction, en_construction_at: Time.zone.local(2018, 10, 17), procedure:) }
|
||||
|
||||
it { is_expected.to eq('17/10/2018') }
|
||||
|
@ -101,7 +101,7 @@ describe DossierProjectionService do
|
|||
end
|
||||
|
||||
context 'for updated_at column' do
|
||||
let(:label) { 'Mis à jour le' }
|
||||
let(:label) { 'Dernière mise à jour le' }
|
||||
let(:dossier) { create(:dossier, procedure:) }
|
||||
|
||||
before { dossier.touch(time: Time.zone.local(2018, 9, 25)) }
|
||||
|
@ -142,7 +142,7 @@ describe DossierProjectionService do
|
|||
end
|
||||
|
||||
context 'for etablissement table' do
|
||||
let(:label) { 'Code postal' }
|
||||
let(:label) { 'Établissement code postal' }
|
||||
|
||||
let!(:dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75008')) }
|
||||
|
||||
|
@ -158,7 +158,7 @@ describe DossierProjectionService do
|
|||
end
|
||||
|
||||
context 'for followers_instructeurs table' do
|
||||
let(:label) { 'Email instructeur' }
|
||||
let(:label) { 'Instructeurs' }
|
||||
|
||||
let(:dossier) { create(:dossier, procedure:) }
|
||||
let!(:follow1) { create(:follow, dossier: dossier, instructeur: create(:instructeur, email: 'b@host.fr')) }
|
||||
|
|
|
@ -99,10 +99,10 @@ describe "procedure filters" do
|
|||
|
||||
scenario "should be able to user custom fiters", js: true do
|
||||
# use date filter
|
||||
add_filter("En construction le", "10/10/2010", type: :date)
|
||||
add_filter("Passé en construction le", "10/10/2010", type: :date)
|
||||
|
||||
# use statut dropdown filter
|
||||
add_filter('Statut', 'En construction', type: :enum)
|
||||
add_filter('État du dossier', 'En construction', type: :enum)
|
||||
|
||||
# use choice dropdown filter
|
||||
add_filter('Choix unique', 'val1', type: :enum)
|
||||
|
|
Loading…
Reference in a new issue