Browse Source

feat: use confirmed behaviour

pull/1003/head
natdeanlewissoftwire 4 years ago
parent
commit
a22192b38c
  1. 9
      app/models/scheme.rb
  2. 6
      db/schema.rb

9
app/models/scheme.rb

@ -200,6 +200,8 @@ class Scheme < ApplicationRecord
end
def validate_confirmed
required_attributes = attribute_names - %w[id created_at updated_at old_id old_visible_id confirmed end_date sensitive secondary_client_group total_units has_other_client_group deactivation_date deactivation_date_type]
if confirmed == true
required_attributes.any? do |attribute|
if self[attribute].blank?
@ -210,16 +212,13 @@ class Scheme < ApplicationRecord
end
end
def required_attributes
attribute_names - %w[id created_at updated_at old_id old_visible_id confirmed end_date sensitive secondary_client_group total_units has_other_client_group deactivation_date deactivation_date_type]
end
def available_from
created_at
end
def status
return :incomplete if required_attributes.any? { |attribute| self[attribute].blank? }
return :incomplete unless confirmed
recent_deactivation = scheme_deactivation_periods.deactivations_without_reactivation.first
return :active if recent_deactivation.blank?
return :deactivating_soon if Time.zone.now < recent_deactivation.deactivation_date

6
db/schema.rb

@ -372,15 +372,15 @@ ActiveRecord::Schema[7.0].define(version: 2022_11_17_103855) do
t.integer "la_known"
t.integer "income1"
t.integer "income1nk"
t.integer "details_known_2"
t.integer "details_known_3"
t.integer "details_known_4"
t.integer "age4"
t.integer "age4_known"
t.integer "age5"
t.integer "age5_known"
t.integer "age6"
t.integer "age6_known"
t.integer "details_known_2"
t.integer "details_known_3"
t.integer "details_known_4"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

Loading…
Cancel
Save