Skip to content

Commit

Permalink
Bug | Fix code for cancelling an EP in BGS (#15093)
Browse files Browse the repository at this point in the history
Connects #14912
### Description
When cancelling a claim, the ruby-bgs method has hardcoded values for the payee_code and benefit_type arguments.  This is causing an error when cancelling a claim if the values for the claim don't match the hardcoded values.

### Acceptance Criteria
- [x] Update ruby-bgs repo to accept arguments for these fields, and set the current data as the default value
  - [x] payee_code: "00"
  - [x] benefit_type: "1"
- [x] Update `BGSService.cancel_end_product to accept these arguments`
- [x] Update the EndProductEstablishment model to send these arguments based on the EPEs data in the `cancel!` method.
- [x] Add a test that we're sending these arguments to BGSService
  • Loading branch information
Sjones352 authored Sep 4, 2020
1 parent d386be0 commit f969443
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/models/end_product_establishment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def potential_decision_ratings
def cancel!
transaction do
# delete end product in bgs & set sync status to canceled
BGSService.new.cancel_end_product(veteran_file_number, code, modifier)
BGSService.new.cancel_end_product(veteran_file_number, code, modifier, payee_code, benefit_type_code)
update!(synced_status: CANCELED_STATUS)
handle_cancelled_ep!
end
Expand Down
10 changes: 7 additions & 3 deletions app/services/external_api/bgs_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,24 @@ def get_end_products(vbms_id)
end
end

def cancel_end_product(veteran_file_number, end_product_code, end_product_modifier)
def cancel_end_product(veteran_file_number, end_product_code, end_product_modifier, payee_code, benefit_type)
DBService.release_db_connections

@end_products[veteran_file_number] ||=
MetricsService.record("BGS: cancel end product by: \
file_number = #{veteran_file_number}, \
end_product_code = #{end_product_code}, \
modifier = #{end_product_modifier}",
modifier = #{end_product_modifier}
payee_code = #{payee_code}
benefit_type = #{benefit_type}",
service: :bgs,
name: "claims.cancel_end_product") do
client.claims.cancel_end_product(
file_number: veteran_file_number,
end_product_code: end_product_code,
modifier: end_product_modifier
modifier: end_product_modifier,
payee_code: payee_code,
benefit_type: benefit_type
)
end
end
Expand Down
6 changes: 4 additions & 2 deletions lib/fakes/bgs_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ def get_rating_record(participant_id)
self.class.rating_store.fetch_and_inflate(participant_id) || {}
end

def cancel_end_product(file_number, end_product_code, end_product_modifier)
# benefit_type_code is not available data on end product data we fetch from BGS,
# and isn't part of the end product store in fakes
def cancel_end_product(file_number, end_product_code, end_product_modifier, payee_code, _benefit_type)
end_products = get_end_products(file_number)
matching_eps = end_products.select do |ep|
ep[:claim_type_code] == end_product_code && ep[:end_product_type_code] == end_product_modifier
ep[:claim_type_code] == end_product_code && ep[:modifier] == end_product_modifier && ep[:payee_code] == payee_code
end
matching_eps.each do |ep|
ep[:status_type_code] = "CAN"
Expand Down
1 change: 1 addition & 0 deletions spec/factories/end_product_establishment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
code { "030HLRR" }
modifier { "030" }
payee_code { EndProduct::DEFAULT_PAYEE_CODE }
benefit_type_code { Veteran::BENEFIT_TYPE_CODE_LIVE }
user { create(:user) }

trait :cleared do
Expand Down
34 changes: 34 additions & 0 deletions spec/models/end_product_establishment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,40 @@
subject
expect(end_product_establishment.reload.synced_status).to eq("CAN")
end

context "#returns cancel_end_product parameters!" do
let!(:modifier) { "030" }
let(:benefit_type_code) { Veteran::BENEFIT_TYPE_CODE_LIVE }
let(:end_product_establishment) do
EndProductEstablishment.new(
source: source,
veteran_file_number: veteran_file_number,
code: code,
payee_code: payee_code,
claim_date: 2.days.ago,
benefit_type_code: benefit_type_code,
modifier: modifier,
reference_id: "1",
synced_status: synced_status,
last_synced_at: last_synced_at
)
end

let!(:bgs_service) { BGSService.new }

before do
allow(BGSService).to receive(:new) { bgs_service }
allow(bgs_service).to receive(:cancel_end_product).and_call_original
end

it do
subject
expect(bgs_service).to have_received(:cancel_end_product).once.with(veteran_file_number,
code, modifier,
payee_code,
benefit_type_code)
end
end
end

context "when source is a RampReview" do
Expand Down
4 changes: 3 additions & 1 deletion spec/models/request_issues_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ def allow_update_contention
expect_any_instance_of(Fakes::BGSService).to receive(:cancel_end_product).with(
veteran.file_number,
"030HLRNR",
"030"
"030",
"00",
"1"
)

allow_remove_contention
Expand Down

0 comments on commit f969443

Please sign in to comment.