Added more infos in category#index cards
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

This commit is contained in:
2026-05-28 19:24:37 +02:00
parent af10dca289
commit b4c57b6f14
2 changed files with 90 additions and 39 deletions

View File

@@ -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