403Webshell
Server IP : 103.175.220.74  /  Your IP : 216.73.216.151
Web Server : nginx/1.18.0
System : Linux p-floo-wj1-db 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : deploy ( 1003)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/app/onega.id/erp/production/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/app/onega.id/erp/production/INVENTORY_MODULE_ANALYSIS.md
# Inventory Module Analysis

## Module Overview
The Inventory module is the core warehouse and stock management system that tracks product inventory across multiple warehouses, manages goods receipts from suppliers, processes delivery orders to customers, handles product repacking, and manages production operations. It serves as the central hub integrating with both Purchase (inbound) and Sales (outbound) modules.

## Module Structure

```
Modules/Inventory/
├── Actions/
│   ├── StoreGoodsReceiptAction.php
│   ├── ProductRepackAction.php
│   ├── DeliveryOrder/
│   │   ├── StoreDeliveryOrderAction.php
│   │   ├── ReverseDeliveryOrderAction.php
│   │   └── ...
│   ├── GoodReceipt/
│   │   ├── StoreGoodsReceiptAction.php
│   │   └── ...
│   ├── Inventory/
│   │   ├── StockAdjustmentAction.php
│   │   └── ...
│   └── Production/
│       └── ...
├── Entities/
│   ├── Inventory.php
│   ├── InventoryHistory.php
│   ├── InventoryProductRepack.php
│   ├── GoodsReceipt.php
│   ├── GoodsReceiptDetail.php
│   ├── DeliveryOrder.php
│   ├── DeliveryOrderDetail.php
│   ├── Production.php
│   ├── ProductionDetail.php
│   ├── PurchaseOrder.php
│   ├── PurchaseOrderDetail.php
│   ├── Vendor.php
│   └── Product.php (reference)
├── Http/
│   ├── Controllers/
│   │   ├── InventoryManagementController.php
│   │   ├── GoodsReceiptController.php
│   │   ├── DeliveryOrderController.php
│   │   ├── InventoryHistoryController.php
│   │   ├── ProductionController.php
│   │   ├── ProductRepackController.php
│   │   ├── StockTransferController.php
│   │   ├── MultiStockAdjustmentController.php
│   │   ├── WarehouseProductController.php
│   │   ├── Mobile/
│   │   └── API/
│   ├── Requests/V1/
│   └── Resources/V1/
├── Routes/
│   ├── web.php
│   ├── api.php
│   └── mobile.php
├── Database/
│   └── Migrations/
├── Tests/
├── Providers/
│   ├── RouteServiceProvider.php
│   └── InventoryServiceProvider.php
└── Config/config.php
```

## Entity Relationships Diagram

```mermaid
erDiagram
    INVENTORY ||--o{ INVENTORY-HISTORY : tracks
    INVENTORY }o--|| PRODUCT : "stores"
    INVENTORY }o--|| WAREHOUSE : "in"
    
    INVENTORY-HISTORY }o--|| INVENTORY : "records"
    
    GOODS-RECEIPT ||--o{ GOODS-RECEIPT-DETAIL : contains
    GOODS-RECEIPT }o--|| PURCHASE-ORDER : "from"
    GOODS-RECEIPT }o--|| WAREHOUSE : "to"
    GOODS-RECEIPT }o--|| USER : "created_by"
    GOODS-RECEIPT }o--|| VENDOR : "vendor_id"
    
    GOODS-RECEIPT-DETAIL }o--|| GOODS-RECEIPT : "in"
    GOODS-RECEIPT-DETAIL }o--|| PRODUCT : "product_id"
    
    DELIVERY-ORDER ||--o{ DELIVERY-ORDER-DETAIL : contains
    DELIVERY-ORDER }o--|| SALES-ORDER : "from"
    DELIVERY-ORDER }o--|| WAREHOUSE : "from"
    DELIVERY-ORDER }o--|| USER : "created_by"
    DELIVERY-ORDER }o--|| CUSTOMER : "to"
    
    DELIVERY-ORDER-DETAIL }o--|| DELIVERY-ORDER : "in"
    DELIVERY-ORDER-DETAIL }o--|| PRODUCT : "product_id"
    
    PRODUCTION ||--o{ PRODUCTION-DETAIL : contains
    PRODUCTION }o--|| PRODUCT : "produces"
    
    PRODUCTION-DETAIL }o--|| PRODUCTION : "in"
    PRODUCTION-DETAIL }o--|| PRODUCT : "source_material"
    
    INVENTORY-PRODUCT-REPACK }o--|| PRODUCT : "source_product"
    INVENTORY-PRODUCT-REPACK }o--|| PRODUCT : "target_product"
    INVENTORY-PRODUCT-REPACK }o--|| WAREHOUSE : "in"
    
    PURCHASE-ORDER ||--o{ PURCHASE-ORDER-DETAIL : contains
    PURCHASE-ORDER }o--|| VENDOR : "from"
    
    PURCHASE-ORDER-DETAIL }o--|| PURCHASE-ORDER : "in"
    PURCHASE-ORDER-DETAIL }o--|| PRODUCT : "product_id"
    
    WAREHOUSE ||--o{ INVENTORY : "contains"
    WAREHOUSE ||--o{ GOODS-RECEIPT : "receives"
    WAREHOUSE ||--o{ DELIVERY-ORDER : "ships"
    
    PRODUCT ||--o{ INVENTORY : "in_stock"
    PRODUCT ||--o{ GOODS-RECEIPT-DETAIL : "received"
    PRODUCT ||--o{ DELIVERY-ORDER-DETAIL : "shipped"
    PRODUCT ||--o{ PRODUCTION-DETAIL : "used_in"
    
    VENDOR ||--o{ PURCHASE-ORDER : "supplies"
    VENDOR ||--o{ GOODS-RECEIPT : "ships"
    
    SALES-ORDER ||--o{ DELIVERY-ORDER : "fulfilled_by"
    CUSTOMER ||--o{ DELIVERY-ORDER : "receives"
```

