Skip to content

Commit

Permalink
Merge branch 'master' into art/poa-requests/allow-list-migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
ojbucao authored Feb 4, 2025
2 parents 802f67e + f31455e commit 697397a
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 19 deletions.
7 changes: 2 additions & 5 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class RemoveAccreditedRelationships < ActiveRecord::Migration[7.2]
disable_ddl_transaction!

def change
safety_assured do
remove_foreign_key :ar_power_of_attorney_requests, :accredited_individuals

remove_reference :ar_power_of_attorney_requests, :accredited_individual,
index: { algorithm: :concurrently }
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class PrepareArPosHolderData < ActiveRecord::Migration[7.2]

def change
safety_assured do
add_column :ar_power_of_attorney_requests, :accredited_individual_registration_number, :string
add_column :ar_power_of_attorney_requests, :power_of_attorney_holder_poa_code, :string
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class RemoveIndexOnPowerOfAttorneyHolder < ActiveRecord::Migration[7.2]
disable_ddl_transaction!

def change
remove_index :ar_power_of_attorney_requests, name: "index_ar_power_of_attorney_requests_on_power_of_attorney_holder", algorithm: :concurrently
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class RemovePowerOfAttorneyHolderIdFromArPowerOfAttorneyRequests < ActiveRecord::Migration[7.2]
def change
safety_assured do
remove_column :ar_power_of_attorney_requests, :power_of_attorney_holder_id
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@ class PoaAssignDependentClaimantJob < ClaimsApi::ServiceBase

def perform(poa_id, rep_id = nil) # rubocop:disable Metrics/MethodLength
poa = ClaimsApi::PowerOfAttorney.find(poa_id)
poa_code = extract_poa_code(poa.form_data)

service = dependent_claimant_poa_assignment_service(
poa.id,
poa.form_data,
poa.auth_headers
)

ClaimsApi::Logger.log(LOG_TAG, poa_id: poa.id, record_consent: poa.form_data['recordConsent'],
consent_address_change: poa.form_data['consentAddressChange'])
ClaimsApi::Logger.log(
LOG_TAG,
poa_id: poa.id,
detail: form_logger_consent_detail(poa, poa_code),
poa_code:,
allow_poa_access: allow_poa_access?(poa_form_data: poa.form_data),
allow_poa_c_add: allow_address_change?(poa)
)

begin
service.assign_poa_to_dependent!
Expand Down Expand Up @@ -53,7 +60,7 @@ def handle_error(poa, e)
def dependent_claimant_poa_assignment_service(poa_id, form_data, auth_headers)
ClaimsApi::DependentClaimantPoaAssignmentService.new(
poa_id:,
poa_code: find_poa_code(form_data),
poa_code: extract_poa_code(form_data),
veteran_participant_id: auth_headers['va_eauth_pid'],
dependent_participant_id: auth_headers.dig('dependent', 'participant_id'),
veteran_file_number: auth_headers['file_number'],
Expand All @@ -62,10 +69,5 @@ def dependent_claimant_poa_assignment_service(poa_id, form_data, auth_headers)
claimant_ssn: auth_headers.dig('dependent', 'ssn')
)
end

def find_poa_code(data)
base = data.key?('serviceOrganization') ? 'serviceOrganization' : 'representative'
data.dig(base, 'poaCode')
end
end
end
9 changes: 3 additions & 6 deletions modules/claims_api/app/sidekiq/claims_api/poa_vbms_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

module ClaimsApi
class PoaVBMSUpdater < ClaimsApi::ServiceBase
LOG_TAG = 'poa_vbms_updater'
sidekiq_options retry_for: 48.hours

def perform(power_of_attorney_id) # rubocop:disable Metrics/MethodLength
Expand All @@ -16,9 +17,9 @@ def perform(power_of_attorney_id) # rubocop:disable Metrics/MethodLength
poa_code = extract_poa_code(poa_form.form_data)

