---
id: TST-COM-ORD-157
title: 'LIFO costing: every open layer newest first (integration, Q09)'
kind: integration
product_area: commerce
module: orders
revision: 1
status: draft
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
repository: services-commerce
files:
  - modules/purchasing/tests/integration/services/cost/lifo-costing.integration.spec.js
implements: []
environment: local
implementation_state: implemented
latest_result: not-run
latest_run_at: null
latest_run_ref: null
conformance: not-verified
estimated_minutes: 2
isolation: The suite creates its own test workspace records and removes them using the fixture cleanup.
evidence:
  - provenance: test
    source: 'services-commerce:modules/purchasing/tests/integration/services/cost/lifo-costing.integration.spec.js'
    test_cases:
      - >-
        draws the two layers received on the 11th first, the greater id of the two first, and leaves the
        oldest untouched
      - 'writes one write_off fact of Σ the draws, naming LIFO and nothing uncosted'
      - leaves the oldest layer whole and three units on the second of the twins
      - 'costs the 6 sold newest first: 4 @ 1200 from the newest layer, then 2 @ 1100, each recorded lifo'
      - answers the handoff 7000 of COGS and writes one relieve_cogs fact of 7000 naming LIFO
      - 'relieves the source newest first: 5 @ 300, then 2 @ 200, each recorded lifo'
      - >-
        lands the 1900 of cost on the destination at the weighted cost of the units drawn, Σ exact: 4 @ 271
        and 3 @ 272
      - leaves the source’s oldest layer whole and three units of the middle one
      - 'draws every open layer, the second page included: 1000 @ 5, then the oldest @ 7, nothing uncosted'
      - 'relieves under FIFO before the switch: 2 @ 100 from the oldest layer, recorded fifo'
      - >-
        relieves under LIFO after the switch over every open layer, the ones recorded fifo included: 5 @ 300,
        then 2 @ 200
      - >-
        never rewrites the relief made before the switch: the FIFO row reads as it was written, version and
        all
      - 'relieves under FIFO again after switching back: 1 @ 100 from the oldest open layer, recorded fifo'
      - keeps every relief with the method of its moment and every layer with the method that recorded it
scenario_coverage: []
dependency_evidence:
  provenance: test
  source: 'services-commerce:modules/purchasing/tests/integration/services/cost/lifo-costing.integration.spec.js'
  declared_by_test: >-
    PostgreSQL, every persistence service, the cost rules, the costed staff movements and transfer, the cost
    relief port the shipping handoff calls. Doubled: nothing (the Accounting products are planted as the
    owner, under `faa`).
---

# LIFO costing: every open layer newest first (integration, Q09)

## Verification Boundary

The suite exercises persistence or workflow operations against the local integration database.

## What This Suite Proves

The registered cases check lIFO costing: every open layer newest first (integration, Q09) with their fixture records and assertions. Scenario bindings name only the examples those cases exercise.

## What It Does Not Prove

A registered file supplies no run result or verified conformance by itself. Local fixtures do not establish deployed cross-service behavior or complete browser journeys.

## Real Dependencies and Test Doubles

PostgreSQL and the exercised Commerce persistence or workflow code are real. Remote service records, clocks and transports follow the suite’s fixtures.

## Must Not Be Doubled

The database constraints, role restrictions, locks and transactions exercised by this suite must use PostgreSQL.
