# Inventory fifo periodic value

`inventory-fifo-periodic-value` · version 1.0.0 · Financial calculations · free, no key needed

Value ending inventory and cost of goods sold under periodic FIFO with exact, reproducible layer retention.

**Use when you need to: periodic FIFO inventory valuation · calculate FIFO COGS · value physical ending inventory.**

## Decide before calling

Read the [versioned contract](/v1/tools/inventory-fifo-periodic-value/versions/1.0.0) and the supported scope below. Reuse `inventory-fifo-periodic-value@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `inventory-fifo-periodic-value@1.0.0` for periodic FIFO inventory valuation. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- periodic FIFO inventory valuation
- calculate FIFO COGS
- value physical ending inventory
- retain FIFO ending layers
- exact FIFO cost flow
- periodic inventory cost schedule

## Not supported

- perpetual FIFO transaction processing
- tax or legal advice

## Behavior

- Periodic FIFO assigns the earliest available units to cost of goods sold and retains the latest units in ending inventory; it does not model intra-period sales.
- Layers sort by acquired_on ascending, then beginning before purchase, then zero-based input_index, then layer_id; input_index makes equal-date ties explicit and deterministic.
- Quantities and unit costs are canonical nonnegative decimal strings. All products and sums use integer/rational arithmetic; binary floating point is never used.
- output_scale is explicit (0 through 12). Rounding is final, independently for each displayed monetary total and layer extended cost; it is not per-unit or cumulative. Supported modes are half-up, half-even, half-down, up, down, ceiling and floor.
- Inputs are immutable. Output contains reference_version IAS-2-2024-25-27+periodic-FIFO-v1.
- Disclaimer: arithmetic calculation only; not financial, tax, legal, or investment advice.

## Input

- `beginning_layers` (array of object, required): max items 500
- `purchases` (array of object, required): max items 500
- `physical_ending_quantity` (string, required): max length 32; pattern `^(0|[1-9][0-9]{0,17})(\.[0-9]{1,12})?$`
- `output_scale` (integer, required): min 0; max 12
- `rounding_mode` (one of "half-up", "half-even", "half-down", "up", "down", "ceiling", "floor", required)

## Output

- `reference_version` (constant "IAS-2-2024-25-27+periodic-FIFO-v1", required)
- `available_quantity` (string, required)
- `ending_quantity` (string, required)
- `sold_quantity` (string, required)
- `goods_available_cost` (string, required)
- `ending_inventory` (string, required)
- `cogs` (string, required)
- `ending_layers` (array of object, required): max items 1000

## Limits

- max input bytes: 131072
- max layers per source: 500
- max layers: 1000
- max string bytes: 64
- max output bytes: 8192

## Example

Request input:

```json
{
  "beginning_layers": [
    {
      "layer_id": "B1",
      "acquired_on": "2026-01-01",
      "quantity": "10",
      "unit_cost": "2.00"
    }
  ],
  "purchases": [
    {
      "layer_id": "P1",
      "acquired_on": "2026-01-10",
      "quantity": "5",
      "unit_cost": "3.00"
    }
  ],
  "physical_ending_quantity": "6",
  "output_scale": 2,
  "rounding_mode": "half-up"
}
```

Response:

```json
{
  "result": {
    "reference_version": "IAS-2-2024-25-27+periodic-FIFO-v1",
    "available_quantity": "15",
    "ending_quantity": "6",
    "sold_quantity": "9",
    "goods_available_cost": "35.00",
    "ending_inventory": "17.00",
    "cogs": "18.00",
    "ending_layers": [
      {
        "layer_id": "B1",
        "source": "beginning",
        "input_index": 0,
        "acquired_on": "2026-01-01",
        "quantity": "1",
        "unit_cost": "2",
        "extended_cost": "2.00"
      },
      {
        "layer_id": "P1",
        "source": "purchase",
        "input_index": 0,
        "acquired_on": "2026-01-10",
        "quantity": "5",
        "unit_cost": "3",
        "extended_cost": "15.00"
      }
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "inventory-fifo-periodic-value",
  "version": "1.0.0",
  "input": {
    "beginning_layers": [
      {
        "layer_id": "B1",
        "acquired_on": "2026-01-01",
        "quantity": "10",
        "unit_cost": "2.00"
      }
    ],
    "purchases": [
      {
        "layer_id": "P1",
        "acquired_on": "2026-01-10",
        "quantity": "5",
        "unit_cost": "3.00"
      }
    ],
    "physical_ending_quantity": "6",
    "output_scale": 2,
    "rounding_mode": "half-up"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/inventory-fifo-periodic-value/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"beginning_layers":[{"layer_id":"B1","acquired_on":"2026-01-01","quantity":"10","unit_cost":"2.00"}],"purchases":[{"layer_id":"P1","acquired_on":"2026-01-10","quantity":"5","unit_cost":"3.00"}],"physical_ending_quantity":"6","output_scale":2,"rounding_mode":"half-up"}'
```

The machine-readable contract is at [/v1/tools/inventory-fifo-periodic-value/versions/1.0.0](/v1/tools/inventory-fifo-periodic-value/versions/1.0.0).

### CLI

```sh
node cli.mjs run inventory-fifo-periodic-value 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Inventory fifo period reconcile](/tools/inventory-fifo-period-reconcile): Reconcile reported ending inventory and COGS against an exact periodic FIFO recomputation.
- [Inventory fifo period close](/tools/inventory-fifo-period-close): Close a periodic FIFO inventory period with exact valuation and a balanced caller-mapped closing entry.
- [Cashflow xnpv](/tools/cashflow-xnpv): NPV of dated cash flows with the Excel XNPV 365-day exponent and an explicit valuation date.
- [Dcf valuation compute](/tools/dcf-valuation-compute): Enterprise and equity value from forecast free cash flows with a Gordon or exit-multiple terminal value.
- [Depreciation schedule](/tools/depreciation-schedule): Straight-line, sum-of-years-digits, declining-balance and Excel DB depreciation schedule that ends at salvage.
- [Interest accrual compute](/tools/interest-accrual-compute): Simple or compound (periodic or continuous) interest over a term in years or a dated span with a day-count basis.
