Skip to content

Commit

Permalink
SeanC/APPEALS-5034 Decided non-comp issues are not getting closed as …
Browse files Browse the repository at this point in the history
…decided (#20126)

* added basic code to meet ac

* updated code in decsion reveiw task

* updated code to set the completed_by as well

* started refactoring handle_issues_with_no_decision_date!

* refactored function to reduce cyclomatic complexity

* fixed a code climate issue

* attempting to fix a code climate issue

* moved handle_issues_with_no_decision_date! to decision_review to fix code climate issue

* Empty-Commit

* put function back

* fixed the failing tests in decision_review_task_spec

* Added _current_user to complete_with_payload in business_line_task

* fixed a test in board_grant_effectuation_task_spec

* created a new def in request_issues for active or decided

* added the new def to the serializer

* changed the name of activeRequestIssues to activeOrDecidedRequestIssues

* updated business_line_task to set completed_by for board grants

* added basic code to meet ac

* updated code in decsion reveiw task

* updated code to set the completed_by as well

* started refactoring handle_issues_with_no_decision_date!

* refactored function to reduce cyclomatic complexity

* fixed a code climate issue

* attempting to fix a code climate issue

* moved handle_issues_with_no_decision_date! to decision_review to fix code climate issue

* Empty-Commit

* put function back

* fixed the failing tests in decision_review_task_spec

* Added _current_user to complete_with_payload in business_line_task

* fixed a test in board_grant_effectuation_task_spec

* created a new def in request_issues for active or decided

* added the new def to the serializer

* changed the name of activeRequestIssues to activeOrDecidedRequestIssues

* updated business_line_task to set completed_by for board grants

* addressing first comment from review

* addressed the second comment of review
  • Loading branch information
seancva authored Dec 21, 2023
1 parent 49659eb commit 2f46c05
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 35 deletions.
2 changes: 1 addition & 1 deletion app/controllers/decision_reviews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def show

def update
if task
if task.complete_with_payload!(decision_issue_params, decision_date)
if task.complete_with_payload!(decision_issue_params, decision_date, current_user)
business_line.tasks.reload
render json: { task_filter_details: task_filter_details }, status: :ok
else
Expand Down
6 changes: 4 additions & 2 deletions app/models/claim_review.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ def handle_issues_with_no_decision_date!
# Guard clause to only perform this update for VHA claim reviews for now
return nil if benefit_type != "vha"

review_task = tasks.find { |task| task.is_a?(DecisionReviewTask) }

return nil unless review_task&.open?

if request_issues_without_decision_dates?
review_task = tasks.find { |task| task.is_a?(DecisionReviewTask) }
review_task&.on_hold!
elsif !request_issues_without_decision_dates?
review_task = tasks.find { |task| task.is_a?(DecisionReviewTask) }
review_task&.assigned!
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/business_line_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
module BusinessLineTask
extend ActiveSupport::Concern

def complete_with_payload!(_decision_issue_params, _decision_date)
def complete_with_payload!(_decision_issue_params, _decision_date, user)
return false unless validate_task

update!(status: Constants.TASK_STATUSES.completed, closed_at: Time.zone.now)
update!(status: Constants.TASK_STATUSES.completed, closed_at: Time.zone.now, completed_by: user)
end

private
Expand Down
4 changes: 4 additions & 0 deletions app/models/request_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ def active_or_ineligible_or_withdrawn
active_or_ineligible.or(withdrawn)
end

def active_or_decided
active.or(decided).order(id: :asc)
end

def active_or_decided_or_withdrawn
active.or(decided).or(withdrawn).order(id: :asc)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def self.representative_tz(object)
uuid: decision_review(object).uuid,
isLegacyAppeal: false,
issueCount: issue_count(object),
activeRequestIssues: skip_acquiring_request_issues || request_issues(object).active.map(&:serialize),
activeOrDecidedRequestIssues:
skip_acquiring_request_issues || request_issues(object).active_or_decided.map(&:serialize),
appellant_type: decision_review(object).claimant&.type
}
end
Expand Down
7 changes: 5 additions & 2 deletions app/models/tasks/decision_review_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ def ui_hash
serialize_task[:attributes]
end

