Added more infos in category#index cards
This commit is contained in:
@@ -2,4 +2,19 @@ class Category < ApplicationRecord
|
||||
has_many :items, dependent: :restrict_with_error
|
||||
|
||||
validates :name, presence: true, uniqueness: true
|
||||
|
||||
# 1. Zählt Artikel im Hauptlager (weder User noch Raum zugewiesen)
|
||||
def items_in_storage_count
|
||||
items.where(user_id: nil, room_id: nil).count
|
||||
end
|
||||
|
||||
# 2. Zählt Artikel, die bei Mitarbeitern im Umlauf sind
|
||||
def items_with_users_count
|
||||
items.where.not(user_id: nil).count
|
||||
end
|
||||
|
||||
# 3. Zählt Artikel, die fest in Räumen verbaut sind
|
||||
def items_in_rooms_count
|
||||
items.where.not(room_id: nil).count
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user