1use serde::{Deserialize, Serialize};
7use std::collections::HashMap;
8use std::time::Duration;
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct BudgetManagementConfig {
13 pub global_budget: GlobalBudgetConfig,
15 pub department_budgets: HashMap<String, DepartmentBudgetConfig>,
17 pub project_budgets: HashMap<String, ProjectBudgetConfig>,
19 pub monitoring: BudgetMonitoringConfig,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct GlobalBudgetConfig {
26 pub total_budget: f64,
28 pub period: BudgetPeriod,
30 pub currency: String,
32 pub rollover_policy: RolloverPolicy,
34}
35
36#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
38pub enum BudgetPeriod {
39 Monthly,
40 Quarterly,
41 Annual,
42 Custom(Duration),
43}
44
45#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
47pub enum RolloverPolicy {
48 NoRollover,
49 FullRollover,
50 PartialRollover(f64),
51 ConditionalRollover,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct DepartmentBudgetConfig {
57 pub name: String,
59 pub allocated_budget: f64,
61 pub spending_limits: SpendingLimits,
63 pub approval_workflow: BudgetApprovalWorkflow,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct SpendingLimits {
70 pub daily_limit: Option<f64>,
72 pub weekly_limit: Option<f64>,
74 pub monthly_limit: Option<f64>,
76 pub per_transaction_limit: Option<f64>,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct BudgetApprovalWorkflow {
83 pub levels: Vec<BudgetApprovalLevel>,
85 pub auto_approval_thresholds: HashMap<String, f64>,
87 pub escalation_timeouts: HashMap<String, Duration>,
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct BudgetApprovalLevel {
94 pub name: String,
96 pub approvers: Vec<String>,
98 pub thresholds: HashMap<String, f64>,
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104pub struct ProjectBudgetConfig {
105 pub name: String,
107 pub budget: f64,
109 pub cost_tracking: ProjectCostTracking,
111 pub alerts: ProjectBudgetAlerts,
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117pub struct ProjectCostTracking {
118 pub granularity: CostTrackingGranularity,
120 pub categories: Vec<CostCategory>,
122 pub allocation_rules: Vec<CostAllocationRule>,
124}
125
126#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
128pub enum CostTrackingGranularity {
129 Hourly,
130 Daily,
131 Weekly,
132 Monthly,
133}
134
135#[derive(Debug, Clone, Serialize, Deserialize)]
137pub struct CostCategory {
138 pub name: String,
140 pub description: String,
142 pub budget_allocation: f64,
144}
145
146#[derive(Debug, Clone, Serialize, Deserialize)]
148pub struct CostAllocationRule {
149 pub name: String,
151 pub source: String,
153 pub target: String,
155 pub percentage: f64,
157}
158
159#[derive(Debug, Clone, Serialize, Deserialize)]
161pub struct ProjectBudgetAlerts {
162 pub thresholds: Vec<f64>,
164 pub recipients: Vec<String>,
166 pub frequency: AlertFrequency,
168}
169
170#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
172pub enum AlertFrequency {
173 Immediate,
174 Daily,
175 Weekly,
176 OnThreshold,
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize)]
181pub struct BudgetMonitoringConfig {
182 pub real_time: bool,
184 pub reporting_frequency: ReportingFrequency,
186 pub variance_analysis: BudgetVarianceAnalysis,
188 pub forecasting: BudgetForecastingConfig,
190}
191
192#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
194pub enum ReportingFrequency {
195 RealTime,
196 Hourly,
197 Daily,
198 Weekly,
199 Monthly,
200}
201
202#[derive(Debug, Clone, Serialize, Deserialize)]
204pub struct BudgetVarianceAnalysis {
205 pub enabled: bool,
207 pub thresholds: BudgetVarianceThresholds,
209 pub methods: Vec<VarianceAnalysisMethod>,
211}
212
213#[derive(Debug, Clone, Serialize, Deserialize)]
215pub struct BudgetVarianceThresholds {
216 pub warning: f64,
218 pub critical: f64,
220 pub emergency: f64,
222}
223
224#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
226pub enum VarianceAnalysisMethod {
227 AbsoluteVariance,
228 PercentageVariance,
229 TrendAnalysis,
230 SeasonalAnalysis,
231}
232
233#[derive(Debug, Clone, Serialize, Deserialize)]
235pub struct BudgetForecastingConfig {
236 pub enabled: bool,
238 pub models: Vec<BudgetForecastingModel>,
240 pub horizon: Duration,
242 pub update_frequency: Duration,
244}
245
246#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
248pub enum BudgetForecastingModel {
249 LinearTrend,
250 ExponentialSmoothing,
251 ARIMA,
252 MachineLearning,
253 Custom(String),
254}