Add basic employee hour balance report

This commit is contained in:
Simon Goller 2024-06-23 18:12:54 +02:00
parent 0eb885216a
commit d4adcb182f
31 changed files with 2155 additions and 5 deletions

View file

@ -1,5 +1,9 @@
use std::sync::Arc;
use dao_impl::{
extra_hours::ExtraHoursDaoImpl, shiftplan_report::ShiftplanReportDaoImpl,
working_hours::WorkingHoursDaoImpl,
};
use sqlx::SqlitePool;
#[cfg(feature = "mock_auth")]
@ -30,6 +34,21 @@ type BookingService = service_impl::booking::BookingServiceImpl<
SalesPersonService,
SlotService,
>;
type ReportingService = service_impl::reporting::ReportingServiceImpl<
dao_impl::extra_hours::ExtraHoursDaoImpl,
dao_impl::shiftplan_report::ShiftplanReportDaoImpl,
dao_impl::working_hours::WorkingHoursDaoImpl,
SalesPersonService,
PermissionService,
ClockService,
UuidService,
>;
type WorkingHoursService = service_impl::working_hours::WorkingHoursServiceImpl<
dao_impl::working_hours::WorkingHoursDaoImpl,
PermissionService,
ClockService,
UuidService,
>;
#[derive(Clone)]
pub struct RestStateImpl {
@ -38,6 +57,8 @@ pub struct RestStateImpl {
slot_service: Arc<SlotService>,
sales_person_service: Arc<SalesPersonService>,
booking_service: Arc<BookingService>,
reporting_service: Arc<ReportingService>,
working_hours_service: Arc<WorkingHoursService>,
}
impl rest::RestStateDef for RestStateImpl {
type UserService = UserService;
@ -45,6 +66,8 @@ impl rest::RestStateDef for RestStateImpl {
type SlotService = SlotService;
type SalesPersonService = SalesPersonService;
type BookingService = BookingService;
type ReportingService = ReportingService;
type WorkingHoursService = WorkingHoursService;
fn user_service(&self) -> Arc<Self::UserService> {
self.user_service.clone()
@ -61,13 +84,22 @@ impl rest::RestStateDef for RestStateImpl {
fn booking_service(&self) -> Arc<Self::BookingService> {
self.booking_service.clone()
}
fn reporting_service(&self) -> Arc<Self::ReportingService> {
self.reporting_service.clone()
}
fn working_hours_service(&self) -> Arc<Self::WorkingHoursService> {
self.working_hours_service.clone()
}
}
impl RestStateImpl {
pub fn new(pool: Arc<sqlx::Pool<sqlx::Sqlite>>) -> Self {
let permission_dao = dao_impl::PermissionDaoImpl::new(pool.clone());
let slot_dao = dao_impl::slot::SlotDaoImpl::new(pool.clone());
let sales_person_dao = dao_impl::sales_person::SalesPersonDaoImpl::new(pool.clone());
let booking_dao = dao_impl::booking::BookingDaoImpl::new(pool);
let booking_dao = dao_impl::booking::BookingDaoImpl::new(pool.clone());
let extra_hours_dao = Arc::new(ExtraHoursDaoImpl::new(pool.clone()));
let shiftplan_report_dao = Arc::new(ShiftplanReportDaoImpl::new(pool.clone()));
let working_hours_dao = Arc::new(WorkingHoursDaoImpl::new(pool.clone()));
// Always authenticate with DEVUSER during development.
// This is used to test the permission service locally without a login service.
@ -102,17 +134,35 @@ impl RestStateImpl {
let booking_service = Arc::new(service_impl::booking::BookingServiceImpl::new(
booking_dao.into(),
permission_service.clone(),
clock_service,
uuid_service,
clock_service.clone(),
uuid_service.clone(),
sales_person_service.clone(),
slot_service.clone(),
));
let reporting_service = Arc::new(service_impl::reporting::ReportingServiceImpl::new(
extra_hours_dao,
shiftplan_report_dao,
working_hours_dao.clone(),
sales_person_service.clone(),
permission_service.clone(),
clock_service.clone(),
uuid_service.clone(),
));
let working_hours_service =
Arc::new(service_impl::working_hours::WorkingHoursServiceImpl::new(
working_hours_dao,
permission_service.clone(),
clock_service,
uuid_service,
));
Self {
user_service,
permission_service,
slot_service,
sales_person_service,
booking_service,
reporting_service,
working_hours_service,
}
}
}