domain capa

domain-inventory

Inventory: stock placement (item ↔ location junction with quantity, status, history)

Inventory: stock placement (item ↔ location junction with quantity, status, history)

Tierdomain
Roleunclassified (baselined)
Pathcrates/domain/inventory
Edition2021
Targetsdomain_inventory
Public items17 across 0 modules
Tests6

What it is for

Inventory library crates.

Provides the canonical item ↔ location junction (StockPlacement) that ERP-style systems need: a single SKU can sit in multiple bins with per-placement quantities, status, and history.

# Loose coupling

StockPlacement stores plain Uuid references for item_id and location_id rather than importing domain-catalog::CatalogItem or domain-storage-locations::StorageLocation. This keeps the crate dependency-light: a consumer that has its own catalog or location representation can still use this junction.

# Schema

See migrations/001_stock_placements.sql for the canonical table definition. The Rust struct mirrors that table; consumers should run the migration (or copy it into their own migration runner) before reading or writing StockPlacement values.

# Status semantics

transfer, QC hold). The metadata JSON should carry the reservation source — see RESERVED_METADATA_RECOMMENDED for a documented shape. Reserved placements ARE counted in "Total Stock" but are NOT "Available to Sell".

real inventory at the location, but the row is kept for history. Soft-deleted placements (deleted_at IS NOT NULL) are removed from query consideration entirely.

Capabilities

crate root

Inventory library crates.

Item
pub const RESERVED_METADATA_RECOMMENDED: & str

PlacementStatus

Inventory library crates.

Item
pub enum PlacementStatus
PlacementStatus :: const fn as_str(self) -> & 'static str
PlacementStatus :: fn parse(s : & str) -> Option <Self>
PlacementStatus :: fn counts_in_total(self) -> bool
PlacementStatus :: fn is_sellable(self) -> bool
PlacementStatus :: fn is_terminal(self) -> bool
PlacementStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

StockPlacement

Inventory library crates.

Item
pub struct StockPlacement
StockPlacement :: fn new(item_id : Uuid, location_id : Uuid, quantity : i32) -> Self
StockPlacement :: fn with_status(mut self, status : PlacementStatus) -> Self
StockPlacement :: fn with_metadata(mut self, metadata : serde_json::Value) -> Self
StockPlacement :: fn is_live_active(& self) -> bool
StockPlacement :: fn id(& self) -> Uuid
StockPlacement :: fn created_at(& self) -> DateTime <Utc>
StockPlacement :: fn updated_at(& self) -> DateTime <Utc>
StockPlacement :: fn deleted_at(& self) -> Option <DateTime <Utc>>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub const RESERVED_METADATA_RECOMMENDED: & strRecommended JSON shape for the metadata field on Reserved placements
pub enum PlacementStatusStatus of a stock placement
PlacementStatus :: const fn as_str(self) -> & 'static strCanonical SQL string form (active, reserved, removed).
PlacementStatus :: fn parse(s : & str) -> Option <Self>Parse from the SQL string form
PlacementStatus :: fn counts_in_total(self) -> boolTrue iff this placement contributes to "Total Stock" reporting.
PlacementStatus :: fn is_sellable(self) -> boolTrue iff this placement is available for new orders / picks.
PlacementStatus :: fn is_terminal(self) -> boolTrue iff this placement is the terminal audit state.
PlacementStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub struct StockPlacementOne placement of a catalog item at a storage location
StockPlacement :: fn new(item_id : Uuid, location_id : Uuid, quantity : i32) -> SelfCreate a new Active placement.
StockPlacement :: fn with_status(mut self, status : PlacementStatus) -> SelfBuilder: set status (default is Active).
StockPlacement :: fn with_metadata(mut self, metadata : serde_json::Value) -> SelfBuilder: set metadata.
StockPlacement :: fn is_live_active(& self) -> boolTrue iff this placement is active and not soft-deleted.
StockPlacement :: fn id(& self) -> Uuid
StockPlacement :: fn created_at(& self) -> DateTime <Utc>
StockPlacement :: fn updated_at(& self) -> DateTime <Utc>
StockPlacement :: fn deleted_at(& self) -> Option <DateTime <Utc>>

No pub use re-exports: every item above is declared in this crate.

Boundary

Reaches into foundation.

Shares tier domain with 41 other crates: domain-agreements, domain-ai-report, domain-billing, domain-catalog, domain-classify, domain-comments, domain-competitive-intel, domain-contact, … (41 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)domain
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/domain/inventory
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_domain["domain"] --> n_foundation["foundation"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-basemodels`foundationnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
chrono^0.4serdenoalways
serde^1derivenoalways
serde_json^1noalways
thiserror^2noalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio-test^0.4noalways

Build. None.

Depended on by. Nothing in this workspace.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  SELF["domain-inventory"]
  SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libdomain_inventory`src/lib.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

No workspace crate depends on this one.

Verification

KindCount
Unit tests6
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root300

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1217
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 12
    "No rustdoc detected" : 5

Metrics

MetricValue
Rust source files1
Source lines276
Code lines177
Public API items17
Public modules0
Tests6
Examples0
Cargo features0
Direct runtime dependencies6
Workspace reverse dependencies0
pie showData
    title Public API by kind
    "constant" : 1
    "enum" : 1
    "method" : 14
    "struct" : 1
pie showData
    title Rust source composition
    "Code" : 177
    "Blank or comment" : 99

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las domain · Manual