Sha256: 59148413605f5ff27a27c3f8bd7c8ee922c02a6c3a5af53fdce39f9ce1e94cd5

Contents?: true

Size: 849 Bytes

Versions: 6

Compression:

Stored size: 849 Bytes

Contents

require "local_service"
require "edition"

class LocalTransactionEdition < Edition
  field :lgsl_code, type: Integer
  field :lgil_override, type: Integer
  field :lgil_code, 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]

  validate :valid_lgsl_code
  validates :lgil_code, numericality: { only_integer: true, message: "can only be whole number between 0 and 999." }

  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 whole_body
    self.introduction
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
govuk_content_models-47.0.0 app/models/local_transaction_edition.rb
govuk_content_models-46.0.1 app/models/local_transaction_edition.rb
govuk_content_models-46.0.0 app/models/local_transaction_edition.rb
govuk_content_models-45.0.0 app/models/local_transaction_edition.rb
govuk_content_models-44.4.0 app/models/local_transaction_edition.rb
govuk_content_models-44.3.0 app/models/local_transaction_edition.rb