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:
commit
f700024df0
2 changed files with 15 additions and 1 deletions
|
@ -59,7 +59,7 @@ class SVASVRDecisionDateCalculatorService
|
||||||
end
|
end
|
||||||
|
|
||||||
def latest_correction_date
|
def latest_correction_date
|
||||||
correction_date dossier.corrections.max_by(&:resolved_at)
|
correction_date dossier.corrections.max_by { _1.resolved_at || Time.current }
|
||||||
end
|
end
|
||||||
|
|
||||||
def calculate_correction_delay(start_date)
|
def calculate_correction_delay(start_date)
|
||||||
|
|
|
@ -139,6 +139,20 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
it 'calculates the date based on SVA rules from the last resolved date' do
|
it 'calculates the date based on SVA rules from the last resolved date' do
|
||||||
expect(subject).to eq(Date.new(2023, 7, 26))
|
expect(subject).to eq(Date.new(2023, 7, 26))
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'there is a pending correction' do
|
context 'there is a pending correction' do
|
||||||
|
|
Loading…
Reference in a new issue