|
@@ -57,11 +57,13 @@ open class TimesheetsService( |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Transactional |
|
|
@Transactional |
|
|
open fun saveMemberTimeEntry(staffId: Long, entry: TimeEntry): TimeEntry { |
|
|
|
|
|
|
|
|
open fun saveMemberTimeEntry(staffId: Long, entry: TimeEntry, recordDate: LocalDate?): Map<String, List<TimeEntry>> { |
|
|
val currentStaff = staffsService.currentStaff() ?: throw BadRequestException() |
|
|
val currentStaff = staffsService.currentStaff() ?: throw BadRequestException() |
|
|
// Make sure current staff is a team lead |
|
|
// Make sure current staff is a team lead |
|
|
teamService.getMyTeamForStaff(currentStaff) ?: throw BadRequestException() |
|
|
teamService.getMyTeamForStaff(currentStaff) ?: throw BadRequestException() |
|
|
|
|
|
|
|
|
|
|
|
val memberStaff = staffsService.getStaff(staffId) |
|
|
|
|
|
|
|
|
val timesheet = timesheetRepository.findById(entry.id).getOrDefault(Timesheet()).apply { |
|
|
val timesheet = timesheetRepository.findById(entry.id).getOrDefault(Timesheet()).apply { |
|
|
val task = entry.taskId?.let { taskRepository.findById(it).getOrNull() } |
|
|
val task = entry.taskId?.let { taskRepository.findById(it).getOrNull() } |
|
|
val project = entry.projectId?.let { projectRepository.findById(it).getOrNull() } |
|
|
val project = entry.projectId?.let { projectRepository.findById(it).getOrNull() } |
|
@@ -71,19 +73,12 @@ open class TimesheetsService( |
|
|
this.otConsumed = entry.otHours |
|
|
this.otConsumed = entry.otHours |
|
|
this.projectTask = projectTask |
|
|
this.projectTask = projectTask |
|
|
this.remark = entry.remark |
|
|
this.remark = entry.remark |
|
|
|
|
|
this.recordDate = this.recordDate ?: recordDate |
|
|
|
|
|
this.staff = this.staff ?: memberStaff |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
timesheetRepository.save(timesheet) |
|
|
timesheetRepository.save(timesheet) |
|
|
|
|
|
|
|
|
return TimeEntry( |
|
|
|
|
|
id = timesheet.id!!, |
|
|
|
|
|
projectId = timesheet.projectTask?.project?.id, |
|
|
|
|
|
taskId = timesheet.projectTask?.task?.id, |
|
|
|
|
|
taskGroupId = timesheet.projectTask?.task?.taskGroup?.id, |
|
|
|
|
|
inputHours = timesheet.normalConsumed ?: 0.0, |
|
|
|
|
|
otHours = timesheet.otConsumed ?: 0.0, |
|
|
|
|
|
remark = timesheet.remark |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
return transformToTimeEntryMap(timesheetRepository.findAllByStaff(memberStaff)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
open fun getTimesheet(): Map<String, List<TimeEntry>> { |
|
|
open fun getTimesheet(): Map<String, List<TimeEntry>> { |
|
|