## Core Workflows

### 1. Goods Receipt Workflow (Inbound - from Purchase)
```
Purchase Order Created → Goods Arrive from Vendor → Create Goods Receipt → 
Add GR Details → Match with PO Details → Submit & Confirm → 
Update Inventory Stock → Track Stock History
```

### 2. Delivery Order Workflow (Outbound - from Sales)
```
Sales Order Approved → Create Delivery Order → Add DO Details (products to ship) → 
Pick from Warehouse Inventory → Submit & Confirm Shipment → 
Deduct from Inventory → Track Delivery → Complete
```

### 3. Inventory Management Workflow
```
Monitor Stock Levels → Stock Below Threshold? → Generate Replenishment Alert → 
Create Stock Adjustment → Multiple Warehouse Transfer → Update Inventory
```

### 4. Production Workflow
```
Production Order Created → Define Production Details (raw materials) → 
Consume Raw Materials from Inventory → Produce Finished Product → 
Add Finished Product to Inventory
```

### 5. Product Repacking Workflow
```
Original Product in Stock → Repacking Request → Create Repacking Record → 
Consume Original Product → Create Repacked Product Variant → Add to Inventory
```

### 6. Stock Movement Flow
```
Purchase GR → +Stock (Inbound)
Delivery DO → -Stock (Outbound)
Stock Transfer → Move between warehouses
Production → Consume materials, create finished goods
Repacking → Convert one product type to another
Stock Adjustment → Manual corrections
```

## Key Entities Description

| Entity | Purpose | Key Fields |
|--------|---------|-----------|
| **Inventory** | Stock levels by product & warehouse | warehouse_id, product_id, stocks, stock_threshold |
| **InventoryHistory** | Audit trail of all stock movements | inventory_id, quantity_change, transaction_type, reference |
| **GoodsReceipt** | Inbound shipment from vendor | transaction_number, po_number, vendor_id, warehouse_id, date |
| **GoodsReceiptDetail** | Line items received | gr_id, product_id, quantity_received, unit_of_measure |
| **DeliveryOrder** | Outbound shipment to customer | transaction_number, so_number, customer_id, warehouse_id, date |
| **DeliveryOrderDetail** | Line items shipped | do_id, product_id, quantity_shipped |
| **Production** | Manufacturing/production orders | production_code, product_id, status, date |
| **ProductionDetail** | Raw materials & quantities used | production_id, source_product_id, quantity |
| **InventoryProductRepack** | Product repacking records | source_product_id, target_product_id, quantity, date |
| **InventoryHistory** | Complete stock movement history | inventory_id, movement_type, quantity, reason |
| **Warehouse** | Physical storage locations | name, address, capacity, location |
| **Product** | Inventory items (from core) | product_code, name, category, unit |

## Controllers

| Controller | Responsibilities |
|------------|------------------|
| **InventoryManagementController** | Main inventory dashboard & overview |
| **GoodsReceiptController** | Receive goods from vendors, match with PO |
| **DeliveryOrderController** | Create/manage customer shipments |
| **InventoryHistoryController** | View stock movement history & audit trail |
| **ProductionController** | Production order management |
| **ProductRepackController** | Product repacking operations |
| **StockTransferController** | Inter-warehouse stock transfers |
| **MultiStockAdjustmentController** | Bulk stock adjustments |
| **WarehouseProductController** | Product availability across warehouses |

## Integration Points

