Skip to content

Commit

Permalink
Merge pull request #10862 from colinux/fix-sva-with-complex-pending-c…
Browse files Browse the repository at this point in the history
…orrections

ETQ usager: corrige la date prévisionnelle SVA lorsqu'il y a un mélange de demandes de corrections résolues et en attente
  • Loading branch information
colinux authored Sep 24, 2024
2 parents 99534ef + b50d42f commit f700024
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/sva_svr_decision_date_calculator_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def latest_incomplete_correction_date
end

def latest_correction_date
correction_date dossier.corrections.max_by(&:resolved_at)
correction_date dossier.corrections.max_by { _1.resolved_at || Time.current }
end

def calculate_correction_delay(start_date)
Expand Down
14 changes: 14 additions & 0 deletions spec/services/sva_svr_decision_date_calculator_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@
it 'calculates the date based on SVA rules from the last resolved date' do
expect(subject).to eq(Date.new(2023, 7, 26))
end

context 'and a pending correction' do
before do
travel_to Time.zone.local(2023, 5, 30, 18) do
dossier.flag_as_pending_correction!(build(:commentaire, dossier:))
end

travel_to Time.zone.local(2023, 6, 5, 8)
end

it 'calculates the date, like if resolution will be today and delay restarted' do
expect(subject).to eq(Date.new(2023, 8, 6))
end
end
end

context 'there is a pending correction' do
Expand Down

0 comments on commit f700024

Please sign in to comment.