Skip to content

Commit

Permalink
Exclude old IAAs from Combined Invoice Supplement Report V2 (#11597)
Browse files Browse the repository at this point in the history
* Exclude old IAAs from Combined Invoice Supplement Report V2

changelog: Internal, Reporting, Exclude old IAAs from Combined Invoice Supplement Report V2

* Add spec
  • Loading branch information
mitchellhenke authored Dec 5, 2024
1 parent 5a76ef8 commit 6301c62
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/jobs/reports/combined_invoice_supplement_report_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class CombinedInvoiceSupplementReportV2 < BaseReport
REPORT_NAME = 'combined-invoice-supplement-report-v2'

def perform(_date)
csv = build_csv(IaaReportingHelper.iaas, IaaReportingHelper.partner_accounts)
# Exclude IAAs that ended more than 90 days ago
iaas = IaaReportingHelper.iaas.filter { |x| x.end_date > 90.days.ago }
csv = build_csv(iaas, IaaReportingHelper.partner_accounts)
save_report(REPORT_NAME, csv, extension: 'csv')
end

Expand Down
28 changes: 25 additions & 3 deletions spec/jobs/reports/combined_invoice_supplement_report_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@

let(:user2) { create(:user, profiles: [profile2]) }
let(:profile2) { build(:profile, verified_at: DateTime.new(2018, 6, 1).utc) }
let(:report_date) { inside_iaa1 }

let(:csv) { CSV.parse(report.perform(Time.zone.today), headers: true) }
let(:csv) do
travel_to report_date do
CSV.parse(report.perform(report_date), headers: true)
end
end

before do
iaa_order1.integrations << build_integration(
Expand Down Expand Up @@ -140,6 +145,14 @@
expect(row['issuer_unique_users'].to_i).to eq(2)
end
end

context 'when IAA ended more than 90 days ago' do
let(:report_date) { iaa1_range.end + 90.days }

it 'is excluded from the report' do
expect(csv.length).to eq(0)
end
end
end

context 'with an IAA with two issuers in September 2020' do
Expand Down Expand Up @@ -206,7 +219,11 @@
let(:user10) { create(:user, profiles: [profile10]) }
let(:profile10) { build(:profile, verified_at: DateTime.new(2015, 1, 1).utc) }

let(:csv) { CSV.parse(report.perform(Time.zone.today), headers: true) }
let(:csv) do
travel_to inside_iaa2 do
CSV.parse(report.perform(Time.zone.today), headers: true)
end
end

before do
iaa_order2.integrations << build_integration(
Expand Down Expand Up @@ -385,6 +402,7 @@
let(:partner_account3) { create(:partner_account) }

let(:iaa3_range) { DateTime.new(2020, 9, 1).utc..DateTime.new(2021, 8, 30).utc }
let(:inside_iaa3) { iaa3_range.begin + 1.day }

let(:gtc3) do
create(
Expand Down Expand Up @@ -417,7 +435,11 @@
let(:user12) { create(:user, profiles: [profile12]) }
let(:profile12) { build(:profile, verified_at: DateTime.new(2017, 9, 10).utc) }

let(:csv) { CSV.parse(report.perform(Time.zone.today), headers: true) }
let(:csv) do
travel_to inside_iaa3 do
CSV.parse(report.perform(Time.zone.today), headers: true)
end
end

before do
iaa_order3.integrations << build_integration(
Expand Down

0 comments on commit 6301c62

Please sign in to comment.