/api/inventory_history_improved

Header
X-Customer-Api-Id: <uuid>
X-Secret: <secret>
Content-Type: application/json
Request Body Schema
{
  "product_code": string|number,         // SKU or internal code
  "sales_unity_cost": number,            // Unit COGS (currency‐agnostic)
  "sales_unity_price": number,           // Unit sell price
  "inventory_daily_cost": number,        // Holding cost per unit per day
  "lead_time_days": number,              // Replenishment lead time
  "inventory_initial_situation": [       // Exactly one opening snapshot
    {
      "inventory_data": "YYYY-MM-DD",    // Date of opening balance
      "inventory_quantity": number       // Units on hand at open
    }
  ],
  "purchases": [                         // Goods‐received notes
    {
      "purchase_date": "YYYY-MM-DD",
      "purchase_quantity": number
    }
    // … additional purchase records …
  ],
  "sales": [                             // Shipments / invoices
    {
      "invoice_date": "YYYY-MM-DD",
      "sales_quantity": number
    }
    // … additional sales records …
  ]
}

Example Request Body
// Example Request
{
  "product_code": 38788,
  "sales_unity_cost": 25.50,
  "sales_unity_price": 60.73,
  "inventory_daily_cost": 0.15,
  "lead_time_days": 7.0,
  "inventory_initial_situation": [
    { "inventory_data": "2023-12-31", "inventory_quantity": 1050.0 }
  ],
  "purchases": [
    { "purchase_date": "2024-01-31", "purchase_quantity": 280.0 },
    { "purchase_date": "2024-02-28", "purchase_quantity": 240.0 },
    { "purchase_date": "2024-03-29", "purchase_quantity": 320.0 }
  ],
  "sales": [
    { "invoice_date": "2024-01-02", "sales_quantity": 5.0 },
    { "invoice_date": "2024-03-15", "sales_quantity": 31.0 }
  ]
}
Example Response Body
// Example Response
{
  "daily_inventory": [
    {
      "date": "2024-01-31",
      "purchase_quantity": 280,
      "sales_quantity": 0,
      "net_change": 280,
      "closing_inventory": 1216,
      "activity": "Only Purchase",
      "pct_change": 29.91
    }
    // … one entry per calendar day …
  ],
  "inventory_analysis": {
    "initial_inventory":            { "value": 1050, "explanation": "Opening stock on 2023-12-31." },
    "cumulative_purchases":         { "value": 840,  "explanation": "Total units received." },
    "cumulative_sales":             { "value": 721,  "explanation": "Total units sold." },
    "turnover_ratio_initial":       { "value": 0.687, "turnover_description": "Very Low Turnover" },
    "inventory_days_of_supply":     { "value": 123.97, "days_supply_description": "Very Sluggish Inventory" },
    "safety_stock":                 { "safety_stock": 42.74, "explanation": "95% service level buffer." },
    // … 30+ additional KPIs with blurbs …
  },
  "inventory_aging": {
    "sold_vs_unsold": {
      "sold_lots": {
        "summary": { "average_aging_days": 22, "std_aging_days": 12.73 }
        // … further sold‐lot details …
      },
      "unsold_lots": {
        "summary": { "weighted_average_current_age": 0 },
        "aging_buckets": { "0-30 days": 0, "31-60 days": 0, "61-90 days": 0, ">90 days": 0 }
      },
      "comparative_analysis": { "turnover_ratio_initial": 0.687 /* … */ }
    }
  },
  "product_details": {
    "product_code": 38788,
    "sales_unity_cost": 25.5,
    "sales_unity_price": 60.73,
    "inventory_daily_cost": 0.15
  },
  "processing_info": {
    "processing_time_seconds": 0.026,
    "calculation_date": "2025-05-21"
  }
}
Description

A comprehensive “one‐stop” ledger that ingests raw purchases and sales, builds a day‐by‐day inventory balance with activity tags and percent‐changes, and delivers a full KPI deck (turnover, DOS, volatility, safety stock, margin, EOQ flags, etc.) plus a lot‐aging dashboard—ideal for operations, finance, and supply-chain teams. text Copiar Editar

Business Usage

• Daily Audit & BI: Feed `daily_inventory` into dashboards for balance reconciliation and activity heat-maps. • Replenishment & Safety-Stock: Use turnover ratios, DOS, and safety‐stock metrics to automate reorder points and notifications. • Aging & Obsolescence: Monitor `inventory_aging` buckets to detect slow-moving lots and trigger markdowns or supplier reviews. • Financial Analysis: Leverage margin, price-elasticity, and carrying‐cost KPIs for P&L forecasting and capital‐tie reporting. • Alerting & Automation: Configure alerts when DOS exits target range or when on-hand falls below EOQ reorder level.

← Back to all routes