Add basic employee hour balance report
This commit is contained in:
parent
0eb885216a
commit
d4adcb182f
31 changed files with 2155 additions and 5 deletions
40
dao/src/extra_hours.rs
Normal file
40
dao/src/extra_hours.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ExtraHoursCategoryEntity {
|
||||
ExtraWork,
|
||||
Vacation,
|
||||
SickLeave,
|
||||
Holiday,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct ExtraHoursEntity {
|
||||
pub id: Uuid,
|
||||
pub sales_person_id: Uuid,
|
||||
pub amount: f32,
|
||||
pub category: ExtraHoursCategoryEntity,
|
||||
pub description: Arc<str>,
|
||||
pub date_time: time::PrimitiveDateTime,
|
||||
pub deleted: Option<time::PrimitiveDateTime>,
|
||||
}
|
||||
|
||||
#[automock]
|
||||
#[async_trait]
|
||||
pub trait ExtraHoursDao {
|
||||
async fn find_by_sales_person_id_and_year(
|
||||
&self,
|
||||
sales_person_id: Uuid,
|
||||
year: u32,
|
||||
until_week: u8,
|
||||
) -> Result<Arc<[ExtraHoursEntity]>, crate::DaoError>;
|
||||
async fn create(&self, entity: &ExtraHoursEntity, process: &str)
|
||||
-> Result<(), crate::DaoError>;
|
||||
async fn update(&self, entity: &ExtraHoursEntity, process: &str)
|
||||
-> Result<(), crate::DaoError>;
|
||||
async fn delete(&self, id: Uuid, process: &str) -> Result<(), crate::DaoError>;
|
||||
}
|
||||
|
|
@ -5,9 +5,12 @@ use mockall::automock;
|
|||
use thiserror::Error;
|
||||
|
||||
pub mod booking;
|
||||
pub mod extra_hours;
|
||||
pub mod permission;
|
||||
pub mod sales_person;
|
||||
pub mod shiftplan_report;
|
||||
pub mod slot;
|
||||
pub mod working_hours;
|
||||
|
||||
pub use permission::MockPermissionDao;
|
||||
pub use permission::PermissionDao;
|
||||
|
|
@ -28,6 +31,12 @@ pub enum DaoError {
|
|||
|
||||
#[error("Date/Time parse error: {0}")]
|
||||
DateTimeParseError(#[from] time::error::Parse),
|
||||
|
||||
#[error("Date/Time format error: {0}")]
|
||||
DateTimeFormatError(#[from] time::error::Format),
|
||||
|
||||
#[error("Enum value not found: {0}")]
|
||||
EnumValueNotFound(Arc<str>),
|
||||
}
|
||||
|
||||
#[automock]
|
||||
|
|
|
|||
41
dao/src/shiftplan_report.rs
Normal file
41
dao/src/shiftplan_report.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::slot::DayOfWeek;
|
||||
use crate::DaoError;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ShiftplanReportEntity {
|
||||
pub sales_person_id: Uuid,
|
||||
pub hours: f32,
|
||||
pub year: u32,
|
||||
pub calendar_week: u8,
|
||||
pub day_of_week: DayOfWeek,
|
||||
}
|
||||
|
||||
pub struct ShiftplanQuickOverviewEntity {
|
||||
pub sales_person_id: Uuid,
|
||||
pub hours: f32,
|
||||
pub year: u32,
|
||||
}
|
||||
|
||||
#[automock]
|
||||
#[async_trait]
|
||||
pub trait ShiftplanReportDao {
|
||||
/// A report which contains the worked hours of a sales person for each day.
|
||||
async fn extract_shiftplan_report(
|
||||
&self,
|
||||
sales_person_id: Uuid,
|
||||
year: u32,
|
||||
until_week: u8,
|
||||
) -> Result<Arc<[ShiftplanReportEntity]>, DaoError>;
|
||||
|
||||
/// A report which shows the summed up yearly work hours of all sales persons.
|
||||
async fn extract_quick_shiftplan_report(
|
||||
&self,
|
||||
year: u32,
|
||||
until_week: u8,
|
||||
) -> Result<Arc<[ShiftplanQuickOverviewEntity]>, DaoError>;
|
||||
}
|
||||
32
dao/src/working_hours.rs
Normal file
32
dao/src/working_hours.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
use crate::DaoError;
|
||||
use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use std::sync::Arc;
|
||||
use time::PrimitiveDateTime;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct WorkingHoursEntity {
|
||||
pub id: Uuid,
|
||||
pub sales_person_id: Uuid,
|
||||
pub expected_hours: f32,
|
||||
pub from_calendar_week: u8,
|
||||
pub from_year: u32,
|
||||
pub to_calendar_week: u8,
|
||||
pub to_year: u32,
|
||||
pub created: PrimitiveDateTime,
|
||||
pub deleted: Option<PrimitiveDateTime>,
|
||||
pub version: Uuid,
|
||||
}
|
||||
|
||||
#[automock]
|
||||
#[async_trait]
|
||||
pub trait WorkingHoursDao {
|
||||
async fn all(&self) -> Result<Arc<[WorkingHoursEntity]>, DaoError>;
|
||||
async fn find_by_sales_person_id(
|
||||
&self,
|
||||
sales_person_id: Uuid,
|
||||
) -> Result<Arc<[WorkingHoursEntity]>, DaoError>;
|
||||
async fn create(&self, entity: &WorkingHoursEntity, process: &str) -> Result<(), DaoError>;
|
||||
async fn update(&self, entity: &WorkingHoursEntity, process: &str) -> Result<(), DaoError>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue