Merge pull request #10862 from colinux/fix-sva-with-complex-pending-corrections

ETQ usager: corrige la date prévisionnelle SVA lorsqu'il y a un mélange de demandes de corrections résolues et en attente
This commit is contained in:
Colin Darie 2024-09-24 12:35:26 +00:00 committed by GitHub
commit f700024df0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -59,7 +59,7 @@ class SVASVRDecisionDateCalculatorService
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)

View file

@ -139,6 +139,20 @@ describe SVASVRDecisionDateCalculatorService do
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