Skip to content
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
12 changes: 12 additions & 0 deletions app/jobs/reports/combined_invoice_supplement_report_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ def combine_by_iaa_month(

year_months.each do |year_month|
iaa_results = by_iaa_and_year_month[ [iaa_key, year_month] ]
if !iaa_results
logger.warn(
{
level: 'warning',
name: 'missing iaa_results',
iaa: iaa_key,
year_month: year_month,
}.to_json,
)
next
end

issuer_results = year_months_data[year_month]
year_month_start = Date.strptime(year_month, '%Y%m')
iaa_start_date = Date.parse(iaa_results.first[:iaa_start_date])
Expand Down
68 changes: 68 additions & 0 deletions spec/jobs/reports/combined_invoice_supplement_report_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,74 @@
end
end

describe '#combine_by_iaa_month' do
let(:service_provider) { create(:service_provider) }

let(:by_iaa_results) do
[
{
key: 'IAA123',
year_month: '202408',
iaa_start_date: '2024-08-01',
iaa_end_date: '2025-07-31',
},
]
end

let(:by_issuer_results) do
[
{
iaa: 'IAA123',
issuer: service_provider.issuer,
year_month: '202408',
},
{
iaa: 'IAA123',
issuer: service_provider.issuer,
year_month: '202409',
},
]
end
Comment on lines +584 to +608
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really just a mismatch on year_month between iaas and issuers? I thought the error was happening because an issuer year_month was outside of the range of the iaa.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the result is the same no?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be, it just makes more sense to me now.


let(:by_partner_results) do
[]
end

let(:by_issuer_profile_age_results) do
[]
end

it 'does not error if by_iaa_results is missing an entry' do
csv_data = report.combine_by_iaa_month(
by_iaa_results:,
by_issuer_results:,
by_partner_results:,
by_issuer_profile_age_results:,
)

csv = CSV.parse(csv_data, headers: true)
expect(csv.length).to be
end

it 'logs a warning for which IAA and which month for debugging' do
expect(Rails.logger).to receive(:warn) do |msg|
expect(JSON.parse(msg, symbolize_names: true)).to eq(
level: 'warning',
name: 'missing iaa_results',
iaa: 'IAA123',
year_month: '202409',
)
end

report.combine_by_iaa_month(
by_iaa_results:,
by_issuer_results:,
by_partner_results:,
by_issuer_profile_age_results:,
)
end
end

def build_iaa_order(order_number:, date_range:, iaa_gtc:)
create(
:iaa_order,
Expand Down