Ver código fonte

Add client type to project

tags/Baseline_30082024_BACKEND_UAT
Wayne 1 ano atrás
pai
commit
ff402849c1
6 arquivos alterados com 21 adições e 0 exclusões
  1. +5
    -0
      src/main/java/com/ffii/tsms/modules/data/service/CustomerService.kt
  2. +4
    -0
      src/main/java/com/ffii/tsms/modules/project/entity/Project.kt
  3. +4
    -0
      src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt
  4. +1
    -0
      src/main/java/com/ffii/tsms/modules/project/web/models/EditProjectDetails.kt
  5. +1
    -0
      src/main/java/com/ffii/tsms/modules/project/web/models/NewProjectRequest.kt
  6. +6
    -0
      src/main/resources/db/changelog/changes/20240812_01_wayne/01_project_add_customer_type.sql

+ 5
- 0
src/main/java/com/ffii/tsms/modules/data/service/CustomerService.kt Ver arquivo

@@ -11,6 +11,7 @@ import com.ffii.tsms.modules.project.web.models.SaveCustomerRequest
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

@Service
open class CustomerService(
@@ -37,6 +38,10 @@ open class CustomerService(
return customerRepository.findByCode(code);
}

open fun findCustomerType(id: Long): CustomerType? {
return customerTypeRepository.findById(id).getOrNull()
}

open fun createClientCode(): String {
val prefix = "CT"



+ 4
- 0
src/main/java/com/ffii/tsms/modules/project/entity/Project.kt Ver arquivo

@@ -135,4 +135,8 @@ open class Project : BaseEntity<Long>() {
@ManyToOne
@JoinColumn(name = "subsidiaryContactId")
open var subsidiaryContact: SubsidiaryContact? = null

@ManyToOne
@JoinColumn(name = "customerTypeId")
open var customerType: CustomerType? = null
}

+ 4
- 0
src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt Ver arquivo

@@ -181,6 +181,7 @@ open class ProjectsService(
.orElseThrow() else null
val teamLead = staffRepository.findById(request.projectLeadId).orElseThrow()
val customer = customerService.findCustomer(request.clientId)
val customerType = request.clientTypeId?.let { customerService.findCustomerType(it) } ?: customer.customerType
val subsidiaryContact =
if (request.clientContactId != null) subsidiaryContactRepository.findById(request.clientContactId)
.orElse(null) else null
@@ -255,6 +256,7 @@ open class ProjectsService(
this.customerSubsidiary = customerSubsidiary
this.customerContact = if (customerSubsidiary == null) clientContact else null
this.subsidiaryContact = if (customerSubsidiary != null) subsidiaryContact else null
this.customerType = customerType
}


@@ -403,6 +405,7 @@ open class ProjectsService(
buildingTypeIds = it.buildingTypes.mapNotNull { buildingType -> buildingType.id },
workNatureIds = it.workNatures.mapNotNull { workNature -> workNature.id },
clientId = it.customer?.id,
clientTypeId = it.customerType?.id ?: it.customer?.customerType?.id,
clientContactId = it.subsidiaryContact?.id ?: it.customerContact?.id,
// subsidiaryContact.find { contact -> contact.name == it.custLeadName }?.id ?: customerContact.find { contact -> contact.name == it.custLeadName }?.id,
clientSubsidiaryId = it.customerSubsidiary?.id,
@@ -745,6 +748,7 @@ open class ProjectsService(
valueTransform = { it.percentage!! }
),
projectActualEnd = null,
clientTypeId = null,
taskTemplateId = taskTemplate.id,
taskGroups = taskGroups,
milestones = mapOf(


+ 1
- 0
src/main/java/com/ffii/tsms/modules/project/web/models/EditProjectDetails.kt Ver arquivo

@@ -29,6 +29,7 @@ data class EditProjectDetails(
val clientId: Long?,
val clientContactId: Long?,
val clientSubsidiaryId: Long?,
val clientTypeId: Long?,

// Allocation
val totalManhour: Double?,


+ 1
- 0
src/main/java/com/ffii/tsms/modules/project/web/models/NewProjectRequest.kt Ver arquivo

@@ -34,6 +34,7 @@ data class NewProjectRequest(
val clientId: Long,
val clientContactId: Long?,
val clientSubsidiaryId: Long?,
val clientTypeId: Long?,

// Allocation
val totalManhour: Double,


+ 6
- 0
src/main/resources/db/changelog/changes/20240812_01_wayne/01_project_add_customer_type.sql Ver arquivo

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

ALTER TABLE project ADD customerTypeId INT NULL;

ALTER TABLE project ADD CONSTRAINT FK_PROJECT_ON_CUSTOMERTYPEID FOREIGN KEY (customerTypeId) REFERENCES customer_type (id);

Carregando…
Cancelar
Salvar