Browse Source

Domain specific constants (#144)

pull/147/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
19e5633e8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/case_log.rb
  2. 7
      app/models/constants/case_log.rb
  3. 6
      app/models/constants/organisation.rb
  4. 2
      app/models/organisation.rb

2
app/models/case_log.rb

@ -30,7 +30,7 @@ end
class CaseLog < ApplicationRecord class CaseLog < ApplicationRecord
include Discard::Model include Discard::Model
include Validations::SoftValidations include Validations::SoftValidations
include Constants::DbEnums include Constants::CaseLog
include Constants::IncomeRanges include Constants::IncomeRanges
default_scope -> { kept } default_scope -> { kept }

7
app/models/constants/db_enums.rb → app/models/constants/case_log.rb

@ -1,4 +1,4 @@
module Constants::DbEnums module Constants::CaseLog
BENEFITCAP = { BENEFITCAP = {
"Yes - benefit cap" => 5, "Yes - benefit cap" => 5,
"Yes - removal of the spare room subsidy" => 4, "Yes - removal of the spare room subsidy" => 4,
@ -676,11 +676,6 @@ module Constants::DbEnums
"Supported housing" => 2, "Supported housing" => 2,
}.freeze }.freeze
ORG_TYPE = {
"LA" => 1,
"PRP" => 2,
}.freeze
LET_TYPE = { LET_TYPE = {
"Social Rent General needs PRP" => 1, "Social Rent General needs PRP" => 1,
"Social Rent Supported housing PRP" => 2, "Social Rent Supported housing PRP" => 2,

6
app/models/constants/organisation.rb

@ -0,0 +1,6 @@
module Constants::Organisation
ORG_TYPE = {
"LA" => 1,
"PRP" => 2,
}.freeze
end

2
app/models/organisation.rb

@ -3,7 +3,7 @@ class Organisation < ApplicationRecord
has_many :owned_case_logs, class_name: "CaseLog", foreign_key: "owning_organisation_id" has_many :owned_case_logs, class_name: "CaseLog", foreign_key: "owning_organisation_id"
has_many :managed_case_logs, class_name: "CaseLog", foreign_key: "managing_organisation_id" has_many :managed_case_logs, class_name: "CaseLog", foreign_key: "managing_organisation_id"
include Constants::DbEnums include Constants::Organisation
enum "Org type": ORG_TYPE, _suffix: true enum "Org type": ORG_TYPE, _suffix: true
def case_logs def case_logs

Loading…
Cancel
Save