Skip to main content

Quality

Struct Quality 

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

Quality control management interface.

Implementations§

Source§

impl Quality

Source

pub fn create_inspection(&self, input: CreateInspection) -> Result<Inspection>

Create a new inspection.

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

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

let inspection = commerce.quality().create_inspection(CreateInspection {
    inspection_type: InspectionType::Receiving,
    reference_type: "purchase_order".into(),
    reference_id: Uuid::new_v4(),
    ..Default::default()
})?;
Source

pub fn get_inspection(&self, id: Uuid) -> Result<Option<Inspection>>

Get an inspection by ID.

Source

pub fn get_inspection_by_number( &self, number: &str, ) -> Result<Option<Inspection>>

Get an inspection by its number.

Source

pub fn list_inspections( &self, filter: InspectionFilter, ) -> Result<Vec<Inspection>>

List inspections with optional filtering.

Source

pub fn update_inspection( &self, id: Uuid, input: UpdateInspection, ) -> Result<Inspection>

Update an inspection.

Source

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

Start an inspection (set status to InProgress).

Source

pub fn record_inspection_result( &self, input: RecordInspectionResult, ) -> Result<InspectionItem>

Record inspection results for an item.

Source

pub fn get_inspection_items( &self, inspection_id: Uuid, ) -> Result<Vec<InspectionItem>>

Get inspection items for an inspection.

Source

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

Complete an inspection (mark as Passed or Failed based on results).

Source

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

Delete an inspection (only if Pending).

Source

pub fn count_inspections(&self, filter: InspectionFilter) -> Result<u64>

Count inspections matching filter.

Source

pub fn create_ncr(&self, input: CreateNonConformance) -> Result<NonConformance>

Create a non-conformance report (NCR).

§Example
use stateset_embedded::{Commerce, CreateNonConformance, NonConformanceSource, Severity};
use rust_decimal_macros::dec;

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

let ncr = commerce.quality().create_ncr(CreateNonConformance {
    source: NonConformanceSource::Inspection,
    severity: Severity::Major,
    sku: "SKU-001".into(),
    quantity_affected: dec!(10),
    description: "Parts do not meet specification".into(),
    ..Default::default()
})?;

println!("Created NCR #{}", ncr.ncr_number);
Source

pub fn get_ncr(&self, id: Uuid) -> Result<Option<NonConformance>>

Get a non-conformance report by ID.

Source

pub fn get_ncr_by_number(&self, number: &str) -> Result<Option<NonConformance>>

Get a non-conformance report by its number.

Source

pub fn list_ncrs( &self, filter: NonConformanceFilter, ) -> Result<Vec<NonConformance>>

List non-conformance reports with optional filtering.

Source

pub fn update_ncr( &self, id: Uuid, input: UpdateNonConformance, ) -> Result<NonConformance>

Update a non-conformance report.

Use this to set root cause, corrective action, disposition, etc.

Source

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

Close an NCR.

Source

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

Cancel an NCR.

Source

pub fn count_ncrs(&self, filter: NonConformanceFilter) -> Result<u64>

Count NCRs matching filter.

Source

pub fn create_hold(&self, input: CreateQualityHold) -> Result<QualityHold>

Create a quality hold on inventory.

§Example
use stateset_embedded::{Commerce, CreateQualityHold, HoldType};
use rust_decimal_macros::dec;

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

let hold = commerce.quality().create_hold(CreateQualityHold {
    sku: "SKU-001".into(),
    lot_number: Some("LOT-2025-001".into()),
    quantity_held: dec!(50),
    reason: "Pending quality inspection".into(),
    hold_type: HoldType::QualityInspection,
    placed_by: Some("QA Team".into()),
    ..Default::default()
})?;

println!("Hold placed on {} units", hold.quantity_held);
Source

pub fn get_hold(&self, id: Uuid) -> Result<Option<QualityHold>>

Get a quality hold by ID.

Source

pub fn list_holds(&self, filter: QualityHoldFilter) -> Result<Vec<QualityHold>>

List quality holds with optional filtering.

Source

pub fn release_hold( &self, id: Uuid, input: ReleaseQualityHold, ) -> Result<QualityHold>

Release a quality hold.

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

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

commerce.quality().release_hold(Uuid::new_v4(), ReleaseQualityHold {
    released_by: "QA Manager".into(),
    notes: Some("Inspection passed".into()),
})?;
Source

pub fn get_active_holds_for_sku(&self, sku: &str) -> Result<Vec<QualityHold>>

Get active holds for a SKU.

Source

pub fn get_active_holds_for_lot( &self, lot_number: &str, ) -> Result<Vec<QualityHold>>

Get active holds for a lot.

Source

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

Count active holds.

Source

pub fn create_defect_code(&self, input: CreateDefectCode) -> Result<DefectCode>

Create a defect code.

Source

pub fn get_defect_code(&self, code: &str) -> Result<Option<DefectCode>>

Get a defect code by code.

Source

pub fn list_defect_codes( &self, category: Option<&str>, ) -> Result<Vec<DefectCode>>

List all defect codes, optionally filtered by category.

Source

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

Deactivate a defect code.

Source

pub fn get_pending_inspections(&self) -> Result<Vec<Inspection>>

Get all pending inspections.

Source

pub fn get_open_ncrs(&self) -> Result<Vec<NonConformance>>

Get all open NCRs.

Source

pub fn get_active_holds(&self) -> Result<Vec<QualityHold>>

Get all active holds.

Trait Implementations§

Source§

impl Debug for Quality

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