Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Vacated Decision Issues from Request Issues #13173

Merged
merged 41 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
38b1d58
added basic support for creating request issues from selected MTV dec…
Dec 18, 2019
8d5c8f3
only create request issues if disposition is grant type
Dec 18, 2019
83d41bc
Merge branch 'master' into jc/12373-mtv-create-request-issues
Dec 20, 2019
1f4cea5
moved creation of request issues to PostDecisionMotion model;
Dec 20, 2019
a9470c4
Merge branch 'master' into jc/12373-mtv-create-request-issues
Dec 20, 2019
29af3f7
adjustments to post_decision_motion_updater_spec to allow tests re in…
Dec 20, 2019
63ba17f
linting
Dec 20, 2019
c3a5296
we now save all MTV issue IDs for "granted" disposition
Dec 23, 2019
c4488d2
Merge branch 'master' into jc/12373-mtv-create-request-issues
Dec 23, 2019
80cf6b8
we now add all decision issue IDs for full grant in PostDecisionMotio…
Dec 24, 2019
b55570f
added test for PostDecisionMotionUpdater adding all vacated_decision_…
Dec 24, 2019
84e4cac
linting
Dec 24, 2019
18451dc
updated schema to indicate addtl usage of vacated_decision_issue_ids …
Jan 2, 2020
84140b9
better logic for populating vacated_decision_issue_ids field in PostD…
Jan 2, 2020
4707bfc
fixed wrong naming in disposition check in PostDecisionMotionUpdater
Jan 2, 2020
9d6fce1
Merge branch 'master' into jc/12373-mtv-create-request-issues
Jan 4, 2020
504fc81
removed superfluous commented line
Jan 4, 2020
c0b14b8
moved logic for creating request issue from decision issue to Decisio…
Jan 6, 2020
ae016df
began adding new_decision_issue_from! method to RequestIssue
Jan 8, 2020
99fcccb
Merge branch 'master' into jc/13069-mtv-create-decision-issues
Jan 14, 2020
dc869f3
updated method name in RequestIssue to "create_vacated_decision_issue!"
Jan 16, 2020
9c4536f
added code & tests for generating vacated decision issues from PostDe…
Jan 16, 2020
425cdf9
adjustments per codeclimate
Jan 16, 2020
b98d0c5
Merge branch 'master' into jc/13069-mtv-create-decision-issues
Jan 18, 2020
fb34f9d
Merge branch 'master' into jc/13069-mtv-create-decision-issues
Jan 18, 2020
f684246
updated various items in DecisionIssue, RequestIssue, & PostDecisionM…
Jan 21, 2020
a26e0c9
Merge branch 'master' into jc/13069-mtv-create-decision-issues
Jan 21, 2020
ea02577
fixed error in MTV test
Jan 21, 2020
74679be
Merge branch 'master' into jc/13069-mtv-create-decision-issues
Jan 21, 2020
7d01a8b
began adding PostDecisionMotionController.create_issues endpoint & tests
Jan 21, 2020
1e2baaa
added "create_issues" endpoint on PostDecisionMotionsController:
Jan 22, 2020
8e78862
linting
Jan 22, 2020
cb160e0
removed mistaken commit of modified capybara.rb
jcq Jan 22, 2020
be25dff
DecisionIssue.create_contesting_request_issue now adds new request is…
Feb 5, 2020
ae0395c
Merge branch 'master' into jc/13069-mtv-create-decision-issues
Feb 7, 2020
b9ee9a6
moved calls to create new request & decision issues to PostDecisionMo…
Feb 7, 2020
c376303
removed create_issues & related from PostDecisionMotionsController
Feb 7, 2020
ba135f4
updated tests in post_decision_motion_spec
Feb 7, 2020
5d84d90
removed tests for PostDecisionMotionsController.create_tasks
Feb 7, 2020
583d3de
removed unsed route for create_issues off of PostDecisionMotionsContr…
Feb 7, 2020
0d24049
Merge branch 'master' into jc/13069-mtv-create-decision-issues
Feb 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/controllers/post_decision_motions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class PostDecisionMotionsController < ApplicationController
before_action :verify_task_access
before_action :verify_task_access, only: [:create, :return_to_lit_support]

