Skip to content

Commit

Permalink
Merge pull request #1159 from DFE-Digital/release-083
Browse files Browse the repository at this point in the history
Release 083
  • Loading branch information
jacksonj04 authored Sep 28, 2020
2 parents 0838bf4 + 243f07c commit 732d5c3
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 36 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog]

## [Unreleased]

## [Release 083] - 2020-09-25

- Geckoboard now only includes claims from the current academic year

## [Release 082] - 2020-09-02

- Break down number of claims and claim amount in payroll runs by policy
Expand Down Expand Up @@ -622,7 +626,9 @@ The format is based on [Keep a Changelog]
- First release for student loan repayments private beta

[unreleased]:
https://github.com/DFE-Digital/dfe-teachers-payment-service/compare/release-082...HEAD
https://github.com/DFE-Digital/dfe-teachers-payment-service/compare/release-083...HEAD
[release 083]:
https://github.com/DFE-Digital/dfe-teachers-payment-service/compare/release-082...release-083
[release 082]:
https://github.com/DFE-Digital/dfe-teachers-payment-service/compare/release-081...release-082
[release 081]:
Expand Down
4 changes: 4 additions & 0 deletions app/models/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class Payment < ApplicationRecord
delegate(*(PERSONAL_DETAILS_ATTRIBUTES_PERMITTING_DISCREPANCIES + PERSONAL_DETAILS_ATTRIBUTES_FORBIDDING_DISCREPANCIES), to: :claim_for_personal_details)
delegate :scheduled_payment_date, to: :payroll_run

def policies_in_payment
claims.map { |claim| claim.policy.to_s }.uniq.sort.join(",")
end

private

def personal_details_must_be_consistent
Expand Down
3 changes: 2 additions & 1 deletion app/models/payment_confirmation_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class PaymentConfirmationCsv
"Employers NI",
"Student Loans",
"Tax",
"Net Pay"
"Net Pay",
"Claim Policies"
].freeze

def initialize(file)
Expand Down
3 changes: 2 additions & 1 deletion app/models/payroll/payments_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class PaymentsCsv
bank_account_number: "ACCOUNT_NUMBER",
roll_number: "ROLL_NUMBER",
scheme_amount: "SCHEME_AMOUNT",
payment_id: "PAYMENT_ID"
payment_id: "PAYMENT_ID",
policies_in_payment: "CLAIM_POLICIES"
}.freeze

def initialize(payroll_run)
Expand Down
6 changes: 3 additions & 3 deletions spec/features/admin_payroll_runs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@
expect(page).to have_content("Upload Payment Confirmation Report")

csv = <<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325,StudentLoans
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534,StudentLoans
CSV

file = Tempfile.new
Expand Down
12 changes: 6 additions & 6 deletions spec/models/payment_confirmation_csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
context "The CSV is valid and has all the correct data" do
let(:csv) do
<<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,88b5dba7-ccf1-4ffd-a3ce-20bd3ce1e500,33.9,38.98,0,89.6,325
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,88b5dba7-ccf1-4ffd-a3ce-20bd3ce1e500,33.9,38.98,0,89.6,325,"MathsAndPhysics,StudentLoans"
CSV
end

Expand All @@ -41,8 +41,8 @@
context "The CSV does not have the expected headers" do
let(:csv) do
<<~CSV
Payroll Ref,Gross Val,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,88b5dba7-ccf1-4ffd-a3ce-20bd3ce1e500,33.9,38.98,0,89.6,325
Payroll Ref,Gross Val,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,88b5dba7-ccf1-4ffd-a3ce-20bd3ce1e500,33.9,38.98,0,89.6,325,StudentLoans
CSV
end

Expand All @@ -69,8 +69,8 @@
let(:byte_order_mark) { "\xEF\xBB\xBF" }
let(:csv) do
<<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,88b5dba7-ccf1-4ffd-a3ce-20bd3ce1e500,33.9,38.98,0,89.6,325
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,88b5dba7-ccf1-4ffd-a3ce-20bd3ce1e500,33.9,38.98,0,89.6,325,StudentLoans
CSV
end

