fix(sva): decision date when start date is at end of month and with correction delay
This commit is contained in:
parent
43fb0ac338
commit
bb7673e697
3 changed files with 47 additions and 2 deletions
|
@ -28,7 +28,7 @@ class SVASVRDecisionDateCalculatorService
|
||||||
start_date = determine_start_date + 1.day
|
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 + duration + correction_delay
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -2,6 +2,10 @@ RSpec.describe ProcedureSVASVRProcessDossierJob, type: :job do
|
||||||
include ActiveJob::TestHelper
|
include ActiveJob::TestHelper
|
||||||
include ActiveSupport::Testing::TimeHelpers
|
include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
|
before do
|
||||||
|
travel_to Date.new(2023, 8, 15, 12)
|
||||||
|
end
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :published, :sva, :for_individual) }
|
let(:procedure) { create(:procedure, :published, :sva, :for_individual) }
|
||||||
let!(:dossier) { create(:dossier, :en_instruction, :with_individual, procedure:, depose_at: 2.months.ago - 1.day, sva_svr_decision_on: Date.current) }
|
let!(:dossier) { create(:dossier, :en_instruction, :with_individual, procedure:, depose_at: 2.months.ago - 1.day, sva_svr_decision_on: Date.current) }
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
include ActiveSupport::Testing::TimeHelpers
|
include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, sva_svr: config) }
|
let(:procedure) { create(:procedure, sva_svr: config) }
|
||||||
let(:dossier) { create(:dossier, :en_instruction, procedure:, depose_at: DateTime.new(2023, 5, 15, 12)) }
|
let(:dossier) { create(:dossier, :en_instruction, procedure:, depose_at:) }
|
||||||
|
let(:depose_at) { DateTime.new(2023, 5, 15, 12) }
|
||||||
|
|
||||||
describe '#decision_date' do
|
describe '#decision_date' do
|
||||||
subject { described_class.new(dossier, procedure).decision_date }
|
subject { described_class.new(dossier, procedure).decision_date }
|
||||||
|
@ -152,6 +153,46 @@ describe SVASVRDecisionDateCalculatorService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when dossier is deposed at end of month with correction delay' do
|
||||||
|
let(:config) { { decision: :sva, period: 2, unit: :months, resume: :continue } }
|
||||||
|
|
||||||
|
let!(:correction) do # add 2 days
|
||||||
|
create(:dossier_correction, dossier:, created_at: depose_at + 1.day, resolved_at: depose_at + 2.days)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'start date = 30' do
|
||||||
|
let(:depose_at) { DateTime.new(2023, 6, 29, 12) }
|
||||||
|
|
||||||
|
it 'calculcates the date accordingly' do
|
||||||
|
expect(subject).to eq(Date.new(2023, 9, 1))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'start date = 31' do
|
||||||
|
let(:depose_at) { DateTime.new(2023, 7, 30, 12) }
|
||||||
|
|
||||||
|
it 'calculcates the date accordingly' do
|
||||||
|
expect(subject).to eq(Date.new(2023, 10, 2))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'start date = 1 in month having 31 days' do
|
||||||
|
let(:depose_at) { DateTime.new(2023, 7, 31, 12) }
|
||||||
|
|
||||||
|
it 'calculcates the date accordingly' do
|
||||||
|
expect(subject).to eq(Date.new(2023, 10, 3))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'start date = 1 in month having 30 days' do
|
||||||
|
let(:depose_at) { DateTime.new(2023, 6, 30, 12) }
|
||||||
|
|
||||||
|
it 'calculcates the date accordingly' do
|
||||||
|
expect(subject).to eq(Date.new(2023, 9, 3))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#decision_date_from_today' do
|
describe '#decision_date_from_today' do
|
||||||
|
|
Loading…
Reference in a new issue