elgibor-solution/laravel-inventory
Composer 安装命令:
composer require elgibor-solution/laravel-inventory
包简介
Inventory, costing (FIFO & Average), journal posting, multi-branch/warehouse/rack, configurable stages for Laravel.
README 文档
README
Comprehensive Laravel Inventory, Costing, and Journal Package
Multi-branch, multi-warehouse, multi-rack, configurable movement stages, FIFO & Average costing, with automatic journal posting.
🚀 Overview
elgibor-solution/laravel-inventory is a full-featured Laravel package for managing inventory, accounting journal, and cost valuation (FIFO and Moving Average).
It is designed for ERP, POS, and SaaS platforms that require accurate, auditable, and multi-location stock control — from branches and warehouses down to racks and stages.
✅ Key Features
- Costing Methods: FIFO and Moving Average
- Multi-Location: Multi-branch, multi-warehouse, multi-rack
- Configurable Stages: Customizable per item type
- Full Document Set: Purchase, Sales, Returns, Stock Opname, Consignment, Transfers
- Automatic Journal Entries: Predefined account mapping for Dr/Cr
- Audit Trail: Immutable stock ledger
- Idempotent Posting: via
external_id - Modular Design: Easily extendable or integrated into existing GL/ERP
📦 Installation
-
Install the package:
composer require elgibor-solution/laravel-inventory:* -
Publish configuration & migrate tables:
php artisan vendor:publish --tag=inventory-config php artisan migrate
⚙️ Configuration (config/inventory.php)
return [ 'default_valuation' => 'fifo', // 'fifo' | 'average' 'valuation_scopes' => [ 'per_branch' => true, 'per_warehouse' => true, 'per_rack' => false, ], 'accounts' => [ 'inventory' => '1100-INV', 'cogs' => '5100-COGS', 'ap' => '2100-AP', 'ar' => '1101-AR', 'purchase_return' => '5201-PurchaseReturn', 'sales_return' => '4102-SalesReturn', 'inventory_gain' => '5202-InvGain', 'inventory_loss' => '5203-InvLoss', 'inventory_interbranch' => '1180-INV-INTRANSIT', ], 'item_type_stages' => [ 'regular' => ['pickup_admin_gudang', 'carried_by_salesman', 'delivered_to_store'], 'fast_move' => ['warehouse_exit', 'received_by_store'], ], 'stage_triggers' => [ 'recognize_cogs_on' => 'final', ], ];
🧠 Core Concepts
1. Cost Valuation
- FIFO: First In First Out — oldest stock layers consumed first.
- Average: Weighted moving average recalculated on every receipt.
2. Location Hierarchy
Branch → Warehouse → Rack → Stage
Every stock movement references branch, warehouse, and optionally rack.
3. Stages
Each item type can have its own movement stages.
Example:
| Item Type | Stages |
|---|---|
| Regular | pickup_admin_gudang → carried_by_salesman → delivered_to_store |
| Fast Move | warehouse_exit → received_by_store |
📄 Supported Documents
| Document | Description | Stock Effect | Accounting Effect |
|---|---|---|---|
| Purchase | Goods received from supplier | IN | Dr Inventory / Cr AP |
| Sale | Goods delivered to customer | OUT | Dr COGS / Cr Inventory |
| Purchase Return | Goods returned to supplier | OUT | Dr AP / Cr Inventory |
| Sales Return | Goods returned from customer | IN | Dr Inventory / Cr COGS |
| Stock Opname | Physical stock adjustment | IN/OUT | Dr/C Inventory Gain/Loss |
| Consignment | Goods sent to consignment | OUT | Optional (On/Off Balance) |
| Transfer Rack | Move between racks | IN/OUT | No journal |
| Transfer Warehouse | Move between warehouses | IN/OUT | No journal |
| Transfer Branch | Move between branches | IN/OUT | Dr Inventory (Dest) / Cr Inventory (Src) |
🧾 Usage Examples
(Examples section omitted here for brevity — same as full README above)
📊 Suggested SQL View
CREATE VIEW inv_item_balances AS SELECT item_id, branch_id, warehouse_id, rack_id, SUM(CASE WHEN direction='in' THEN qty ELSE -qty END) AS qty_on_hand, SUM(CASE WHEN direction='in' THEN amount ELSE -amount END) AS amount_on_hand FROM inv_stock_ledgers GROUP BY item_id, branch_id, warehouse_id, rack_id;
🛡️ Best Practices
- Always post documents within a DB transaction.
- Never modify
inv_stock_ledgersorinv_cost_layersmanually. - Use
external_idto ensure idempotent synchronization. - Add indexes
(item_id, branch_id, warehouse_id, rack_id, created_at)for performance. lockForUpdate()is used to ensure cost consistency under concurrency.
🧰 Recommended Extensions
- Add
DocumentPostedevents for webhook integration. - Extend
JournalManagerto push entries to your accounting module. - Create
InventoryPolicyto control stage posting permissions by user role.
📜 License
Apache 2.0 License
© 2025 PT Elgibor Solusi Digital
elgibor-solution/laravel-inventory 适用场景与选型建议
elgibor-solution/laravel-inventory 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 elgibor-solution/laravel-inventory 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elgibor-solution/laravel-inventory 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2025-10-09