class Base::FonteDeRecursoDaContaBancaria < ApplicationRecord
  has_paper_trail

  belongs_to :fonte_de_recurso, class_name: 'Base::FonteDeRecursos', foreign_key: :fonte_de_recurso_id
  belongs_to :conta_bancaria, class_name: 'Base::ContaBancaria'

  validates :fonte_de_recurso_id, presence: true
  # validates_numericality_of :saldo_inicial, less_than_or_equal_to: -> (fonte_de_recurso) { fonte_de_recurso.conta_bancaria.saldo_inicial }, 
  #                           allow_nil: true, if: Proc.new { conta_bancaria.present? }


  def numero_agencia_e_banco
		self.conta_bancaria ? self.conta_bancaria.to_s : ""
	end
end
