karnoweb/laravel-inventory

Warehouse inventory package for Laravel: batches, FIFO/FEFO, transfers, reservations, and stock counts.

Maintainers

Package info

github.com/karnoweb/laravel-inventory

pkg:composer/karnoweb/laravel-inventory

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

13.1.0 2026-08-20 17:32 UTC

This package is auto-updated.

Last update: 2026-08-20 17:33:24 UTC


README

لایه انبارداری مستقل برای Laravel: انبار، دسته، دفتر حرکت، رزرو، انتقال و انبارگردانی.

پکیج سند خرید یا سفارش نمی‌شناسد. پروژه میزبان با HasInventory / HasInventorySource و Inventory facade وصل می‌شود — همان الگوی karnoweb/laravel-accounting.

نیازمندی‌ها

  • PHP ^8.2
  • Laravel 11 / 12 / 13

نصب

composer require karnoweb/laravel-inventory:^13.1
php artisan vendor:publish --tag=inventory-config
php artisan migrate

مستندات کامل مفاهیم و روال‌ها داخل پکیج است: docs/

php artisan vendor:publish --tag=inventory-docs

جدول‌ها با پیشوند inv_ ساخته می‌شوند (inv_warehouses, inv_batches, inv_movements, ...).

اتصال مدل کالا

use Karnoweb\Inventory\Traits\HasInventory;

class Product extends Model
{
    use HasInventory;
}

عملیات هسته

use Karnoweb\Inventory\Facades\Inventory;

Inventory::stock()->receive($product, 10, 8000, sourceable: $purchaseItem, expiryDate: '2027-01-01', lotNumber: 'LOT-1');
Inventory::stock()->issue($product, 2, sourceable: $orderItem);
Inventory::stock()->waste($product, 1, reason: 'expired');
Inventory::policies()->upsert($product, minQuantity: 5, reorderPoint: 8);
Inventory::reservations()->reserve($product, 2, sourceable: $cartItem);
Inventory::transfers()->create($from, $to, [['stockable' => $product, 'quantity' => 3]]);
Inventory::counts()->create($warehouse, [['stockable' => $product, 'counted_quantity' => 9]]);

سند مبدأ:

use Karnoweb\Inventory\Traits\HasInventorySource;

class PurchaseItem extends Model
{
    use HasInventorySource; // inventoryBatch(), inventoryMovements()
}

کانفیگ شعبه مثل حسابداری است: config/inventory.phpbranch.model و branch.resolver.

رویدادها (بعد از commit): StockReceived, StockIssued, StockWasted, TransferConfirmed, ReservationCreated, CountConfirmed.

رزروهای منقضی:

php artisan inventory:expire-reservations

موجودی و گزارش

onHand و available وقتی warehouseId خالی است روی همهٔ انبارهای شعبه حساب می‌شوند. وقتی id داده شود هر دو روی همان انبار هستند.

available = موجودی قابل‌فروش (بدون بچ منقضی) − رزرو فعال.

Inventory::stock()->onHandAsOf($product, now()->subDay());
Inventory::reports()->kardex($product, $warehouseId, now()->startOfMonth(), now());
Inventory::reports()->lowStock();
Inventory::reports()->expiringWithin(30);

ویرایش سند ورود، دفتر را پاک نمی‌کند؛ حرکت reversal می‌زند.

هزینه: fifo | fefo | wac از config('inventory.general.costing').

مستندات

موضوع صفحه
شروع ساده docs/overview.md
مفاهیم (مثلاً رزرو) docs/concepts/reservation.md
استفاده همان روال docs/usage/reservation.md
قوانین و خطاها docs/usage/rules.md · docs/usage/errors.md

فهرست کامل: docs/README.md