datasynth_core/models/sourcing/
contract.rs1use chrono::NaiveDate;
4use rust_decimal::Decimal;
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
9#[serde(rename_all = "snake_case")]
10pub enum ContractType {
11 #[default]
13 FixedPrice,
14 Blanket,
16 TimeAndMaterials,
18 CostPlus,
20 ServiceAgreement,
22}
23
24#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
26#[serde(rename_all = "snake_case")]
27pub enum ContractStatus {
28 #[default]
30 Draft,
31 PendingApproval,
33 Active,
35 Suspended,
37 Expired,
39 Terminated,
41 Renewed,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct ContractTerms {
48 pub payment_terms: String,
50 pub delivery_terms: Option<String>,
52 pub warranty_months: Option<u32>,
54 pub early_termination_penalty_pct: Option<f64>,
56 pub auto_renewal: bool,
58 pub termination_notice_days: u32,
60 pub price_adjustment_clause: bool,
62 pub max_annual_price_increase_pct: Option<f64>,
64}
65
66impl Default for ContractTerms {
67 fn default() -> Self {
68 Self {
69 payment_terms: "NET30".to_string(),
70 delivery_terms: None,
71 warranty_months: None,
72 early_termination_penalty_pct: None,
73 auto_renewal: false,
74 termination_notice_days: 90,
75 price_adjustment_clause: false,
76 max_annual_price_increase_pct: None,
77 }
78 }
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83pub struct ContractSla {
84 pub metric_name: String,
86 pub target_value: f64,
88 pub minimum_value: f64,
90 pub breach_penalty_pct: f64,
92 pub measurement_frequency: String,
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
98pub struct ContractLineItem {
99 pub line_number: u16,
101 pub material_id: Option<String>,
103 pub description: String,
105 #[serde(with = "rust_decimal::serde::str")]
107 pub unit_price: Decimal,
108 pub uom: String,
110 pub min_quantity: Option<Decimal>,
112 pub max_quantity: Option<Decimal>,
114 #[serde(default)]
116 pub quantity_released: Decimal,
117 #[serde(default, with = "rust_decimal::serde::str")]
119 pub value_released: Decimal,
120}
121
122#[derive(Debug, Clone, Serialize, Deserialize)]
124pub struct ProcurementContract {
125 pub contract_id: String,
127 pub company_code: String,
129 pub contract_type: ContractType,
131 pub status: ContractStatus,
133 pub vendor_id: String,
135 pub title: String,
137 pub sourcing_project_id: Option<String>,
139 pub bid_id: Option<String>,
141 pub start_date: NaiveDate,
143 pub end_date: NaiveDate,
145 #[serde(with = "rust_decimal::serde::str")]
147 pub total_value: Decimal,
148 #[serde(with = "rust_decimal::serde::str")]
150 pub consumed_value: Decimal,
151 pub terms: ContractTerms,
153 pub slas: Vec<ContractSla>,
155 pub line_items: Vec<ContractLineItem>,
157 pub category_id: String,
159 pub owner_id: String,
161 pub amendment_count: u32,
163 pub previous_contract_id: Option<String>,
165}