Skip to main content

StockAssignmentDTO

Represents a stock assignment decision that allocates specific product quantities from a warehouse to a store. Each assignment includes distance metrics for logistics planning.

Fields

id
UUID
required
Unique identifier for the stock assignment
storeId
string
required
Reference to the destination store receiving the stock
warehouseId
string
required
Reference to the source warehouse providing the stock
productId
string
required
Reference to the product being assigned
size
string
required
Specific size variant of the product being assigned (e.g., “S”, “M”, “L”, “XL”)
quantity
integer
required
Number of units being assigned from warehouse to store
distanceKm
double
required
Distance in kilometers between the warehouse and store locations

Example

{
  "id": "770e8400-e29b-41d4-a716-446655440000",
  "storeId": "STORE-001",
  "warehouseId": "WH-001",
  "productId": "PROD-001",
  "size": "M",
  "quantity": 100,
  "distanceKm": 245.8
}

Multiple Assignments Example

[
  {
    "id": "770e8400-e29b-41d4-a716-446655440000",
    "storeId": "STORE-001",
    "warehouseId": "WH-001",
    "productId": "PROD-001",
    "size": "M",
    "quantity": 100,
    "distanceKm": 245.8
  },
  {
    "id": "770e8400-e29b-41d4-a716-446655440001",
    "storeId": "STORE-001",
    "warehouseId": "WH-002",
    "productId": "PROD-001",
    "size": "L",
    "quantity": 150,
    "distanceKm": 312.4
  },
  {
    "id": "770e8400-e29b-41d4-a716-446655440002",
    "storeId": "STORE-002",
    "warehouseId": "WH-001",
    "productId": "PROD-002",
    "size": "S",
    "quantity": 75,
    "distanceKm": 189.2
  }
]

Business Logic

Assignment Creation
  • Assignments are created through the distribution calculation algorithm
  • Each assignment represents a fulfillment decision
  • Multiple assignments may be created for a single store’s demand
Quantity Constraints
  • Assigned quantity cannot exceed warehouse available stock
  • Assigned quantity cannot exceed store remaining capacity
  • Assigned quantity should match or partially fulfill store demand
Distance Calculation
  • Distance is calculated using the Haversine formula
  • Based on warehouse and store latitude/longitude coordinates
  • Used for logistics planning and optimization metrics
Optimization Goals
  • Minimize total shipping distance
  • Maximize demand fulfillment
  • Balance warehouse utilization
  • Respect capacity constraints

Assignment States

While not explicitly stored in the DTO, assignments typically flow through these states:
  1. Calculated - Assignment proposed by distribution algorithm
  2. Confirmed - Assignment accepted and recorded in system
  3. In Transit - Physical shipment underway
  4. Delivered - Stock received at destination store

Build docs developers (and LLMs) love