Expand Down
36 changes: 18 additions & 18 deletions spec/models/payment_confirmation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
let(:payroll_run) { create(:payroll_run, claims_counts: {[MathsAndPhysics, StudentLoans] => 1, StudentLoans => 1}) }
let(:csv) do
<<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325
DFE00002,"1,211.15",#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325,StudentLoans
DFE00002,"1,211.15",#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534,"MathsAndPhysics,StudentLoans"
CSV
end
let(:file) do
Expand Down Expand Up @@ -94,8 +94,8 @@
let(:payroll_run) { create(:payroll_run, claims_counts: {StudentLoans => 1}) }
let(:csv) do
<<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,,6,325
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,,6,325,StudentLoans
CSV
end

Expand All @@ -120,10 +120,10 @@
let(:extra_claim) { create(:claim) }
let(:csv) do
<<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534
DFE00003,904.15,#{extra_claim.reference},77.84,89.51,40,162.8,534
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325,StudentLoans
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534,StudentLoans
DFE00003,904.15,#{extra_claim.reference},77.84,89.51,40,162.8,534,StudentLoans
CSV
end

Expand All @@ -139,8 +139,8 @@
context "The CSV has a claim missing from the run" do
let(:csv) do
<<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325,MathsAndPhysics
CSV
end

Expand All @@ -158,10 +158,10 @@
context "The CSV has a duplicate claim" do
let(:csv) do
<<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325,StudentLoans
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534,StudentLoans
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534,StudentLoans
CSV
end

Expand All @@ -181,9 +181,9 @@
context "The CSV has a blank value for a required field" do
let(:csv) do
<<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,,#{payroll_run.payments[0].id},,38.98,0,89.6,325
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,,#{payroll_run.payments[0].id},,38.98,0,89.6,325,StudentLoans
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534,StudentLoans
CSV
end

Expand Down
40 changes: 40 additions & 0 deletions spec/models/payment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,44 @@
expect(payment.payroll_gender).to eq("female")
end
end

describe "policies in payment" do
let(:personal_details) do
{
national_insurance_number: generate(:national_insurance_number),
teacher_reference_number: generate(:teacher_reference_number),
email_address: generate(:email_address),
bank_sort_code: "112233",
bank_account_number: "95928482",
address_line_1: "64 West Lane",
student_loan_plan: StudentLoan::PLAN_1
}
end

it "returns the correct string for a payment with one claim" do
payment = create(:payment, claims: [
create(:claim, :approved, personal_details.merge(policy: StudentLoans))
])

expect(payment.policies_in_payment).to eq("StudentLoans")
end

it "returns the correct string for a payment with multiple claims under one policy" do
payment = create(:payment, claims: [
create(:claim, :approved, personal_details.merge(policy: StudentLoans)),
create(:claim, :approved, personal_details.merge(policy: StudentLoans))
])

expect(payment.policies_in_payment).to eq("StudentLoans")
end

it "returns the correct string for a payment with multiple claims under different policies" do
payment = create(:payment, claims: [
create(:claim, :approved, personal_details.merge(policy: StudentLoans)),
create(:claim, :approved, personal_details.merge(policy: MathsAndPhysics))
])

expect(payment.policies_in_payment).to eq("MathsAndPhysics,StudentLoans")
end
end
end
3 changes: 2 additions & 1 deletion spec/models/payroll/payment_csv_row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
claim.bank_account_number,
claim.building_society_roll_number,
payment_award_amount.to_s,
payment.id
payment.id,
payment.policies_in_payment
])
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/models/payroll/payments_csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
ROLL_NUMBER
SCHEME_AMOUNT
PAYMENT_ID
CLAIM_POLICIES
].join(",")

expect(file_lines[0]).to eq(expected_header_row)
Expand Down
10 changes: 5 additions & 5 deletions spec/requests/admin_payment_confirmation_report_upload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
let(:payroll_run) { create(:payroll_run, claims_counts: {StudentLoans => 2}) }
let(:csv) do
<<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325,StudentLoans
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,534,StudentLoans
CSV
end

Expand All @@ -51,8 +51,8 @@
let(:payroll_run) { create(:payroll_run, claims_counts: {StudentLoans => 2}) }
let(:csv) do
<<~CSV
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325
Payroll Reference,Gross Value,Payment ID,NI,Employers NI,Student Loans,Tax,Net Pay,Claim Policies
DFE00001,487.48,#{payroll_run.payments[0].id},33.9,38.98,0,89.6,325,StudentLoans
DFE00002,904.15,#{payroll_run.payments[1].id},77.84,89.51,40,162.8,
CSV
end
Expand Down

0 comments on commit 732d5c3

Please sign in to comment.