fix(sva): compute decision date from the day after deposit or resolution
This commit is contained in:
parent
b4e6c20bbd
commit
f369775d5b
3 changed files with 16 additions and 16 deletions
|
@ -14,7 +14,7 @@ class SVASVRDecisionDateCalculatorService
|
||||||
def decision_date
|
def decision_date
|
||||||
duration = calculate_duration
|
duration = calculate_duration
|
||||||
|
|
||||||
start_date = determine_start_date
|
start_date = determine_start_date + 1.day
|
||||||
correction_delay = calculate_correction_delay(start_date)
|
correction_delay = calculate_correction_delay(start_date)
|
||||||
|
|
||||||
start_date + correction_delay + duration
|
start_date + correction_delay + duration
|
||||||
|
@ -54,7 +54,7 @@ class SVASVRDecisionDateCalculatorService
|
||||||
resolved_date = correction_date(correction)
|
resolved_date = correction_date(correction)
|
||||||
next 0 unless resolved_date > start_date
|
next 0 unless resolved_date > start_date
|
||||||
|
|
||||||
(resolved_date - correction.created_at.to_date).days
|
(resolved_date + 1.day - correction.created_at.to_date).days # restart from next day after resolution
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1125,7 +1125,7 @@ describe Dossier, type: :model do
|
||||||
|
|
||||||
it 'passes dossier en instruction' do
|
it 'passes dossier en instruction' do
|
||||||
expect(subject.followers_instructeurs).not_to include(instructeur)
|
expect(subject.followers_instructeurs).not_to include(instructeur)
|
||||||
expect(subject.sva_svr_decision_on).to eq(2.months.from_now.to_date)
|
expect(subject.sva_svr_decision_on).to eq(2.months.from_now.to_date + 1.day)
|
||||||
expect(last_operation.operation).to eq('passer_en_instruction')
|
expect(last_operation.operation).to eq('passer_en_instruction')
|
||||||
expect(last_operation.automatic_operation?).to be_truthy
|
expect(last_operation.automatic_operation?).to be_truthy
|
||||||
expect(operation_serialized['operation']).to eq('passer_en_instruction')
|
expect(operation_serialized['operation']).to eq('passer_en_instruction')
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
let(:config) { { decision: :sva, period: 2, unit: :months, resume: :continue } }
|
let(:config) { { decision: :sva, period: 2, unit: :months, resume: :continue } }
|
||||||
|
|
||||||
it 'calculates the date based on SVA rules' do
|
it 'calculates the date based on SVA rules' do
|
||||||
expect(subject).to eq(Date.new(2023, 7, 15))
|
expect(subject).to eq(Date.new(2023, 7, 16))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
let(:config) { { decision: :sva, period: 30, unit: :days, resume: :continue } }
|
let(:config) { { decision: :sva, period: 30, unit: :days, resume: :continue } }
|
||||||
|
|
||||||
it 'calculates the date based on SVA rules' do
|
it 'calculates the date based on SVA rules' do
|
||||||
expect(subject).to eq(Date.new(2023, 6, 14))
|
expect(subject).to eq(Date.new(2023, 6, 15))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
let(:config) { { decision: :sva, period: 8, unit: :weeks, resume: :continue } }
|
let(:config) { { decision: :sva, period: 8, unit: :weeks, resume: :continue } }
|
||||||
|
|
||||||
it 'calculates the date based on SVA rules' do
|
it 'calculates the date based on SVA rules' do
|
||||||
expect(subject).to eq(Date.new(2023, 7, 10))
|
expect(subject).to eq(Date.new(2023, 7, 11))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates the date based on SVA rules with correction delay' do
|
it 'calculates the date based on SVA rules with correction delay' do
|
||||||
expect(subject).to eq(Date.new(2023, 7, 20))
|
expect(subject).to eq(Date.new(2023, 7, 22))
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when there are multiple corrections' do
|
context 'when there are multiple corrections' do
|
||||||
|
@ -55,7 +55,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates the date based on SVA rules with all correction delays' do
|
it 'calculates the date based on SVA rules with all correction delays' do
|
||||||
expect(subject).to eq(Date.new(2023, 7, 24))
|
expect(subject).to eq(Date.new(2023, 7, 27))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
dossier.flag_as_pending_correction!(build(:commentaire, dossier:))
|
dossier.flag_as_pending_correction!(build(:commentaire, dossier:))
|
||||||
end
|
end
|
||||||
|
|
||||||
travel_to DateTime.new(2023, 6, 5, 8) # 6 days elapsed
|
travel_to DateTime.new(2023, 6, 5, 8) # 6 days elapsed, restart 1 day after resolved
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates the date, like if resolution will be today' do
|
it 'calculates the date, like if resolution will be today' do
|
||||||
expect(subject).to eq(Date.new(2023, 7, 26))
|
expect(subject).to eq(Date.new(2023, 7, 29))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates the date, like if resolution will be today' do
|
it 'calculates the date, like if resolution will be today' do
|
||||||
expect(subject).to eq(Date.new(2023, 8, 5))
|
expect(subject).to eq(Date.new(2023, 8, 6))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates the date by resetting delay' do
|
it 'calculates the date by resetting delay' do
|
||||||
expect(subject).to eq(Date.new(2023, 7, 25))
|
expect(subject).to eq(Date.new(2023, 7, 26))
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when there are multiple corrections' do
|
context 'when there are multiple corrections' do
|
||||||
|
@ -106,7 +106,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates the date based on SVA rules with all correction delays' do
|
it 'calculates the date based on SVA rules with all correction delays' do
|
||||||
expect(subject).to eq(Date.new(2023, 7, 29))
|
expect(subject).to eq(Date.new(2023, 7, 31))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -118,7 +118,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
|
|
||||||
context 'there is no correction' do
|
context 'there is no correction' do
|
||||||
it 'calculates the date based on deposed_at' do
|
it 'calculates the date based on deposed_at' do
|
||||||
expect(subject).to eq(Date.new(2023, 7, 15))
|
expect(subject).to eq(Date.new(2023, 7, 16))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
end
|
end
|
||||||
|
|
||||||
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, 25))
|
expect(subject).to eq(Date.new(2023, 7, 26))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates the date, like if resolution will be today and delay restarted' do
|
it 'calculates the date, like if resolution will be today and delay restarted' do
|
||||||
expect(subject).to eq(Date.new(2023, 8, 5))
|
expect(subject).to eq(Date.new(2023, 8, 6))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue