Skip to content

Commit

Permalink
Minor fixes (#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
pskl authored Aug 21, 2024
1 parent df08a8a commit 9d64a7f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/schoolings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def set_classe
def retry_eligibile_payment_requests!
@schooling.pfmps.in_state(:validated).each do |pfmp|
payment_request = pfmp.latest_payment_request
payment_request.mark_ready! if payment_request.eligible_for_auto_retry?
payment_request.mark_ready! if payment_request&.eligible_for_auto_retry?
end
end
end
3 changes: 3 additions & 0 deletions app/jobs/poll_payments_server_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def perform
ProcessASPResponseFileJob.perform_later(filename)

ASP::Server.remove_file!(filename: filename)
rescue ASP::Errors::UnmatchedResponseFile => e
Sentry.capture_exception(e)
next
end
end
end
1 change: 1 addition & 0 deletions app/models/pfmp_state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class PfmpStateMachine
transition from: :completed, to: :validated
transition from: :completed, to: :pending
transition from: :validated, to: :rectified
transition from: :rectified, to: :rectified

guard_transition(to: :completed) do |pfmp|
pfmp.day_count.present?
Expand Down
4 changes: 2 additions & 2 deletions app/models/rib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Rib < ApplicationRecord

enum :owner_type, { personal: 0, other_person: 1, moral_person: 2 }

has_one :payment_request, class_name: "ASP::PaymentRequest", dependent: :nullify
has_many :payment_requests, class_name: "ASP::PaymentRequest", dependent: :nullify

validates :iban, :bic, :name, presence: true

Expand Down Expand Up @@ -45,7 +45,7 @@ def archive!
end

def archivable?
payment_request.nil? || payment_request.terminated?
payment_requests.empty? || payment_requests.all?(&:terminated?)
end

def readonly?
Expand Down
1 change: 1 addition & 0 deletions spec/models/rib_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

describe "associations" do
it { is_expected.to belong_to(:student) }
it { is_expected.to have_many(:payment_requests) }
end

describe "validations" do
Expand Down

0 comments on commit 9d64a7f

Please sign in to comment.