From 0281150db9d312f567fc6a8f4a9e253956c07533 Mon Sep 17 00:00:00 2001 From: Nick Jackson Date: Wed, 23 Sep 2020 14:03:49 +0100 Subject: [PATCH 1/3] Add payment method to list policies claimed under To allow for adding a new column to the payroll report, this new method lists (in alphabetical order) the unique policies which have been claimed under for claims within a given payment. The list is a comma-delimited string. --- app/models/payment.rb | 4 ++++ spec/models/payment_spec.rb | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/app/models/payment.rb b/app/models/payment.rb index be2c51d445..705eed17c3 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -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 diff --git a/spec/models/payment_spec.rb b/spec/models/payment_spec.rb index 5f07d66da7..1fa265361f 100644 --- a/spec/models/payment_spec.rb +++ b/spec/models/payment_spec.rb @@ -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 From 2c21cc5002a9020402c6d008f54b718b4c746af6 Mon Sep 17 00:00:00 2001 From: Nick Jackson Date: Wed, 23 Sep 2020 15:05:12 +0100 Subject: [PATCH 2/3] Add support for new "Claim Policies" column in payroll confirmation This column is not processed as part of ingesting a payroll confirmation (it is data which is entirely derived from Claim in the first place, echoed straight back to us). This does, however, now expect the column to be present. --- app/models/payment_confirmation_csv.rb | 3 +- app/models/payroll/payments_csv.rb | 3 +- spec/features/admin_payroll_runs_spec.rb | 6 ++-- spec/models/payment_confirmation_csv_spec.rb | 12 +++---- spec/models/payment_confirmation_spec.rb | 36 +++++++++---------- spec/models/payroll/payment_csv_row_spec.rb | 3 +- spec/models/payroll/payments_csv_spec.rb | 1 + ...payment_confirmation_report_upload_spec.rb | 10 +++--- 8 files changed, 39 insertions(+), 35 deletions(-) diff --git a/app/models/payment_confirmation_csv.rb b/app/models/payment_confirmation_csv.rb index 74488cdf6f..9621f79298 100644 --- a/app/models/payment_confirmation_csv.rb +++ b/app/models/payment_confirmation_csv.rb @@ -11,7 +11,8 @@ class PaymentConfirmationCsv "Employers NI", "Student Loans", "Tax", - "Net Pay" + "Net Pay", + "Claim Policies" ].freeze def initialize(file) diff --git a/app/models/payroll/payments_csv.rb b/app/models/payroll/payments_csv.rb index 2fab02fa33..0842d66bbd 100644 --- a/app/models/payroll/payments_csv.rb +++ b/app/models/payroll/payments_csv.rb @@ -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) diff --git a/spec/features/admin_payroll_runs_spec.rb b/spec/features/admin_payroll_runs_spec.rb index 9b1f0876ef..21089e096d 100644 --- a/spec/features/admin_payroll_runs_spec.rb +++ b/spec/features/admin_payroll_runs_spec.rb @@ -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 diff --git a/spec/models/payment_confirmation_csv_spec.rb b/spec/models/payment_confirmation_csv_spec.rb index dd3767a059..61e0f513fc 100644 --- a/spec/models/payment_confirmation_csv_spec.rb +++ b/spec/models/payment_confirmation_csv_spec.rb @@ -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 @@ -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 @@ -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 diff --git a/spec/models/payment_confirmation_spec.rb b/spec/models/payment_confirmation_spec.rb index 8a4b124f39..59f2f045d0 100644 --- a/spec/models/payment_confirmation_spec.rb +++ b/spec/models/payment_confirmation_spec.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/spec/models/payroll/payment_csv_row_spec.rb b/spec/models/payroll/payment_csv_row_spec.rb index 80a6f58980..1fc0fa7ae1 100644 --- a/spec/models/payroll/payment_csv_row_spec.rb +++ b/spec/models/payroll/payment_csv_row_spec.rb @@ -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 diff --git a/spec/models/payroll/payments_csv_spec.rb b/spec/models/payroll/payments_csv_spec.rb index eaf2fdfea1..6f5798f2b4 100644 --- a/spec/models/payroll/payments_csv_spec.rb +++ b/spec/models/payroll/payments_csv_spec.rb @@ -44,6 +44,7 @@ ROLL_NUMBER SCHEME_AMOUNT PAYMENT_ID + CLAIM_POLICIES ].join(",") expect(file_lines[0]).to eq(expected_header_row) diff --git a/spec/requests/admin_payment_confirmation_report_upload_spec.rb b/spec/requests/admin_payment_confirmation_report_upload_spec.rb index 5c7eafc01f..0e40bdf884 100644 --- a/spec/requests/admin_payment_confirmation_report_upload_spec.rb +++ b/spec/requests/admin_payment_confirmation_report_upload_spec.rb @@ -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 @@ -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 From 243f07ccedd8bbce5bd96391fdc5a4f74cb59a5b Mon Sep 17 00:00:00 2001 From: Nick Jackson Date: Fri, 25 Sep 2020 16:42:05 +0100 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af427ba4c6..4e34dfebab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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]: