Skip to content

Commit

Permalink
Merge pull request #3451 from DFE-Digital/ey-report-serialiser
Browse files Browse the repository at this point in the history
[CAPT-2047] Add EY serializer for admin data report
  • Loading branch information
asmega authored Dec 4, 2024
2 parents f1c7841 + 1491dc9 commit cbc26f2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
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

0 comments on commit cbc26f2

Please sign in to comment.