Skip to main content

PickingBatchProjectionRepository

Struct PickingBatchProjectionRepository 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

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).

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Default for PickingBatchProjectionRepository

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more