<commit_before># Q1
multiple_choice :what_would_you_like_to_check? do
  option "current_payment"
  option "past_payment"

  save_input_as :current_or_past_payments

  next_node do |response|
    case response
    when 'current_payment'
      :are_you_an_apprentice?
    when 'past_payment'
      :past_payment_date?
    end
  end

  calculate :calculator do
    Calculators::MinimumWageCalculator.new
  end
end

# Q1A
multiple_choice :past_payment_date? do
  option "2013-10-01"
  option "2012-10-01"
  option "2011-10-01"
  option "2010-10-01"
  option "2009-10-01"
  option "2008-10-01"

  next_node do |response|
    calculator.date = Date.parse(response)
    :were_you_an_apprentice?
  end
end

# Q2
multiple_choice :are_you_an_apprentice? do
  option "not_an_apprentice"
  option "apprentice_under_19"
  option "apprentice_over_19_first_year"
  option "apprentice_over_19_second_year_onwards"

  save_input_as :is_apprentice

  next_node do |response|
    case response
    when 'not_an_apprentice', 'apprentice_over_19_second_year_onwards'
      :how_old_are_you?
    when 'apprentice_under_19', 'apprentice_over_19_first_year'
      :how_often_do_you_get_paid?
    end
  end
end

# Q2 Past
multiple_choice :were_you_an_apprentice? do
  option "no"
  option "apprentice_under_19"
  option "apprentice_over_19"

  save_input_as :was_apprentice

  next_node do |response|
    case response
    when "no"
      :how_old_were_you?
    else
      if calculator.date < Date.parse('2010-10-01')
        :does_not_apply_to_historical_apprentices
      else
        :how_often_did_you_get_paid?
      end
    end
  end
end

# Q3
value_question :how_old_are_you?, parse: Integer do
  validate do |response|
    response > 0 && response <= 200
  end

  next_node do |response|
    calculator.age = response
    if response < 16
      :under_school_leaving_age
    else
      :how_often_do_you_get_paid?
    end
  end
end

# Q3 Past
value_question :how_old_were_you?, parse: Integer do
  validate do |response|
    response > 0 && response <= 200
  end

  next_node do |response|
    calculator.age = response
    if response < 16
      :under_school_leaving_age_past
    else
      :how_often_did_you_get_paid?
    end
  end
end

# Q4
value_question :how_often_do_you_get_paid?, parse: :to_i do
  validate do |response|
    response >= 1 && response <= 31
  end

  next_node do |response|
    calculator.pay_frequency = response
    :how_many_hours_do_you_work?
  end
end

# Q4 Past
value_question :how_often_did_you_get_paid?, parse: :to_i do
  validate do |response|
    response >= 1 && response <= 31
  end

  next_node do |response|
    calculator.pay_frequency = response
    :how_many_hours_did_you_work?
  end
end

# Q5
value_question :how_many_hours_do_you_work?, parse: Float do
  validate(:error_hours) do |response|
    response > 0 && response <= (calculator.pay_frequency * 16)
  end

  next_node do |response|
    calculator.basic_hours = response
    :how_much_are_you_paid_during_pay_period?
  end
end

# Q5 Past
value_question :how_many_hours_did_you_work?, parse: Float do
  validate(:error_hours) do |response|
    response > 0 && response <= (calculator.pay_frequency * 16)
  end

  next_node do |response|
    calculator.basic_hours = response
    :how_much_were_you_paid_during_pay_period?
  end
end

# Q6
money_question :how_much_are_you_paid_during_pay_period? do
  calculate :calculator do |response|
    calculator.basic_pay = Float(response)
    calculator.is_apprentice = (is_apprentice == 'apprentice_under_19' ||
                    is_apprentice == 'apprentice_over_19_first_year')
    calculator
  end

  next_node :how_many_hours_overtime_do_you_work?
end

# Q6 Past
money_question :how_much_were_you_paid_during_pay_period? do
  calculate :calculator do |response|
    calculator.basic_pay = Float(response)
    calculator.is_apprentice = (was_apprentice != 'no')
    calculator
  end

  next_node :how_many_hours_overtime_did_you_work?
end

# Q7
value_question :how_many_hours_overtime_do_you_work?, parse: Float do
  validate do |response|
    response >= 0
  end

  next_node do |response|
    calculator.overtime_hours = response
    if response.to_i == 0
      :is_provided_with_accommodation?
    else
      :what_is_overtime_pay_per_hour?
    end<commit_msg>Set the is_apprentice on the calculator earlier in the flow<commit_after># Q1
