Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
added check to to only trigger on raw materials
Browse files Browse the repository at this point in the history
  • Loading branch information
dvalnn committed May 21, 2024
1 parent bda12ec commit c8a884b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions migrations/005_items.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ RETURNS TRIGGER AS $$
RETURN NEW; -- Insert as usual, no need to allocate stock
END IF;

IF NEW.piece_kind NOT IN ( SELECT code FROM pieces WHERE category = 'raw') THEN
RETURN NEW; -- Insert as usual, we are only looking for raw materials
END IF;

SELECT * INTO free_stock FROM items As i
WHERE i.piece_kind = NEW.piece_kind
AND i.status = 'in_stock'
Expand Down

0 comments on commit c8a884b

Please sign in to comment.