ClaimsApi::Logger.log(
'poa_vbms_updater',
LOG_TAG,
poa_id: power_of_attorney_id,
detail: 'Updating Access',
detail: form_logger_consent_detail(poa_form, poa_code),
poa_code:,
allow_poa_access: allow_poa_access?(poa_form_data: poa_form.form_data),
allow_poa_c_add: allow_address_change?(poa_form)
Expand Down Expand Up @@ -55,10 +56,6 @@ def perform(power_of_attorney_id) # rubocop:disable Metrics/MethodLength
ClaimsApi::Logger.log('poa', poa_id: poa_form.id, detail: 'BGS Error', error: e)
end

def allow_address_change?(poa_form)
poa_form.form_data['consentAddressChange']
end

def update_poa_access(poa_form:, participant_id:, poa_code:)
# allow_poa_c_add reports 'No Data' if sent lowercase
service = if Flipper.enabled? :claims_api_poa_vbms_updater_uses_local_bgs
Expand Down
10 changes: 10 additions & 0 deletions modules/claims_api/app/sidekiq/claims_api/service_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def retry_limits_for_notification

protected

def form_logger_consent_detail(poa, poa_code)
"Updating Access. recordConsent: #{poa.form_data['recordConsent'] || false}" \
"#{poa.form_data['consentLimits'] ? ', consentLimits included' : nil}" \
" for representative #{poa_code}"
end

def dependent_filing?(poa)
poa.auth_headers.key?('dependent')
end
Expand Down Expand Up @@ -182,6 +188,10 @@ def will_retry?(auto_claim, error)
NO_RETRY_ERROR_CODES.exclude?(msg)
end

def allow_address_change?(poa_form)
poa_form.form_data['consentAddressChange']
end

def will_retry_status_code?(error)
status = get_original_status_code(error)
RETRY_STATUS_CODES.include?(status.to_s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@
status: ClaimsApi::PowerOfAttorney::SUBMITTED)
end

it 'logs out the details correctly for consent information' do
poa_code = poa.form_data['data']['attributes']['serviceOrganization']['poaCode']
consent_msg = 'Updating Access. recordConsent: false ' \
"for representative #{poa_code}"

allow_any_instance_of(ClaimsApi::DependentClaimantPoaAssignmentService)
.to receive(:assign_poa_to_dependent!).and_return(
true
)

detail_msg = ClaimsApi::ServiceBase.new.send(:form_logger_consent_detail, poa, poa_code)

expect(detail_msg).to eq(consent_msg)
described_class.new.perform(poa.id, 'Rep Data')
end

it "marks the POA status as 'updated'" do
allow_any_instance_of(ClaimsApi::DependentClaimantPoaAssignmentService)
.to receive(:assign_poa_to_dependent!).and_return(
Expand Down
33 changes: 33 additions & 0 deletions modules/claims_api/spec/sidekiq/poa_vbms_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,27 @@
end
end

context 'consent details' do
let(:allow_poa_c_add) { 'Y' }
let(:consent_address_change) { true }

it 'logs correct with consentLimits included' do
poa = create_poa(allow_poa_access: true)
poa.form_data['consentLimits'] = ['HIV']
poa.save
create_mock_lighthouse_service_no_access
poa_code = poa.form_data['serviceOrganization']['poaCode']
consent_msg = 'Updating Access. recordConsent: true' \
', consentLimits included ' \
"for representative #{poa_code}"

detail_msg = ClaimsApi::ServiceBase.new.send(:form_logger_consent_detail, poa, poa_code)

expect(detail_msg).to eq(consent_msg)
subject.new.perform(poa.id)
end
end

context 'when address change is not present' do
let(:allow_poa_c_add) { 'N' }
let(:consent_address_change) { nil }
Expand Down Expand Up @@ -137,6 +158,18 @@ def create_mock_lighthouse_service
expect(BGS::Services).to receive(:new).and_return(service_double)
end

def create_mock_lighthouse_service_no_access
expect(@corporate_update_stub).to receive(:update_poa_access).with(
participant_id: user.participant_id,
poa_code: '074',
allow_poa_access: 'N',
allow_poa_c_add:
).and_return({ return_code: 'GUIE50000' })
service_double = instance_double(BGS::Services)
expect(service_double).to receive(:corporate_update).and_return(@corporate_update_stub)
expect(BGS::Services).to receive(:new).and_return(service_double)
end

def create_mock_lighthouse_service_bgs_failure
allow_any_instance_of(@clazz).to receive(:corporate_update) do |_instance|
corporate_update_stub = instance_double(BGS::CorporateUpdate)
Expand Down

0 comments on commit 697397a

Please sign in to comment.