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

FFS-2326: Encapsulate Pinwheel responses into data objects #432

Merged
merged 7 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions app/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ gem "gpgme", "~> 2.0", ">= 2.0.12"
gem "pdf-reader", "~> 2.12.0"

gem "maybe_later"
gem "activeresource"

group :development, :test do
gem "brakeman", "~> 5.2"
Expand All @@ -82,13 +83,12 @@ group :development, :test do
gem "debug", platforms: %i[mri mingw x64_mingw]
gem "dotenv-rails", "~> 2.7"
gem "erb_lint", require: false
gem "i18n-tasks", "~> 1.0"
gem "i18n-tasks", "~> 1.0", require: false
gem "rspec-rails", "~> 6.1"
gem "rubocop"
gem "rubocop-rspec"
gem "rubocop-rails-omakase"
gem "selenium-webdriver"
gem "standard", "~> 1.7"
gem "timecop"
end

Expand Down
46 changes: 20 additions & 26 deletions app/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ GEM
globalid (>= 0.3.6)
activemodel (7.1.5.1)
activesupport (= 7.1.5.1)
activemodel-serializers-xml (1.0.3)
activemodel (>= 5.0.0.a)
activesupport (>= 5.0.0.a)
builder (~> 3.1)
activerecord (7.1.5.1)
activemodel (= 7.1.5.1)
activesupport (= 7.1.5.1)
timeout (>= 0.4.0)
activeresource (6.1.4)
activemodel (>= 6.0)
activemodel-serializers-xml (~> 1.0)
activesupport (>= 6.0)
activestorage (7.1.5.1)
actionpack (= 7.1.5.1)
activejob (= 7.1.5.1)
Expand Down Expand Up @@ -225,11 +233,10 @@ GEM
jmespath (1.6.2)
jsbundling-rails (1.3.1)
railties (>= 6.0.0)
json (2.7.2)
json (2.9.1)
jwt (2.8.2)
base64
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
language_server-protocol (3.17.0.4)
logger (1.6.2)
loofah (2.23.1)
crass (~> 1.0.2)
Expand Down Expand Up @@ -294,8 +301,8 @@ GEM
actionpack (>= 4.2)
omniauth (~> 2.0)
orm_adapter (0.5.0)
parallel (1.25.1)
parser (3.3.4.0)
parallel (1.26.3)
parser (3.3.7.0)
ast (~> 2.4.1)
racc
pdf-reader (2.12.0)
Expand Down Expand Up @@ -382,7 +389,7 @@ GEM
rdoc (6.8.1)
psych (>= 4.0.0)
redis (4.8.1)
regexp_parser (2.9.2)
regexp_parser (2.10.0)
reline (0.5.12)
io-console (~> 0.5)
responders (3.1.1)
Expand All @@ -406,18 +413,17 @@ GEM
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rubocop (1.64.1)
rubocop (1.71.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.0)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.38.0)
parser (>= 3.3.1.0)
rubocop-minitest (0.35.1)
rubocop (>= 1.61, < 2.0)
Expand Down Expand Up @@ -465,18 +471,6 @@ GEM
activesupport (>= 6.1)
sprockets (>= 3.0.0)
stackprof (0.2.26)
standard (1.39.2)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.64.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.4)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.4.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stringio (3.1.2)
Expand All @@ -492,7 +486,7 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
uri (0.13.0)
version_gem (1.1.4)
view_component (3.13.0)
Expand Down Expand Up @@ -532,6 +526,7 @@ PLATFORMS

DEPENDENCIES
actioncable-enhanced-postgresql-adapter
activeresource
aws-actionmailer-ses
aws-sdk-rails
aws-sdk-s3
Expand Down Expand Up @@ -578,7 +573,6 @@ DEPENDENCIES
sidekiq (~> 6.4)
sprockets-rails
stackprof
standard (~> 1.7)
stimulus-rails
timecop
turbo-rails
Expand Down
28 changes: 17 additions & 11 deletions app/app/controllers/cbv/payment_details_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ def show
return redirect_to(cbv_flow_entry_url, flash: { slim_alert: { message: t("cbv.error_no_access"), type: "error" } })
end

@employment = has_employment_data? && pinwheel.fetch_employment(account_id: account_id)["data"]
@income_metadata = has_income_data? && pinwheel.fetch_income_metadata(account_id: account_id)["data"]
@payments = has_paystubs_data? ? set_payments(account_id) : []
@employment = has_employment_data? && pinwheel.fetch_employment(account_id: account_id)
@income = has_income_data? && pinwheel.fetch_income(account_id: account_id)

if has_paystubs_data?
set_payments(account_id)
else
@payments = []
end

@account_comment = account_comment
end

Expand Down Expand Up @@ -65,50 +71,50 @@ def has_paystubs_data?
def employer_name
return I18n.t("cbv.payment_details.show.unknown") unless has_employment_data?

@employment["employer_name"]
@employment.employer_name
end

def employment_start_date
return I18n.t("cbv.payment_details.show.unknown") unless has_employment_data?

@employment["start_date"]
@employment.start_date
end

def employment_end_date
return I18n.t("cbv.payment_details.show.unknown") unless has_employment_data?

@employment["termination_date"]
@employment.termination_date
end

def employment_status
return I18n.t("cbv.payment_details.show.unknown") unless has_employment_data?

@employment["status"]&.humanize
@employment.status&.humanize
end

def pay_frequency
return I18n.t("cbv.payment_details.show.unknown") unless has_income_data?

@income_metadata["pay_frequency"]
@income.pay_frequency&.humanize
end

def compensation_unit
return I18n.t("cbv.payment_details.show.unknown") unless has_income_data?

@income_metadata["compensation_unit"]
@income.compensation_unit
end

def compensation_amount
return I18n.t("cbv.payment_details.show.unknown") unless has_income_data?

@income_metadata["compensation_amount"]
@income.compensation_amount
end

def gross_pay
return I18n.t("cbv.payment_details.show.unknown") unless has_paystubs_data?

@payments
.map { |payment| payment[:gross_pay_amount] }
.map { |payment| payment.gross_pay_amount.to_i }
.reduce(:+)
end

Expand Down
6 changes: 1 addition & 5 deletions app/app/controllers/cbv/summaries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ def has_consent
params[:cbv_flow] && params[:cbv_flow][:consent_to_authorized_use] == "1"
end

def total_gross_income
@payments.reduce(0) { |sum, payment| sum + payment[:gross_pay_amount] }
end

def transmit_to_caseworker
case current_site.transmission_method
when "shared_email"
Expand Down Expand Up @@ -214,7 +210,7 @@ def track_accessed_income_summary_event(cbv_flow, payments)
site_id: cbv_flow.site_id,
cbv_flow_id: cbv_flow.id,
invitation_id: cbv_flow.cbv_flow_invitation_id,
account_count: payments.map { |p| p[:account_id] }.uniq.count,
account_count: payments.map { |p| p.account_id }.uniq.count,
paystub_count: payments.count,
account_count_with_additional_information:
cbv_flow.additional_information.values.count { |info| info["comment"].present? },
Expand Down
Loading