Skip to content

Commit

Permalink
Bugfixes (#1132)
Browse files Browse the repository at this point in the history
  • Loading branch information
pskl authored Oct 7, 2024
1 parent ce2beee commit dc8e5cc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
5 changes: 5 additions & 0 deletions app/models/asp/payment_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def to_consider
end
end

# XXX: Some records dont have a rib attached (yet)
def rib_with_fallback
rib || student.rib(pfmp.establishment)
end

def mark_ready!
transition_to!(:ready)
rescue ASP::Errors::IncompletePaymentRequestError
Expand Down
2 changes: 1 addition & 1 deletion app/models/asp/payment_request_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def student
end

def rib
@rib ||= payment_request.rib || student.rib
@rib ||= payment_request.rib_with_fallback
end

def pfmp
Expand Down
2 changes: 1 addition & 1 deletion app/models/pfmp_state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PfmpStateMachine
end

guard_transition(to: :rectified) do |pfmp|
pfmp.latest_payment_request.in_state?(:paid)
pfmp.latest_payment_request&.in_state?(:paid)
end

after_transition(to: :rectified) do |pfmp|
Expand Down
2 changes: 1 addition & 1 deletion app/services/asp/mappers/coord_paie_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CoordPaieMapper
attr_reader :rib, :iban

def initialize(payment_request)
@rib = payment_request.rib || payment_request.student.rib
@rib = payment_request.rib_with_fallback
@iban = Bank::IBAN.new(rib.iban)
end

Expand Down
9 changes: 5 additions & 4 deletions app/views/asp/schoolings/_schooling.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,23 @@
%table
%caption.fr-h2 Coordonnées bancaires
%tbody
- rib = @schooling.student.rib(@schooling.establishment)
- if @schooling.student.rib.blank?
%tr
%td Pas de coordonnées bancaires renseignées
- else
%tr
%td Nom du RIB
%td= @schooling.student.rib.name
%td= rib.name
%tr
%td IBAN
%td= @schooling.student.rib.iban
%td= rib.iban
%tr
%td BIC
%td= @schooling.student.rib.bic
%td= rib.bic
%tr
%td RIB appartient à l'élève ?
%td= @schooling.student.rib.personal? ? "Oui" : "Non"
%td= rib.personal? ? "Oui" : "Non"

%h2 Demandes de paiements
- if @pfmps.blank?
Expand Down
2 changes: 1 addition & 1 deletion app/views/pfmps/confirm_rectification.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
%td= number_to_currency(last_paid_request.pfmp.amount, unit: "", format: "%n %u")
%tr
%th{scope: "row"} IBAN
%td= last_paid_request.rib&.iban || @student.rib(current_establishment).iban
%td= last_paid_request.rib_with_fallback&.iban
- else
%tr
%td{colspan: 2} Aucun paiement effectué
Expand Down
7 changes: 4 additions & 3 deletions app/views/ribs/confirm_deletion.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
= dsfr_alert(type: :warning, title: "La suppression des coordonnées bancaires est irréversible")

.fr-col-md-6.fr-mt-3w
- rib = @student.rib(current_establishment)
%ul
%li
Titulaire :
%span= @student.rib.name
%span= rib.name
%li
IBAN :
%code= @student.rib.iban
%code= rib.iban
%li
BIC :
%code= @student.rib.bic
%code= rib.bic

.fr-btns-group.fr-btns-group--inline.fr-mt-3w
= link_to "Annuler", student_path(@student), class: 'fr-btn fr-btn--secondary'
Expand Down

0 comments on commit dc8e5cc

Please sign in to comment.