Catalog/acct-inventory-wac

Finance

Weighted-average inventory cost API

Computes weighted-average-cost inventory (perpetual moving-average ledger or periodic single average) with running COGS and ending inventory value from a purchase/sale stream. Answers 'What is COGS under weighted average?', 'What is my ending inventory value?'.

Price$0.06per request
MethodPOST
Route/v1/finance/inventory-weighted-average
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
inventoryweighted-averagewaccogscost-accountingperpetualperiodicvaluation
API URLhttps://x402.hexl.dev/v1/finance/inventory-weighted-average
Integration docs
Example request
{
  "beginningQuantity": 100,
  "beginningUnitCost": 10,
  "transactions": [
    {
      "type": "purchase",
      "quantity": 100,
      "unitCost": 12
    },
    {
      "type": "sale",
      "quantity": 150
    },
    {
      "type": "purchase",
      "quantity": 50,
      "unitCost": 14
    }
  ]
}
Example response
{
  "system": "perpetual",
  "costOfGoodsSold": 1650,
  "unitsSold": 150,
  "endingQuantity": 100,
  "endingInventoryValue": 1250,
  "endingMovingAvgCost": 12.5,
  "ledger": [
    {
      "step": 1,
      "type": "purchase",
      "quantity": 100,
      "unitCost": 12,
      "movingAvgCost": 11,
      "onHandQty": 200,
      "inventoryValue": 2200
    },
    {
      "step": 2,
      "type": "sale",
      "quantity": 150,
      "unitCost": 11,
      "movingAvgCost": 11,
      "onHandQty": 50,
      "inventoryValue": 550,
      "cogsThisStep": 1650
    },
    {
      "step": 3,
      "type": "purchase",
      "quantity": 50,
      "unitCost": 14,
      "movingAvgCost": 12.5,
      "onHandQty": 100,
      "inventoryValue": 1250
    }
  ],
  "interpretation": "Perpetual WAC: moving average recomputed after each purchase; ending inventory 100 units worth $1250."
}
Input schema
{
  "type": "object",
  "required": [
    "transactions"
  ],
  "properties": {
    "beginningQuantity": {
      "type": "number",
      "examples": [
        100
      ]
    },
    "beginningUnitCost": {
      "type": "number",
      "examples": [
        10
      ]
    },
    "transactions": {
      "type": "array",
      "items": {
        "type": "object"
      },
      "examples": [
        [
          {
            "type": "purchase",
            "quantity": 100,
            "unitCost": 12
          },
          {
            "type": "sale",
            "quantity": 150
          },
          {
            "type": "purchase",
            "quantity": 50,
            "unitCost": 14
          }
        ]
      ]
    },
    "system": {
      "type": "string",
      "enum": [
        "perpetual",
        "periodic"
      ],
      "examples": [
        "perpetual"
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}