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 c0c8c276e3b..5a2f0c2c824 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 @@ -17,8 +17,8 @@ def perform @to, consumer_claims_totals: monthly_claims_totals, poa_totals: monthly_poa_totals, - itf_totals:, - ews_totals: + itf_totals: monthly_itf_totals, + ews_totals: monthly_ews_totals ).deliver_now end @@ -65,11 +65,31 @@ def monthly_claims_totals def monthly_poa_totals monthly_poa_consumers = ClaimsApi::PowerOfAttorney.where(created_at: @from..@to) - monthly_poa_by_cid_by_status = monthly_poa_consumers.group_by(&:cid).transform_values do |poas| - poas.group_by(&:status).transform_values(&:count) + monthly_poa_by_cid_by_status = monthly_poa_consumers.group_by(&:cid).transform_values do |poa| + poa.group_by(&:status).transform_values(&:count) end get_monthly_summary_by_consumer_by_status(monthly_poa_by_cid_by_status) end + + def monthly_itf_totals + monthly_itf_consumers = ClaimsApi::IntentToFile.where(created_at: @from..@to) + + monthly_itf_by_cid_by_status = monthly_itf_consumers.group_by(&:cid).transform_values do |itf| + itf.group_by(&:status).transform_values(&:count) + end + + get_monthly_summary_by_consumer_by_status(monthly_itf_by_cid_by_status) + end + + def monthly_ews_totals + monthly_ews_consumers = ClaimsApi::EvidenceWaiverSubmission.where(created_at: @from..@to) + + monthly_ews_by_cid_by_status = monthly_ews_consumers.group_by(&:cid).transform_values do |ews| + ews.group_by(&:status).transform_values(&:count) + end + + get_monthly_summary_by_consumer_by_status(monthly_ews_by_cid_by_status) + end end end diff --git a/modules/claims_api/spec/sidekiq/report_monthly_submissions_spec.rb b/modules/claims_api/spec/sidekiq/report_monthly_submissions_spec.rb index cd06312c1c8..023115b8d21 100644 --- a/modules/claims_api/spec/sidekiq/report_monthly_submissions_spec.rb +++ b/modules/claims_api/spec/sidekiq/report_monthly_submissions_spec.rb @@ -29,8 +29,8 @@ [] end, poa_totals: defined?(expected_poa_totals) ? match_array(expected_poa_totals) : [], - ews_totals: [], - itf_totals: [] + itf_totals: defined?(expected_itf_totals) ? match_array(expected_itf_totals) : [], + ews_totals: defined?(expected_ews_totals) ? match_array(expected_ews_totals) : [] ).and_return(double.tap do |mailer| expect(mailer).to receive(:deliver_now).once end) @@ -132,6 +132,36 @@ def setup_three_poas it_behaves_like 'sends mail with expected totals' end + context 'three ITFs' do + let(:claim_setup) { :setup_three_itfs } + let(:expected_itf_totals) do + [{ 'VA TurboClaim' => { submitted: 1, errored: 1, totals: 2 } }, + { 'VA.gov' => { submitted: 1, totals: 1 } }, + { 'Totals' => { submitted: 2, errored: 1, totals: 3 } }] + end + + def setup_three_itfs + create(:intent_to_file, cid: '0oa9uf05lgXYk6ZXn297') + create(:intent_to_file, status: 'errored', cid: '0oa9uf05lgXYk6ZXn297') + create(:intent_to_file, cid: '0oagdm49ygCSJTp8X297') + end + end + + context 'three EWSs' do + let(:claim_setup) { :setup_three_ews } + let(:expected_ews_totals) do + [{ 'VA TurboClaim' => { submitted: 1, errored: 1, totals: 2 } }, + { 'VA.gov' => { submitted: 1, totals: 1 } }, + { 'Totals' => { submitted: 2, errored: 1, totals: 3 } }] + end + + def setup_three_ews + create(:evidence_waiver_submission, cid: '0oa9uf05lgXYk6ZXn297') + create(:evidence_waiver_submission, status: 'errored', cid: '0oa9uf05lgXYk6ZXn297') + create(:evidence_waiver_submission, cid: '0oagdm49ygCSJTp8X297') + end + end + context 'shared reporting behavior' do it_behaves_like 'shared reporting behavior' end diff --git a/spec/mailers/previews/claims_api_submission_report_mailer_preview.rb b/spec/mailers/previews/claims_api_submission_report_mailer_preview.rb index f38015427b4..6b3424b63c5 100644 --- a/spec/mailers/previews/claims_api_submission_report_mailer_preview.rb +++ b/spec/mailers/previews/claims_api_submission_report_mailer_preview.rb @@ -47,7 +47,8 @@ def unsuccessful_poa_submissions def ews_totals [ { 'consumer 1' => { totals: 10, updated: 5, errored: 2, pending: 1, uploaded: 2 } }, - { 'consumer 2' => { totals: 8, updated: 3, errored: 2, pending: 1, uploaded: 2 } } + { 'consumer 2' => { totals: 8, updated: 3, errored: 2, pending: 1, uploaded: 2 } }, + { 'Totals' => { totals: 18, updated: 8, errored: 4, pending: 2, uploaded: 4 } } ] end @@ -61,7 +62,8 @@ def unsuccessful_evidence_waiver_submissions def itf_totals [ { 'consumer 1' => { totals: 2, submitted: 1, errored: 1 } }, - { 'consumer 2' => { totals: 1, submitted: 1, errored: 0 } } + { 'consumer 2' => { totals: 1, submitted: 1, errored: 0 } }, + { 'Totals' => { totals: 3, submitted: 2, errored: 1 } } ] end end