Inventory Items
Item Structure
Each inventory item contains:app/Models/InventoryItem.php:14-22
Creating Items
When creating a new inventory item, an initial movement record is automatically generated:app/Services/InventoryService.php:15-43
Stock Adjustments
Movement Types
Addition
Increase stock (purchases, returns, corrections)
Removal
Decrease stock (sales, usage, corrections)
Adjustment Process
app/Services/InventoryService.php:45-77
Validation Rules
Fromapp/Http/Requests/AdjustInventoryStockRequest.php:15-22:
| Field | Type | Rules |
|---|---|---|
movement_type | string | Required, must be addition or removal |
quantity | integer | Required, 1-1,000,000 |
notes | string | Optional, max 255 chars |
inventory module access can adjust stock.
Negative Stock Prevention
The system prevents stock from going negative:Movement History
Movement Records
Every stock change creates an immutable audit record:app/Models/InventoryMovement.php:13-22
Viewing History
Recent movements are displayed on the inventory dashboard:app/Http/Controllers/Worker/InventoryController.php:39-44
Low Stock Alerts
Alert Logic
Items are considered low stock when:app/Models/InventoryItem.php:49-52
Automatic Notifications
After every stock adjustment, the system checks if notifications should be sent:- All active admins in the company
- Workers with
can_access_inventorypermission
app/Services/InventoryService.php:79-108
Finding Low Stock Items
app/Services/InventoryService.php:110-117
Integration with Billing
Sale-Enabled Items
Only items withis_sale_enabled = true can be added to invoices:
Stock Availability Check
Before creating a billing document:app/Services/BillingService.php:89-102
Automatic Stock Deduction
When an invoice is created (not a quote), inventory is automatically consumed:app/Services/BillingService.php:216-244
Search Functionality
- By Name
- By Internal Code
- Combined
app/Http/Controllers/Worker/InventoryController.php:30-35
Relations
Inventory items maintain relationships with:- Company - Owner of the inventory
- Movements - Complete audit trail
- Billing Items - Sales and quotes referencing this item
app/Models/InventoryItem.php:34-47