pub struct StockPickingRepository;Expand description
The picking mint/probe/heal SQL. Stateless — every method takes the caller’s connection so the header, its moves, and the projection commit as one unit (moves themselves are minted through the engine’s own guarded transactions).
Implementations§
Source§impl StockPickingRepository
impl StockPickingRepository
pub fn new() -> Self
Sourcepub async fn insert_transfer(
&self,
conn: &mut PgConnection,
t: &NewPickingRow<'_>,
) -> Result<(), Error>
pub async fn insert_transfer( &self, conn: &mut PgConnection, t: &NewPickingRow<'_>, ) -> Result<(), Error>
Insert the transfer header. Leaks the raw sqlx::Error deliberately so the service can
turn a unique violation on the name — the composing decorator’s org-scoped arbiter —
into a typed duplicate-name error.
Sourcepub async fn fetch_transfer(
&self,
conn: &mut PgConnection,
transfer_id: Uuid,
) -> Result<Option<TransferHeaderRow>, Error>
pub async fn fetch_transfer( &self, conn: &mut PgConnection, transfer_id: Uuid, ) -> Result<Option<TransferHeaderRow>, Error>
Read one transfer header (probe surface — the projected state is READ here, never asserted by callers).
Sourcepub async fn fetch_moves_of_transfer(
&self,
conn: &mut PgConnection,
transfer_id: Uuid,
) -> Result<Vec<MoveStateRow>, Error>
pub async fn fetch_moves_of_transfer( &self, conn: &mut PgConnection, transfer_id: Uuid, ) -> Result<Vec<MoveStateRow>, Error>
Read a transfer’s member moves (the projection inputs, for the probe surface).
Sourcepub async fn move_ids_of_transfer(
&self,
conn: &mut PgConnection,
transfer_id: Uuid,
) -> Result<Vec<Uuid>, Error>
pub async fn move_ids_of_transfer( &self, conn: &mut PgConnection, transfer_id: Uuid, ) -> Result<Vec<Uuid>, Error>
The ids of a transfer’s member moves (the validate surface iterates these).
Sourcepub async fn fetch_operation_type(
&self,
conn: &mut PgConnection,
operation_type_id: Uuid,
) -> Result<Option<OperationTypeFacts>, Error>
pub async fn fetch_operation_type( &self, conn: &mut PgConnection, operation_type_id: Uuid, ) -> Result<Option<OperationTypeFacts>, Error>
The operation type’s facts. None when the type does not exist or is archived.
Sourcepub async fn find_open_group_picking(
&self,
conn: &mut PgConnection,
picking_type_id: Uuid,
location_id: Uuid,
location_dest_id: Uuid,
partner_id: Option<Uuid>,
origin: Option<&str>,
) -> Result<Option<Uuid>, Error>
pub async fn find_open_group_picking( &self, conn: &mut PgConnection, picking_type_id: Uuid, location_id: Uuid, location_dest_id: Uuid, partner_id: Option<Uuid>, origin: Option<&str>, ) -> Result<Option<Uuid>, Error>
The OPEN transfer a move would join when it is grouped for fulfillment: the most
recently scheduled transfer whose operation type, source, destination, partner, and
origin (the procurement-group stand-in — moves launched for one source document share
it) all match, and whose projection has not reached a terminal state (done picks
nothing more up; a cancel never reopens). None when no open transfer matches — the
caller mints one.
Sourcepub async fn resolve_internal_location(
&self,
conn: &mut PgConnection,
warehouse_id: Uuid,
) -> Result<Option<Uuid>, Error>
pub async fn resolve_internal_location( &self, conn: &mut PgConnection, warehouse_id: Uuid, ) -> Result<Option<Uuid>, Error>
The warehouse’s stock location: the internal location the warehouse tree resolves to
(deterministic: shallowest in the tree, then name). None when the warehouse has no
internal location yet — the caller decides whether to bootstrap one.
Sourcepub async fn resolve_inventory_loss_location(
&self,
conn: &mut PgConnection,
) -> Result<Option<Uuid>, Error>
pub async fn resolve_inventory_loss_location( &self, conn: &mut PgConnection, ) -> Result<Option<Uuid>, Error>
The inventory-loss location (the far end of every adjustment move). None when none
exists — the caller decides whether to bootstrap one.
Sourcepub async fn ensure_internal_location(
&self,
conn: &mut PgConnection,
warehouse_id: Uuid,
) -> Result<Uuid, Error>
pub async fn ensure_internal_location( &self, conn: &mut PgConnection, warehouse_id: Uuid, ) -> Result<Uuid, Error>
Bootstrap a warehouse’s stock location (internal usage). The adjustment door and the picking mint use this the first time a warehouse without a location tree stages a count or mints a picking — a physical grain needs a location, and minting the warehouse’s own stock location is the least-surprise resolution.
Sourcepub async fn ensure_inventory_loss_location(
&self,
conn: &mut PgConnection,
) -> Result<Uuid, Error>
pub async fn ensure_inventory_loss_location( &self, conn: &mut PgConnection, ) -> Result<Uuid, Error>
Bootstrap the inventory-loss location (usage inventory — the scrap /
adjustment sink). Shared root trees would normally seed this; the module ships no
location seed yet, so the door mints it on first use.
Sourcepub async fn resolve_partner_location(
&self,
conn: &mut PgConnection,
usage: &str,
) -> Result<Option<Uuid>, Error>
pub async fn resolve_partner_location( &self, conn: &mut PgConnection, usage: &str, ) -> Result<Option<Uuid>, Error>
Resolve the location of a partner usage (supplier / customer). None when none
exists — the caller decides whether to bootstrap one.
Sourcepub async fn ensure_partner_location(
&self,
conn: &mut PgConnection,
usage: &str,
) -> Result<Uuid, Error>
pub async fn ensure_partner_location( &self, conn: &mut PgConnection, usage: &str, ) -> Result<Uuid, Error>
Bootstrap the counterpart location for a partner usage (supplier — the
far end of every goods receipt; customer — the far end of every delivery). Voucher
doors are warehouse-grain, moves are location-grain: this is the resolve-or-mint that
gives the door’s moves their virtual counterpart endpoint.
Sourcepub async fn ensure_quant_surface(
&self,
conn: &mut PgConnection,
item_id: Uuid,
location_id: Uuid,
warehouse_id: Option<Uuid>,
) -> Result<(), Error>
pub async fn ensure_quant_surface( &self, conn: &mut PgConnection, item_id: Uuid, location_id: Uuid, warehouse_id: Option<Uuid>, ) -> Result<(), Error>
The quant-surface backfill: guarantee a quant row exists at the bin grain
(item, location, all tracking dims NULL), initialized from the Bin balance of the
location’s warehouse. Stock seeded through the legacy voucher paths wrote Bins without
quants; converged moves draw from quants, so the first converged touch of a grain
heals it. Idempotent by construction (NOT EXISTS guard + the same advisory-lock
pattern QuantRepository::lock_or_init uses — the unique index does not dedup NULL
dimensions, so creation must serialize). A second call finds the row and does nothing:
this is a one-time catch-up, never an ongoing second writer of quantity (the move
pipeline is the only ongoing writer).
Sourcepub async fn find_adjustment_moves(
&self,
conn: &mut PgConnection,
item_id: Uuid,
location_a: Uuid,
location_b: Uuid,
) -> Result<Vec<AdjustmentMoveRow>, Error>
pub async fn find_adjustment_moves( &self, conn: &mut PgConnection, item_id: Uuid, location_a: Uuid, location_b: Uuid, ) -> Result<Vec<AdjustmentMoveRow>, Error>
The adjustment door’s mint-once gate: an existing is_inventory move addressing this
item between exactly these two locations (either direction — the count direction only
flips the pair). Live moves first (resume candidates), then done ones (the
already-applied evidence), newest first.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StockPickingRepository
impl RefUnwindSafe for StockPickingRepository
impl Send for StockPickingRepository
impl Sync for StockPickingRepository
impl Unpin for StockPickingRepository
impl UnsafeUnpin for StockPickingRepository
impl UnwindSafe for StockPickingRepository
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more