Skip to main content

datasynth_core/models/
time_entry.rs

1//! Time entry models for the Hire-to-Retire (H2R) process.
2//!
3//! These models represent employee time tracking entries including regular hours,
4//! overtime, PTO, and sick leave with an approval workflow.
5
6use chrono::NaiveDate;
7use serde::{Deserialize, Serialize};
8
9/// Approval status of a time entry.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
11#[serde(rename_all = "snake_case")]
12pub enum TimeApprovalStatus {
13    /// Awaiting manager approval
14    #[default]
15    Pending,
16    /// Approved by manager
17    Approved,
18    /// Rejected by manager
19    Rejected,
20}
21
22/// A time entry recording hours worked or leave taken by an employee.
23#[derive(Debug, Clone, Serialize, Deserialize)]
24pub struct TimeEntry {
25    /// Unique time entry identifier
26    pub entry_id: String,
27    /// Employee who recorded the time
28    pub employee_id: String,
29    /// Date the time entry applies to
30    pub date: NaiveDate,
31    /// Regular hours worked
32    pub hours_regular: f64,
33    /// Overtime hours worked
34    pub hours_overtime: f64,
35    /// Paid time off hours used
36    pub hours_pto: f64,
37    /// Sick leave hours used
38    pub hours_sick: f64,
39    /// Project the time was charged to
40    pub project_id: Option<String>,
41    /// Cost center allocation
42    pub cost_center: Option<String>,
43    /// Description of work performed
44    pub description: Option<String>,
45    /// Current approval status
46    pub approval_status: TimeApprovalStatus,
47    /// Manager who approved/rejected the entry
48    pub approved_by: Option<String>,
49    /// Date the entry was submitted for approval
50    pub submitted_at: Option<NaiveDate>,
51}