pub struct PickingBatchProjectionRepository;Expand description
The batch mint/membership/probe SQL. Stateless — every method takes the caller’s connection so the header insert, the membership write, and the projection recompute commit as one unit.
Implementations§
Source§impl PickingBatchProjectionRepository
impl PickingBatchProjectionRepository
pub fn new() -> Self
Sourcepub async fn insert_batch(
&self,
conn: &mut PgConnection,
b: &NewBatchRow<'_>,
) -> Result<(), Error>
pub async fn insert_batch( &self, conn: &mut PgConnection, b: &NewBatchRow<'_>, ) -> Result<(), Error>
Insert the batch header (a draft grouping point). 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 the typed duplicate-name error.
Sourcepub async fn fetch_batch(
&self,
conn: &mut PgConnection,
batch_id: Uuid,
) -> Result<Option<BatchHeaderRow>, Error>
pub async fn fetch_batch( &self, conn: &mut PgConnection, batch_id: Uuid, ) -> Result<Option<BatchHeaderRow>, Error>
Read one batch header (probe surface — the projected state is READ here, never asserted by callers).
Sourcepub async fn fetch_members(
&self,
conn: &mut PgConnection,
batch_id: Uuid,
) -> Result<Vec<BatchMemberRow>, Error>
pub async fn fetch_members( &self, conn: &mut PgConnection, batch_id: Uuid, ) -> Result<Vec<BatchMemberRow>, Error>
Read a batch’s member pickings (the projection inputs, for the probe surface).
Sourcepub async fn add_member(
&self,
conn: &mut PgConnection,
batch_id: Uuid,
picking_id: Uuid,
) -> Result<(), Error>
pub async fn add_member( &self, conn: &mut PgConnection, batch_id: Uuid, picking_id: Uuid, ) -> Result<(), Error>
Attach a picking to its batch: set the membership pointer and stamp the SB-1
discriminator (had_members — once true, an empty batch auto-cancels instead of
falling back to draft). The caller reprojects right after; this write only
moves the pointer.
Sourcepub async fn remove_member(
&self,
conn: &mut PgConnection,
batch_id: Uuid,
picking_id: Uuid,
) -> Result<bool, Error>
pub async fn remove_member( &self, conn: &mut PgConnection, batch_id: Uuid, picking_id: Uuid, ) -> Result<bool, Error>
Detach a picking from its batch (removal is always allowed — a done or cancelled picking still leaves its batch). Returns false when the picking was not a member.
Sourcepub async fn reproject_batch(
&self,
conn: &mut PgConnection,
batch_id: Uuid,
) -> Result<Option<String>, Error>
pub async fn reproject_batch( &self, conn: &mut PgConnection, batch_id: Uuid, ) -> Result<Option<String>, Error>
The SB-1 projection recompute (spec misc-features.md SB, ADR-0016 projection
shape). picking_batches.state is a STORED COMPUTE over its member pickings:
the LEAST-advanced live member band, with cancelled members dropping out of the
aggregation entirely —
live member draft/confirmed → batch draft (nothing ready to wave-pick yet)
every live member ≥ waiting → waiting
every live member ≥ assigned → ready
every live member done → done
no live member, members exist (all cancelled) → cancel
no member at all, the batch HAS grouped one before → cancel (auto-cancel on
empty — SB-1: an emptied batch must not linger as a live work item)
no member at all, never grouped one → draft (a freshly minted batch the
operator is about to fill)
A member’s confirmed counts at the draft band (Odoo’s _compute_state has no
confirmed in any prefix: a confirmed-but-unreserved picking is not wave-ready).
Returns the new projected state (text), or None when the batch row is gone.
Sourcepub async fn picking_membership(
&self,
conn: &mut PgConnection,
picking_id: Uuid,
) -> Result<Option<Option<Uuid>>, Error>
pub async fn picking_membership( &self, conn: &mut PgConnection, picking_id: Uuid, ) -> Result<Option<Option<Uuid>>, Error>
Read one picking’s batch membership. Outer None = the transfer row is absent
(or fenced out — the ambient org scope’s fence hides it); inner None = the
picking belongs to no batch. The membership-guard input for the typed
already-batched refusal.
Sourcepub async fn reproject_batch_of_picking(
&self,
conn: &mut PgConnection,
picking_id: Uuid,
) -> Result<Option<String>, Error>
pub async fn reproject_batch_of_picking( &self, conn: &mut PgConnection, picking_id: Uuid, ) -> Result<Option<String>, Error>
The picking-projection cascade entry: after a picking’s own state was re-derived,
re-derive its batch’s (if the picking belongs to one). Called by
StockMoveRepository::reproject_picking on every member-state change so the
batch never lags its members — the picking and its batch roll-up commit in the
same transaction.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PickingBatchProjectionRepository
impl RefUnwindSafe for PickingBatchProjectionRepository
impl Send for PickingBatchProjectionRepository
impl Sync for PickingBatchProjectionRepository
impl Unpin for PickingBatchProjectionRepository
impl UnsafeUnpin for PickingBatchProjectionRepository
impl UnwindSafe for PickingBatchProjectionRepository
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