pub struct Receiving { /* private fields */ }Expand description
Receiving and goods receipt management interface.
Implementations§
Source§impl Receiving
impl Receiving
Sourcepub fn create_receipt(&self, input: CreateReceipt) -> Result<Receipt>
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()
})?;Sourcepub fn get_receipt_by_number(&self, number: &str) -> Result<Option<Receipt>>
pub fn get_receipt_by_number(&self, number: &str) -> Result<Option<Receipt>>
Get a receipt by receipt number.
Sourcepub fn update_receipt(&self, id: Uuid, input: UpdateReceipt) -> Result<Receipt>
pub fn update_receipt(&self, id: Uuid, input: UpdateReceipt) -> Result<Receipt>
Update receipt details (carrier, tracking, expected date).
Sourcepub fn list_receipts(&self, filter: ReceiptFilter) -> Result<Vec<Receipt>>
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()
})?;Sourcepub fn delete_receipt(&self, id: Uuid) -> Result<()>
pub fn delete_receipt(&self, id: Uuid) -> Result<()>
Delete a receipt (only if still in ‘expected’ status).
Sourcepub fn start_receiving(&self, id: Uuid) -> Result<Receipt>
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.
Sourcepub fn receive_items(&self, input: ReceiveItems) -> Result<Receipt>
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()),
})?;Sourcepub fn complete_receiving(&self, id: Uuid) -> Result<Receipt>
pub fn complete_receiving(&self, id: Uuid) -> Result<Receipt>
Complete receiving (all items received).
Transitions receipt to ‘received’ status.
Sourcepub fn cancel_receipt(&self, id: Uuid) -> Result<Receipt>
pub fn cancel_receipt(&self, id: Uuid) -> Result<Receipt>
Cancel a receipt.
Sourcepub fn get_receipt_items(&self, receipt_id: Uuid) -> Result<Vec<ReceiptItem>>
pub fn get_receipt_items(&self, receipt_id: Uuid) -> Result<Vec<ReceiptItem>>
Get all line items for a receipt.
Sourcepub fn count_receipts(&self, filter: ReceiptFilter) -> Result<u64>
pub fn count_receipts(&self, filter: ReceiptFilter) -> Result<u64>
Count receipts matching the filter.
Sourcepub fn create_put_away(&self, input: CreatePutAway) -> Result<PutAway>
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,
})?;Sourcepub fn list_put_aways(&self, filter: PutAwayFilter) -> Result<Vec<PutAway>>
pub fn list_put_aways(&self, filter: PutAwayFilter) -> Result<Vec<PutAway>>
List put-away tasks with optional filtering.
Sourcepub fn assign_put_away(&self, id: Uuid, assigned_to: &str) -> Result<PutAway>
pub fn assign_put_away(&self, id: Uuid, assigned_to: &str) -> Result<PutAway>
Assign a put-away task to a user.
Sourcepub fn start_put_away(&self, id: Uuid) -> Result<PutAway>
pub fn start_put_away(&self, id: Uuid) -> Result<PutAway>
Start a put-away task.
Sourcepub fn complete_put_away(&self, input: CompletePutAway) -> Result<PutAway>
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()),
})?;Sourcepub fn cancel_put_away(&self, id: Uuid) -> Result<PutAway>
pub fn cancel_put_away(&self, id: Uuid) -> Result<PutAway>
Cancel a put-away task.
Sourcepub fn get_pending_put_aways(&self, receipt_id: Uuid) -> Result<Vec<PutAway>>
pub fn get_pending_put_aways(&self, receipt_id: Uuid) -> Result<Vec<PutAway>>
Get pending put-away tasks for a receipt.
Sourcepub fn count_put_aways(&self, filter: PutAwayFilter) -> Result<u64>
pub fn count_put_aways(&self, filter: PutAwayFilter) -> Result<u64>
Count put-away tasks matching the filter.
Sourcepub fn create_receipt_from_po(
&self,
po_id: Uuid,
warehouse_id: i32,
) -> Result<Receipt>
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);Sourcepub fn create_receipts_batch(
&self,
inputs: Vec<CreateReceipt>,
) -> Result<BatchResult<Receipt>>
pub fn create_receipts_batch( &self, inputs: Vec<CreateReceipt>, ) -> Result<BatchResult<Receipt>>
Create multiple receipts in a batch.