roughly_rs/
data.rs

1
2use serde::{Deserialize, Serialize};
3use std::collections::{HashMap, HashSet};
4
5#[derive(Debug, Serialize, Deserialize)]
6pub struct Customer {
7    #[serde(rename = "_id")]
8    pub id: String,
9    pub name: String,
10    pub image: Option<String>,
11}
12
13#[derive(Debug, Serialize, Deserialize)]
14pub struct WeekData {
15    #[serde(rename = "_id")]
16    pub id: Option<String>,
17    pub project: Option<String>,
18    pub employee: Option<String>,
19    pub start: Option<String>,
20    pub end: Option<String>,
21    pub activity: Option<String>,
22    pub created_by: Option<String>,
23    pub updated_by: Option<String>,
24    pub created_at: Option<String>,
25    pub updated_at: Option<String>,
26    #[serde(rename = "__v")]
27    pub v: Option<f64>,
28    pub weeks: Option<HashMap<String, f64>>,
29    pub comments: Option<HashMap<String, String>>,
30    #[serde(rename = "dayPlanning)]")]
31    pub day_planning: Option<HashMap<String, bool>>,
32    #[serde(rename = "weekdayHours)]")]
33    pub weekday_hours: Option<HashMap<String, HashMap<String, Option<f64>>>>,
34    pub preliminary: Option<HashMap<String, serde_json::Value>>,
35}
36
37
38
39#[derive(Debug, Serialize, Deserialize)]
40pub struct Project {
41    #[serde(rename = "_id")]
42    pub id: String,
43    //pub activities: Option<Vec<Activity>>,
44    #[serde(rename = "customerId")]
45    pub customer_id: Option<String>,
46    pub finished: Option<bool>,
47    pub name: String,
48//    pub probability: Option<String>,
49//    #[serde(rename = "updatedAt)]")]
50//    pub updated_at: Option<String>,
51//    #[serde(rename = "createdAt)]")]
52//    pub created_at: Option<String>,
53//    #[serde(rename = "startDate)]")]
54//    pub start_date: Option<String>,
55//    #[serde(rename = "refNo)]")]
56//    pub ref_no: Option<String>,
57//    #[serde(rename = "numberAndName)]")]
58//    pub number_and_name: Option<String>,
59//    #[serde(rename = "legacyUpdatedAt)]")]
60//    pub legacy_created_at: Option<String>,
61//    #[serde(rename = "id")]
62//    pub legacy_id: Option<String>,
63//    //pub phases: Vec<Phase>,
64//    pub tags: Option<Vec<String>>,
65//    #[serde(rename = "projectLead)]")]
66//    pub project_lead: Option<String>,
67}
68
69#[derive(Debug, Serialize, Deserialize)]
70pub struct Activity {
71    #[serde(rename = "activityId)]")]
72    pub activity_id: Option<String>,
73    pub name: Option<String>,
74    pub rate: Option<f64>,
75    pub active: Option<bool>,
76    #[serde(rename = "_id")]
77    pub id: Option<String>,
78    pub hours: Option<f64>,
79}
80
81#[derive(Debug, Serialize, Deserialize)]
82pub struct Employee {
83    #[serde(rename = "_id")]
84    pub id: String,
85    pub name: String,
86    pub email: String,
87    pub title: Option<String>,
88    pub image: Option<String>,
89    pub user_id: Option<String>,
90    pub color: Option<String>,
91}
92
93#[derive(Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
94pub struct CompactEmployee {
95    pub name: String,
96    pub image: Option<String>,
97}
98
99#[derive(Debug, Serialize, Deserialize)]
100pub struct CompactProject {
101    pub project: String,
102    pub image: Option<String>,
103    pub employees: HashSet<CompactEmployee>,
104}
105
106#[derive(Debug, Serialize, Deserialize)]
107pub struct MonthlyAnalysis {
108    pub all_hours: f64,
109    pub all_hours_billable: f64,
110    pub all_hours_non_billable: f64,
111    pub all_hours_with_cost: f64,
112    pub billing_rate: f64,
113    pub average_rate: f64,
114    pub total_invoiced: f64,
115    pub hours_away: f64,
116}
117
118
119
120