|
|
@@ -201,6 +201,10 @@ open class ProjectsService( |
|
|
|
return project.getOrNull()?.let { |
|
|
|
val customerContact = it.customer?.id?.let { customerId -> customerContactService.findAllByCustomerId(customerId) } ?: emptyList() |
|
|
|
|
|
|
|
val milestoneMap = it.milestones |
|
|
|
.filter { milestone -> milestone.taskGroup?.id != null } |
|
|
|
.associateBy { milestone -> milestone.taskGroup!!.id!! } |
|
|
|
|
|
|
|
EditProjectDetails( |
|
|
|
projectCode = it.code, |
|
|
|
projectName = it.name, |
|
|
@@ -217,10 +221,27 @@ open class ProjectsService( |
|
|
|
clientContactId = customerContact.find { contact -> contact.name == it.custLeadName }?.id, |
|
|
|
clientSubsidiaryId = it.customerSubsidiary?.id, |
|
|
|
totalManhour = it.totalManhour, |
|
|
|
manhourPercentageByGrade = emptyMap(), |
|
|
|
taskGroups = emptyMap(), |
|
|
|
allocatedStaffIds = emptyList(), |
|
|
|
milestones = emptyMap(), |
|
|
|
manhourPercentageByGrade = gradeAllocationRepository.findByProject(it) |
|
|
|
.filter { allocation -> allocation.grade?.id != null } |
|
|
|
.associate { allocation -> Pair(allocation.grade!!.id!!, allocation.manhour ?: 0.0) }, |
|
|
|
taskGroups = projectTaskRepository.findAllByProject(it) |
|
|
|
.mapNotNull { projectTask -> if (projectTask.task?.taskGroup?.id != null) projectTask.task else null } |
|
|
|
.groupBy { task -> task.taskGroup!!.id!! } |
|
|
|
.mapValues { (taskGroupId, tasks) -> TaskGroupAllocation( |
|
|
|
taskIds = tasks.mapNotNull { task -> task.id }, |
|
|
|
percentAllocation = milestoneMap[taskGroupId]?.stagePercentAllocation ?: 0.0 |
|
|
|
) }, |
|
|
|
allocatedStaffIds = staffAllocationRepository.findByProject(it).mapNotNull { allocation -> allocation.staff?.id }, |
|
|
|
milestones = milestoneMap.mapValues { (_, milestone) -> com.ffii.tsms.modules.project.web.models.Milestone( |
|
|
|
startDate = milestone.startDate?.format(DateTimeFormatter.ISO_LOCAL_DATE), |
|
|
|
endDate = milestone.endDate?.format(DateTimeFormatter.ISO_LOCAL_DATE), |
|
|
|
payments = milestone.milestonePayments.map { payment -> PaymentInputs( |
|
|
|
id = payment.id!!, |
|
|
|
amount = payment.amount!!, |
|
|
|
description = payment.description!!, |
|
|
|
date = payment.date!!.format(DateTimeFormatter.ISO_LOCAL_DATE) |
|
|
|
)} |
|
|
|
)}, |
|
|
|
expectedProjectFee = it.expectedTotalFee |
|
|
|
) |
|
|
|
} |
|
|
|