- **Purchase Module**: GoodsReceipt integrates with PO, receives inventory from suppliers
- **Sales Module**: DeliveryOrder integrates with SO, ships inventory to customers
- **Core App**: Product, Warehouse, User, UnitOfMeasure references
- **Accounting Module**: Stock movements can be linked to accounting entries

## Action Classes

### DeliveryOrder Actions
- **StoreDeliveryOrderAction**: Create new delivery orders from SO
- **ReverseDeliveryOrderAction**: Reverse/cancel delivery orders

### GoodsReceipt Actions
- **StoreGoodsReceiptAction**: Create goods receipts matching PO

### Inventory Actions
- **StockAdjustmentAction**: Manual stock adjustments
- **StockTransferAction**: Move inventory between warehouses

### Production Actions
- **CreateProductionAction**: Create production orders
- **CompleteProductionAction**: Finish production & add to inventory

### Other Actions
- **ProductRepackAction**: Repack products into different variants

## Key Features

1. **Multi-Warehouse Management**: Track inventory across multiple warehouse locations
2. **Stock Tracking**: Real-time stock levels with thresholds for low stock alerts
3. **Inbound Management**: Goods receipt processing with vendor matching
4. **Outbound Management**: Delivery order fulfillment for customer orders
5. **Audit Trail**: Complete history of all stock movements with timestamps
6. **Production Support**: Track raw materials consumed and finished goods produced
7. **Product Repacking**: Convert/repack products into different variants
8. **Stock Transfers**: Move inventory between warehouses
9. **Reversals**: Reverse delivery orders to return items to inventory
10. **Stock Adjustments**: Manual corrections for discrepancies
11. **Threshold Alerts**: Low stock notifications for inventory management
12. **Reference Tracking**: Link movements to source documents (PO, SO)

## Stock Movement Types

```
IN:
  - Goods Receipt (from supplier via PO)
  - Stock Transfer (from another warehouse)
  - Stock Adjustment (manual correction)
  - Production Output (finished goods)

OUT:
  - Delivery Order (to customer via SO)
  - Stock Transfer (to another warehouse)
  - Stock Adjustment (manual correction)
  - Production Input (raw materials consumed)
  - Product Repacking (source product consumed)

INTERNAL:
  - Repack (convert one product to another)
  - Transfer (move between warehouses)
```

## Data Flows

### Inbound Flow
```
PO Created → Vendor Ships → GR Created → Match with PO Details → 
Confirm Receipt → +Inventory Stock → Record in InventoryHistory
```

### Outbound Flow
```
SO Approved → DO Created → Match with SO Details → Confirm Shipment → 
-Inventory Stock → Record in InventoryHistory → Customer Receives
```

### Cross-Warehouse Transfer
```
Warehouse A Stock → Stock Transfer Request → -From Warehouse A → 
+To Warehouse B → Update Both Inventory Records
```

### Production Flow
```
Production Order → Consume Raw Materials (-Stock) → Produce Finished Goods → 
+Finished Product Stock → Update Inventory
```

## Business Rules

1. **Stock Check**: Delivery orders validate stock availability before shipment
2. **Threshold Alerts**: Inventory below threshold triggers alerts
3. **Warehouse Isolation**: Stock tracked separately per warehouse
4. **Audit Trail**: All movements logged with user, timestamp, and reference
5. **Reference Tracking**: Each movement linked to source document (PO, SO, etc)
6. **Soft Deletes**: All transactions support soft delete for compliance
7. **Reversal Support**: Delivery orders can be reversed to return items to stock
8. **Production Dependency**: Production requires sufficient raw material stock

## Status Values

```
Goods Receipt: IN (inbound) or CANCELED
Delivery Order: OUT (outbound) or CANCELED

Movement Types for History:
  - IN: Goods receipt
  - OUT: Delivery order
  - TRANSFER: Inter-warehouse transfer
  - ADJUSTMENT: Stock adjustment
  - PRODUCTION: Production output/input
  - REPACK: Product repacking
```

## Performance Optimizations

- Inventory eager loads product & warehouse relationships
- InventoryHistory indexed for fast lookups
- Stock threshold checks optimized with indexes
- Soft deletes maintained for audit compliance
- Reference tracking enables traceability

## Stock Threshold Management

- Each Inventory record has configurable `stock_threshold`
- Alerts when stock falls below threshold
- Helps prevent stockouts
- Triggers replenishment workflows

## Reporting & Analytics

- Complete inventory history for audit trails
- Stock movement reports by product, warehouse, or date range
- Low stock alerts for inventory planning
- Production efficiency metrics (materials consumed vs produced)
- Warehouse utilization tracking

Youez - 2016 - github.com/yon3zu
LinuXploit