Sha256: 139324e35330a4f7d5a007ab2e292b72f2fba061a4a859f5dedbb542e2d384a3

Contents?: true

Size: 936 Bytes

Versions: 19

Compression:

Stored size: 936 Bytes

Contents

require "local_service"
require "edition"

class LocalTransactionEdition < Edition
  field :lgsl_code, type: Integer
  field :lgil_override, type: Integer
  field :introduction, type: String
  field :more_information, type: String
  field :need_to_know, type: String

  GOVSPEAK_FIELDS = [:introduction, :more_information, :need_to_know]

  @fields_to_clone = [
    :lgsl_code, :introduction, :more_information, :need_to_know
  ]

  validate :valid_lgsl_code

  def valid_lgsl_code
    if ! self.service
      errors.add(:lgsl_code, "#{lgsl_code} not recognised")
    end
  end

  def format_name
    "Local transaction"
  end

  def search_format
    "transaction"
  end

  def service
    LocalService.find_by_lgsl_code(lgsl_code)
  end

  def service_provided_by?(snac)
    authority = LocalAuthority.find_by_snac(snac)
    authority && authority.provides_service?(lgsl_code)
  end

  def whole_body
    self.introduction
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
govuk_content_models-29.1.2 app/models/local_transaction_edition.rb
govuk_content_models-29.1.1 app/models/local_transaction_edition.rb
govuk_content_models-29.1.0 app/models/local_transaction_edition.rb
govuk_content_models-29.0.1 app/models/local_transaction_edition.rb
govuk_content_models-29.0.0 app/models/local_transaction_edition.rb
govuk_content_models-28.10.0 app/models/local_transaction_edition.rb
govuk_content_models-28.9.0 app/models/local_transaction_edition.rb
govuk_content_models-28.8.0 app/models/local_transaction_edition.rb
govuk_content_models-28.7.1 app/models/local_transaction_edition.rb
govuk_content_models-28.7.0 app/models/local_transaction_edition.rb
govuk_content_models-28.6.2 app/models/local_transaction_edition.rb
govuk_content_models-28.6.1 app/models/local_transaction_edition.rb
govuk_content_models-28.6.0 app/models/local_transaction_edition.rb
govuk_content_models-28.5.0 app/models/local_transaction_edition.rb
govuk_content_models-28.4.0 app/models/local_transaction_edition.rb
govuk_content_models-28.3.0 app/models/local_transaction_edition.rb
govuk_content_models-28.2.0 app/models/local_transaction_edition.rb
govuk_content_models-28.1.0 app/models/local_transaction_edition.rb
govuk_content_models-28.0.1 app/models/local_transaction_edition.rb