Stock Balances Component
Responsibilities
Section titled “Responsibilities”Mengelola snapshot saldo stok per produk, lokasi, satuan, batch, dan serial untuk menyediakan visibilitas inventori real-time.
Interfaces/APIs
Section titled “Interfaces/APIs”Inputs
Section titled “Inputs”- Product ID, Location ID, UOM ID
- Batch number, serial number, expiry date
- Kuantitas on hand dan reserved
- Referensi last move
Outputs
Section titled “Outputs”- Posisi saldo stok terkini yang digunakan untuk allocation, replenishment, dan keputusan operasional gudang.
Error Handling
Section titled “Error Handling”- Menolak quant duplikat untuk kombinasi kunci yang sama
- Menolak saldo negatif pada lokasi fisik
- Menolak update balance yang tidak atomik terhadap transaksi move atau reservation.
Data Structures:
Section titled “Data Structures:”| Field | Data Type | Constraints | Nullable | Description |
|---|---|---|---|---|
| balance_id | ULID | Primary Key | Tidak | Identifier unik quant balance |
| product_id | ULID | Foreign Key -> product_product.product_product_id | Tidak | Produk pada quant |
| location_id | ULID | Foreign Key -> location.location_id | Tidak | Lokasi penyimpanan |
| uom_id | ULID | Foreign Key -> uom.uom_id | Tidak | Satuan penyimpanan |
| qty_on_hand | DECIMAL(15,2) | Default 0, >= 0 | Tidak | Kuantitas fisik aktual |
| qty_reserved | DECIMAL(15,2) | Default 0, >= 0 | Tidak | Kuantitas yang sudah dibooking |
| qty_available | DECIMAL(15,2) | Computed: on_hand - reserved | Tidak | Kuantitas tersedia untuk alokasi |
| batch_number | VARCHAR(50) | Indexed | Ya | Identitas batch atau lot |
| serial_number | VARCHAR(100) | Indexed | Ya | Nomor seri unit |
Algorithms/Logic
Section titled “Algorithms/Logic”Menjaga sinkronisasi kuantitas tersedia dari pergerakan dan reservasi, menggabungkan quant identik, serta mendukung strategi FEFO berdasarkan expiry date.
State Management
Section titled “State Management”Menyimpan state saldo sebagai snapshot aktif agar proses outbound dan replenishment dapat mengambil keputusan berbasis data inventori terkini.