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.