diff --git a/app/models/cpd_lead_provider.rb b/app/models/cpd_lead_provider.rb index 236904053c..f1642d8e87 100644 --- a/app/models/cpd_lead_provider.rb +++ b/app/models/cpd_lead_provider.rb @@ -7,7 +7,6 @@ class CpdLeadProvider < ApplicationRecord has_many :participant_declarations has_many :statements, class_name: "Finance::Statement" has_many :ecf_statements, class_name: "Finance::Statement::ECF" - has_many :npq_statements, class_name: "Finance::Statement::NPQ" validates :name, presence: { message: "Enter a name" } end diff --git a/app/models/finance/schedule.rb b/app/models/finance/schedule.rb index 1183c3eb05..246b8e0c09 100644 --- a/app/models/finance/schedule.rb +++ b/app/models/finance/schedule.rb @@ -11,12 +11,7 @@ class Schedule < ApplicationRecord # cohort_start_year delegate :start_year, to: :cohort, prefix: true - - def npq? - false - end end end require "finance/schedule/ecf" -require "finance/schedule/npq" diff --git a/app/models/finance/schedule/npq.rb b/app/models/finance/schedule/npq.rb deleted file mode 100644 index e8ee360d5f..0000000000 --- a/app/models/finance/schedule/npq.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class Finance::Schedule::NPQ < Finance::Schedule - def npq? - true - end -end - -require "finance/schedule/npq_leadership" -require "finance/schedule/npq_specialist" -require "finance/schedule/npq_support" diff --git a/app/models/finance/schedule/npq_ehco.rb b/app/models/finance/schedule/npq_ehco.rb deleted file mode 100644 index dfc29e04b4..0000000000 --- a/app/models/finance/schedule/npq_ehco.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -class Finance::Schedule::NPQEhco < Finance::Schedule::NPQ - IDENTIFIERS = %w[ - npq-early-headship-coaching-offer - ].freeze - - PERMITTED_COURSE_IDENTIFIERS = IDENTIFIERS - - def self.default_for(cohort: Cohort.current) - find_by!(cohort:, schedule_identifier: "npq-ehco-june") - end - - def self.schedule_for(cohort: Cohort.current) - return Finance::Schedule::NPQEhco.find_by!(cohort:) unless cohort_with_multiple_schedules?(cohort) - - case Date.current - when first_day_of_september_current_year(cohort.start_year)..last_day_of_november_current_year(cohort.start_year) - Finance::Schedule::NPQEhco.find_by!(cohort:, schedule_identifier: "npq-ehco-november") - when first_day_of_december_current_year(cohort.start_year)..last_day_of_february_next_year(cohort.start_year) - Finance::Schedule::NPQEhco.find_by!(cohort:, schedule_identifier: "npq-ehco-december") - when first_day_of_march_next_year(cohort.start_year)..last_day_of_may_next_year(cohort.start_year) - Finance::Schedule::NPQEhco.find_by!(cohort:, schedule_identifier: "npq-ehco-march") - when first_day_of_june_next_year(cohort.start_year)..last_day_of_september_next_year(cohort.start_year) - Finance::Schedule::NPQEhco.find_by!(cohort:, schedule_identifier: "npq-ehco-june") - else - default_for(cohort:) - end - end - - def self.cohort_with_multiple_schedules?(cohort) - Cohort.where(start_year: 2022..).include?(cohort) - end - - def self.first_day_of_september_current_year(cohort_start_year) - Date.new(cohort_start_year, 9, 1) - end - - def self.last_day_of_november_current_year(cohort_start_year) - Date.new(cohort_start_year, 11, -1) - end - - def self.first_day_of_december_current_year(cohort_start_year) - Date.new(cohort_start_year, 12, 1) - end - - def self.last_day_of_february_next_year(cohort_start_year) - Date.new(cohort_start_year + 1, 2, -1) - end - - def self.first_day_of_march_next_year(cohort_start_year) - Date.new(cohort_start_year + 1, 3, 1) - end - - def self.last_day_of_may_next_year(cohort_start_year) - Date.new(cohort_start_year + 1, 5, -1) - end - - def self.first_day_of_june_next_year(cohort_start_year) - Date.new(cohort_start_year + 1, 6, 1) - end - - def self.last_day_of_september_next_year(cohort_start_year) - Date.new(cohort_start_year + 1, 9, -1) - end -end diff --git a/app/models/finance/schedule/npq_leadership.rb b/app/models/finance/schedule/npq_leadership.rb deleted file mode 100644 index 4569e0ff44..0000000000 --- a/app/models/finance/schedule/npq_leadership.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -class Finance::Schedule::NPQLeadership < Finance::Schedule::NPQ - IDENTIFIERS = %w[ - npq-senior-leadership - npq-headship - npq-executive-leadership - npq-early-years-leadership - npq-senco - ].freeze - - PERMITTED_COURSE_IDENTIFIERS = IDENTIFIERS - - def self.default_for(cohort: Cohort.current) - find_by!(cohort:, schedule_identifier: "npq-leadership-spring") - end - - def self.schedule_for(cohort: Cohort.current, schedule_date: Date.current) - if autumn_schedule_2022?(schedule_date) - find_by!(cohort:, schedule_identifier: "npq-leadership-autumn") - elsif spring_schedule?(schedule_date) - find_by!(cohort:, schedule_identifier: "npq-leadership-spring") - elsif autumn_schedule?(schedule_date) - find_by!(cohort:, schedule_identifier: "npq-leadership-autumn") - else - default_for(cohort:) - end - end - - def self.autumn_schedule_2022?(date) - (Date.new(2022, 6, 1)..Date.new(2022, 12, 25)).include?(date) - end - - def self.spring_schedule?(date) - # Between: Dec 26 to Apr 2 - (Date.new(date.year, 1, 1)..Date.new(date.year, 4, 2)).include?(date) || - (Date.new(date.year, 12, 26)..Date.new(date.year, 12, 31)).include?(date) - end - - def self.autumn_schedule?(date) - # Between: Apr 3 to Dec 25 - (Date.new(date.year, 4, 3)..Date.new(date.year, 12, 25)).include?(date) - end -end diff --git a/app/models/finance/schedule/npq_specialist.rb b/app/models/finance/schedule/npq_specialist.rb deleted file mode 100644 index f271ac6e20..0000000000 --- a/app/models/finance/schedule/npq_specialist.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -class Finance::Schedule::NPQSpecialist < Finance::Schedule::NPQ - IDENTIFIERS = %w[ - npq-leading-teaching - npq-leading-behaviour-culture - npq-leading-teaching-development - npq-leading-literacy - npq-leading-primary-mathematics - ].freeze - - PERMITTED_COURSE_IDENTIFIERS = IDENTIFIERS - - def self.default_for(cohort: Cohort.current) - find_by!(cohort:, schedule_identifier: "npq-specialist-spring") - end - - def self.schedule_for(cohort: Cohort.current, schedule_date: Date.current) - if autumn_schedule_2022?(schedule_date) - find_by!(cohort:, schedule_identifier: "npq-specialist-autumn") - elsif spring_schedule?(schedule_date) - find_by!(cohort:, schedule_identifier: "npq-specialist-spring") - elsif autumn_schedule?(schedule_date) - find_by!(cohort:, schedule_identifier: "npq-specialist-autumn") - else - default_for(cohort:) - end - end - - def self.autumn_schedule_2022?(date) - (Date.new(2022, 6, 1)..Date.new(2022, 12, 25)).include?(date) - end - - def self.spring_schedule?(date) - # Between: Dec 26 to Apr 2 - (Date.new(date.year, 1, 1)..Date.new(date.year, 4, 2)).include?(date) || - (Date.new(date.year, 12, 26)..Date.new(date.year, 12, 31)).include?(date) - end - - def self.autumn_schedule?(date) - # Between: Apr 3 to Dec 25 - (Date.new(date.year, 4, 3)..Date.new(date.year, 12, 25)).include?(date) - end -end diff --git a/app/models/finance/schedule/npq_support.rb b/app/models/finance/schedule/npq_support.rb deleted file mode 100644 index a1b780ef9c..0000000000 --- a/app/models/finance/schedule/npq_support.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class Finance::Schedule::NPQSupport < Finance::Schedule::NPQ - IDENTIFIERS = %w[ - npq-additional-support-offer - ].freeze - - PERMITTED_COURSE_IDENTIFIERS = IDENTIFIERS - - def self.default - find_by(cohort: Cohort.current, schedule_identifier: "npq-aso-december") - end -end diff --git a/app/models/finance/statement.rb b/app/models/finance/statement.rb index fe2f1bc89e..3dcb8537be 100644 --- a/app/models/finance/statement.rb +++ b/app/models/finance/statement.rb @@ -45,8 +45,6 @@ class Finance::Statement < ApplicationRecord .where("deadline_date >= ?", Date.current) } - STATEMENT_TYPES = %w[ecf npq].freeze - class << self def current with_future_deadline_date.order(deadline_date: :asc).first @@ -84,10 +82,6 @@ def ecf? false end - def npq? - false - end - def payable? false end @@ -102,4 +96,3 @@ def marked_as_paid? end require "finance/statement/ecf" -require "finance/statement/npq" diff --git a/app/models/finance/statement/npq.rb b/app/models/finance/statement/npq.rb deleted file mode 100644 index 4178baeceb..0000000000 --- a/app/models/finance/statement/npq.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class Finance::Statement::NPQ < Finance::Statement - STATEMENT_TYPE = "npq" - - def payable! - update!(type: "Finance::Statement::NPQ::Payable") - end - - def previous_statements - Finance::Statement::NPQ - .where(cohort:) - .where(cpd_lead_provider:) - .where("payment_date < ?", payment_date) - end - - def paid! - update!(type: "Finance::Statement::NPQ::Paid") - end - - def show_targeted_delivery_funding? - cohort.start_year >= 2022 - end - - def npq? - true - end -end -require "finance/statement/npq/payable" -require "finance/statement/npq/paid" diff --git a/app/models/finance/statement/npq/paid.rb b/app/models/finance/statement/npq/paid.rb deleted file mode 100644 index 09292bf285..0000000000 --- a/app/models/finance/statement/npq/paid.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class Finance::Statement::NPQ::Paid < Finance::Statement::NPQ - def open? - false - end - - def paid? - true - end -end diff --git a/app/models/finance/statement/npq/payable.rb b/app/models/finance/statement/npq/payable.rb deleted file mode 100644 index 9c72b956d2..0000000000 --- a/app/models/finance/statement/npq/payable.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class Finance::Statement::NPQ::Payable < Finance::Statement::NPQ - def open? - false - end - - def payable? - true - end -end diff --git a/db/data/schedules/schedules.csv b/db/data/schedules/schedules.csv index 01d7350351..3085523660 100644 --- a/db/data/schedules/schedules.csv +++ b/db/data/schedules/schedules.csv @@ -1,8 +1,4 @@ type,schedule-identifier,schedule-name,schedule-cohort-year,milestone-name,milestone-declaration-type,milestone-start-date,milestone-date,milestone-payment-date -npq_ehco,npq-ehco-june,NPQ EHCO June,2023,Output 1 - Participant Start,started,2024-06-01,,2024-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2023,Output 2 - Retention Point 1,retained-1,2024-06-01,,2024-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2023,Output 3 - Retention Point 2,retained-2,2024-06-01,,2024-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2023,Output 4 - Participant Completion,completed,2024-06-01,,2024-06-01 ecf_extended,ecf-extended-september,ECF Extended September,2023,Output 1 - Participant Start,started,2023-09-01,,2023-09-01 ecf_extended,ecf-extended-september,ECF Extended September,2023,Output 2 - Retention Point 1,retained-1,2023-09-01,,2023-09-01 ecf_extended,ecf-extended-september,ECF Extended September,2023,Output 3 - Retention Point 2,retained-2,2023-09-01,,2023-09-01 @@ -45,9 +41,6 @@ ecf_reduced,ecf-reduced-april,ECF Reduced April,2022,Output 3 - Retention Point ecf_reduced,ecf-reduced-april,ECF Reduced April,2022,Output 4 - Retention Point 3,retained-3,2023-04-01,,2023-04-01 ecf_reduced,ecf-reduced-april,ECF Reduced April,2022,Output 5 - Retention Point 4,retained-4,2023-04-01,,2023-04-01 ecf_reduced,ecf-reduced-april,ECF Reduced April,2022,Output 6 - Participant Completion,completed,2023-04-01,,2023-04-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2022,Output 1 - Participant Start,started,2022-10-01,,2022-11-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2022,Output 2 - Retention Point 1,retained-1,2022-10-01,,2022-11-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2022,Output 3 - Participant Completion,completed,2022-10-01,,2022-11-01 ecf_extended,ecf-extended-september,ECF Extended September,2022,Output 1 - Participant Start,started,2022-09-01,,2022-09-01 ecf_extended,ecf-extended-september,ECF Extended September,2022,Output 2 - Retention Point 1,retained-1,2022-09-01,,2022-09-01 ecf_extended,ecf-extended-september,ECF Extended September,2022,Output 3 - Retention Point 2,retained-2,2022-09-01,,2022-09-01 @@ -66,10 +59,6 @@ ecf_extended,ecf-extended-january,ECF Extended January,2022,Output 6 - Participa ecf_extended,ecf-extended-january,ECF Extended January,2022,Output 7 - Extended Point 1,extended-1,2023-01-01,,2023-01-01 ecf_extended,ecf-extended-january,ECF Extended January,2022,Output 8 - Extended Point 2,extended-2,2023-01-01,,2023-01-01 ecf_extended,ecf-extended-january,ECF Extended January,2022,Output 9 - Extended Point 3,extended-3,2023-01-01,,2023-01-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2022,Output 1 - Participant Start,started,2022-10-01,,2022-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2022,Output 2 - Retention Point 1,retained-1,2022-10-01,,2022-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2022,Output 3 - Retention Point 2,retained-2,2022-10-01,,2022-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2022,Output 4 - Participant Completion,completed,2022-10-01,,2022-11-01 ecf_extended,ecf-extended-april,ECF Extended April,2022,Output 1 - Participant Start,started,2023-04-01,,2023-04-01 ecf_extended,ecf-extended-april,ECF Extended April,2022,Output 2 - Retention Point 1,retained-1,2023-04-01,,2023-04-01 ecf_extended,ecf-extended-april,ECF Extended April,2022,Output 3 - Retention Point 2,retained-2,2023-04-01,,2023-04-01 @@ -103,10 +92,6 @@ ecf_replacement,ecf-replacement-april,ECF Replacement April,2022,Output 3 - Rete ecf_replacement,ecf-replacement-april,ECF Replacement April,2022,Output 4 - Retention Point 3,retained-3,2023-04-01,,2023-04-01 ecf_replacement,ecf-replacement-april,ECF Replacement April,2022,Output 5 - Retention Point 4,retained-4,2023-04-01,,2023-04-01 ecf_replacement,ecf-replacement-april,ECF Replacement April,2022,Output 6 - Participant Completion,completed,2023-04-01,,2023-04-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2022,Output 1 - Participant Start,started,2023-06-01,,2023-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2022,Output 2 - Retention Point 1,retained-1,2023-06-01,,2023-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2022,Output 3 - Retention Point 2,retained-2,2023-06-01,,2023-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2022,Output 4 - Participant Completion,completed,2023-06-01,,2023-06-01 ecf_replacement,ecf-replacement-january,ECF Replacement January,2021,Output 1 - Participant Start,started,2022-01-01,,2022-01-01 ecf_replacement,ecf-replacement-january,ECF Replacement January,2021,Output 2 - Retention Point 1,retained-1,2022-01-01,,2022-01-01 ecf_replacement,ecf-replacement-january,ECF Replacement January,2021,Output 3 - Retention Point 2,retained-2,2022-01-01,,2022-01-01 @@ -125,10 +110,6 @@ ecf_standard,ecf-standard-april,ECF Standard April,2022,Output 3 - Retention Poi ecf_standard,ecf-standard-april,ECF Standard April,2022,Output 4 - Retention Point 3,retained-3,2024-04-01,2024-07-31,2024-08-31 ecf_standard,ecf-standard-april,ECF Standard April,2022,Output 5 - Retention Point 4,retained-4,2024-08-01,2024-12-31,2025-01-31 ecf_standard,ecf-standard-april,ECF Standard April,2022,Output 6 - Participant Completion,completed,2025-01-01,2025-03-31,2025-04-30 -npq_ehco,npq-ehco-march,NPQ EHCO March,2022,Output 1 - Participant Start,started,2023-03-01,,2023-03-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2022,Output 2 - Retention Point 1,retained-1,2023-03-01,,2023-03-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2022,Output 3 - Retention Point 2,retained-2,2023-03-01,,2023-03-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2022,Output 4 - Participant Completion,completed,2023-03-01,,2023-03-01 ecf_extended,ecf-extended-april,ECF Extended April,2021,Output 1 - Participant Start,started,2022-04-01,,2022-04-01 ecf_extended,ecf-extended-april,ECF Extended April,2021,Output 2 - Retention Point 1,retained-1,2022-04-01,,2022-04-01 ecf_extended,ecf-extended-april,ECF Extended April,2021,Output 3 - Retention Point 2,retained-2,2022-04-01,,2022-04-01 @@ -144,47 +125,18 @@ ecf_reduced,ecf-reduced-january,ECF Reduced January,2021,Output 3 - Retention Po ecf_reduced,ecf-reduced-january,ECF Reduced January,2021,Output 4 - Retention Point 3,retained-3,2022-01-01,,2022-01-01 ecf_reduced,ecf-reduced-january,ECF Reduced January,2021,Output 5 - Retention Point 4,retained-4,2022-01-01,,2022-01-01 ecf_reduced,ecf-reduced-january,ECF Reduced January,2021,Output 6 - Participant Completion,completed,2022-01-01,,2022-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2022,Output 1 - Participant Start,started,2023-01-01,,2023-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2022,Output 2 - Retention Point 1,retained-1,2023-01-01,,2023-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2022,Output 3 - Retention Point 2,retained-2,2023-01-01,,2023-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2022,Output 4 - Participant Completion,completed,2023-01-01,,2023-01-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2022,Output 1 - Participant Start,started,2022-12-01,,2022-12-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2022,Output 2 - Retention Point 1,retained-1,2022-12-01,,2022-12-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2022,Output 3 - Retention Point 2,retained-2,2022-12-01,,2022-12-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2022,Output 4 - Participant Completion,completed,2022-12-01,,2022-12-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2021,Output 1 - Participant Start,started,2022-06-01,,2022-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2021,Output 2 - Retention Point 1,retained-1,2022-06-01,,2022-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2021,Output 3 - Retention Point 2,retained-2,2022-06-01,,2022-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2021,Output 4 - Participant Completion,completed,2022-06-01,,2022-06-01 ecf_standard,ecf-standard-september,ECF Standard September,2022,Output 1 - Participant Start,started,2022-06-01,2022-12-31,2022-11-30 ecf_standard,ecf-standard-september,ECF Standard September,2022,Output 2 - Retention Point 1,retained-1,2023-01-01,2023-03-31,2023-04-30 ecf_standard,ecf-standard-september,ECF Standard September,2022,Output 3 - Retention Point 2,retained-2,2023-04-01,2023-07-31,2023-08-31 ecf_standard,ecf-standard-september,ECF Standard September,2022,Output 4 - Retention Point 3,retained-3,2023-08-01,2023-12-31,2024-01-31 ecf_standard,ecf-standard-september,ECF Standard September,2022,Output 5 - Retention Point 4,retained-4,2024-01-01,2024-03-31,2024-04-30 ecf_standard,ecf-standard-september,ECF Standard September,2022,Output 6 - Participant Completion,completed,2024-04-01,2024-07-31,2024-08-31 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2023,Output 1 - Participant Start,started,2023-10-01,,2023-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2023,Output 2 - Retention Point 1,retained-1,2023-10-01,,2023-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2023,Output 3 - Retention Point 2,retained-2,2023-10-01,,2023-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2023,Output 4 - Participant Completion,completed,2023-10-01,,2023-11-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2022,Output 1 - Participant Start,started,2023-01-01,,2023-01-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2022,Output 2 - Retention Point 1,retained-1,2023-01-01,,2023-01-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2022,Output 3 - Participant Completion,completed,2023-01-01,,2023-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2023,Output 1 - Participant Start,started,2024-01-01,,2024-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2023,Output 2 - Retention Point 1,retained-1,2024-01-01,,2024-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2023,Output 3 - Retention Point 2,retained-2,2024-01-01,,2024-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2023,Output 4 - Participant Completion,completed,2024-01-01,,2024-01-01 ecf_reduced,ecf-reduced-september,ECF Reduced September,2021,Output 1 - Participant Start,started,2021-09-01,,2021-09-01 ecf_reduced,ecf-reduced-september,ECF Reduced September,2021,Output 2 - Retention Point 1,retained-1,2021-09-01,,2021-09-01 ecf_reduced,ecf-reduced-september,ECF Reduced September,2021,Output 3 - Retention Point 2,retained-2,2021-09-01,,2021-09-01 ecf_reduced,ecf-reduced-september,ECF Reduced September,2021,Output 4 - Retention Point 3,retained-3,2021-09-01,,2021-09-01 ecf_reduced,ecf-reduced-september,ECF Reduced September,2021,Output 5 - Retention Point 4,retained-4,2021-09-01,,2021-09-01 ecf_reduced,ecf-reduced-september,ECF Reduced September,2021,Output 6 - Participant Completion,completed,2021-09-01,,2021-09-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2023,Output 1 - Participant Start,started,2023-10-01,,2023-11-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2023,Output 2 - Retention Point 1,retained-1,2023-10-01,,2023-11-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2023,Output 3 - Participant Completion,completed,2023-10-01,,2023-11-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2023,Output 1 - Participant Start,started,2024-01-01,,2024-01-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2023,Output 2 - Retention Point 1,retained-1,2024-01-01,,2024-01-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2023,Output 3 - Participant Completion,completed,2024-01-01,,2024-01-01 ecf_extended,ecf-extended-september,ECF Extended September,2021,Output 1 - Participant Start,started,2021-09-01,,2021-09-01 ecf_extended,ecf-extended-september,ECF Extended September,2021,Output 2 - Retention Point 1,retained-1,2021-09-01,,2021-09-01 ecf_extended,ecf-extended-september,ECF Extended September,2021,Output 3 - Retention Point 2,retained-2,2021-09-01,,2021-09-01 @@ -203,38 +155,18 @@ ecf_extended,ecf-extended-january,ECF Extended January,2021,Output 6 - Participa ecf_extended,ecf-extended-january,ECF Extended January,2021,Output 7 - Extended Point 1,extended-1,2022-01-01,,2022-01-01 ecf_extended,ecf-extended-january,ECF Extended January,2021,Output 8 - Extended Point 2,extended-2,2022-01-01,,2022-01-01 ecf_extended,ecf-extended-january,ECF Extended January,2021,Output 9 - Extended Point 3,extended-3,2022-01-01,,2022-01-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2022,Output 1 - Participant Start,started,2022-10-01,,2022-11-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2022,Output 2 - Retention Point 1,retained-1,2022-10-01,,2022-11-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2022,Output 3 - Retention Point 2,retained-2,2022-10-01,,2022-11-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2022,Output 4 - Participant Completion,completed,2022-10-01,,2022-11-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2023,Output 1 - Participant Start,started,2023-11-01,,2023-11-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2023,Output 2 - Retention Point 1,retained-1,2023-11-01,,2023-11-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2023,Output 3 - Retention Point 2,retained-2,2023-11-01,,2023-11-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2023,Output 4 - Participant Completion,completed,2023-11-01,,2023-11-01 ecf_replacement,ecf-replacement-april,ECF Replacement April,2021,Output 1 - Participant Start,started,2022-04-01,,2022-04-01 ecf_replacement,ecf-replacement-april,ECF Replacement April,2021,Output 2 - Retention Point 1,retained-1,2022-04-01,,2022-04-01 ecf_replacement,ecf-replacement-april,ECF Replacement April,2021,Output 3 - Retention Point 2,retained-2,2022-04-01,,2022-04-01 ecf_replacement,ecf-replacement-april,ECF Replacement April,2021,Output 4 - Retention Point 3,retained-3,2022-04-01,,2022-04-01 ecf_replacement,ecf-replacement-april,ECF Replacement April,2021,Output 5 - Retention Point 4,retained-4,2022-04-01,,2022-04-01 ecf_replacement,ecf-replacement-april,ECF Replacement April,2021,Output 6 - Participant Completion,completed,2022-04-01,,2022-04-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2023,Output 1 - Participant Start,started,2023-12-01,,2023-12-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2023,Output 2 - Retention Point 1,retained-1,2023-12-01,,2023-12-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2023,Output 3 - Retention Point 2,retained-2,2023-12-01,,2023-12-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2023,Output 4 - Participant Completion,completed,2023-12-01,,2023-12-01 ecf_replacement,ecf-replacement-september,ECF Replacement September,2021,Output 1 - Participant Start,started,2021-09-01,,2021-09-01 ecf_replacement,ecf-replacement-september,ECF Replacement September,2021,Output 2 - Retention Point 1,retained-1,2021-09-01,,2021-09-01 ecf_replacement,ecf-replacement-september,ECF Replacement September,2021,Output 3 - Retention Point 2,retained-2,2021-09-01,,2021-09-01 ecf_replacement,ecf-replacement-september,ECF Replacement September,2021,Output 4 - Retention Point 3,retained-3,2021-09-01,,2021-09-01 ecf_replacement,ecf-replacement-september,ECF Replacement September,2021,Output 5 - Retention Point 4,retained-4,2021-09-01,,2021-09-01 ecf_replacement,ecf-replacement-september,ECF Replacement September,2021,Output 6 - Participant Completion,completed,2021-09-01,,2021-09-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2021,Output 1 - Participant Start,started,2022-01-01,,2022-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2021,Output 2 - Retention Point 1,retained-1,2022-01-01,,2022-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2021,Output 3 - Retention Point 2,retained-2,2022-01-01,,2022-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2021,Output 4 - Participant Completion,completed,2022-01-01,,2022-01-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2023,Output 1 - Participant Start,started,2024-03-01,,2024-03-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2023,Output 2 - Retention Point 1,retained-1,2024-03-01,,2024-03-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2023,Output 3 - Retention Point 2,retained-2,2024-03-01,,2024-03-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2023,Output 4 - Participant Completion,completed,2024-03-01,,2024-03-01 ecf_extended,ecf-extended-april,ECF Extended April,2023,Output 1 - Participant Start,started,2024-04-01,,2024-04-01 ecf_extended,ecf-extended-april,ECF Extended April,2023,Output 2 - Retention Point 1,retained-1,2024-04-01,,2024-04-01 ecf_extended,ecf-extended-april,ECF Extended April,2023,Output 3 - Retention Point 2,retained-2,2024-04-01,,2024-04-01 @@ -304,41 +236,11 @@ ecf_standard,ecf-standard-april,ECF Standard April,2023,Output 3 - Retention Poi ecf_standard,ecf-standard-april,ECF Standard April,2023,Output 4 - Retention Point 3,retained-3,2025-04-01,2025-07-31,2025-08-31 ecf_standard,ecf-standard-april,ECF Standard April,2023,Output 5 - Retention Point 4,retained-4,2025-08-01,2025-12-31,2026-01-31 ecf_standard,ecf-standard-april,ECF Standard April,2023,Output 6 - Participant Completion,completed,2026-01-01,2026-03-31,2026-04-30 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2021,Output 1 - Participant Start,started,2021-11-01,,2021-11-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2021,Output 2 - Retention Point 1,retained-1,2021-11-01,,2021-11-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2021,Output 3 - Participant Completion,completed,2021-11-01,,2021-11-01 ecf_standard,ecf-standard-january,ECF Standard January,2021,Output 1 - Participant Start,started,2021-12-01,2022-01-31,2022-02-28 ecf_standard,ecf-standard-january,ECF Standard January,2021,Output 2 - Retention Point 1,retained-1,2022-02-01,2022-04-30,2022-05-31 ecf_standard,ecf-standard-january,ECF Standard January,2021,Output 3 - Retention Point 2,retained-2,2022-05-01,2022-09-30,2022-10-31 ecf_standard,ecf-standard-january,ECF Standard January,2021,Output 4 - Retention Point 3,retained-3,2022-10-01,2023-01-31,2023-02-28 ecf_standard,ecf-standard-january,ECF Standard January,2021,Output 5 - Retention Point 4,retained-4,2023-02-01,2023-04-30,2023-05-31 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2021,Output 1 - Participant Start,started,2021-11-01,,2021-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2021,Output 2 - Retention Point 1,retained-1,2021-11-01,,2021-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2021,Output 3 - Retention Point 2,retained-2,2021-11-01,,2021-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2021,Output 4 - Participant Completion,completed,2021-11-01,,2021-11-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2021,Output 1 - Participant Start,started,2022-01-01,,2022-01-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2021,Output 2 - Retention Point 1,retained-1,2022-01-01,,2022-01-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2021,Output 3 - Participant Completion,completed,2022-01-01,,2022-01-01 -npq_aso,npq-aso-november,NPQ ASO November,2021,Output 1 - Participant Start,started,01/11/2021,,01/11/2021 -npq_aso,npq-aso-november,NPQ ASO November,2021,Output 2 - Retention Point 1,retained-1,01/11/2021,,01/11/2021 -npq_aso,npq-aso-november,NPQ ASO November,2021,Output 3 - Retention Point 2,retained-2,01/11/2021,,01/11/2021 -npq_aso,npq-aso-november,NPQ ASO November,2021,Output 4 - Participant Completion,completed,01/11/2021,,01/11/2021 -npq_aso,npq-aso-december,NPQ ASO December,2021,Output 1 - Participant Start,started,01/12/2021,,01/12/2021 -npq_aso,npq-aso-december,NPQ ASO December,2021,Output 2 - Retention Point 1,retained-1,01/12/2021,,01/12/2021 -npq_aso,npq-aso-december,NPQ ASO December,2021,Output 3 - Retention Point 2,retained-2,01/12/2021,,01/12/2021 -npq_aso,npq-aso-december,NPQ ASO December,2021,Output 4 - Participant Completion,completed,01/12/2021,,01/12/2021 -npq_aso,npq-aso-march,NPQ ASO March,2021,Output 1 - Participant Start,started,01/03/2022,,01/03/2022 -npq_aso,npq-aso-march,NPQ ASO March,2021,Output 2 - Retention Point 1,retained-1,01/03/2022,,01/03/2022 -npq_aso,npq-aso-march,NPQ ASO March,2021,Output 3 - Retention Point 2,retained-2,01/03/2022,,01/03/2022 -npq_aso,npq-aso-march,NPQ ASO March,2021,Output 4 - Participant Completion,completed,01/03/2022,,01/03/2022 -npq_aso,npq-aso-june,NPQ ASO June,2021,Output 1 - Participant Start,started,01/06/2022,,01/06/2022 -npq_aso,npq-aso-june,NPQ ASO June,2021,Output 2 - Retention Point 1,retained-1,01/06/2022,,01/06/2022 -npq_aso,npq-aso-june,NPQ ASO June,2021,Output 3 - Retention Point 2,retained-2,01/06/2022,,01/06/2022 -npq_aso,npq-aso-june,NPQ ASO June,2021,Output 4 - Participant Completion,completed,01/06/2022,,01/06/2022 -npq_ehco,npq-ehco-june,NPQ EHCO June,2024,Output 1 - Participant Start,started,2025-06-01,,2025-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2024,Output 2 - Retention Point 1,retained-1,2025-06-01,,2025-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2024,Output 3 - Retention Point 2,retained-2,2025-06-01,,2025-06-01 -npq_ehco,npq-ehco-june,NPQ EHCO June,2024,Output 4 - Participant Completion,completed,2025-06-01,,2025-06-01 ecf_extended,ecf-extended-september,ECF Extended September,2024,Output 1 - Participant Start,started,2024-09-01,,2024-09-01 ecf_extended,ecf-extended-september,ECF Extended September,2024,Output 2 - Retention Point 1,retained-1,2024-09-01,,2024-09-01 ecf_extended,ecf-extended-september,ECF Extended September,2024,Output 3 - Retention Point 2,retained-2,2024-09-01,,2024-09-01 @@ -357,32 +259,6 @@ ecf_extended,ecf-extended-january,ECF Extended January,2024,Output 6 - Participa ecf_extended,ecf-extended-january,ECF Extended January,2024,Output 7 - Extended Point 1,extended-1,2025-01-01,,2025-01-01 ecf_extended,ecf-extended-january,ECF Extended January,2024,Output 8 - Extended Point 2,extended-2,2025-01-01,,2025-01-01 ecf_extended,ecf-extended-january,ECF Extended January,2024,Output 9 - Extended Point 3,extended-3,2025-01-01,,2025-01-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2024,Output 1 - Participant Start,started,2024-10-01,,2024-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2024,Output 2 - Retention Point 1,retained-1,2024-10-01,,2024-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2024,Output 3 - Retention Point 2,retained-2,2024-10-01,,2024-11-01 -npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,2024,Output 4 - Participant Completion,completed,2024-10-01,,2024-11-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2024,Output 1 - Participant Start,started,2025-01-01,,2025-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2024,Output 2 - Retention Point 1,retained-1,2025-01-01,,2025-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2024,Output 3 - Retention Point 2,retained-2,2025-01-01,,2025-01-01 -npq_leadership,npq-leadership-spring,NPQ Leadership Spring,2024,Output 4 - Participant Completion,completed,2025-01-01,,2025-01-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2024,Output 1 - Participant Start,started,2024-10-01,,2024-11-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2024,Output 2 - Retention Point 1,retained-1,2024-10-01,,2024-11-01 -npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,2024,Output 3 - Participant Completion,completed,2024-10-01,,2024-11-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2024,Output 1 - Participant Start,started,2025-01-01,,2025-01-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2024,Output 2 - Retention Point 1,retained-1,2025-01-01,,2025-01-01 -npq_specialist,npq-specialist-spring,NPQ Specialist Spring,2024,Output 3 - Participant Completion,completed,2025-01-01,,2025-01-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2024,Output 1 - Participant Start,started,2024-11-01,,2024-11-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2024,Output 2 - Retention Point 1,retained-1,2024-11-01,,2024-11-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2024,Output 3 - Retention Point 2,retained-2,2024-11-01,,2024-11-01 -npq_ehco,npq-ehco-november,NPQ EHCO November,2024,Output 4 - Participant Completion,completed,2024-11-01,,2024-11-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2024,Output 1 - Participant Start,started,2024-12-01,,2024-12-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2024,Output 2 - Retention Point 1,retained-1,2024-12-01,,2024-12-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2024,Output 3 - Retention Point 2,retained-2,2024-12-01,,2024-12-01 -npq_ehco,npq-ehco-december,NPQ EHCO December,2024,Output 4 - Participant Completion,completed,2024-12-01,,2024-12-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2024,Output 1 - Participant Start,started,2025-03-01,,2025-03-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2024,Output 2 - Retention Point 1,retained-1,2025-03-01,,2025-03-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2024,Output 3 - Retention Point 2,retained-2,2025-03-01,,2025-03-01 -npq_ehco,npq-ehco-march,NPQ EHCO March,2024,Output 4 - Participant Completion,completed,2025-03-01,,2025-03-01 ecf_extended,ecf-extended-april,ECF Extended April,2024,Output 1 - Participant Start,started,2025-04-01,,2025-04-01 ecf_extended,ecf-extended-april,ECF Extended April,2024,Output 2 - Retention Point 1,retained-1,2025-04-01,,2025-04-01 ecf_extended,ecf-extended-april,ECF Extended April,2024,Output 3 - Retention Point 2,retained-2,2025-04-01,,2025-04-01 diff --git a/db/migrate/20250115142033_delete_npq_finance_statements.rb b/db/migrate/20250115142033_delete_npq_finance_statements.rb new file mode 100644 index 0000000000..b40d6b0171 --- /dev/null +++ b/db/migrate/20250115142033_delete_npq_finance_statements.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class DeleteNPQFinanceStatements < ActiveRecord::Migration[7.1] + def up + statement_types = [ + "Finance::Statement::NPQ", + "Finance::Statement::NPQ::Payable", + "Finance::Statement::NPQ::Paid", + ] + + Finance::StatementLineItem.includes(:statement).where(statement: { type: statement_types }).in_batches(of: 10_000) { |batch| batch.delete_all } + Finance::Adjustment.includes(:statement).where(statement: { type: statement_types }).in_batches(of: 10_000) { |batch| batch.delete_all } + Finance::Statement.where(type: statement_types).in_batches(of: 10_000) { |batch| batch.delete_all } + end +end diff --git a/db/migrate/20250115143446_delete_npq_finance_schedules.rb b/db/migrate/20250115143446_delete_npq_finance_schedules.rb new file mode 100644 index 0000000000..fabd227bb1 --- /dev/null +++ b/db/migrate/20250115143446_delete_npq_finance_schedules.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DeleteNPQFinanceSchedules < ActiveRecord::Migration[7.1] + def up + schedule_types = [ + "Finance::Schedule::NPQ", + "Finance::Schedule::NPQEhco", + "Finance::Schedule::NPQSupport", + "Finance::Schedule::NPQSpecialist", + "Finance::Schedule::NPQLeadership", + ] + + ParticipantProfileSchedule.includes(:schedule).where(schedule: { type: schedule_types }).in_batches(of: 10_000) { |batch| batch.delete_all } + Finance::ScheduleMilestone.includes(:schedule).where(schedule: { type: schedule_types }).in_batches(of: 10_000) { |batch| batch.delete_all } + Finance::Milestone.includes(:schedule).where(schedule: { type: schedule_types }).in_batches(of: 10_000) { |batch| batch.delete_all } + Finance::Schedule.where(type: schedule_types).in_batches(of: 10_000) { |batch| batch.delete_all } + end +end diff --git a/db/new_seeds/base/add_schedules.rb b/db/new_seeds/base/add_schedules.rb index e9e0cc8623..0a6fd2a0a1 100644 --- a/db/new_seeds/base/add_schedules.rb +++ b/db/new_seeds/base/add_schedules.rb @@ -3,138 +3,3 @@ Rails.logger.info("Importing schedules") Importers::CreateSchedule.new(path_to_csv: Rails.root.join("db/data/schedules/schedules.csv")).call - -# Ensure Cohort.next always has NPQ schedules that can be used -if Finance::Schedule.find_by(cohort: Cohort.next, schedule_identifier: "npq-ehco-november").nil? - next_start_year = Cohort.next.start_year - csv = Tempfile.new("data.csv") - - csv.write "type,schedule-identifier,schedule-name,schedule-cohort-year,milestone-name,milestone-declaration-type,milestone-start-date,milestone-date,milestone-payment-date" - csv.write "\n" - - csv.write "npq_ehco,npq-ehco-november,NPQ EHCO November,#{next_start_year},Output 1 - Participant Start,started,01/11/#{next_start_year},,01/11/#{next_start_year}" - csv.write "npq_ehco,npq-ehco-november,NPQ EHCO November,#{next_start_year},Output 2 - Retention Point 1,retained-1,01/11/#{next_start_year},,01/11/#{next_start_year}" - csv.write "npq_ehco,npq-ehco-november,NPQ EHCO November,#{next_start_year},Output 3 - Retention Point 2,retained-2,01/11/#{next_start_year},,01/11/#{next_start_year}" - csv.write "npq_ehco,npq-ehco-november,NPQ EHCO November,#{next_start_year},Output 4 - Participant Completion,completed,01/11/#{next_start_year},,01/11/#{next_start_year}" - - csv.close - - Importers::CreateSchedule.new(path_to_csv: csv.path).call -end - -if Finance::Schedule.find_by(cohort: Cohort.next, schedule_identifier: "npq-ehco-december").nil? - next_start_year = Cohort.next.start_year - csv = Tempfile.new("data.csv") - - csv.write "type,schedule-identifier,schedule-name,schedule-cohort-year,milestone-name,milestone-declaration-type,milestone-start-date,milestone-date,milestone-payment-date" - csv.write "\n" - - csv.write "npq_ehco,npq-ehco-december,NPQ EHCO December,#{next_start_year},Output 1 - Participant Start,started,01/12/#{next_start_year},,01/12/#{next_start_year}" - csv.write "npq_ehco,npq-ehco-december,NPQ EHCO December,#{next_start_year},Output 2 - Retention Point 1,retained-1,01/12/#{next_start_year},,01/12/#{next_start_year}" - csv.write "npq_ehco,npq-ehco-december,NPQ EHCO December,#{next_start_year},Output 3 - Retention Point 2,retained-2,01/12/#{next_start_year},,01/12/#{next_start_year}" - csv.write "npq_ehco,npq-ehco-december,NPQ EHCO December,#{next_start_year},Output 4 - Participant Completion,completed,01/12/#{next_start_year},,01/12/#{next_start_year}" - - csv.close - - Importers::CreateSchedule.new(path_to_csv: csv.path).call -end - -if Finance::Schedule.find_by(cohort: Cohort.next, schedule_identifier: "npq-ehco-march").nil? - next_start_year = Cohort.next.start_year - csv = Tempfile.new("data.csv") - - csv.write "type,schedule-identifier,schedule-name,schedule-cohort-year,milestone-name,milestone-declaration-type,milestone-start-date,milestone-date,milestone-payment-date" - csv.write "\n" - - csv.write "npq_ehco,npq-ehco-march,NPQ EHCO March,#{next_start_year},Output 1 - Participant Start,started,01/03/#{next_start_year + 1},,01/03/#{next_start_year + 1}" - csv.write "npq_ehco,npq-ehco-march,NPQ EHCO March,#{next_start_year},Output 2 - Retention Point 1,retained-1,01/03/#{next_start_year + 1},,01/03/#{next_start_year + 1}" - csv.write "npq_ehco,npq-ehco-march,NPQ EHCO March,#{next_start_year},Output 3 - Retention Point 2,retained-2,01/03/#{next_start_year + 1},,01/03/#{next_start_year + 1}" - csv.write "npq_ehco,npq-ehco-march,NPQ EHCO March,#{next_start_year},Output 4 - Participant Completion,completed,01/03/#{next_start_year + 1},,01/03/#{next_start_year + 1}" - - csv.close - - Importers::CreateSchedule.new(path_to_csv: csv.path).call -end - -if Finance::Schedule.find_by(cohort: Cohort.next, schedule_identifier: "npq-ehco-june").nil? - next_start_year = Cohort.next.start_year - csv = Tempfile.new("data.csv") - - csv.write "type,schedule-identifier,schedule-name,schedule-cohort-year,milestone-name,milestone-declaration-type,milestone-start-date,milestone-date,milestone-payment-date" - csv.write "\n" - - csv.write "npq_ehco,npq-ehco-june,NPQ EHCO June,#{next_start_year},Output 1 - Participant Start,started,01/06/#{next_start_year + 1},,01/06/#{next_start_year + 1}" - csv.write "npq_ehco,npq-ehco-june,NPQ EHCO June,#{next_start_year},Output 2 - Retention Point 1,retained-1,01/06/#{next_start_year + 1},,01/06/#{next_start_year + 1}" - csv.write "npq_ehco,npq-ehco-june,NPQ EHCO June,#{next_start_year},Output 3 - Retention Point 2,retained-2,01/06/#{next_start_year + 1},,01/06/#{next_start_year + 1}" - csv.write "npq_ehco,npq-ehco-june,NPQ EHCO June,#{next_start_year},Output 4 - Participant Completion,completed,01/06/#{next_start_year + 1},,01/06/#{next_start_year + 1}" - - csv.close - - Importers::CreateSchedule.new(path_to_csv: csv.path).call -end - -if Finance::Schedule.find_by(cohort: Cohort.next, schedule_identifier: "npq-leadership-autumn").nil? - next_start_year = Cohort.next.start_year - csv = Tempfile.new("data.csv") - - csv.write "type,schedule-identifier,schedule-name,schedule-cohort-year,milestone-name,milestone-declaration-type,milestone-start-date,milestone-date,milestone-payment-date" - csv.write "\n" - - csv.write "npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,#{next_start_year},Output 1 - Participant Start,started,01/11/#{next_start_year},,01/11/#{next_start_year}" - csv.write "npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,#{next_start_year},Output 2 - Retention Point 1,retained-1,01/11/#{next_start_year},,01/11/#{next_start_year}" - csv.write "npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,#{next_start_year},Output 3 - Retention Point 2,retained-2,01/11/#{next_start_year},,01/11/#{next_start_year}" - csv.write "npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,#{next_start_year},Output 4 - Participant Completion,completed,01/11/#{next_start_year},,01/11/#{next_start_year}" - - csv.close - - Importers::CreateSchedule.new(path_to_csv: csv.path).call -end - -if Finance::Schedule.find_by(cohort: Cohort.next, schedule_identifier: "npq-leadership-spring").nil? - next_start_year = Cohort.next.start_year - csv = Tempfile.new("data.csv") - - csv.write "type,schedule-identifier,schedule-name,schedule-cohort-year,milestone-name,milestone-declaration-type,milestone-start-date,milestone-date,milestone-payment-date" - csv.write "\n" - - csv.write "npq_leadership,npq-leadership-spring,NPQ Leadership Spring,#{next_start_year},Output 1 - Participant Start,started,01/01/#{next_start_year + 1},,01/01/#{next_start_year + 1}" - csv.write "npq_leadership,npq-leadership-spring,NPQ Leadership Spring,#{next_start_year},Output 2 - Retention Point 1,retained-1,01/01/#{next_start_year + 1},,01/01/#{next_start_year + 1}" - csv.write "npq_leadership,npq-leadership-spring,NPQ Leadership Spring,#{next_start_year},Output 3 - Retention Point 2,retained-2,01/01/#{next_start_year + 1},,01/01/#{next_start_year + 1}" - csv.write "npq_leadership,npq-leadership-spring,NPQ Leadership Spring,#{next_start_year},Output 4 - Participant Completion,completed,01/01/#{next_start_year + 1},,01/01/#{next_start_year + 1}" - - csv.close - - Importers::CreateSchedule.new(path_to_csv: csv.path).call -end - -if Finance::Schedule.find_by(cohort: Cohort.next, schedule_identifier: "npq-specialist-autumn").nil? - next_start_year = Cohort.next.start_year - csv = Tempfile.new("data.csv") - - csv.write "type,schedule-identifier,schedule-name,schedule-cohort-year,milestone-name,milestone-declaration-type,milestone-start-date,milestone-date,milestone-payment-date" - csv.write "\n" - - csv.write "npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,#{next_start_year},Output 1 - Participant Start,started,01/11/#{next_start_year},,01/11/#{next_start_year}" - csv.write "npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,#{next_start_year},Output 2 - Retention Point 1,retained-1,01/11/#{next_start_year},,01/11/#{next_start_year}" - csv.write "npq_specialist,npq-specialist-autumn,NPQ Specialist Autumn,#{next_start_year},Output 3 - Participant Completion,completed,01/11/#{next_start_year},,01/11/#{next_start_year}" - - csv.close - - Importers::CreateSchedule.new(path_to_csv: csv.path).call -end - -if Finance::Schedule.find_by(cohort: Cohort.next, schedule_identifier: "npq-specialist-spring").nil? - next_start_year = Cohort.next.start_year - csv = Tempfile.new("data.csv") - - csv.write "type,schedule-identifier,schedule-name,schedule-cohort-year,milestone-name,milestone-declaration-type,milestone-start-date,milestone-date,milestone-payment-date" - csv.write "\n" - - csv.write "npq_specialist,npq-specialist-spring,NPQ Specialist Spring,#{next_start_year},Output 1 - Participant Start,started,01/01/#{next_start_year + 1},,01/01/#{next_start_year + 1}" - csv.write "npq_specialist,npq-specialist-spring,NPQ Specialist Spring,#{next_start_year},Output 2 - Retention Point 1,retained-1,01/01/#{next_start_year + 1},,01/01/#{next_start_year + 1}" - csv.write "npq_specialist,npq-specialist-spring,NPQ Specialist Spring,#{next_start_year},Output 3 - Participant Completion,completed,01/01/#{next_start_year + 1},,01/01/#{next_start_year + 1}" - - csv.close - - Importers::CreateSchedule.new(path_to_csv: csv.path).call -end diff --git a/db/schema.rb b/db/schema.rb index 5dc61d1646..308b098fd8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2025_01_14_144917) do +ActiveRecord::Schema[7.1].define(version: 2025_01_15_143446) do # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "fuzzystrmatch" diff --git a/spec/factories/finance/schedules.rb b/spec/factories/finance/schedules.rb index 1ffe52869c..d61f845876 100644 --- a/spec/factories/finance/schedules.rb +++ b/spec/factories/finance/schedules.rb @@ -93,25 +93,6 @@ end end - trait(:with_npq_milestones) do - after(:create) do |schedule| - start_year = schedule.cohort.start_year - [ - { name: "Output 1 - Participant Start", start_date: Date.new(start_year, 9, 1), payment_date: Date.new(start_year, 11, 30), declaration_type: "started" }, - { name: "Output 2 - Retention Point 1", start_date: Date.new(start_year, 11, 1), payment_date: Date.new(start_year + 1, 2, 28), declaration_type: "retained-1" }, - { name: "Output 3 - Retention Point 2", start_date: Date.new(start_year + 1, 2, 1), payment_date: Date.new(start_year + 1, 5, 31), declaration_type: "retained-2" }, - { name: "Output 4 - Participant Completion", start_date: Date.new(start_year + 2, 2, 1), payment_date: Date.new(start_year + 2, 5, 31), declaration_type: "completed" }, - ].each do |hash| - Finance::Milestone.find_or_create_by!( - schedule:, - name: hash[:name], - start_date: hash[:start_date], - payment_date: hash[:payment_date], - ).update!(declaration_type: hash[:declaration_type]) - end - end - end - cohort { Cohort.current || create(:cohort, :current) } sequence(:schedule_identifier) { |n| "schedule-identifier-#{n}" } @@ -150,33 +131,5 @@ with_ecf_milestones end - - factory :npq_specialist_schedule, class: "Finance::Schedule::NPQSpecialist", parent: :schedule do - name { "NPQ Specialist Spring" } - schedule_identifier { "npq-specialist-spring" } - - with_npq_milestones - end - - factory :npq_leadership_schedule, class: "Finance::Schedule::NPQLeadership", parent: :schedule do - name { "NPQ Leadership Spring" } - schedule_identifier { "npq-leadership-spring" } - - with_npq_milestones - end - - factory :npq_aso_schedule, class: "Finance::Schedule::NPQSupport", parent: :schedule do - name { "NPQ Additional Support Offer December" } - schedule_identifier { "npq-aso-december" } - - with_npq_milestones - end - - factory :npq_ehco_schedule, class: "Finance::Schedule::NPQEhco", parent: :schedule do - name { "NPQ EHCO December" } - schedule_identifier { "npq-ehco-december" } - - with_npq_milestones - end end end diff --git a/spec/factories/finance/statements.rb b/spec/factories/finance/statements.rb index 4249bdf761..6999f437b1 100644 --- a/spec/factories/finance/statements.rb +++ b/spec/factories/finance/statements.rb @@ -8,18 +8,6 @@ cohort { Cohort.current || create(:cohort, :current) } contract_version { "1.0" } - factory :npq_statement, class: "Finance::Statement::NPQ" do - cpd_lead_provider { association :cpd_lead_provider } - factory :npq_payable_statement, class: "Finance::Statement::NPQ::Payable" do - payable - end - - factory :npq_paid_statement, class: "Finance::Statement::NPQ::Paid" do - paid - marked_as_paid_at { Time.zone.now } - end - end - factory :ecf_statement, class: "Finance::Statement::ECF" do cpd_lead_provider { association :cpd_lead_provider, :with_lead_provider } diff --git a/spec/models/cohort_spec.rb b/spec/models/cohort_spec.rb index 646f6469be..be35a31dda 100644 --- a/spec/models/cohort_spec.rb +++ b/spec/models/cohort_spec.rb @@ -234,8 +234,6 @@ let!(:ecf_schedule) { create(:ecf_schedule, cohort:) } let(:cohort) { described_class.create!(start_year: 3000) } - before { create(:npq_leadership_schedule, cohort:) } - it { is_expected.to contain_exactly(ecf_schedule) } end diff --git a/spec/models/finance/schedule/ecf_spec.rb b/spec/models/finance/schedule/ecf_spec.rb index 0c60be3d9c..aab406ac38 100644 --- a/spec/models/finance/schedule/ecf_spec.rb +++ b/spec/models/finance/schedule/ecf_spec.rb @@ -70,10 +70,4 @@ end end end - - describe ".npq?" do - it "should return false" do - expect(described_class.new.npq?).to be(false) - end - end end diff --git a/spec/models/finance/schedule/npq_ehco_spec.rb b/spec/models/finance/schedule/npq_ehco_spec.rb deleted file mode 100644 index d19bad8f29..0000000000 --- a/spec/models/finance/schedule/npq_ehco_spec.rb +++ /dev/null @@ -1,107 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -RSpec.describe Finance::Schedule::NPQEhco, type: :model do - before do - Finance::Milestone.delete_all - Finance::Schedule.delete_all - - load Rails.root.join("db/legacy_seeds/schedules.rb").to_s - end - - it "seeds from csv" do - schedule = described_class.find_by(schedule_identifier: "npq-ehco-march") - expect(schedule).to be_present - expect(schedule.milestones.count).to eql(4) - end - - describe ".default_for" do - let(:cohort) { Cohort.find_by!(start_year: 2022) } - it "returns NPQ EHCO June schedule for the cohort" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-ehco-june") - - expect(described_class.default_for(cohort:)).to eql(expected_schedule) - end - end - - describe ".schedule_for" do - let(:cohort) { Cohort.find_by!(start_year: 2022) } - let(:cohort_start_year) { cohort.start_year } - - context "when date is between September and November of cohort start year" do - it "returns NPQ EHCO November schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-ehco-november") - - travel_to Date.new(cohort_start_year, 9, 1) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when date is between December of cohort start year and February of the next year" do - it "returns NPQ EHCO December schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-ehco-december") - - travel_to Date.new(cohort_start_year, 12, 1) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when date is between March and May of the next year" do - it "returns NPQ EHCO March schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-ehco-march") - - travel_to Date.new(cohort_start_year + 1, 3, 1) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when date is between June and September of the next year" do - it "returns NPQ EHCO June schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-ehco-june") - - travel_to Date.new(cohort_start_year + 1, 6, 1) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when date range exceeds the current cohort" do - it "returns default schedule for cohort" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-ehco-june") - - travel_to Date.new(cohort_start_year + 1, 10, 1) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when no schedule exists for the cohort" do - let(:start_year) { Cohort.ordered_by_start_year.last.start_year + 128 } - let(:cohort) { FactoryBot.create :seed_cohort, start_year: } - - it "raises an error" do - expect { described_class.schedule_for(cohort:) }.to raise_error(ActiveRecord::RecordNotFound) - end - end - - context "when selected cohort is before multiple schedules existed for EHCO" do - let(:cohort) { Cohort.find_by!(start_year: 2021) } - - it "returns NPQ EHCO June schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-ehco-june") - - expect(described_class.schedule_for(cohort:)).to eql(expected_schedule) - end - end - end - - describe ".npq?" do - it "should return true" do - expect(described_class.new.npq?).to be(true) - end - end -end diff --git a/spec/models/finance/schedule/npq_leadership_spec.rb b/spec/models/finance/schedule/npq_leadership_spec.rb deleted file mode 100644 index a6ca053efc..0000000000 --- a/spec/models/finance/schedule/npq_leadership_spec.rb +++ /dev/null @@ -1,124 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -RSpec.describe Finance::Schedule::NPQLeadership, type: :model do - before do - Finance::Milestone.delete_all - Finance::Schedule.delete_all - - load Rails.root.join("db/legacy_seeds/schedules.rb").to_s - end - - it "seeds from csv" do - schedule = described_class.find_by(schedule_identifier: "npq-leadership-spring") - expect(schedule).to be_present - expect(schedule.milestones.count).to eql(4) - end - - describe ".default_for" do - let(:cohort) { Cohort.find_by!(start_year: 2022) } - - it "returns NPQ Leadership Spring 2022 schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-leadership-spring") - - expect(described_class.default_for(cohort:)).to eql(expected_schedule) - end - end - - describe ".schedule_for" do - let(:cohort) { Cohort.find_by!(start_year: 2022) } - let(:cohort_start_year) { cohort.start_year } - - context "when date is between June and December of cohort start year" do - it "returns NPQ Leadership Autumn schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-leadership-autumn") - - travel_to Date.new(cohort_start_year, 6, 1) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when date is between December of cohort start year and April of the next year" do - it "returns NPQ Leadership Spring schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-leadership-spring") - - travel_to Date.new(cohort_start_year, 12, 26) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when date is between April and December of the next year" do - it "returns NPQ Leadership Autumn schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-leadership-autumn") - - travel_to Date.new(cohort_start_year + 1, 4, 3) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when date is between December of next year and April in 2 years" do - it "returns NPQ Leadership Spring schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-leadership-spring") - - travel_to Date.new(cohort_start_year + 1, 12, 26) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when no schedule exists for the cohort" do - let(:start_year) { Cohort.ordered_by_start_year.last.start_year + 128 } - let(:cohort) { FactoryBot.create :seed_cohort, start_year: } - - it "raises an error" do - expect { described_class.schedule_for(cohort:) }.to raise_error(ActiveRecord::RecordNotFound) - end - end - end - - describe ".spring_schedule?" do - it "returns true when date between Dec 26 to Apr 2" do - (2.years.ago.year..Date.current.year).each do |year| - (("#{year}-12-26".to_date)..("#{year + 1}-04-2".to_date)).each do |date| - expect(described_class.spring_schedule?(date)).to be(true) - end - end - end - - it "returns false when date between Apr 3 to Dec 25" do - (2.years.ago.year..Date.current.year).each do |year| - (("#{year}-04-3".to_date)..("#{year}-12-25".to_date)).each do |date| - expect(described_class.spring_schedule?(date)).to be(false) - end - end - end - end - - describe ".autumn_schedule?" do - it "returns true when date between Apr 3 to Dec 25" do - (2.years.ago.year..Date.current.year).each do |year| - (("#{year}-04-3".to_date)..("#{year}-12-25".to_date)).each do |date| - expect(described_class.autumn_schedule?(date)).to be(true) - end - end - end - - it "returns false when date between Dec 26 to Apr 2" do - (2.years.ago.year..Date.current.year).each do |year| - (("#{year}-12-26".to_date)..("#{year + 1}-04-2".to_date)).each do |date| - expect(described_class.autumn_schedule?(date)).to be(false) - end - end - end - end - - describe ".npq?" do - it "should return true" do - expect(described_class.new.npq?).to be(true) - end - end -end diff --git a/spec/models/finance/schedule/npq_specialist_spec.rb b/spec/models/finance/schedule/npq_specialist_spec.rb deleted file mode 100644 index 276cf85be5..0000000000 --- a/spec/models/finance/schedule/npq_specialist_spec.rb +++ /dev/null @@ -1,124 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -RSpec.describe Finance::Schedule::NPQSpecialist, type: :model do - before do - Finance::Milestone.delete_all - Finance::Schedule.delete_all - - load Rails.root.join("db/legacy_seeds/schedules.rb").to_s - end - - it "seeds from csv" do - schedule = described_class.find_by(schedule_identifier: "npq-specialist-spring") - expect(schedule).to be_present - expect(schedule.milestones.count).to eql(3) - end - - describe ".default_for" do - let(:cohort) { Cohort.find_by!(start_year: 2022) } - - it "returns NPQ Specialist Spring 2022 schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-specialist-spring") - - expect(described_class.default_for(cohort:)).to eql(expected_schedule) - end - end - - describe ".schedule_for" do - let(:cohort) { Cohort.find_by!(start_year: 2022) } - let(:cohort_start_year) { cohort.start_year } - - context "when date is between June and December of cohort start year" do - it "returns NPQ Specialist Autumn schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-specialist-autumn") - - travel_to Date.new(cohort_start_year, 6, 1) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when date is between December of cohort start year and April of the next year" do - it "returns NPQ Specialist Spring schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-specialist-spring") - - travel_to Date.new(cohort_start_year, 12, 26) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when date is between April and December of the next year" do - it "returns NPQ Specialist Autumn schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-specialist-autumn") - - travel_to Date.new(cohort_start_year + 1, 4, 3) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when date is between December of next year and April in 2 years" do - it "returns NPQ Specialist Spring schedule" do - expected_schedule = described_class.find_by(cohort:, schedule_identifier: "npq-specialist-spring") - - travel_to Date.new(cohort_start_year + 1, 12, 26) do - expect(described_class.schedule_for(cohort:)).to eq(expected_schedule) - end - end - end - - context "when no schedule exists for the cohort" do - let(:start_year) { Cohort.ordered_by_start_year.last.start_year + 128 } - let(:cohort) { FactoryBot.create :seed_cohort, start_year: } - - it "raises an error" do - expect { described_class.schedule_for(cohort:) }.to raise_error(ActiveRecord::RecordNotFound) - end - end - end - - describe ".spring_schedule?" do - it "returns true when date between Dec 26 to Apr 2" do - (2.years.ago.year..Date.current.year).each do |year| - (("#{year}-12-26".to_date)..("#{year + 1}-04-2".to_date)).each do |date| - expect(described_class.spring_schedule?(date)).to be(true) - end - end - end - - it "returns false when date between Apr 3 to Dec 25" do - (2.years.ago.year..Date.current.year).each do |year| - (("#{year}-04-3".to_date)..("#{year}-12-25".to_date)).each do |date| - expect(described_class.spring_schedule?(date)).to be(false) - end - end - end - end - - describe ".autumn_schedule?" do - it "returns true when date between Apr 3 to Dec 25" do - (2.years.ago.year..Date.current.year).each do |year| - (("#{year}-04-3".to_date)..("#{year}-12-25".to_date)).each do |date| - expect(described_class.autumn_schedule?(date)).to be(true) - end - end - end - - it "returns false when date between Dec 26 to Apr 2" do - (2.years.ago.year..Date.current.year).each do |year| - (("#{year}-12-26".to_date)..("#{year + 1}-04-2".to_date)).each do |date| - expect(described_class.autumn_schedule?(date)).to be(false) - end - end - end - end - - describe ".npq?" do - it "should return true" do - expect(described_class.new.npq?).to be(true) - end - end -end diff --git a/spec/models/finance/schedule/npq_support_spec.rb b/spec/models/finance/schedule/npq_support_spec.rb deleted file mode 100644 index 00faef5035..0000000000 --- a/spec/models/finance/schedule/npq_support_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -RSpec.describe Finance::Schedule::NPQSupport, type: :model do - before do - Finance::Milestone.delete_all - Finance::Schedule.delete_all - - load Rails.root.join("db/legacy_seeds/schedules.rb").to_s - end - - it "seeds from csv" do - schedule = described_class.find_by(schedule_identifier: "npq-aso-march") - expect(schedule).to be_present - expect(schedule.milestones.count).to eql(4) - end - - describe "default" do - it "returns NPQ ASO December schedule" do - expected_schedule = described_class.find_by(cohort: Cohort.current, schedule_identifier: "npq-aso-december") - expect(described_class.default).to eql(expected_schedule) - end - end - - describe ".npq?" do - it "should return true" do - expect(described_class.new.npq?).to be(true) - end - end -end diff --git a/spec/models/finance/statement/npq/paid_spec.rb b/spec/models/finance/statement/npq/paid_spec.rb deleted file mode 100644 index b857ef09b1..0000000000 --- a/spec/models/finance/statement/npq/paid_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -RSpec.describe Finance::Statement::NPQ::Paid do - subject { create(:npq_paid_statement) } - - describe "#paid?" do - it { is_expected.to be_paid } - end -end diff --git a/spec/models/finance/statement/npq_spec.rb b/spec/models/finance/statement/npq_spec.rb deleted file mode 100644 index e4e844dd17..0000000000 --- a/spec/models/finance/statement/npq_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -RSpec.describe Finance::Statement::NPQ do - subject { create(:npq_statement) } - - describe "#payable!" do - it "transitions the statement to payable" do - expect { - subject.payable! - }.to change(subject, :type).from("Finance::Statement::NPQ").to("Finance::Statement::NPQ::Payable") - end - end - - describe "#show_targeted_delivery_funding?" do - context "cohort 2021" do - subject { build(:npq_statement, cohort: build(:cohort, start_year: 2021)) } - - it "returns false" do - expect(subject.show_targeted_delivery_funding?).to eql(false) - end - end - - context "cohort 2022" do - subject { build(:npq_statement, cohort: build(:cohort, start_year: 2022)) } - - it "returns true" do - expect(subject.show_targeted_delivery_funding?).to eql(true) - end - end - end -end diff --git a/spec/models/finance/statement_spec.rb b/spec/models/finance/statement_spec.rb index c59b7c3905..7486eea420 100644 --- a/spec/models/finance/statement_spec.rb +++ b/spec/models/finance/statement_spec.rb @@ -79,14 +79,6 @@ subject { build :ecf_statement } it { is_expected.to be_ecf } - it { is_expected.to_not be_npq } - end - - context ".npq?" do - subject { build :npq_statement } - - it { is_expected.to_not be_ecf } - it { is_expected.to be_npq } end context ".payable?" do diff --git a/spec/requests/finance/ecf/assurance_reports_spec.rb b/spec/requests/finance/ecf/assurance_reports_spec.rb index 89c76c5290..bcfb587392 100644 --- a/spec/requests/finance/ecf/assurance_reports_spec.rb +++ b/spec/requests/finance/ecf/assurance_reports_spec.rb @@ -8,7 +8,7 @@ let(:lead_provider) { cpd_lead_provider.lead_provider } let(:statement) { create(:ecf_statement, cpd_lead_provider:) } let(:other_cpd_lead_provider) { create(:cpd_lead_provider, :with_lead_provider) } - let(:other_statement) { create(:npq_statement, cpd_lead_provider: other_cpd_lead_provider) } + let(:other_statement) { create(:ecf_statement, cpd_lead_provider: other_cpd_lead_provider) } let(:parsed_response) { CSV.parse(response.body.force_encoding("utf-8"), headers: true, encoding: "utf-8", col_sep: ",") } diff --git a/spec/services/api/v3/finance/statements_query_spec.rb b/spec/services/api/v3/finance/statements_query_spec.rb index a221810c51..bd9fc89ff2 100644 --- a/spec/services/api/v3/finance/statements_query_spec.rb +++ b/spec/services/api/v3/finance/statements_query_spec.rb @@ -43,24 +43,6 @@ payment_date: 3.days.ago, ) end - let!(:npq_statement_next_cohort) do - create( - :npq_statement, - :output_fee, - cpd_lead_provider:, - cohort: next_cohort, - payment_date: 2.days.ago, - ) - end - let!(:npq_statement_current_cohort) do - create( - :npq_statement, - :output_fee, - cpd_lead_provider:, - cohort: current_cohort, - payment_date: 1.day.ago, - ) - end it "returns all output ecf statements for the cpd provider ordered by payment_date" do expect(subject.statements).to eq([ @@ -104,8 +86,6 @@ before do ecf_statement_next_cohort.update!(updated_at: 3.days.ago) ecf_statement_current_cohort.update!(updated_at: 1.day.ago) - npq_statement_next_cohort.update!(updated_at: 1.day.ago) - npq_statement_current_cohort.update!(updated_at: 6.days.ago) end it "returns ecf statements for the specific updated time" do @@ -126,27 +106,19 @@ end end - context "with npq type filter" do - let(:params) { { filter: { type: "npq" } } } + context "with incorrect type filter" do + let(:params) { { filter: { type: "does-not-exist" } } } it "returns no statements" do expect(subject.statements).to be_empty end + end - context "with incorrect type filter" do - let(:params) { { filter: { type: "does-not-exist" } } } - - it "returns no statements" do - expect(subject.statements).to be_empty - end - end - - context "with an ecf and cohort filter" do - let(:params) { { filter: { type: "ecf", cohort: current_cohort.display_name } } } + context "with an ecf and cohort filter" do + let(:params) { { filter: { type: "ecf", cohort: current_cohort.display_name } } } - it "returns ecf statement that belongs to the cohort" do - expect(subject.statements).to contain_exactly(ecf_statement_current_cohort) - end + it "returns ecf statement that belongs to the cohort" do + expect(subject.statements).to contain_exactly(ecf_statement_current_cohort) end end end @@ -183,24 +155,6 @@ expect { subject.statement }.to raise_error(ActiveRecord::RecordNotFound) end end - - context "when requesting NPQ statement" do - let!(:npq_statement_next_cohort) do - create( - :npq_statement, - :output_fee, - cpd_lead_provider:, - cohort: next_cohort, - payment_date: 2.days.ago, - ) - end - - let(:params) { { id: npq_statement_next_cohort.id } } - - it "does not return the finance statement" do - expect { subject.statement }.to raise_error(ActiveRecord::RecordNotFound) - end - end end end end diff --git a/spec/services/importers/create_schedule_spec.rb b/spec/services/importers/create_schedule_spec.rb index 75ac9ca583..356fad5185 100644 --- a/spec/services/importers/create_schedule_spec.rb +++ b/spec/services/importers/create_schedule_spec.rb @@ -70,53 +70,6 @@ end end end - - context "NPQ" do - let(:klass) { Finance::Schedule::NPQLeadership } - - before do - csv.write "type,schedule-identifier,schedule-name,schedule-cohort-year,milestone-name,milestone-declaration-type,milestone-start-date,milestone-date,milestone-payment-date" - csv.write "\n" - csv.write "npq_leadership,npq-leadership-autumn,NPQ Leadership Autumn,#{cohort.start_year},Output 1 - Participant Start,started,01/11/#{cohort.start_year},01/11/#{cohort.start_year},01/11/#{cohort.start_year}" - csv.close - end - - context "new schedule" do - it "creates a new schedule for the correct cohort" do - original_schedules_count = klass.count - subject.call - expect(klass.count).to eql(original_schedules_count + 1) - expect(klass.where(cohort:).count).to eql(1) - - schedule = klass.where(cohort:).first - expect(schedule.name).to eql("NPQ Leadership Autumn") - - milestone = schedule.milestones.first - expect(milestone.name).to eql("Output 1 - Participant Start") - expect(milestone.declaration_type).to eql("started") - expect(milestone.start_date).to eql("01/11/#{cohort.start_year}".to_date) - expect(milestone.milestone_date).to eql("01/11/#{cohort.start_year}".to_date) - expect(milestone.payment_date).to eql("01/11/#{cohort.start_year}".to_date) - - schedule_milestone = schedule.schedule_milestones.first - expect(schedule_milestone.name).to eql("Output 1 - Participant Start") - expect(schedule_milestone.declaration_type).to eql("started") - end - end - - context "existing schedule" do - let!(:schedule) { create(:npq_leadership_schedule, name: "New NPQ name", schedule_identifier: "npq-leadership-autumn", cohort:) } - - it "updates the name" do - expect(schedule.type).to eql(klass.name) - expect(klass.where(cohort:).count).to eql(1) - expect(schedule.reload.name).to eql("New NPQ name") - subject.call - expect(klass.where(cohort:).count).to eql(1) - expect(schedule.reload.name).to eql("NPQ Leadership Autumn") - end - end - end end describe "#type_to_klass" do @@ -125,10 +78,6 @@ end it "returns correct schedule class for each type" do - expect(subject.send(:type_to_klass, "npq_specialist")).to eql(Finance::Schedule::NPQSpecialist) - expect(subject.send(:type_to_klass, "npq_leadership")).to eql(Finance::Schedule::NPQLeadership) - expect(subject.send(:type_to_klass, "npq_aso")).to eql(Finance::Schedule::NPQSupport) - expect(subject.send(:type_to_klass, "npq_ehco")).to eql(Finance::Schedule::NPQEhco) expect(subject.send(:type_to_klass, "ecf_standard")).to eql(Finance::Schedule::ECF) expect(subject.send(:type_to_klass, "ecf_reduced")).to eql(Finance::Schedule::ECF) expect(subject.send(:type_to_klass, "ecf_extended")).to eql(Finance::Schedule::ECF) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a394ae27f2..28a2b39938 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -113,17 +113,6 @@ (2020..end_year).each do |start_year| cohort = Cohort.find_by(start_year:) || FactoryBot.create(:cohort, start_year:) Finance::Schedule::ECF.default_for(cohort:) || FactoryBot.create(:ecf_schedule, cohort:) - - { - npq_specialist_schedule: %w[npq-specialist-spring npq-specialist-autumn], - npq_leadership_schedule: %w[npq-leadership-spring npq-leadership-autumn], - npq_aso_schedule: %w[npq-aso-december], - npq_ehco_schedule: %w[npq-ehco-november npq-ehco-december npq-ehco-march npq-ehco-june], - }.each do |schedule_type, schedule_identifiers| - schedule_identifiers.each do |schedule_identifier| - Finance::Schedule.find_by(cohort:, schedule_identifier:) || FactoryBot.create(schedule_type, cohort:, schedule_identifier:) - end - end end end end