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
def previous_collection_start_year
current_collection_start_year - 1
current_collection_start_year - 2
end
def previous_collection_start_date
current_collection_start_date - 1.year
current_collection_start_date - 2.year
end
end

12
app/models/log.rb

@ -106,15 +106,11 @@ class Log < ApplicationRecord
end
def collection_period_open?
return false if older_than_previous_collection_year?
form.new_logs_end_date > Time.zone.today
return true
end
def collection_period_open_for_editing?
return false if older_than_previous_collection_year?
form.edit_end_date > Time.zone.today
return true
end
def blank_invalid_non_setup_fields!
@ -207,9 +203,7 @@ private
# Handle logs that are older than previous collection start date
def older_than_previous_collection_year?
return false unless startdate
startdate < previous_collection_start_date
return false
end
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
def validate_saledate_collection_year(record)
return unless record.saledate && date_valid?("saledate", record) && FeatureToggle.saledate_collection_window_validation_enabled?
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
return
end
def validate_saledate_two_weeks(record)

12
app/models/validations/setup_validations.rb

@ -3,17 +3,7 @@ module Validations::SetupValidations
include CollectionTimeHelper
def validate_startdate_setup(record)
return unless record.startdate && date_valid?("startdate", record)
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
return
end
def validate_organisation(record)

Loading…
Cancel
Save