Browse Source

Add non billable tasks for timesheets

tags/Baseline_30082024_BACKEND_UAT
Wayne 1 year ago
parent
commit
3cda2a8d6e
3 changed files with 17 additions and 8 deletions
  1. +5
    -0
      src/main/java/com/ffii/tsms/modules/timesheet/entity/Timesheet.kt
  2. +6
    -8
      src/main/java/com/ffii/tsms/modules/timesheet/service/TimesheetsService.kt
  3. +6
    -0
      src/main/resources/db/changelog/changes/20240725_01_wayne/01_update_timesheet_non_billable_task.sql

+ 5
- 0
src/main/java/com/ffii/tsms/modules/timesheet/entity/Timesheet.kt View File

@@ -4,6 +4,7 @@ import com.ffii.core.entity.BaseEntity
import com.ffii.tsms.modules.data.entity.Staff import com.ffii.tsms.modules.data.entity.Staff
import com.ffii.tsms.modules.project.entity.Project import com.ffii.tsms.modules.project.entity.Project
import com.ffii.tsms.modules.project.entity.ProjectTask import com.ffii.tsms.modules.project.entity.ProjectTask
import com.ffii.tsms.modules.project.entity.Task
import jakarta.persistence.* import jakarta.persistence.*
import jakarta.validation.constraints.NotNull import jakarta.validation.constraints.NotNull
import java.time.LocalDate import java.time.LocalDate
@@ -30,6 +31,10 @@ open class Timesheet : BaseEntity<Long>() {
@JoinColumn(name = "projectTaskId") @JoinColumn(name = "projectTaskId")
open var projectTask: ProjectTask? = null open var projectTask: ProjectTask? = null


@ManyToOne
@JoinColumn(name = "nonBillableTaskId")
open var nonBillableTask: Task? = null

@ManyToOne @ManyToOne
@JoinColumn(name = "projectId") @JoinColumn(name = "projectId")
open var project: Project? = null open var project: Project? = null


+ 6
- 8
src/main/java/com/ffii/tsms/modules/timesheet/service/TimesheetsService.kt View File

@@ -1,15 +1,10 @@
package com.ffii.tsms.modules.timesheet.service package com.ffii.tsms.modules.timesheet.service


import com.ffii.core.exception.BadRequestException import com.ffii.core.exception.BadRequestException
import com.ffii.core.utils.ExcelUtils
import com.ffii.tsms.modules.data.entity.BuildingType
import com.ffii.tsms.modules.data.entity.Staff
import com.ffii.tsms.modules.data.entity.StaffRepository import com.ffii.tsms.modules.data.entity.StaffRepository
import com.ffii.tsms.modules.data.entity.WorkNature
import com.ffii.tsms.modules.data.service.StaffsService import com.ffii.tsms.modules.data.service.StaffsService
import com.ffii.tsms.modules.data.service.TeamService import com.ffii.tsms.modules.data.service.TeamService
import com.ffii.tsms.modules.project.entity.* import com.ffii.tsms.modules.project.entity.*
import com.ffii.tsms.modules.project.web.models.*
import com.ffii.tsms.modules.timesheet.entity.Leave import com.ffii.tsms.modules.timesheet.entity.Leave
import com.ffii.tsms.modules.timesheet.entity.LeaveRepository import com.ffii.tsms.modules.timesheet.entity.LeaveRepository
import com.ffii.tsms.modules.timesheet.entity.Timesheet import com.ffii.tsms.modules.timesheet.entity.Timesheet
@@ -58,6 +53,7 @@ open class TimesheetsService(
this.projectTask = projectTask this.projectTask = projectTask
this.project = project this.project = project
this.remark = timeEntry.remark this.remark = timeEntry.remark
this.nonBillableTask = if (project == null) task else null
} }
} }
} }
@@ -96,6 +92,7 @@ open class TimesheetsService(
this.remark = entry.remark this.remark = entry.remark
this.recordDate = this.recordDate ?: recordDate this.recordDate = this.recordDate ?: recordDate
this.staff = this.staff ?: memberStaff this.staff = this.staff ?: memberStaff
this.nonBillableTask = if (project == null) task else null
} }


timesheetRepository.save(timesheet) timesheetRepository.save(timesheet)
@@ -151,11 +148,12 @@ open class TimesheetsService(
.groupBy { timesheet -> timesheet.recordDate!!.format(DateTimeFormatter.ISO_LOCAL_DATE) } .groupBy { timesheet -> timesheet.recordDate!!.format(DateTimeFormatter.ISO_LOCAL_DATE) }
.mapValues { (_, timesheets) -> .mapValues { (_, timesheets) ->
timesheets.map { timesheet -> timesheets.map { timesheet ->
val projectTask = timesheet.projectTask
TimeEntry( TimeEntry(
id = timesheet.id!!, id = timesheet.id!!,
projectId = timesheet.projectTask?.project?.id ?: timesheet.project?.id,
taskId = timesheet.projectTask?.task?.id,
taskGroupId = timesheet.projectTask?.task?.taskGroup?.id,
projectId = projectTask?.project?.id ?: timesheet.project?.id,
taskId = (projectTask?.task ?: timesheet.nonBillableTask)?.id,
taskGroupId = (projectTask?.task ?: timesheet.nonBillableTask)?.taskGroup?.id,
inputHours = timesheet.normalConsumed ?: 0.0, inputHours = timesheet.normalConsumed ?: 0.0,
otHours = timesheet.otConsumed ?: 0.0, otHours = timesheet.otConsumed ?: 0.0,
remark = timesheet.remark remark = timesheet.remark


+ 6
- 0
src/main/resources/db/changelog/changes/20240725_01_wayne/01_update_timesheet_non_billable_task.sql View File

@@ -0,0 +1,6 @@
-- liquibase formatted sql
-- changeset wayne:update_timesheet_non_billable_task

ALTER TABLE timesheet ADD nonBillableTaskId INT NULL;

ALTER TABLE timesheet ADD CONSTRAINT FK_TIMESHEET_ON_NONBILLABLETASKID FOREIGN KEY (nonBillableTaskId) REFERENCES task (id);

Loading…
Cancel
Save