@ -143,6 +143,20 @@ class BulkUpload::Lettings::RowParser
					 
			
		
	
		
			
				
					  validates  :field_1 ,  presence :  {  message :  I18n . t ( " validations.not_answered " ,  question :  " letting type " )  } ,   
			
		
	
		
			
				
					                      inclusion :  {  in :  ( 1 .. 12 ) . to_a ,  message :  I18n . t ( " validations.invalid_option " ,  question :  " letting type " )  }   
			
		
	
		
			
				
					  validates  :field_4 ,  presence :  {  if :  proc  {  [ 2 ,  4 ,  6 ,  8 ,  10 ,  12 ] . include? ( field_1 )  }  }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  validates  :field_12 ,  format :  {  with :  / \ A \ d{1,3} \ z| \ AR \ z / ,  message :  " Age of person 1 must be a number or the letter R "  }   
			
		
	
		
			
				
					  validates  :field_13 ,  format :  {  with :  / \ A \ d{1,3} \ z| \ AR \ z / ,  message :  " Age of person 2 must be a number or the letter R "  }   
			
		
	
		
			
				
					  validates  :field_14 ,  format :  {  with :  / \ A \ d{1,3} \ z| \ AR \ z / ,  message :  " Age of person 3 must be a number or the letter R "  }   
			
		
	
		
			
				
					  validates  :field_15 ,  format :  {  with :  / \ A \ d{1,3} \ z| \ AR \ z / ,  message :  " Age of person 4 must be a number or the letter R "  }   
			
		
	
		
			
				
					  validates  :field_16 ,  format :  {  with :  / \ A \ d{1,3} \ z| \ AR \ z / ,  message :  " Age of person 5 must be a number or the letter R "  }   
			
		
	
		
			
				
					  validates  :field_17 ,  format :  {  with :  / \ A \ d{1,3} \ z| \ AR \ z / ,  message :  " Age of person 6 must be a number or the letter R "  }   
			
		
	
		
			
				
					  validates  :field_18 ,  format :  {  with :  / \ A \ d{1,3} \ z| \ AR \ z / ,  message :  " Age of person 7 must be a number or the letter R "  }   
			
		
	
		
			
				
					  validates  :field_19 ,  format :  {  with :  / \ A \ d{1,3} \ z| \ AR \ z / ,  message :  " Age of person 8 must be a number or the letter R "  }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  validates  :field_96 ,  presence :  {  message :  I18n . t ( " validations.not_answered " ,  question :  " tenancy start date (day) " )  }   
			
		
	
		
			
				
					  validates  :field_97 ,  presence :  {  message :  I18n . t ( " validations.not_answered " ,  question :  " tenancy start date (month) " )  }   
			
		
	
		
			
				
					  validates  :field_98 ,  presence :  {  message :  I18n . t ( " validations.not_answered " ,  question :  " tenancy start date (year) " )  }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  validates  :field_98 ,  format :  {  with :  / \ A \ d{2} \ z / ,  message :  I18n . t ( " validations.setup.startdate.year_not_two_digits " )  }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  validate  :validate_data_types   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -181,7 +195,12 @@ class BulkUpload::Lettings::RowParser
					 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    log . errors . each  do  | error |   
			
		
	
		
			
				
					      fields  =  field_mapping_for_errors [ error . attribute ]  ||  [ ]   
			
		
	
		
			
				
					      fields . each  {  | field |  errors . add ( field ,  error . type )  }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					      fields . each  do  | field |   
			
		
	
		
			
				
					        unless  errors . include? ( field )   
			
		
	
		
			
				
					          errors . add ( field ,  error . type )   
			
		
	
		
			
				
					        end   
			
		
	
		
			
				
					      end   
			
		
	
		
			
				
					    end   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    errors . blank?   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -341,7 +360,7 @@ private
					 
			
		
	
		
			
				
					  end   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  def  validate_relevant_collection_window   
			
		
	
		
			
				
					    return  unless  start_date  && bulk_upload . form   
			
		
	
		
			
				
					    return  if  start_date . blank?  || bulk_upload . form . blank?   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    unless  bulk_upload . form . valid_start_date_for_form? ( start_date )   
			
		
	
		
			
				
					      errors . add ( :field_96 ,  I18n . t ( " validations.date.outside_collection_window " ) )   
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -351,6 +370,8 @@ private
					 
			
		
	
		
			
				
					  end   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  def  start_date   
			
		
	
		
			
				
					    return  if  field_98 . blank?  ||  field_97 . blank?  ||  field_96 . blank?   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    Date . parse ( " 20 #{ field_98 . to_s . rjust ( 2 ,  '0' ) } - #{ field_97 } - #{ field_96 } " )   
			
		
	
		
			
				
					  rescue  StandardError   
			
		
	
		
			
				
					    nil   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -392,9 +413,17 @@ private
					 
			
		
	
		
			
				
					      next  if  question . completed? ( log )   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					      if  setup_question? ( question )   
			
		
	
		
			
				
					        fields . each  {  | field |  errors . add ( field ,  I18n . t ( " validations.not_answered " ,  question :  question . check_answer_label & . downcase ) ,  category :  :setup )  }   
			
		
	
		
			
				
					        fields . each  do  | field |   
			
		
	
		
			
				
					          if  errors [ field ] . present?   
			
		
	
		
			
				
					            errors . add ( field ,  I18n . t ( " validations.not_answered " ,  question :  question . check_answer_label & . downcase ) ,  category :  :setup )   
			
		
	
		
			
				
					          end   
			
		
	
		
			
				
					        end   
			
		
	
		
			
				
					      else   
			
		
	
		
			
				
					        fields . each  {  | field |  errors . add ( field ,  I18n . t ( " validations.not_answered " ,  question :  question . check_answer_label & . downcase ) )  }   
			
		
	
		
			
				
					        fields . each  do  | field |   
			
		
	
		
			
				
					          unless  errors . any?  {  | e |  fields . include? ( e . attribute )  }   
			
		
	
		
			
				
					            errors . add ( field ,  I18n . t ( " validations.not_answered " ,  question :  question . check_answer_label & . downcase ) )   
			
		
	
		
			
				
					          end   
			
		
	
		
			
				
					        end   
			
		
	
		
			
				
					      end   
			
		
	
		
			
				
					    end   
			
		
	
		
			
				
					  end   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -642,28 +671,28 @@ private
					 
			
		
	
		
			
				
					    attributes [ " declaration " ]  =  field_132   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    attributes [ " age1_known " ]  =  field_12  ==  " R "  ?  1  :  0   
			
		
	
		
			
				
					    attributes [ " age1 " ]  =  field_12  if  attributes [ " age1_known " ] . zero?   
			
		
	
		
			
				
					    attributes [ " age1 " ]  =  field_12  if  attributes [ " age1_known " ] . zero?  &&  field_12 & . match ( / \ A \ d{1,3} \ z| \ AR \ z / )    
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    attributes [ " age2_known " ]  =  field_13  ==  " R "  ?  1  :  0   
			
		
	
		
			
				
					    attributes [ " age2 " ]  =  field_13  if  attributes [ " age2_known " ] . zero?   
			
		
	
		
			
				
					    attributes [ " age2 " ]  =  field_13  if  attributes [ " age2_known " ] . zero?  &&  field_13 & . match ( / \ A \ d{1,3} \ z| \ AR \ z / )    
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    attributes [ " age3_known " ]  =  field_14  ==  " R "  ?  1  :  0   
			
		
	
		
			
				
					    attributes [ " age3 " ]  =  field_14  if  attributes [ " age3_known " ] . zero?   
			
		
	
		
			
				
					    attributes [ " age3 " ]  =  field_14  if  attributes [ " age3_known " ] . zero?  &&  field_14 & . match ( / \ A \ d{1,3} \ z| \ AR \ z / )    
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    attributes [ " age4_known " ]  =  field_15  ==  " R "  ?  1  :  0   
			
		
	
		
			
				
					    attributes [ " age4 " ]  =  field_15  if  attributes [ " age4_known " ] . zero?   
			
		
	
		
			
				
					    attributes [ " age4 " ]  =  field_15  if  attributes [ " age4_known " ] . zero?  &&  field_15 & . match ( / \ A \ d{1,3} \ z| \ AR \ z / )    
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    attributes [ " age5_known " ]  =  field_16  ==  " R "  ?  1  :  0   
			
		
	
		
			
				
					    attributes [ " age5 " ]  =  field_16  if  attributes [ " age5_known " ] . zero?   
			
		
	
		
			
				
					    attributes [ " age5 " ]  =  field_16  if  attributes [ " age5_known " ] . zero?  &&  field_16 & . match ( / \ A \ d{1,3} \ z| \ AR \ z / )    
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    attributes [ " age6_known " ]  =  field_17  ==  " R "  ?  1  :  0   
			
		
	
		
			
				
					    attributes [ " age6 " ]  =  field_17  if  attributes [ " age6_known " ] . zero?   
			
		
	
		
			
				
					    attributes [ " age6 " ]  =  field_17  if  attributes [ " age6_known " ] . zero?  &&  field_17 & . match ( / \ A \ d{1,3} \ z| \ AR \ z / )    
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    attributes [ " age7_known " ]  =  field_18  ==  " R "  ?  1  :  0   
			
		
	
		
			
				
					    attributes [ " age7 " ]  =  field_18  if  attributes [ " age7_known " ] . zero?   
			
		
	
		
			
				
					    attributes [ " age7 " ]  =  field_18  if  attributes [ " age7_known " ] . zero?  &&  field_18 & . match ( / \ A \ d{1,3} \ z| \ AR \ z / )    
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    attributes [ " age8_known " ]  =  field_19  ==  " R "  ?  1  :  0   
			
		
	
		
			
				
					    attributes [ " age8 " ]  =  field_19  if  attributes [ " age8_known " ] . zero?   
			
		
	
		
			
				
					    attributes [ " age8 " ]  =  field_19  if  attributes [ " age8_known " ] . zero?  &&  field_19 & . match ( / \ A \ d{1,3} \ z| \ AR \ z / )    
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    attributes [ " sex1 " ]  =  field_20   
			
		
	
		
			
				
					    attributes [ " sex2 " ]  =  field_21   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -882,6 +911,8 @@ private
					 
			
		
	
		
			
				
					      0   
			
		
	
		
			
				
					    when  nil   
			
		
	
		
			
				
					      rsnvac  ==  14  ?  1  :  0   
			
		
	
		
			
				
					    else   
			
		
	
		
			
				
					      field_134   
			
		
	
		
			
				
					    end   
			
		
	
		
			
				
					  end