Skip to main content

Receiving

Struct Receiving 

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

Receiving and goods receipt management interface.

Implementations§

Source§

impl Receiving

Source

pub fn create_receipt(&self, input: CreateReceipt) -> Result<Receipt>

Create a new receipt (ASN/Goods Receipt).

§Example
use stateset_embedded::{Commerce, CreateReceipt, CreateReceiptItem, ReceiptType};
use rust_decimal_macros::dec;
use chrono::{Utc, Duration};

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

let receipt = commerce.receiving().create_receipt(CreateReceipt {
    receipt_type: ReceiptType::PurchaseOrder,
    warehouse_id: 1,
    carrier: Some("UPS".into()),
    tracking_number: Some("1Z999AA10123456784".into()),
    expected_date: Some(Utc::now() + Duration::days(3)),
    items: vec![
        CreateReceiptItem {
            sku: "WIDGET-001".into(),
            description: Some("Standard Widget".into()),
            expected_quantity: dec!(50),
            unit_cost: Some(dec!(10.00)),
            ..Default::default()
        },
        CreateReceiptItem {
            sku: "GADGET-002".into(),
            description: Some("Premium Gadget".into()),
            expected_quantity: dec!(25),
            unit_cost: Some(dec!(25.00)),
            ..Default::default()
        },
    ],
    ..Default::default()
})?;
Source

pub fn get_receipt(&self, id: Uuid) -> Result<Option<Receipt>>

Get a receipt by ID.

Source

pub fn get_receipt_by_number(&self, number: &str) -> Result<Option<Receipt>>

Get a receipt by receipt number.

Source

pub fn update_receipt(&self, id: Uuid, input: UpdateReceipt) -> Result<Receipt>

Update receipt details (carrier, tracking, expected date).

Source

pub fn list_receipts(&self, filter: ReceiptFilter) -> Result<Vec<Receipt>>

List receipts with optional filtering.

§Example
use stateset_embedded::{Commerce, ReceiptFilter, ReceiptStatus};

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

// Get all in-progress receipts for a warehouse
let receipts = commerce.receiving().list_receipts(ReceiptFilter {
    warehouse_id: Some(1),
    status: Some(ReceiptStatus::InProgress),
    limit: Some(50),
    ..Default::default()
})?;
Source

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

Delete a receipt (only if still in ‘expected’ status).

Source

pub fn start_receiving(&self, id: Uuid) -> Result<Receipt>

Start receiving goods (transition from ‘expected’ to ‘in_progress’).

Call this when goods arrive and receiving process begins.

Source

pub fn receive_items(&self, input: ReceiveItems) -> Result<Receipt>

Receive items against a receipt.

Updates receipt item quantities with actual received amounts. Can be called multiple times for partial receipts.

§Example
use stateset_embedded::{Commerce, ReceiveItems, ReceiveItemLine};
use rust_decimal_macros::dec;
use uuid::Uuid;

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

// Receive items with lot tracking
let receipt = commerce.receiving().receive_items(ReceiveItems {
    receipt_id: Uuid::new_v4(), // receipt ID
    items: vec![ReceiveItemLine {
        receipt_item_id: Uuid::new_v4(), // receipt item ID
        quantity_received: dec!(48),
        quantity_rejected: Some(dec!(2)),
        rejection_reason: Some("Damaged in transit".into()),
        lot_number: Some("LOT-2025-001".into()),
        serial_numbers: None,
        expiration_date: None,
        notes: None,
    }],
    receiving_location_id: Some(1),
    received_by: Some("warehouse_user".into()),
})?;
Source

pub fn complete_receiving(&self, id: Uuid) -> Result<Receipt>

Complete receiving (all items received).

Transitions receipt to ‘received’ status.

Source

pub fn cancel_receipt(&self, id: Uuid) -> Result<Receipt>

Cancel a receipt.

Source

pub fn get_receipt_items(&self, receipt_id: Uuid) -> Result<Vec<ReceiptItem>>

Get all line items for a receipt.

Source

pub fn count_receipts(&self, filter: ReceiptFilter) -> Result<u64>

Count receipts matching the filter.

Source

pub fn create_put_away(&self, input: CreatePutAway) -> Result<PutAway>

Create a put-away task for received items.

Put-away tasks direct warehouse workers to move received goods from the receiving area to storage locations.

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

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

let put_away = commerce.receiving().create_put_away(CreatePutAway {
    receipt_id: Uuid::new_v4(),
    receipt_item_id: Uuid::new_v4(),
    sku: "WIDGET-001".into(),
    from_location_id: Some(1), // Receiving dock
    to_location_id: 5,         // Storage location A-01-02
    quantity: dec!(50),
    lot_id: None,
    assigned_to: Some("forklift_operator".into()),
    notes: None,
})?;
Source

pub fn get_put_away(&self, id: Uuid) -> Result<Option<PutAway>>

Get a put-away task by ID.

Source

pub fn list_put_aways(&self, filter: PutAwayFilter) -> Result<Vec<PutAway>>

List put-away tasks with optional filtering.

Source

pub fn assign_put_away(&self, id: Uuid, assigned_to: &str) -> Result<PutAway>

Assign a put-away task to a user.

Source

pub fn start_put_away(&self, id: Uuid) -> Result<PutAway>

Start a put-away task.

Source

pub fn complete_put_away(&self, input: CompletePutAway) -> Result<PutAway>

Complete a put-away task.

§Example
use stateset_embedded::{Commerce, CompletePutAway};
use uuid::Uuid;

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

// Complete put-away (optionally with different actual location)
let put_away = commerce.receiving().complete_put_away(CompletePutAway {
    put_away_id: Uuid::new_v4(),
    actual_location_id: Some(6), // Different from planned if needed
    completed_by: Some("forklift_operator".into()),
    notes: Some("Placed in alternate bin due to space".into()),
})?;
Source

pub fn cancel_put_away(&self, id: Uuid) -> Result<PutAway>

Cancel a put-away task.

Source

pub fn get_pending_put_aways(&self, receipt_id: Uuid) -> Result<Vec<PutAway>>

Get pending put-away tasks for a receipt.

Source

pub fn count_put_aways(&self, filter: PutAwayFilter) -> Result<u64>

Count put-away tasks matching the filter.

Source

pub fn create_receipt_from_po( &self, po_id: Uuid, warehouse_id: i32, ) -> Result<Receipt>

Create a receipt directly from a purchase order.

Copies PO line items to create expected receipt items.

§Example
use stateset_embedded::Commerce;
use uuid::Uuid;

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

let receipt = commerce.receiving().create_receipt_from_po(
    Uuid::new_v4(), // PO ID
    1,              // Warehouse ID
)?;

println!("Created receipt {} from PO", receipt.receipt_number);
Source

pub fn create_receipts_batch( &self, inputs: Vec<CreateReceipt>, ) -> Result<BatchResult<Receipt>>

Create multiple receipts in a batch.

Source

pub fn get_receipts_batch(&self, ids: Vec<Uuid>) -> Result<Vec<Receipt>>

Get multiple receipts by ID.

Trait Implementations§

Source§

impl Debug for Receiving

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