datasynth_core/models/sourcing/scorecard.rs
1//! Supplier scorecard models for vendor performance tracking.
2
3use chrono::NaiveDate;
4use serde::{Deserialize, Serialize};
5
6/// Trend direction for scorecard metrics.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
8#[serde(rename_all = "snake_case")]
9pub enum ScoreboardTrend {
10 /// Improving performance
11 Improving,
12 /// Stable performance
13 Stable,
14 /// Declining performance
15 Declining,
16}
17
18/// Recommendation from scorecard review.
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
20#[serde(rename_all = "snake_case")]
21pub enum ScorecardRecommendation {
22 /// Maintain current relationship
23 Maintain,
24 /// Expand relationship (more categories/volume)
25 Expand,
26 /// Place on probation with improvement plan
27 Probation,
28 /// Initiate replacement sourcing
29 Replace,
30}
31
32/// Contract compliance metrics within a scorecard.
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct ContractComplianceMetrics {
35 /// Contract ID
36 pub contract_id: String,
37 /// Contract utilization (consumed / total value)
38 pub utilization_pct: f64,
39 /// Number of SLA breaches
40 pub sla_breach_count: u32,
41 /// Price compliance (% of orders at contract price)
42 pub price_compliance_pct: f64,
43 /// Number of contract amendments
44 pub amendment_count: u32,
45}
46
47/// Supplier scorecard for a review period.
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct SupplierScorecard {
50 /// Unique scorecard identifier
51 pub scorecard_id: String,
52 /// Vendor ID
53 pub vendor_id: String,
54 /// Company code
55 pub company_code: String,
56 /// Review period start
57 pub period_start: NaiveDate,
58 /// Review period end
59 pub period_end: NaiveDate,
60 /// On-time delivery rate (0.0 to 1.0)
61 pub on_time_delivery_rate: f64,
62 /// Quality acceptance rate (0.0 to 1.0)
63 pub quality_rate: f64,
64 /// Price competitiveness score (0.0 to 100.0)
65 pub price_score: f64,
66 /// Responsiveness score (0.0 to 100.0)
67 pub responsiveness_score: f64,
68 /// Overall weighted score (0.0 to 100.0)
69 pub overall_score: f64,
70 /// Letter grade (A, B, C, D, F)
71 pub grade: String,
72 /// Trend direction
73 pub trend: ScoreboardTrend,
74 /// Contract compliance details
75 pub contract_compliance: Vec<ContractComplianceMetrics>,
76 /// Recommendation
77 pub recommendation: ScorecardRecommendation,
78 /// Reviewer ID
79 pub reviewer_id: String,
80 /// Review comments
81 pub comments: Option<String>,
82}