Overview
The Batch Tracking system implements First-In-First-Out (FIFO) inventory management at the batch level. Each purchase creates a unique batch with its own quantity, cost, and expiration tracking.Batch tracking enables precise cost accounting, expiration management, and supplier traceability for all inventory items.
Batch Data Model
Each batch represents a specific purchase lot of a product:Batch Attributes
Unique batch identifier (UUID)
Reference to the product being stocked
Original quantity purchased in this batch
Current remaining quantity (updated as sales occur)
Cost per unit paid to supplier (used for COGS calculation)
When the batch was received into inventory
Expiration date for perishable products (null for non-perishables)
Reference to the supplier who provided this batch
Receiving Inventory (Creating Batches)
When inventory is purchased, a new batch is created through the purchase entry workflow:API Endpoint
Receive Purchase
POST
/api/v1/batches/receiveCreates a new inventory batch from a purchase.FIFO Algorithm
The system uses First-In-First-Out (FIFO) logic to automatically select which batches to deduct from during sales:Sort Batches
For perishable products: Sort by expiration date (earliest first)For non-perishables: Sort by purchase date (oldest first)
FIFO Implementation
For perishable products, this algorithm implements FEFO (First Expired, First Out) by prioritizing batches with earlier expiration dates.
Batch Lifecycle
Batches go through several states during their lifecycle:Batch States
Active
Active
Batch has
available_quantity > 0 and is available for salesPartially Depleted
Partially Depleted
Batch has been used for some sales but still has remaining quantity
Depleted
Depleted
Batch has
available_quantity = 0, no longer used in FIFO calculationsViewing Batches
Query all batches for a specific product:Query Parameters
Filter to only show batches with available quantity > 0
Get Batches by Product
GET
/api/v1/batches/product/{product_id}Retrieves all batches for a specific product.Cost of Goods Sold (COGS)
Batch tracking enables accurate COGS calculation for each sale:Identify Affected Batches
Determine which batches will be used to fulfill the sale quantity using FIFO
Example COGS Calculation
Scenario: Selling 150 units when you have:
- Batch A: 100 units @ Bs 10.00 each
- Batch B: 200 units @ Bs 12.00 each
- Use all 100 from Batch A: 100 × 10.00 = Bs 1,000.00
- Use 50 from Batch B: 50 × 12.00 = Bs 600.00
Supplier Traceability
Each batch can be linked to a supplier for complete traceability:Benefits of Supplier Tracking
Quality Issues
Quickly identify all batches from a supplier if quality problems arise
Cost Analysis
Compare costs across different suppliers for the same product
Recall Management
Efficiently handle product recalls by supplier and batch
Supplier Performance
Track which suppliers provide the best quality and pricing
Expiration Management
For perishable products, batch-level expiration tracking is critical:Expiration Workflow
- Set expiration date when receiving inventory
- FEFO sorting automatically uses soon-to-expire batches first
- Dashboard alerts warn about products approaching expiration
- Manual adjustments can write off expired inventory
Best Practices
Always Link Suppliers
Always Link Suppliers
Associate each batch with a supplier for full traceability and better supplier management.
Set Accurate Costs
Set Accurate Costs
Enter the actual unit cost paid to ensure accurate COGS and profit margin calculations.
Track Expiration Dates
Track Expiration Dates
For perishable products, always set expiration dates to enable FEFO and reduce waste.
Monitor Batch Depletion
Monitor Batch Depletion
Regularly review batch status to identify slow-moving inventory.
Use Transaction References
Use Transaction References
The
entry_transaction_ref links batches to their purchase movements for audit trails.Integration with Movements
Batches are tightly integrated with the stock movement system:- ENTRY movements create new batches
- EXIT movements deduct from batches using FIFO
- ADJUSTMENT movements can modify batch quantities
Related Documentation
Product Management
Learn about product catalog setup
Stock Movements
Understand inventory transactions
Stakeholder Management
Manage suppliers and customers