Sha256: 20b2ade9c755a867847ab47dbafd77a74b1081eea0974e71d28c36980c9679e0

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

class Unico::BankAccount < Unico::Model
  extend EnumerateIt

  self.abstract_class = true
  self.table_name = :unico_bank_accounts

  attr_writer :bank, :bank_id

  attr_modal :description, :agency_id, :account_number

  has_enumeration_for :status
  has_enumeration_for :kind, with: BankAccountKind

  belongs_to :agency, class_name: '::Agency'

  has_one :bank, through: :agency

  delegate :number, :digit, to: :agency, allow_nil: true, prefix: true
  delegate :bank_id, to: :agency, allow_nil: true, prefix: false

  validates :description, :agency, :kind, :account_number, :digit, presence: true
  validates :account_number, numericality: true
  validates :description, uniqueness: { scope: :agency_id }, allow_blank: true

  orderize :account_number
  filterize

  def to_s
    description
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unico-training-7.8.0 app/models/unico/bank_account.rb