Browse Source

Temp remove some date restrictions

pull/2107/head
Rachael Booth 12 months ago
parent
commit
cd7f18f9f1
  1. 4
      app/helpers/collection_time_helper.rb
  2. 12
      app/models/log.rb
  3. 12
      app/models/validations/sales/setup_validations.rb
  4. 12
      app/models/validations/setup_validations.rb

4
app/helpers/collection_time_helper.rb

@ -39,10 +39,10 @@ module CollectionTimeHelper
end end
def previous_collection_start_year def previous_collection_start_year
current_collection_start_year - 1 current_collection_start_year - 2
end end
def previous_collection_start_date def previous_collection_start_date
current_collection_start_date - 1.year current_collection_start_date - 2.year
end end
end end

12
app/models/log.rb

@ -106,15 +106,11 @@ class Log < ApplicationRecord
end end
def collection_period_open? def collection_period_open?
return false if older_than_previous_collection_year? return true
form.new_logs_end_date > Time.zone.today
end end
def collection_period_open_for_editing? def collection_period_open_for_editing?
return false if older_than_previous_collection_year? return true
form.edit_end_date > Time.zone.today
end end
def blank_invalid_non_setup_fields! def blank_invalid_non_setup_fields!
@ -207,9 +203,7 @@ private
# Handle logs that are older than previous collection start date # Handle logs that are older than previous collection start date
def older_than_previous_collection_year? def older_than_previous_collection_year?
return false unless startdate return false
startdate < previous_collection_start_date
end end
def plural_gender_for_person(person_num) def plural_gender_for_person(person_num)

12
app/models/validations/sales/setup_validations.rb

@ -3,17 +3,7 @@ module Validations::Sales::SetupValidations
include CollectionTimeHelper include CollectionTimeHelper
def validate_saledate_collection_year(record) def validate_saledate_collection_year(record)
return unless record.saledate && date_valid?("saledate", record) && FeatureToggle.saledate_collection_window_validation_enabled? return
first_collection_start_date = if record.saledate_was.present?
editable_collection_start_date
else
active_collection_start_date
end
unless record.saledate.between?(first_collection_start_date, current_collection_end_date)
record.errors.add :saledate, saledate_validation_error_message
end
end end
def validate_saledate_two_weeks(record) def validate_saledate_two_weeks(record)

12
app/models/validations/setup_validations.rb

@ -3,17 +3,7 @@ module Validations::SetupValidations
include CollectionTimeHelper include CollectionTimeHelper
def validate_startdate_setup(record) def validate_startdate_setup(record)
return unless record.startdate && date_valid?("startdate", record) return
first_collection_start_date = if record.startdate_was.present?
editable_collection_start_date
else
active_collection_start_date
end
unless record.startdate.between?(first_collection_start_date, current_collection_end_date)
record.errors.add :startdate, startdate_validation_error_message
end
end end
def validate_organisation(record) def validate_organisation(record)

Loading…
Cancel
Save