pub struct Backorders { /* private fields */ }Expand description
Backorder Management interface.
Implementations§
Source§impl Backorders
impl Backorders
Sourcepub fn create_backorder(&self, input: CreateBackorder) -> Result<Backorder>
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()
})?;Sourcepub fn get_backorder_by_number(&self, number: &str) -> Result<Option<Backorder>>
pub fn get_backorder_by_number(&self, number: &str) -> Result<Option<Backorder>>
Get a backorder by backorder number.
Sourcepub fn update_backorder(
&self,
id: Uuid,
input: UpdateBackorder,
) -> Result<Backorder>
pub fn update_backorder( &self, id: Uuid, input: UpdateBackorder, ) -> Result<Backorder>
Update a backorder.
Sourcepub fn list_backorders(&self, filter: BackorderFilter) -> Result<Vec<Backorder>>
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()
})?;Sourcepub fn cancel_backorder(&self, id: Uuid) -> Result<Backorder>
pub fn cancel_backorder(&self, id: Uuid) -> Result<Backorder>
Cancel a backorder.
Sourcepub fn get_backorders_for_order(&self, order_id: Uuid) -> Result<Vec<Backorder>>
pub fn get_backorders_for_order(&self, order_id: Uuid) -> Result<Vec<Backorder>>
Get all backorders for an order.
Sourcepub fn get_backorders_for_customer(
&self,
customer_id: Uuid,
) -> Result<Vec<Backorder>>
pub fn get_backorders_for_customer( &self, customer_id: Uuid, ) -> Result<Vec<Backorder>>
Get all backorders for a customer.
Sourcepub fn get_backorders_for_sku(&self, sku: &str) -> Result<Vec<Backorder>>
pub fn get_backorders_for_sku(&self, sku: &str) -> Result<Vec<Backorder>>
Get all backorders for a SKU.
Sourcepub fn fulfill_backorder(&self, input: FulfillBackorder) -> Result<Backorder>
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);Sourcepub fn get_fulfillment_history(
&self,
backorder_id: Uuid,
) -> Result<Vec<BackorderFulfillment>>
pub fn get_fulfillment_history( &self, backorder_id: Uuid, ) -> Result<Vec<BackorderFulfillment>>
Get fulfillment history for a backorder.
Sourcepub fn allocate_backorder(
&self,
input: AllocateBackorder,
) -> Result<BackorderAllocation>
pub fn allocate_backorder( &self, input: AllocateBackorder, ) -> Result<BackorderAllocation>
Allocate inventory to a backorder.
Reserves inventory for the backorder until it can be fulfilled.
Sourcepub fn get_allocations(
&self,
backorder_id: Uuid,
) -> Result<Vec<BackorderAllocation>>
pub fn get_allocations( &self, backorder_id: Uuid, ) -> Result<Vec<BackorderAllocation>>
Get allocations for a backorder.
Sourcepub fn release_allocation(
&self,
allocation_id: Uuid,
) -> Result<BackorderAllocation>
pub fn release_allocation( &self, allocation_id: Uuid, ) -> Result<BackorderAllocation>
Release an allocation.
Sourcepub fn confirm_allocation(
&self,
allocation_id: Uuid,
) -> Result<BackorderAllocation>
pub fn confirm_allocation( &self, allocation_id: Uuid, ) -> Result<BackorderAllocation>
Confirm an allocation.
Sourcepub fn expire_allocations(&self) -> Result<u32>
pub fn expire_allocations(&self) -> Result<u32>
Expire old allocations past their expiration date.
Sourcepub fn auto_allocate_inventory(
&self,
sku: &str,
) -> Result<Vec<BackorderAllocation>>
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).
Sourcepub fn get_summary(&self) -> Result<BackorderSummary>
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);Sourcepub fn get_sku_summary(&self, sku: &str) -> Result<Option<SkuBackorderSummary>>
pub fn get_sku_summary(&self, sku: &str) -> Result<Option<SkuBackorderSummary>>
Get backorder summary for a specific SKU.
Sourcepub fn get_overdue_backorders(&self) -> Result<Vec<Backorder>>
pub fn get_overdue_backorders(&self) -> Result<Vec<Backorder>>
Get overdue backorders.
Sourcepub fn count_pending(&self) -> Result<u64>
pub fn count_pending(&self) -> Result<u64>
Count pending backorders.