# publishStandardCost

## Overview

Publishes a new standard cost generation for an item, effective today. Generations are append-only: a revision inserts a new StandardCost row rather than mutating history. When a prior generation exists, each company holding on-hand stock is revalued by (new − previous) × on-hand in a balanced journal entry created and posted in financial-accounting against the standard cost adjustment account (sourceDocumentType STANDARD_COST_REVISION); the first generation never revalues, and already-issued COGS is never restated. A revaluation requires an OPEN accounting period covering the posting date. Returns the StandardCost generation ID.

## Modules Commands Used

- [inventory] PublishStandardCost

## Exception Handling

| Error Code | Description |
| --- | --- |
| INVENTORY_INVALID_UNIT_COST | Unit cost must be zero or greater |
| INVENTORY_ITEM_VALUATION_NOT_FOUND | A company holds on-hand stock of the item but the item is not cost-tracked there |
| INVENTORY_ACCOUNTING_PERIOD_NOT_FOUND | No open accounting period covers the posting date |
