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

[CAPT-2047] Add EY serializer for admin data report #3451

Merged
merged 1 commit into from
Dec 4, 2024
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
18 changes: 18 additions & 0 deletions app/models/claim/data_report_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ def to_csv_row
end
end

class EarlyYearsPayments < Base
def to_csv_row
[
ExcelUtils.escape_formulas(claim.reference),
nil,
ExcelUtils.escape_formulas(claim.national_insurance_number),
ExcelUtils.escape_formulas(claim.full_name),
ExcelUtils.escape_formulas(claim.email_address),
ExcelUtils.escape_formulas(claim.date_of_birth),
nil,
ExcelUtils.escape_formulas(claim.policy),
ExcelUtils.escape_formulas(claim.eligibility.eligible_ey_provider.nursery_name),
ExcelUtils.escape_formulas(claim.eligibility.eligible_ey_provider.urn),
ExcelUtils.escape_formulas(claim.payroll_gender)
]
end
end

class InternationalRelocationPayments < Base
def to_csv_row
[
Expand Down
36 changes: 33 additions & 3 deletions spec/models/claim/data_report_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let(:csv) { CSV.parse(subject.to_csv, headers: true) }

describe "#to_csv" do
context "early policies" do
context "original policies" do
let(:claims) do
[
create(:claim, :submitted, policy: Policies::StudentLoans),
Expand Down Expand Up @@ -36,7 +36,7 @@
end
end

context "FE policy" do
context "FE policy claims" do
let(:claims) do
[
create(:claim, :submitted, policy: Policies::FurtherEducationPayments)
Expand All @@ -63,7 +63,7 @@
end
end

context "IRP claims" do
context "IRP policy claims" do
let(:claims) do
[
create(:claim, :submitted, policy: Policies::InternationalRelocationPayments)
Expand Down Expand Up @@ -92,6 +92,36 @@
end
end

context "EY policy claims" do
let(:claims) do
[
create(:claim, :submitted, policy: Policies::EarlyYearsPayments)
]
end

it "contains the correct headers" do
expect(csv.headers).to eql(Claim::DataReportRequest::HEADERS)
end

it "contains the correct values" do
claims.each_with_index do |claim, index|
expect(csv[index]["Claim reference"]).to eql(claim.reference)
expect(csv[index]["Teacher reference number"]).to be_nil
expect(csv[index]["NINO"]).to eql(claim.national_insurance_number)
expect(csv[index]["Full name"]).to eql(claim.full_name)
expect(csv[index]["Email"]).to eql(claim.email_address)
expect(csv[index]["Date of birth"]).to eql(claim.date_of_birth.to_s)
expect(csv[index]["ITT subject"]).to be_nil
expect(csv[index]["Policy name"]).to eql(claim.policy.to_s)
expect(csv[index]["School name"]).to eql(claim.eligibility.eligible_ey_provider.nursery_name)
expect(csv[index]["School unique reference number"]).to eql(claim.eligibility.eligible_ey_provider.urn)
expect(csv[index]["Payroll gender"]).to eql(claim.payroll_gender)
expect(csv[index]["Nationality"]).to be_nil
expect(csv[index]["Passport number"]).to be_nil
end
end
end

context "when there is a single quotation sign in name field" do
let(:claims) do
[
Expand Down
Loading