| 
						
						
						
					 | 
					 | 
					@ -1,6 +1,6 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					class CaseLogValidator < ActiveModel::Validator | 
					 | 
					 | 
					 | 
					class CaseLogValidator < ActiveModel::Validator | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  # Validations methods need to be called 'validate_<page_name>' to run on model save | 
					 | 
					 | 
					 | 
					  # Validations methods need to be called 'validate_' to run on model save | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  # or 'validate_' to run on submit as well | 
					 | 
					 | 
					 | 
					  # or form page submission | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  include HouseholdValidations | 
					 | 
					 | 
					 | 
					  include HouseholdValidations | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  include PropertyValidations | 
					 | 
					 | 
					 | 
					  include PropertyValidations | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  include FinancialValidations | 
					 | 
					 | 
					 | 
					  include FinancialValidations | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -8,17 +8,9 @@ class CaseLogValidator < ActiveModel::Validator | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  include DateValidations | 
					 | 
					 | 
					 | 
					  include DateValidations | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  def validate(record) | 
					 | 
					 | 
					 | 
					  def validate(record) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # If we've come from the form UI we only want to validate the specific fields | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # that have just been submitted. If we're submitting a log via API or Bulk Upload | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # we want to validate all data fields. | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    page_to_validate = record.page_id | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if page_to_validate | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      public_send("validate_#{page_to_validate}", record) if respond_to?("validate_#{page_to_validate}") | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    else | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    validation_methods = public_methods.select { |method| method.starts_with?("validate_") } | 
					 | 
					 | 
					 | 
					    validation_methods = public_methods.select { |method| method.starts_with?("validate_") } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    validation_methods.each { |meth| public_send(meth, record) } | 
					 | 
					 | 
					 | 
					    validation_methods.each { |meth| public_send(meth, record) } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  end | 
					 | 
					 | 
					 | 
					  end | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  end | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					private | 
					 | 
					 | 
					 | 
					private | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -49,8 +41,6 @@ class CaseLog < ApplicationRecord | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  scope :for_organisation, ->(org) { where(owning_organisation: org).or(where(managing_organisation: org)) } | 
					 | 
					 | 
					 | 
					  scope :for_organisation, ->(org) { where(owning_organisation: org).or(where(managing_organisation: org)) } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  attr_accessor :page_id | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  enum status: { "not_started" => 0, "in_progress" => 1, "completed" => 2 } | 
					 | 
					 | 
					 | 
					  enum status: { "not_started" => 0, "in_progress" => 1, "completed" => 2 } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  enum ethnic: DbEnums.ethnic | 
					 | 
					 | 
					 | 
					  enum ethnic: DbEnums.ethnic | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |