| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -31,6 +31,12 @@ module Validations::DateValidations | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  def validate_startdate(record) | 
					 | 
					 | 
					 | 
					  def validate_startdate(record) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return unless record.startdate && date_valid?("startdate", record) | 
					 | 
					 | 
					 | 
					    return unless record.startdate && date_valid?("startdate", record) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    created_at = record.created_at || Time.zone.now | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if created_at > first_collection_end_date && record.startdate < second_collection_start_date | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      record.errors.add :startdate, I18n.t("validations.date.outside_collection_window") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    end | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if record.startdate < first_collection_start_date || record.startdate > second_collection_end_date | 
					 | 
					 | 
					 | 
					    if record.startdate < first_collection_start_date || record.startdate > second_collection_end_date | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      record.errors.add :startdate, I18n.t("validations.date.outside_collection_window") | 
					 | 
					 | 
					 | 
					      record.errors.add :startdate, I18n.t("validations.date.outside_collection_window") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    end | 
					 | 
					 | 
					 | 
					    end | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -57,6 +63,14 @@ private | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @first_collection_start_date ||= FormHandler.instance.forms.map { |form| form.second.start_date }.compact.min | 
					 | 
					 | 
					 | 
					    @first_collection_start_date ||= FormHandler.instance.forms.map { |form| form.second.start_date }.compact.min | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  end | 
					 | 
					 | 
					 | 
					  end | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  def first_collection_end_date | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    @first_collection_end_date ||= FormHandler.instance.forms.map { |form| form.second.end_date }.compact.min | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  end | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  def second_collection_start_date | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    @second_collection_start_date ||= FormHandler.instance.forms.map { |form| form.second.start_date }.compact.max | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  end | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  def second_collection_end_date | 
					 | 
					 | 
					 | 
					  def second_collection_end_date | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @second_collection_end_date ||= FormHandler.instance.forms.map { |form| form.second.end_date }.compact.max | 
					 | 
					 | 
					 | 
					    @second_collection_end_date ||= FormHandler.instance.forms.map { |form| form.second.end_date }.compact.max | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  end | 
					 | 
					 | 
					 | 
					  end | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |