pub struct Material {Show 23 fields
pub material_id: String,
pub description: String,
pub material_type: MaterialType,
pub material_group: MaterialGroup,
pub base_uom: UnitOfMeasure,
pub valuation_method: ValuationMethod,
pub standard_cost: Decimal,
pub list_price: Decimal,
pub purchase_price: Decimal,
pub bom_components: Option<Vec<BomComponent>>,
pub account_determination: MaterialAccountDetermination,
pub weight_kg: Option<Decimal>,
pub volume_m3: Option<Decimal>,
pub shelf_life_days: Option<u32>,
pub is_active: bool,
pub company_code: Option<String>,
pub plants: Vec<String>,
pub min_order_quantity: Decimal,
pub lead_time_days: u16,
pub safety_stock: Decimal,
pub reorder_point: Decimal,
pub preferred_vendor_id: Option<String>,
pub abc_classification: char,
}Expand description
Material master data.
Fields§
§material_id: StringMaterial ID (e.g., “MAT-001234”)
description: StringMaterial description
material_type: MaterialTypeType of material
material_group: MaterialGroupMaterial group
base_uom: UnitOfMeasureBase unit of measure
valuation_method: ValuationMethodValuation method
standard_cost: DecimalStandard cost per base unit
list_price: DecimalList price (selling price) per base unit
purchase_price: DecimalPurchase price per base unit
bom_components: Option<Vec<BomComponent>>Bill of materials components (if this is a produced item)
account_determination: MaterialAccountDeterminationAccount determination rules
weight_kg: Option<Decimal>Weight per base unit (kg)
volume_m3: Option<Decimal>Volume per base unit (m3)
shelf_life_days: Option<u32>Shelf life in days (for perishables)
is_active: boolIs this material active?
company_code: Option<String>Company code (if material is company-specific)
plants: Vec<String>Plant/location codes where material is available
min_order_quantity: DecimalMinimum order quantity
lead_time_days: u16Lead time in days for procurement
safety_stock: DecimalSafety stock quantity
reorder_point: DecimalReorder point
preferred_vendor_id: Option<String>Preferred vendor ID
abc_classification: charABC classification (A=high value, C=low value)
Implementations§
Source§impl Material
impl Material
Sourcepub fn new(
material_id: impl Into<String>,
description: impl Into<String>,
material_type: MaterialType,
) -> Self
pub fn new( material_id: impl Into<String>, description: impl Into<String>, material_type: MaterialType, ) -> Self
Create a new material with minimal required fields.
Sourcepub fn with_group(self, group: MaterialGroup) -> Self
pub fn with_group(self, group: MaterialGroup) -> Self
Set material group.
Sourcepub fn with_standard_cost(self, cost: Decimal) -> Self
pub fn with_standard_cost(self, cost: Decimal) -> Self
Set standard cost.
Sourcepub fn with_list_price(self, price: Decimal) -> Self
pub fn with_list_price(self, price: Decimal) -> Self
Set list price.
Sourcepub fn with_purchase_price(self, price: Decimal) -> Self
pub fn with_purchase_price(self, price: Decimal) -> Self
Set purchase price.
Sourcepub fn with_bom(self, components: Vec<BomComponent>) -> Self
pub fn with_bom(self, components: Vec<BomComponent>) -> Self
Set BOM components.
Sourcepub fn with_company_code(self, code: impl Into<String>) -> Self
pub fn with_company_code(self, code: impl Into<String>) -> Self
Set company code.
Sourcepub fn with_preferred_vendor(self, vendor_id: impl Into<String>) -> Self
pub fn with_preferred_vendor(self, vendor_id: impl Into<String>) -> Self
Set preferred vendor.
Sourcepub fn with_abc_classification(self, classification: char) -> Self
pub fn with_abc_classification(self, classification: char) -> Self
Set ABC classification.
Sourcepub fn calculate_bom_cost(
&self,
component_costs: &HashMap<String, Decimal>,
) -> Option<Decimal>
pub fn calculate_bom_cost( &self, component_costs: &HashMap<String, Decimal>, ) -> Option<Decimal>
Calculate the theoretical cost from BOM.
Sourcepub fn gross_margin_percent(&self) -> Decimal
pub fn gross_margin_percent(&self) -> Decimal
Calculate gross margin percentage.
Sourcepub fn needs_reorder(&self, current_stock: Decimal) -> bool
pub fn needs_reorder(&self, current_stock: Decimal) -> bool
Check if reorder is needed based on current stock.
Sourcepub fn suggested_reorder_quantity(&self) -> Decimal
pub fn suggested_reorder_quantity(&self) -> Decimal
Calculate reorder quantity based on EOQ principles.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Material
impl<'de> Deserialize<'de> for Material
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Material
impl RefUnwindSafe for Material
impl Send for Material
impl Sync for Material
impl Unpin for Material
impl UnsafeUnpin for Material
impl UnwindSafe for Material
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.