Files
plottservice/app/models/job.rb
David Böhm e3d5d97c6c Worked on layout, added model funktions, changed database
Changes to the migration file make it necessary to reimport the
database: db:drop, db:create, db:migrate, db:seed
2024-08-01 00:27:55 +02:00

26 lines
641 B
Ruby

class Job < ApplicationRecord
belongs_to :operator, class_name: 'User', optional: true
belongs_to :costumer, class_name: 'User', optional: true
# NOTE: Multiple status if paing before brinting
enum status: {
open: 0,
printing: 1,
ready_for_pickup: 2,
paid: 3,
cancelled: 4
}
# BUG: shows the hole day of the utc timezone
scope :today, -> { where('DATE(created_at) = ?', Time.now.utc.to_date) }
def self.current_jobs
today.order(created_at: :desc, status: :asc)
# today.order(created_at: :desc, status: :asc)
end
def fullname
[costumer_firstname, ' ', costumer_lastname].join
end
end