Skip to content

Commit

Permalink
Indus part 1 (#1071)
Browse files Browse the repository at this point in the history
Closes #1066 

⚠️ Contains an update to Rails 7.2

Boyscout checklist:
- [x] new state on Pfmp Model
- [x] new guard on transition
- [x] add new ASP mocks to mock rectifications file and filename
properly -> betagouv/aplypro-mock-data#31
- [x] maybe add a new factory to create rectified pfmps at will in specs
- [x] after transition recalculate amounts
- [x] add new controllers actions on pfmp controller
- [x] after transition mark as ready
- [x] add state machine spec file with new business logic tested
- [x] modification to Pfmp#locked? definition
- [x] checkbox of confirmation on rectification form
- [x] new interface for users to confirm new data for new payment
- [x] add new type of attachment to ASP::PaymentReturn to parse the new
type of file in the FTP for ordre de reversement
- [x] ~~add new type of attachment to ASP::Request to handle maybe new
integrations file? has to be clarified~~ According to SERAPIS docs it
seems like the files should be the same
- [x] parse new return file and associated P_R as before but mark it as
paid once more
- [x] spec new parser
- [x] forward new xml attribute in ASP xml when rectification happened
- [x] Make cool interface
- [x] spec manager, spec controller
- [ ] validate new interface and wording with stakeholders
  • Loading branch information
pskl authored Aug 14, 2024
1 parent 0521273 commit 6dcfc34
Show file tree
Hide file tree
Showing 26 changed files with 560 additions and 145 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ require:

AllCops:
NewCops: enable
Exclude:
- 'mock/**/*'
- 'db/**/*'
- 'bin/**/*'

Style/StringLiterals:
Enabled: true
Expand Down
20 changes: 0 additions & 20 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,9 @@ Rails/FilePath:
- 'lib/tasks/cucumber.rake'
- 'spec/rails_helper.rb'

# Offense count: 5
# Configuration parameters: Database, Include.
# SupportedDatabases: mysql
# Include: db/**/*.rb
Rails/NotNullColumn:
Exclude:
- 'db/migrate/20230517062450_add_establishment_id_to_principals.rb'
- 'db/migrate/20230713131807_rework_mefstat_table.rb'
- 'db/migrate/20230809121618_add_name_and_personal_to_ribs.rb'
- 'db/migrate/20230826134628_create_schoolings.rb'
- 'db/migrate/20231208091401_add_mef_code_to_wages.rb'

# Offense count: 1
# Configuration parameters: ForbiddenMethods, AllowedMethods.
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
Rails/SkipsModelValidations:
Exclude:
- 'app/models/pfmp_transition.rb'

# Offense count: 2
# Configuration parameters: Include.
# Include: db/**/*.rb
Rails/ThreeStateBooleanColumn:
Exclude:
- 'db/migrate/20230522231400_create_pfmp_transitions.rb'
- 'db/migrate/20230615143825_create_payment_transitions.rb'
150 changes: 74 additions & 76 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,82 +1,78 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.1.3.4)
actionpack (= 7.1.3.4)
activesupport (= 7.1.3.4)
actioncable (7.2.0)
actionpack (= 7.2.0)
activesupport (= 7.2.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.1.3.4)
actionpack (= 7.1.3.4)
activejob (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.3.4)
actionpack (= 7.1.3.4)
actionview (= 7.1.3.4)
activejob (= 7.1.3.4)
activesupport (= 7.1.3.4)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
actionmailbox (7.2.0)
actionpack (= 7.2.0)
activejob (= 7.2.0)
activerecord (= 7.2.0)
activestorage (= 7.2.0)
activesupport (= 7.2.0)
mail (>= 2.8.0)
actionmailer (7.2.0)
actionpack (= 7.2.0)
actionview (= 7.2.0)
activejob (= 7.2.0)
activesupport (= 7.2.0)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.1.3.4)
actionview (= 7.1.3.4)
activesupport (= 7.1.3.4)
actionpack (7.2.0)
actionview (= 7.2.0)
activesupport (= 7.2.0)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actiontext (7.1.3.4)
actionpack (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
useragent (~> 0.16)
actiontext (7.2.0)
actionpack (= 7.2.0)
activerecord (= 7.2.0)
activestorage (= 7.2.0)
activesupport (= 7.2.0)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.3.4)
activesupport (= 7.1.3.4)
actionview (7.2.0)
activesupport (= 7.2.0)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
active_decorator (1.4.1)
activesupport
activejob (7.1.3.4)
activesupport (= 7.1.3.4)
activejob (7.2.0)
activesupport (= 7.2.0)
globalid (>= 0.3.6)
activemodel (7.1.3.4)
activesupport (= 7.1.3.4)
activerecord (7.1.3.4)
activemodel (= 7.1.3.4)
activesupport (= 7.1.3.4)
activemodel (7.2.0)
activesupport (= 7.2.0)
activerecord (7.2.0)
activemodel (= 7.2.0)
activesupport (= 7.2.0)
timeout (>= 0.4.0)
activestorage (7.1.3.4)
actionpack (= 7.1.3.4)
activejob (= 7.1.3.4)
activerecord (= 7.1.3.4)
activesupport (= 7.1.3.4)
activestorage (7.2.0)
actionpack (= 7.2.0)
activejob (= 7.2.0)
activerecord (= 7.2.0)
activesupport (= 7.2.0)
marcel (~> 1.0)
activesupport (7.1.3.4)
activesupport (7.2.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
aes_key_wrap (1.1.0)
Expand Down Expand Up @@ -124,7 +120,7 @@ GEM
chronic (0.10.2)
cmdparse (3.0.7)
coderay (1.1.3)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
content_disposition (1.0.0)
crack (1.0.0)
Expand Down Expand Up @@ -251,7 +247,7 @@ GEM
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.7.2)
irb (1.13.2)
irb (1.14.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jbuilder (2.12.0)
Expand All @@ -272,6 +268,7 @@ GEM
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.0)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -285,16 +282,15 @@ GEM
matrix (0.4.2)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.23.1)
minitest (5.24.1)
msgpack (1.7.2)
multi_test (1.1.0)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
mutex_m (0.2.0)
nenv (0.3.0)
net-http (0.4.1)
uri
net-imap (0.4.13)
net-imap (0.4.14)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -307,11 +303,11 @@ GEM
net-protocol
net-ssh (7.2.3)
nio4r (2.7.3)
nokogiri (1.16.6-aarch64-linux)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.6-arm64-darwin)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)
Expand Down Expand Up @@ -365,7 +361,7 @@ GEM
public_suffix (5.1.1)
puma (6.4.2)
nio4r (~> 2.0)
racc (1.8.0)
racc (1.8.1)
rack (3.1.7)
rack-mini-profiler (3.3.1)
rack (>= 1.2.0)
Expand All @@ -386,20 +382,20 @@ GEM
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (7.1.3.4)
actioncable (= 7.1.3.4)
actionmailbox (= 7.1.3.4)
actionmailer (= 7.1.3.4)
actionpack (= 7.1.3.4)
actiontext (= 7.1.3.4)
actionview (= 7.1.3.4)
activejob (= 7.1.3.4)
activemodel (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
rails (7.2.0)
actioncable (= 7.2.0)
actionmailbox (= 7.2.0)
actionmailer (= 7.2.0)
actionpack (= 7.2.0)
actiontext (= 7.2.0)
actionview (= 7.2.0)
activejob (= 7.2.0)
activemodel (= 7.2.0)
activerecord (= 7.2.0)
activestorage (= 7.2.0)
activesupport (= 7.2.0)
bundler (>= 1.15.0)
railties (= 7.1.3.4)
railties (= 7.2.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -411,10 +407,10 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.3.4)
actionpack (= 7.1.3.4)
activesupport (= 7.1.3.4)
irb
railties (7.2.0)
actionpack (= 7.2.0)
activesupport (= 7.2.0)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
Expand Down Expand Up @@ -490,6 +486,7 @@ GEM
scenic (1.8.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
securerandom (0.3.1)
sentry-rails (5.17.3)
railties (>= 5.0)
sentry-ruby (~> 5.17.3)
Expand Down Expand Up @@ -549,6 +546,7 @@ GEM
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
uri (0.13.0)
useragent (0.16.10)
validate_url (1.0.15)
activemodel (>= 3.0.0)
public_suffix
Expand Down Expand Up @@ -580,7 +578,7 @@ GEM
chronic (>= 0.6.3)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.16)
zeitwerk (2.6.17)
zip_tricks (4.8.3)
zipline (1.6.0)
actionpack (>= 6.0, < 8.0)
Expand Down
37 changes: 36 additions & 1 deletion app/controllers/pfmps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PfmpsController < ApplicationController
include PfmpResource

before_action :check_director, :update_confirmed_director!, :check_confirmed_director,
only: %i[validate]
only: %i[validate rectify]

before_action :set_classe, :set_schooling
before_action :set_pfmp_breadcrumbs, except: :confirm_deletion
Expand Down Expand Up @@ -62,6 +62,30 @@ def confirm_deletion
redirect_to student_path(@schooling.student)
end

def confirm_rectification
if @pfmp.can_transition_to?(:rectified)
@student = @pfmp.student
render :confirm_rectification
else
redirect_to school_year_class_schooling_pfmp_path(selected_school_year, @classe, @schooling, @pfmp),
alert: t("flash.pfmps.cannot_rectify")
end
end

def rectify
if @pfmp.can_transition_to?(:rectified)
@student = @pfmp.student
PfmpManager.new(@pfmp).rectify_and_update_attributes!(pfmp_params, address_params)
redirect_to school_year_class_schooling_pfmp_path(selected_school_year, @classe, @schooling, @pfmp),
notice: t("flash.pfmps.rectified")
else
redirect_to school_year_class_schooling_pfmp_path(selected_school_year, @classe, @schooling, @pfmp),
alert: t("flash.pfmps.cannot_rectify")
end
rescue ActiveRecord::RecordInvalid
render :confirm_rectification, status: :unprocessable_entity
end

def destroy
if @pfmp.destroy
redirect_to student_path(@schooling.student),
Expand All @@ -74,6 +98,17 @@ def destroy

private

def address_params
params.require(:pfmp).permit(
:address_line1,
:address_line2,
:address_postal_code,
:address_city,
:address_city_insee_code,
:address_country_code
)
end

def pfmp_params
params.require(:pfmp).permit(
:start_date,
Expand Down
3 changes: 2 additions & 1 deletion app/decorators/pfmp_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module PfmpDecorator
PFMP_STATE_MAPPING = {
pending: :new,
completed: :info,
validated: :success
validated: :success,
rectified: :error
}.freeze

def status_badge
Expand Down
Loading

0 comments on commit 6dcfc34

Please sign in to comment.