diff --git a/lib/periodic_jobs.rb b/lib/periodic_jobs.rb
index 6ca7889613e..14c85656381 100644
--- a/lib/periodic_jobs.rb
+++ b/lib/periodic_jobs.rb
@@ -102,8 +102,8 @@
# Daily alert of pending claims longer than acceptable threshold
mgr.register('15 23 * * *', 'ClaimsApi::ReportUnsuccessfulSubmissions')
# Weekly report of unsuccessful claims submissions
- mgr.register('15 23 1 * *', 'ClaimsApi::ReportMonthlySubmissions')
- # Weekly report of unsuccessful claims submissions
+ mgr.register('00 00 1 * *', 'ClaimsApi::ReportMonthlySubmissions')
+ # Monthly report of submissions
mgr.register('30 2 * * *', 'Identity::UserAcceptableVerifiedCredentialTotalsJob')
diff --git a/modules/claims_api/app/mailers/claims_api/submission_report_mailer.rb b/modules/claims_api/app/mailers/claims_api/submission_report_mailer.rb
index 6f8007b9540..ed0d51b3c72 100644
--- a/modules/claims_api/app/mailers/claims_api/submission_report_mailer.rb
+++ b/modules/claims_api/app/mailers/claims_api/submission_report_mailer.rb
@@ -12,33 +12,20 @@ class SubmissionReportMailer < ApplicationMailer
rockwell.rice@oddball.io
].freeze
- def build(date_from, date_to, submissions = nil, yearly_submissions = nil) # rubocop:disable Metrics/MethodLength
+ # rubocop:disable Metrics/ParameterLists
+ def build(date_from, date_to, pact_act_data, disability_compensation_count,
+ poa_count, itf_count, ews_count)
+
@date_from = date_from.in_time_zone('Eastern Time (US & Canada)').strftime('%a %D %I:%M %p')
@date_to = date_to.in_time_zone('Eastern Time (US & Canada)').strftime('%a %D %I:%M %p')
- @data = { month: {}, year: {} }
- submissions = ClaimsApi::ClaimSubmission.where(created_at: @from..@to) if submissions.nil?
-
- submissions.pluck(:claim_type).uniq.sort.each do |kind|
- @data[:month][kind] = {}
- subs = submissions.select { |sub| sub[:claim_type] == kind }
- subs.pluck(:consumer_label).uniq.sort.each do |label|
- @data[:month][kind][label] = subs.select { |sub| sub[:consumer_label] == label }.size
- end
- end
+ @data = { month: {} }
- if yearly_submissions.nil?
- year_start = Date.new(Time.zone.today.year, 1, 1)
- year_end = Date.new(Time.zone.today.year + 1, 1, 1)
- yearly_submissions = ClaimsApi::ClaimSubmission.where('created_at > ? AND created_at < ?', year_start, year_end)
- end
+ pact_act_submissions(pact_act_data)
+ disability_compensation_submissions(disability_compensation_count)
+ poa_submissions(poa_count)
+ itf_submissions(itf_count)
+ ews_submissions(ews_count)
- yearly_submissions.pluck(:claim_type).uniq.sort.each do |kind|
- @data[:year][kind] = {}
- subs = yearly_submissions.select { |sub| sub[:claim_type] == kind }
- subs.pluck(:consumer_label).uniq.sort.each do |label|
- @data[:year][kind][label] = subs.select { |sub| sub[:consumer_label] == label }.size
- end
- end
@data.deep_symbolize_keys!
template = File.read(path)
@@ -51,6 +38,7 @@ def build(date_from, date_to, submissions = nil, yearly_submissions = nil) # rub
body:
)
end
+ # rubocop:enable Metrics/ParameterLists
private
@@ -63,5 +51,73 @@ def path
'submission_report.html.erb'
)
end
+
+ def pact_act_submissions(pact_act_data)
+ pact_act_data = ClaimsApi::ClaimSubmission.where(created_at: @date_from..@date_to) if pact_act_data.nil?
+
+ add_monthly_pact_data(pact_act_data)
+ end
+
+ def disability_compensation_submissions(disability_compensation_count)
+ if disability_compensation_count.nil?
+ disability_compensation_count = ClaimsApi::AutoEstablishedClaim
+ .where(created_at: @date_from..@date_to)
+ .pluck(:id)
+ .uniq
+ .size
+ end
+
+ add_monthly_data(disability_compensation_count, 'Disability Compensation', 'Form 526')
+ end
+
+ def poa_submissions(poa_count)
+ if poa_count.nil?
+ poa_count = ClaimsApi::PowerOfAttorney
+ .where(created_at: @date_from..@date_to)
+ .pluck(:id)
+ .uniq
+ .size
+ end
+
+ add_monthly_data(poa_count, 'Power of Attorney', 'Form 2122/2122a')
+ end
+
+ def itf_submissions(itf_count)
+ if itf_count.nil?
+ itf_count = ClaimsApi::IntentToFile.where(created_at: @date_from..@date_to)
+ .pluck(:id)
+ .uniq
+ .size
+ end
+
+ add_monthly_data(itf_count, 'Intent to File', 'Form 0966')
+ end
+
+ def ews_submissions(ews_count)
+ if ews_count.nil?
+ ews_count = ClaimsApi::EvidenceWaiverSubmission.where(created_at: @date_from..@date_to)
+ .pluck(:id)
+ .uniq
+ .size
+ end
+
+ add_monthly_data(ews_count, 'Evidence Waiver', 'Form 5133')
+ end
+
+ def add_monthly_data(records_count, kind, label)
+ @data[:month][kind] ||= {}
+
+ @data[:month][kind][label] = records_count
+ end
+
+ def add_monthly_pact_data(pact_act_data)
+ pact_act_data.pluck(:claim_type).uniq.sort.each do |kind|
+ @data[:month][kind] = {}
+ subs = pact_act_data.select { |sub| sub[:claim_type] == kind }
+ subs.pluck(:consumer_label).uniq.sort.each do |label|
+ @data[:month][kind][label] = subs.select { |sub| sub[:consumer_label] == label }.size
+ end
+ end
+ end
end
end
diff --git a/modules/claims_api/app/sidekiq/claims_api/report_monthly_submissions.rb b/modules/claims_api/app/sidekiq/claims_api/report_monthly_submissions.rb
index 5d0fa89b7cf..60f4944f57f 100644
--- a/modules/claims_api/app/sidekiq/claims_api/report_monthly_submissions.rb
+++ b/modules/claims_api/app/sidekiq/claims_api/report_monthly_submissions.rb
@@ -9,12 +9,20 @@ def perform
@to = Time.zone.now
@from = 1.month.ago
- submissions = ClaimsApi::ClaimSubmission.where(created_at: @from..@to)
+ pact_act_data = ClaimsApi::ClaimSubmission.where(created_at: @from..@to)
+ disability_compensation_count = ClaimsApi::AutoEstablishedClaim.where(created_at: @from..@to).pluck(:id).uniq.size
+ power_of_attorney_count = ClaimsApi::PowerOfAttorney.where(created_at: @from..@to).pluck(:id).uniq.size
+ intent_to_file_count = ClaimsApi::IntentToFile.where(created_at: @from..@to).pluck(:id).uniq.size
+ evidence_waiver_count = ClaimsApi::EvidenceWaiverSubmission.where(created_at: @from..@to).pluck(:id).uniq.size
ClaimsApi::SubmissionReportMailer.build(
@from,
@to,
- submissions
+ pact_act_data,
+ disability_compensation_count,
+ power_of_attorney_count,
+ intent_to_file_count,
+ evidence_waiver_count
).deliver_now
end
end
diff --git a/modules/claims_api/app/views/claims_api/submission_report_mailer/submission_report.html.erb b/modules/claims_api/app/views/claims_api/submission_report_mailer/submission_report.html.erb
index 3b3d976dd6d..95b4a946f6e 100644
--- a/modules/claims_api/app/views/claims_api/submission_report_mailer/submission_report.html.erb
+++ b/modules/claims_api/app/views/claims_api/submission_report_mailer/submission_report.html.erb
@@ -10,6 +10,8 @@
}
table {
border-collapse: collapse;
+ margin-bottom:35px;
+ min-width:475px;
}
table tr th, table tr td {
border: 1px solid #d3d3d3;
@@ -49,8 +51,9 @@
<%= @date_from %> - <%= @date_to %> (Eastern Time)
+ Monthly Submissions
+
<% @data[:month].keys.each do |kind| %>
- Monthly 526EZ <%= kind %> Claim Submissions
Consumer |
@@ -64,24 +67,5 @@
<% end %>
<% end %>
-
-
-
- <% @data[:year].keys.each do |kind| %>
- Yearly 526EZ <%= kind %> Claim Submissions
-
-
- Consumer |
- <%= kind %> submissions |
-
- <% @data[:year][kind].keys.each do |label| %>
-
- <%= label %> |
- <%= @data[:year][kind][label] %> |
-
- <% end %>
-
- <% end %>
-