Skip to main content

datasynth_core/models/sourcing/
sourcing_project.rs

1//! Sourcing project models for strategic procurement initiatives.
2
3use chrono::NaiveDate;
4use rust_decimal::Decimal;
5use serde::{Deserialize, Serialize};
6
7/// Type of sourcing project.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
9#[serde(rename_all = "snake_case")]
10pub enum SourcingProjectType {
11    /// New category sourcing
12    #[default]
13    NewSourcing,
14    /// Contract renewal/renegotiation
15    Renewal,
16    /// Supplier consolidation
17    Consolidation,
18    /// Emergency sourcing
19    Emergency,
20    /// Strategic partnership
21    StrategicPartnership,
22}
23
24/// Status of a sourcing project.
25#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
26#[serde(rename_all = "snake_case")]
27pub enum SourcingProjectStatus {
28    /// Project created, not yet started
29    #[default]
30    Draft,
31    /// Spend analysis in progress
32    SpendAnalysis,
33    /// Supplier qualification phase
34    Qualification,
35    /// RFx in progress
36    RfxActive,
37    /// Evaluating bids
38    Evaluation,
39    /// Contract negotiation
40    Negotiation,
41    /// Contract awarded
42    Awarded,
43    /// Project completed
44    Completed,
45    /// Project cancelled
46    Cancelled,
47}
48
49/// A sourcing project tracking a procurement initiative.
50#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct SourcingProject {
52    /// Unique project identifier
53    pub project_id: String,
54    /// Project name
55    pub project_name: String,
56    /// Company code
57    pub company_code: String,
58    /// Project type
59    pub project_type: SourcingProjectType,
60    /// Current status
61    pub status: SourcingProjectStatus,
62    /// Spend category being sourced
63    pub category_id: String,
64    /// Estimated annual spend
65    #[serde(with = "rust_decimal::serde::str")]
66    pub estimated_annual_spend: Decimal,
67    /// Target savings percentage
68    pub target_savings_pct: f64,
69    /// Project owner (buyer/sourcing manager)
70    pub owner_id: String,
71    /// Start date
72    pub start_date: NaiveDate,
73    /// Target completion date
74    pub target_end_date: NaiveDate,
75    /// Actual completion date
76    pub actual_end_date: Option<NaiveDate>,
77    /// Related spend analysis ID
78    pub spend_analysis_id: Option<String>,
79    /// Related RFx event IDs
80    pub rfx_ids: Vec<String>,
81    /// Awarded contract ID
82    pub contract_id: Option<String>,
83    /// Actual savings achieved
84    pub actual_savings_pct: Option<f64>,
85}