def complete_with_payload!(decision_issue_params, decision_date)
def complete_with_payload!(decision_issue_params, decision_date, user)
return false unless validate_task(decision_issue_params)

transaction do
appeal.create_decision_issues_for_tasks(decision_issue_params, decision_date)
update!(status: Constants.TASK_STATUSES.completed, closed_at: Time.zone.now)
update!(status: Constants.TASK_STATUSES.completed, closed_at: Time.zone.now, completed_by: user)
decision_issue_params.each do |param|
RequestIssue.find(param[:request_issue_id]).close_decided_issue!
end
end

appeal.on_decision_issues_sync_processed if appeal.is_a?(HigherLevelReview)
Expand Down
28 changes: 14 additions & 14 deletions client/.storybook/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
"id": "6115",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Caregiver | Eligibility",
Expand Down Expand Up @@ -41,7 +41,7 @@ module.exports = {
"id": "6114",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Initial Eligibility and Enrollment in VHA Healthcare",
Expand Down Expand Up @@ -70,7 +70,7 @@ module.exports = {
"id": "17",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Initial Eligibility and Enrollment in VHA Healthcare",
Expand Down Expand Up @@ -99,7 +99,7 @@ module.exports = {
"id": "3f67e4b2-392b-4248-a722-0845b2d3a29e",
"isLegacyAppeal": false,
"issueCount": 0,
"activeRequestIssues": 0
"activeOrDecidedRequestIssues": 0
},
"issue_count": 0,
"issue_types": "",
Expand Down Expand Up @@ -128,7 +128,7 @@ module.exports = {
"id": "14",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Caregiver | Revocation/Discharge",
Expand Down Expand Up @@ -157,7 +157,7 @@ module.exports = {
"id": "13",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Initial Eligibility and Enrollment in VHA Healthcare",
Expand Down Expand Up @@ -186,7 +186,7 @@ module.exports = {
"id": "5061",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Initial Eligibility and Enrollment in VHA Healthcare",
Expand Down Expand Up @@ -243,7 +243,7 @@ module.exports = {
"id": "5105",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Foreign Medical Program",
Expand Down Expand Up @@ -272,7 +272,7 @@ module.exports = {
"id": "5096",
"isLegacyAppeal": false,
"issueCount": 2,
"activeRequestIssues": 2
"activeOrDecidedRequestIssues": 2
},
"issue_count": 2,
"issue_types": "Foreign Medical Program,Spina Bifida Treatment (Non-Compensation)",
Expand Down Expand Up @@ -301,7 +301,7 @@ module.exports = {
"id": "5083",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Spina Bifida Treatment (Non-Compensation)",
Expand Down Expand Up @@ -330,7 +330,7 @@ module.exports = {
"id": "5081",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Camp Lejune Family Member",
Expand Down Expand Up @@ -359,7 +359,7 @@ module.exports = {
"id": "5106",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Camp Lejune Family Member",
Expand Down Expand Up @@ -388,7 +388,7 @@ module.exports = {
"id": "5101",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Other",
Expand Down Expand Up @@ -417,7 +417,7 @@ module.exports = {
"id": "5094",
"isLegacyAppeal": false,
"issueCount": 1,
"activeRequestIssues": 1
"activeOrDecidedRequestIssues": 1
},
"issue_count": 1,
"issue_types": "Caregiver | Other",
Expand Down
2 changes: 1 addition & 1 deletion client/app/nonComp/components/Disposition.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class NonCompDispositions extends React.PureComponent {

this.state = {
requestIssues: formatRequestIssuesWithDecisionIssues(
this.props.task.appeal.activeRequestIssues, this.props.appeal.decisionIssues),
this.props.task.appeal.activeOrDecidedRequestIssues, this.props.appeal.decisionIssues),
decisionDate: '',
isFilledOut: false
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const completedHLRTaskData = {
id: '17',
isLegacyAppeal: false,
issueCount: 1,
activeRequestIssues: [
activeOrDecidedRequestIssues: [
{
id: 3710,
rating_issue_reference_id: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
id: appeal.external_id,
isLegacyAppeal: false,
issueCount: 0,
activeRequestIssues: [],
activeOrDecidedRequestIssues: [],
uuid: appeal.uuid,
appellant_type: appeal.claimant.type
},
Expand Down Expand Up @@ -75,7 +75,7 @@
id: appeal.external_id,
isLegacyAppeal: false,
issueCount: 0,
activeRequestIssues: [],
activeOrDecidedRequestIssues: [],
uuid: appeal.uuid,
appellant_type: appeal.claimant.type
},
Expand Down Expand Up @@ -134,7 +134,7 @@
id: appeal.external_id,
isLegacyAppeal: false,
issueCount: 0,
activeRequestIssues: [],
activeOrDecidedRequestIssues: [],
uuid: appeal.uuid,
appellant_type: appeal.claimant.type
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
id: hlr.id.to_s,
isLegacyAppeal: false,
issueCount: 0,
activeRequestIssues: [],
activeOrDecidedRequestIssues: [],
uuid: task.appeal.uuid,
appellant_type: "VeteranClaimant"
},
Expand Down Expand Up @@ -76,7 +76,7 @@
id: hlr.id.to_s,
isLegacyAppeal: false,
issueCount: 0,
activeRequestIssues: [],
activeOrDecidedRequestIssues: [],
uuid: task.appeal.uuid,
appellant_type: nil
},
Expand Down Expand Up @@ -128,7 +128,7 @@
id: hlr.id.to_s,
isLegacyAppeal: false,
issueCount: 0,
activeRequestIssues: [],
activeOrDecidedRequestIssues: [],
uuid: task.appeal.uuid,
appellant_type: claimant.type
},
Expand Down Expand Up @@ -192,7 +192,7 @@
id: hlr.id.to_s,
isLegacyAppeal: false,
issueCount: 2,
activeRequestIssues: serialized_issues,
activeOrDecidedRequestIssues: serialized_issues,
appellant_type: "VeteranClaimant",
uuid: task.appeal.uuid
},
Expand Down
2 changes: 1 addition & 1 deletion spec/models/tasks/board_grant_effectuation_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
end

describe "#complete_with_payload!" do
subject { task.complete_with_payload!(nil, nil) }
subject { task.complete_with_payload!(nil, nil, nil) }

context "assigned task" do
it "can be completed" do
Expand Down
10 changes: 7 additions & 3 deletions spec/models/tasks/decision_review_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

let(:benefit_type) { "education" }

let(:user) { create(:default_user) }

describe "#label" do
subject { create(:higher_level_review_task) }

Expand Down Expand Up @@ -60,7 +62,7 @@
]
end
let(:task) { create(:higher_level_review_task, trait, appeal: hlr) }
subject { task.complete_with_payload!(decision_issue_params, decision_date) }
subject { task.complete_with_payload!(decision_issue_params, decision_date, user) }

context "assigned task" do
it "can be completed" do
Expand All @@ -85,6 +87,8 @@
caseflow_decision_date: caseflow_decision_date
)).to_not be_nil
expect(task.status).to eq "completed"
expect(task.completed_by_id).to eq user.id
expect(task.appeal.request_issues.first.closed_status).to eq "decided"

remand_sc = hlr.remand_supplemental_claims.first
expect(remand_sc).to_not be_nil
Expand Down Expand Up @@ -123,7 +127,7 @@
id: hlr.id.to_s,
isLegacyAppeal: false,
issueCount: 0,
activeRequestIssues: [],
activeOrDecidedRequestIssues: [],
appellant_type: "VeteranClaimant",
uuid: hlr.uuid
},
Expand Down Expand Up @@ -167,7 +171,7 @@
id: hlr.id.to_s,
isLegacyAppeal: false,
issueCount: 0,
activeRequestIssues: [],
activeOrDecidedRequestIssues: [],
uuid: hlr.uuid,
appellant_type: "VeteranClaimant"
},
Expand Down

0 comments on commit 2f46c05

Please sign in to comment.