def create
motion_updater = PostDecisionMotionUpdater.new(task, motion_params)
Expand Down Expand Up @@ -40,4 +40,8 @@ def task
def motion_params
params.permit(:disposition, :task_id, :vacate_type, :instructions, :assigned_to_id, vacated_decision_issue_ids: [])
end

def post_decision_motion
PostDecisionMotion.find(motion_id)
end
end
5 changes: 3 additions & 2 deletions app/models/decision_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ def associated_request_issue
end

def create_contesting_request_issue!
RequestIssue.create!(
decision_review: decision_review,
vacate_appeal_stream = Appeal.find_by(stream_type: "vacate", stream_docket_number: decision_review.docket_number)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good for now, we'll probably update it in Sandra's ticket to pass in the decision review so it can be used for De Novo's too.

RequestIssue.find_or_create_by!(
decision_review: vacate_appeal_stream,
decision_review_type: decision_review_type,
contested_decision_issue_id: id,
contested_rating_issue_reference_id: rating_issue_reference_id,
Expand Down
18 changes: 15 additions & 3 deletions app/models/post_decision_motion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,26 @@ class PostDecisionMotion < ApplicationRecord
vacate_and_de_novo: "vacate_and_de_novo"
}

def vacated_issues
def decision_issues_for_vacatur
return [] unless vacated_decision_issue_ids

DecisionIssue.find(vacated_decision_issue_ids)
end

def create_request_issues_for_vacature
vacated_issues.map(&:create_contesting_request_issue!)
def request_issues_for_vacatur
@request_issues_for_vacatur ||= RequestIssue.where(contested_decision_issue_id: vacated_decision_issue_ids)
end

def create_request_issues_for_vacatur
decision_issues_for_vacatur.map(&:create_contesting_request_issue!)
end

def vacated_decision_issues
@vacated_decision_issues ||= request_issues_for_vacatur.map { |ri| ri.decision_issues.first }
end

def create_vacated_decision_issues
request_issues_for_vacatur.map(&:create_vacated_decision_issue!)
end

private
Expand Down
12 changes: 12 additions & 0 deletions app/models/request_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,18 @@ def create_decision_issue_from_params(decision_issue_param)
)
end

def create_vacated_decision_issue!
decision_issues.find_or_create_by!(
decision_review: decision_review,
jcq marked this conversation as resolved.
Show resolved Hide resolved
decision_review_type: decision_review_type,
disposition: "vacated",
description: "The decision: #{description} has been vacated.",
caseflow_decision_date: Time.zone.today,
benefit_type: benefit_type,
participant_id: decision_review.veteran.participant_id
)
end

jcq marked this conversation as resolved.
Show resolved Hide resolved
def requires_record_request_task?
eligible? && !is_unidentified && !benefit_type_requires_payee_code?
end
Expand Down
3 changes: 3 additions & 0 deletions app/workflows/post_decision_motion_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def create_motion
end

motion.save
motion
end

# We create an AbstractMotionToVacateTask as sibling to the JudgeAddressMotionToVacateTask
Expand Down Expand Up @@ -85,6 +86,8 @@ def handle_grant

vacate_stream = appeal.create_stream(:vacate)
create_new_stream_tasks(vacate_stream)
post_decision_motion.create_request_issues_for_vacatur
post_decision_motion.create_vacated_decision_issues
end

def create_abstract_task
Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/post_decision_motions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
let(:judge) { create(:user) }
let(:judge_team) { JudgeTeam.create_for_judge(judge) }

let(:post_decision_motion) { create(:post_decision_motion) }

before do
User.authenticate!(roles: ["System Admin"])
User.stub = judge
Expand Down
21 changes: 19 additions & 2 deletions spec/factories/post_decision_motions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@

FactoryBot.define do
factory :post_decision_motion do
disposition { "MyString" }
task { nil }
task { create(:judge_address_motion_to_vacate_task) }
disposition { "granted" }
vacate_type { "straight_vacate" }

before(:create) do |post_decision_motion|
appeal = post_decision_motion.task.appeal
return unless appeal.reload.decision_issues.empty?

