transfer.rb 869 B

12345678910111213141516171819202122232425
  1. class Transfer < ActiveRecord::Base
  2. audited
  3. belongs_to :origin, :class_name => 'Pointsale'
  4. belongs_to :destiny, :class_name => 'Pointsale'
  5. belongs_to :user, :class_name => 'User'
  6. belongs_to :received_by, :class_name => 'User'
  7. has_many :transfer_details
  8. has_many :products, :through => :transfer_details
  9. has_many :inventories_moves
  10. enum status: [:cancelled, :pending, :received]
  11. accepts_nested_attributes_for :transfer_details
  12. validates_associated :transfer_details
  13. validates :origin_id, presence: { message: "Debe indicar origen del traspaso." }, :on => [:create, :update]
  14. validates :destiny_id, presence: { message: "Debe indicar destino del traspaso." }, :on => [:create, :update]
  15. validates :received_by_id, presence: { message: "Debe indicar quien recibió el traspaso." }, :on => [:update]
  16. scope :activos, -> { where("status = 1") }
  17. end