components/financial_assistance/app/models/financial_assistance/applicant.rb
# rubocop:disable Metrics/ClassLength TODO: Remove this
disable Metrics/ClassLength TODO: Remove this
disable Metrics / ClassLength TODO : Remove this
def presence_of_attr_other_qns 
      if is_pregnant
        errors.add(:pregnancy_due_on, "' Pregnancy Due date' should be answered if you are pregnant") if pregnancy_due_on.blank? && FinancialAssistanceRegistry.feature_enabled?(:pregnancy_due_on_required)
        errors.add(:children_expected_count, "' How many children is this person expecting?' should be answered") if children_expected_count.blank?
      elsif is_post_partum_period.nil? || is_post_partum_period == ""
        errors.add(:is_post_partum_period, "' Was this person pregnant in the last 60 days?' should be answered")
      end
      if is_post_partum_period.present?
        errors.add(:is_enrolled_on_medicaid, "' Was this person on Medicaid during pregnancy?' should be answered") if is_enrolled_on_medicaid.nil?
        errors.add(:pregnancy_end_on, "' Pregnancy End on date' should be answered") if pregnancy_end_on.blank?
      end
      if FinancialAssistanceRegistry.feature_enabled?(:primary_caregiver_other_question) &&
         age_of_applicant >= 19 && is_applying_coverage == true && is_primary_caregiver.nil?
        errors.add(
          :is_primary_caregiver,
          "' Is this person the main person taking care of any children age 18 or younger? *' should be answered"
        )
      end
      return unless is_applying_coverage
      if age_of_applicant > 18 && age_of_applicant < 26
        errors.add(:is_former_foster_care, "' Was this person in foster care at age 18 or older?' should be answered") if is_former_foster_care.nil?
        if is_former_foster_care
          errors.add(:foster_care_us_state, "' Where was this person in foster care?' should be answered") if foster_care_us_state.blank?
          errors.add(:age_left_foster_care, "' How old was this person when they left foster care?' should be answered") if age_left_foster_care.nil?
        end
      end
      if is_student && FinancialAssistanceRegistry.feature_enabled?(:student_follow_up_questions)
        errors.add(:student_kind, "' #{l10n('faa.other_ques.is_student')}' should be answered") if student_kind.blank?
        errors.add(:student_status_end_on, "' Student status end on date?'  should be answered") if student_status_end_on.blank?
        errors.add(:student_school_kind, "' What type of school do you go to?' should be answered") if student_school_kind.blank?
      end
      errors.add(:is_student, "' #{l10n('faa.other_ques.is_student')}' should be answered") if age_of_applicant.between?(18,19) && is_student.nil?
    end
def presence_of_attr_other_qns if is_pregnant errors . add ( :pregnancy_due_on , "' Pregnancy Due date' should be answered if you are pregnant" ) if pregnancy_due_on . blank? && FinancialAssistanceRegistry . feature_enabled? ( :pregnancy_due_on_required ) errors . add ( :children_expected_count , "' How many children is this person expecting?' should be answered" ) if children_expected_count . blank? elsif is_post_partum_period . nil? || is_post_partum_period == "" errors . add ( :is_post_partum_period , "' Was this person pregnant in the last 60 days?' should be answered" ) end if is_post_partum_period . present? errors . add ( :is_enrolled_on_medicaid , "' Was this person on Medicaid during pregnancy?' should be answered" ) if is_enrolled_on_medicaid . nil? errors . add ( :pregnancy_end_on , "' Pregnancy End on date' should be answered" ) if pregnancy_end_on . blank? end if FinancialAssistanceRegistry . feature_enabled? ( :primary_caregiver_other_question ) && age_of_applicant >= 19 && is_applying_coverage == true && is_primary_caregiver . nil? errors . add ( :is_primary_caregiver , "' Is this person the main person taking care of any children age 18 or younger? *' should be answered" ) end return unless is_applying_coverage if age_of_applicant > 18 && age_of_applicant < 26 errors . add ( :is_former_foster_care , "' Was this person in foster care at age 18 or older?' should be answered" ) if is_former_foster_care . nil? if is_former_foster_care errors . add ( :foster_care_us_state , "' Where was this person in foster care?' should be answered" ) if foster_care_us_state . blank? errors . add ( :age_left_foster_care , "' How old was this person when they left foster care?' should be answered" ) if age_left_foster_care . nil? end end if is_student && FinancialAssistanceRegistry . feature_enabled? ( :student_follow_up_questions ) errors . add ( :student_kind , "' #{l10n('faa.other_ques.is_student')}' should be answered" ) if student_kind . blank? errors . add ( :student_status_end_on , "' Student status end on date?'  should be answered" ) if student_status_end_on . blank? errors . add ( :student_school_kind , "' What type of school do you go to?' should be answered" ) if student_school_kind . blank? end errors . add ( :is_student , "' #{l10n('faa.other_ques.is_student')}' should be answered" ) if age_of_applicant . between? ( 18 , 19 ) && is_student . nil? end
rubocop:disable Metrics/ClassLength TODO: Remove this
rubocop : disable Metrics / ClassLength TODO : Remove this
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity TODO: Remove this # Nil or "" means unanswered, true/or false boolean will be passed through # Even if they aren't pregnant, still need to ask if they were pregnant within the last 60 days # If they're in post partum period, they need to tell us if they were on medicaid and when the pregnancy ended # Enrolled on medicaid must check if nil # TODO: Decide if these validations should be ended? # errors.add(:claimed_as_tax_dependent_by, "' This person will be claimed as a dependent by' can't be blank") if is_claimed_as_tax_dependent && claimed_as_tax_dependent_by.nil? # errors.add(:is_required_to_file_taxes, "' is_required_to_file_taxes can't be blank") if is_required_to_file_taxes.nil?