Skip to content

Commit

Permalink
# This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

Update BRIEFF.BFHA when hearing disposition is changed

# This is the commit message #2:

Better names
  • Loading branch information
aroltsch committed Aug 1, 2017
1 parent 8419237 commit 335176a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
16 changes: 16 additions & 0 deletions app/mappers/hearing_mapper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module HearingMapper
def self.bfha_vacols_code(hearing_record, case_record)
case hearing_record.hearing_disp
when "H"
return "1" if case_record.bfhr == "1"
return "2" if case_record.bfhr == "2" && case_record.bfdocind != "V"
return "6" if case_record.bfhr == "2" && case_record.bfdocind == "V"
when "P"
nil
when "C"
"5"
else
"5"
end
end
end
10 changes: 9 additions & 1 deletion app/models/vacols/case_hearing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class VACOLS::CaseHearing < VACOLS::Record
self.primary_key = "hearing_pkseq"

has_one :staff, foreign_key: :sattyid, primary_key: :board_member
has_one :brieff, foreign_key: :bfkey, primary_key: :folder_nr
has_one :brieff, foreign_key: :bfkey, primary_key: :folder_nr, class_name: "Case"

HEARING_TYPES = {
V: :video,
Expand Down Expand Up @@ -49,6 +49,8 @@ class VACOLS::CaseHearing < VACOLS::Record
-- an older hearing still awaiting a disposition
}.freeze

after_update :update_hearing_action, if: :hearing_disp_changed?

# :nocov:
class << self
def upcoming_for_judge(vacols_user_id, date_diff: 7.days)
Expand Down Expand Up @@ -105,5 +107,11 @@ def update_hearing!(hearing_info)
update(attrs.merge(mduser: slogid, mdtime: VacolsHelper.local_time_with_utc_timezone))
end
end

private

def update_hearing_action
brieff.update(bfha: HearingMapper.bfha_vacols_code(self, brieff))
end
# :nocov:
end
32 changes: 32 additions & 0 deletions spec/mappers/hearing_mapper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
describe HearingMapper do
context ".bfha_vacols_code" do
let(:hearing) do
OpenStruct.new(
folder_nr: "123C",
hearing_disp: hearing_disp,
)
end

let(:brieff) do
OpenStruct.new(bfhr: bfhr, bfdocind: bfdocind)
end

subject { HearingMapper.bfha_vacols_code(hearing, brieff) }

context "when disposition is held and it is central office hearing" do
let(:hearing_disp) { "H" }
let(:bfhr) { "1" }
let(:bfdocind) { nil }

it { is_expected.to eq "1" }
end

context "when disposition is held and it is video hearing" do
let(:hearing_disp) { "H" }
let(:bfhr) { "2" }
let(:bfdocind) { "V" }

it { is_expected.to eq "6" }
end
end
end
1 change: 1 addition & 0 deletions spec/models/vacols/case_hearing_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 335176a

Please sign in to comment.