Skip to main content

Backorders

Struct Backorders 

Source
pub struct Backorders { /* private fields */ }
Expand description

Backorder Management interface.

Implementations§

Source§

impl Backorders

Source

pub fn create_backorder(&self, input: CreateBackorder) -> Result<Backorder>

Create a backorder.

§Example
use stateset_embedded::{Commerce, CreateBackorder, BackorderPriority};
use rust_decimal_macros::dec;
use chrono::{Utc, Duration};
use uuid::Uuid;

let commerce = Commerce::new(":memory:")?;

let backorder = commerce.backorder().create_backorder(CreateBackorder {
    order_id: Uuid::new_v4(),
    order_line_id: Some(Uuid::new_v4()),
    customer_id: Uuid::new_v4(),
    sku: "GADGET-002".into(),
    quantity: dec!(25),
    priority: Some(BackorderPriority::Critical),
    expected_date: Some(Utc::now() + Duration::days(7)),
    notes: Some("Rush order - customer requested expedite".into()),
    ..Default::default()
})?;
Source

pub fn get_backorder(&self, id: Uuid) -> Result<Option<Backorder>>

Get a backorder by ID.

Source

pub fn get_backorder_by_number(&self, number: &str) -> Result<Option<Backorder>>

Get a backorder by backorder number.

Source

pub fn update_backorder( &self, id: Uuid, input: UpdateBackorder, ) -> Result<Backorder>

Update a backorder.

Source

pub fn list_backorders(&self, filter: BackorderFilter) -> Result<Vec<Backorder>>

List backorders with optional filtering.

§Example
use stateset_embedded::{Commerce, BackorderFilter, BackorderStatus, BackorderPriority};

let commerce = Commerce::new(":memory:")?;

// Get all critical pending backorders
let backorders = commerce.backorder().list_backorders(BackorderFilter {
    status: Some(BackorderStatus::Pending),
    priority: Some(BackorderPriority::Critical),
    limit: Some(50),
    ..Default::default()
})?;
Source

pub fn cancel_backorder(&self, id: Uuid) -> Result<Backorder>

Cancel a backorder.

Source

pub fn get_backorders_for_order(&self, order_id: Uuid) -> Result<Vec<Backorder>>

Get all backorders for an order.

Source

pub fn get_backorders_for_customer( &self, customer_id: Uuid, ) -> Result<Vec<Backorder>>

Get all backorders for a customer.

Source

pub fn get_backorders_for_sku(&self, sku: &str) -> Result<Vec<Backorder>>

Get all backorders for a SKU.

Source

pub fn fulfill_backorder(&self, input: FulfillBackorder) -> Result<Backorder>

Fulfill a backorder (partial or complete).

§Example
use stateset_embedded::{Commerce, FulfillBackorder, FulfillmentSourceType};
use rust_decimal_macros::dec;
use uuid::Uuid;

let commerce = Commerce::new(":memory:")?;

// Fulfill from received inventory
let backorder = commerce.backorder().fulfill_backorder(FulfillBackorder {
    backorder_id: Uuid::new_v4(),
    quantity: dec!(25),
    source_type: FulfillmentSourceType::PurchaseOrder,
    source_id: Some(Uuid::new_v4()), // PO receipt ID
    notes: Some("Fulfilled from PO-123".into()),
    fulfilled_by: Some("warehouse_user".into()),
})?;

println!("Remaining: {}", backorder.quantity_remaining);
Source

pub fn get_fulfillment_history( &self, backorder_id: Uuid, ) -> Result<Vec<BackorderFulfillment>>

Get fulfillment history for a backorder.

Source

pub fn allocate_backorder( &self, input: AllocateBackorder, ) -> Result<BackorderAllocation>

Allocate inventory to a backorder.

Reserves inventory for the backorder until it can be fulfilled.

Source

pub fn get_allocations( &self, backorder_id: Uuid, ) -> Result<Vec<BackorderAllocation>>

Get allocations for a backorder.

Source

pub fn release_allocation( &self, allocation_id: Uuid, ) -> Result<BackorderAllocation>

Release an allocation.

Source

pub fn confirm_allocation( &self, allocation_id: Uuid, ) -> Result<BackorderAllocation>

Confirm an allocation.

Source

pub fn expire_allocations(&self) -> Result<u32>

Expire old allocations past their expiration date.

Source

pub fn auto_allocate_inventory( &self, sku: &str, ) -> Result<Vec<BackorderAllocation>>

Automatically allocate available inventory to pending backorders.

Allocates in priority order (critical first, then by oldest date).

Source

pub fn get_summary(&self) -> Result<BackorderSummary>

Get overall backorder summary.

§Example
use stateset_embedded::Commerce;

let commerce = Commerce::new(":memory:")?;

let summary = commerce.backorder().get_summary()?;
println!("Total backorders: {}", summary.total_backorders);
println!("Critical: {}", summary.critical_count);
println!("Overdue: {}", summary.overdue_count);
Source

pub fn get_sku_summary(&self, sku: &str) -> Result<Option<SkuBackorderSummary>>

Get backorder summary for a specific SKU.

Source

pub fn get_overdue_backorders(&self) -> Result<Vec<Backorder>>

Get overdue backorders.

Source

pub fn count_pending(&self) -> Result<u64>

Count pending backorders.

Trait Implementations§

Source§

impl Debug for Backorders

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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