generated from betagouv/rails-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce InduEtrangerMapper + Improve StudentMerger (#1393)
- Loading branch information
Showing
13 changed files
with
278 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module ASP | ||
module Mappers | ||
module Adresse | ||
class InduEtrangerMapper < FranceMapper | ||
def localiteetranger | ||
student.address_city | ||
end | ||
|
||
def bureaudistribetranger | ||
student.address_postal_code | ||
end | ||
|
||
def voiepointgeoetranger | ||
student.address_line1 | ||
end | ||
|
||
def districtetranger | ||
student.address_line2 | ||
end | ||
|
||
def regionetranger | ||
student.address_line2 | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Aplypro | ||
VERSION = "2.2.2" | ||
VERSION = "2.2.3" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Fusion élèves | ||
|
||
## Description | ||
|
||
Dans les SI du système éducatif français il n'est pas impossible qu'un élève physique se retrouve avec 2 INE. Lorsque c'est le cas il est possible qu'un retour d'intégration ASP échoue car il existe une contrainte d'unicité sur l'attribut `asp_individu_id`. Pour remédier ces cas et relancer l'intégration il est nécessaire de dédoublonner l'objet `Student` qui pose problème. Il existe à cet effet la classe `StudentMerger`. | ||
|
||
## Mode d'emploi | ||
|
||
## Etape 1: selectionner l'étudiant | ||
|
||
En utilisant l'id qui remonte dans Sentry ou Sidekiq: | ||
|
||
`student = Student.find_by!(asp_individu_id: asp_id)` | ||
|
||
## Etape 2: Verifier si il y a des doublons | ||
|
||
`students = Student.where(last_name: student.last_name, first_name: student.first_name, birthplace_city_inseecode: student.birthplace_city_inseecode, birthdate: student.birthdate)` | ||
|
||
## Etape 3: Fusionner les étudiants | ||
|
||
`StudentMerger.new(students.to_a).merge!` | ||
|
||
## Etape 4: Relancer les fichiers d'intégration | ||
|
||
Cliquer "Retry Now" pour le job dans le panneau d'administration de Sidekiq. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
module ASP | ||
module Entities | ||
module Adresse | ||
class InduEtranger < Entity | ||
ADRESSE_ATTR_MAX_LENGTH = 38 | ||
|
||
attribute :localiteetranger, :string | ||
attribute :bureaudistribetranger, :string | ||
attribute :voiepointgeoetranger, :string | ||
attribute :districtetranger, :string | ||
attribute :regionetranger, :string | ||
attribute :codetypeadr, :string | ||
attribute :codeinseepays, :string | ||
|
||
validates_presence_of %i[ | ||
localiteetranger | ||
bureaudistribetranger | ||
codetypeadr | ||
codeinseepays | ||
] | ||
|
||
validates_length_of :localiteetranger, maximum: ADRESSE_ATTR_MAX_LENGTH | ||
validates_length_of :bureaudistribetranger, maximum: ADRESSE_ATTR_MAX_LENGTH | ||
|
||
validates_length_of :voiepointgeoetranger, maximum: ADRESSE_ATTR_MAX_LENGTH, allow_nil: true | ||
validates_length_of :districtetranger, maximum: ADRESSE_ATTR_MAX_LENGTH, allow_nil: true | ||
validates_length_of :regionetranger, maximum: ADRESSE_ATTR_MAX_LENGTH, allow_nil: true | ||
|
||
def self.payment_mapper_class | ||
Mappers::Adresse::InduEtrangerMapper | ||
end | ||
|
||
def root_node_name | ||
"adresse" | ||
end | ||
|
||
def fragment(xml) # rubocop:disable Metrics/AbcSize | ||
xml.codetypeadr(codetypeadr) | ||
xml.codeinseepays(codeinseepays) | ||
|
||
xml.localiteetranger(localiteetranger) | ||
xml.bureaudistribetranger(bureaudistribetranger) | ||
|
||
xml.voiepointgeoetranger(voiepointgeoetranger) if voiepointgeoetranger.present? | ||
xml.districtetranger(districtetranger) if districtetranger.present? | ||
xml.regionetranger(regionetranger) if regionetranger.present? | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
describe ASP::Entities::Adresse::InduEtranger, type: :model do | ||
describe "fragment" do | ||
let(:pfmp) { create(:pfmp, :rectified) } | ||
|
||
before do | ||
pfmp.student.update( | ||
address_line1: "A" * 38, | ||
address_line2: "B" * 38, | ||
address_city: "Cool City", | ||
address_postal_code: 66_666 | ||
) | ||
end | ||
|
||
describe "validation" do | ||
it { is_expected.to validate_presence_of(:localiteetranger) } | ||
it { is_expected.to validate_presence_of(:bureaudistribetranger) } | ||
it { is_expected.to validate_presence_of(:codetypeadr) } | ||
end | ||
|
||
it_behaves_like "an XML-fragment producer" do | ||
let(:entity) { described_class.from_payment_request(pfmp.latest_payment_request) } | ||
let(:probe) { %w[codetypeadr PRINCIPALE] } | ||
|
||
it "uses the establishment details for the address" do # rubocop:disable RSpec/MultipleExpectations | ||
expect(document.at("localiteetranger").text).to eq "Cool City" | ||
expect(document.at("bureaudistribetranger").text).to eq 66_666.to_s | ||
end | ||
|
||
context "when the addresse is too long" do | ||
before do | ||
pfmp.student.update( | ||
address_city: "A" * 50 | ||
) | ||
end | ||
|
||
it "errors" do | ||
expect { document.to_s }.to raise_error ActiveModel::ValidationError | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.