multiple_choice :what_would_you_like_to_check? do
  option "current_payment"
  option "past_payment"

  save_input_as :current_or_past_payments

  next_node do |response|
    case response
    when 'current_payment'
      :are_you_an_apprentice?
    when 'past_payment'
      :past_payment_date?
    end
  end

  calculate :calculator do
    Calculators::MinimumWageCalculator.new
  end
end

# Q1A
multiple_choice :past_payment_date? do
  option "2013-10-01"
  option "2012-10-01"
  option "2011-10-01"
  option "2010-10-01"
  option "2009-10-01"
  option "2008-10-01"

  next_node do |response|
    calculator.date = Date.parse(response)
    :were_you_an_apprentice?
  end
end

# Q2
multiple_choice :are_you_an_apprentice? do
  option "not_an_apprentice"
  option "apprentice_under_19"
  option "apprentice_over_19_first_year"
  option "apprentice_over_19_second_year_onwards"

  next_node do |response|
    case response
    when 'not_an_apprentice', 'apprentice_over_19_second_year_onwards'
      calculator.is_apprentice = false
      :how_old_are_you?
    when 'apprentice_under_19', 'apprentice_over_19_first_year'
      calculator.is_apprentice = true
      :how_often_do_you_get_paid?
    end
  end
end

# Q2 Past
multiple_choice :were_you_an_apprentice? do
  option "no"
  option "apprentice_under_19"
  option "apprentice_over_19"

  next_node do |response|
    case response
    when "no"
      calculator.is_apprentice = false
      :how_old_were_you?
    else
      calculator.is_apprentice = true
      if calculator.date < Date.parse('2010-10-01')
        :does_not_apply_to_historical_apprentices
      else
        :how_often_did_you_get_paid?
      end
    end
  end
end

# Q3
value_question :how_old_are_you?, parse: Integer do
  validate do |response|
    response > 0 && response <= 200
  end

  next_node do |response|
    calculator.age = response
    if response < 16
      :under_school_leaving_age
    else
      :how_often_do_you_get_paid?
    end
  end
end

# Q3 Past
value_question :how_old_were_you?, parse: Integer do
  validate do |response|
    response > 0 && response <= 200
  end

  next_node do |response|
    calculator.age = response
    if response < 16
      :under_school_leaving_age_past
    else
      :how_often_did_you_get_paid?
    end
  end
end

# Q4
value_question :how_often_do_you_get_paid?, parse: :to_i do
  validate do |response|
    response >= 1 && response <= 31
  end

  next_node do |response|
    calculator.pay_frequency = response
    :how_many_hours_do_you_work?
  end
end

# Q4 Past
value_question :how_often_did_you_get_paid?, parse: :to_i do
  validate do |response|
    response >= 1 && response <= 31
  end

  next_node do |response|
    calculator.pay_frequency = response
    :how_many_hours_did_you_work?
  end
end

# Q5
value_question :how_many_hours_do_you_work?, parse: Float do
  validate(:error_hours) do |response|
    response > 0 && response <= (calculator.pay_frequency * 16)
  end

  next_node do |response|
    calculator.basic_hours = response
    :how_much_are_you_paid_during_pay_period?
  end
end

# Q5 Past
value_question :how_many_hours_did_you_work?, parse: Float do
  validate(:error_hours) do |response|
    response > 0 && response <= (calculator.pay_frequency * 16)
  end

  next_node do |response|
    calculator.basic_hours = response
    :how_much_were_you_paid_during_pay_period?
  end
end

# Q6
money_question :how_much_are_you_paid_during_pay_period? do
  calculate :calculator do |response|
    calculator.basic_pay = Float(response)
    calculator
  end

  next_node :how_many_hours_overtime_do_you_work?
end

# Q6 Past
money_question :how_much_were_you_paid_during_pay_period? do
  calculate :calculator do |response|
    calculator.basic_pay = Float(response)
    calculator
  end

  next_node :how_many_hours_overtime_did_you_work?
end

# Q7
value_question :how_many_hours_overtime_do_you_work?, parse: Float do
  validate do |response|
    response >= 0
  end

  next_node do |response|
    calculator.overtime_hours = response
    if response.to_i == 0
      :is_provided_with_accommodation?
    else
      :what_is_overtime_pay_per_hour?
    end
{'fraction_non_alphanumeric': 0.07155425219941348, 'fraction_numerical': 0.02651026392961877, 'mean_word_length': 3.877574370709382, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2007774', 'n_tokens_mistral': 3312, 'n_tokens_neox': 3053, 'n_words': 660}