3.times do |idx|
create(
:decision_issue,
:rating,
decision_review: appeal,
disposition: "denied",
description: "Decision issue description #{idx}",
decision_text: "decision issue"
)
end
end
end
end
2 changes: 1 addition & 1 deletion spec/feature/queue/motion_to_vacate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
motion = PostDecisionMotion.find_by(task: judge_address_motion_to_vacate_task)
expect(motion).to_not be_nil
expect(motion.disposition).to eq("partially_granted")
expect(motion.vacated_issues.length).to eq(issues_to_select.length)
expect(motion.decision_issues_for_vacatur.length).to eq(issues_to_select.length)

visit_vacate_stream
end
Expand Down
36 changes: 29 additions & 7 deletions spec/models/post_decision_motion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
end
let(:motions_atty) { create(:user, full_name: "Motions attorney") }
let(:appeal) { create(:appeal) }
let(:vacate_stream) { appeal.create_stream(:vacate) }
let(:orig_decision_issues) do
Array.new(3) do
Array.new(3) do |index|
create(
:decision_issue,
decision_review: appeal,
disposition: "denied"
disposition: "denied",
description: "issue #{index}",
participant_id: appeal.veteran.participant_id
)
end
end
Expand All @@ -41,15 +44,34 @@
lit_support_team.add_user(motions_atty)
end

context "handles creation of request issues" do
context "#create_request_issues_for_vacatur" do
let(:disposition) { "granted" }
let(:vacate_type) { "vacate_and_readjudication" }
subject { post_decision_motion.create_request_issues_for_vacatur }

it "creates a request issue for every selected decision issue" do
expect(appeal.request_issues.length).to eq 0
post_decision_motion.create_request_issues_for_vacature
appeal.reload
expect(appeal.request_issues.length).to eq 3
expect(vacate_stream.request_issues.size).to eq 0
subject
vacate_stream.reload
expect(vacate_stream.request_issues.size).to eq 3
end
end

context "#create_vacated_decision_issues" do
let(:disposition) { "granted" }
let(:vacate_type) { "vacate_and_readjudication" }
subject { post_decision_motion.create_vacated_decision_issues }

before do
vacate_stream.reload
end

it "creates a vacated decision issue for every selected decision issue" do
expect(post_decision_motion.decision_issues_for_vacatur.size).to eq 3
post_decision_motion.create_request_issues_for_vacatur
subject
vacate_stream.reload
expect(vacate_stream.decision_issues.size).to eq 3
end
end
end
22 changes: 19 additions & 3 deletions spec/workflows/post_decision_motion_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
end
let(:motions_atty) { create(:user, full_name: "Motions attorney") }
let(:appeal) { create(:appeal) }
let(:orig_decision_issues) do
let!(:orig_decision_issues) do
Array.new(3) do
create(
:decision_issue,
Expand Down Expand Up @@ -65,6 +65,8 @@
expect(task.reload.status).to eq Constants.TASK_STATUSES.completed
verify_vacate_stream
end

it "should create decision issues on new vacate"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a stray line

end

context "when vacate type is straight vacate" do
Expand All @@ -74,6 +76,7 @@
subject.process
expect(task.reload.status).to eq Constants.TASK_STATUSES.completed
verify_vacate_stream
verify_decision_issues_created
end

it "saves all decision issue IDs for full grant" do
Expand All @@ -92,6 +95,8 @@
subject.process
expect(task.reload.status).to eq Constants.TASK_STATUSES.completed
verify_vacate_stream
verify_vacate_stream
verify_decision_issues_created
end
end

Expand Down Expand Up @@ -217,9 +222,11 @@
end
end

def verify_vacate_stream
vacate_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "vacate")
def vacate_stream
Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "vacate")
end

def verify_vacate_stream
expect(vacate_stream).to_not be_nil
expect(vacate_stream.claimant.participant_id).to eq(appeal.claimant.participant_id)

Expand All @@ -235,4 +242,13 @@ def verify_vacate_stream

expect(attorney_task).to_not be_nil
end

def verify_decision_issues_created
motion = PostDecisionMotion.first
request_issues = vacate_stream.request_issues
expect(request_issues.size).to eq(motion.decision_issues_for_vacatur.size)

decision_issues = vacate_stream.decision_issues
expect(decision_issues.size).to eq(motion.decision_issues_for_vacatur.size)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

end
end