Ver código fonte

Update Pnl, Cost and Expense and Financial Status Report, the time range is the first timesheet entry to today

tags/Baseline_30082024_BACKEND_UAT
MSI\2Fi 1 ano atrás
pai
commit
874bfa8c8e
2 arquivos alterados com 26 adições e 11 exclusões
  1. +22
    -11
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt
  2. +4
    -0
      src/main/java/com/ffii/tsms/modules/timesheet/entity/TimesheetRepository.kt

+ 22
- 11
src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt Ver arquivo

@@ -10,6 +10,7 @@ import com.ffii.tsms.modules.project.entity.Project
import com.ffii.tsms.modules.project.entity.ProjectRepository
import com.ffii.tsms.modules.report.web.model.costAndExpenseRequest
import com.ffii.tsms.modules.timesheet.entity.Timesheet
import com.ffii.tsms.modules.timesheet.entity.TimesheetRepository
import org.apache.commons.logging.Log
import org.apache.commons.logging.LogFactory
import org.apache.poi.ss.usermodel.*
@@ -45,7 +46,7 @@ data class DayInfo(val date: String?, val weekday: String?)
open class ReportService(
private val jdbcDao: JdbcDao,
private val projectRepository: ProjectRepository,
private val salaryEffectiveService: SalaryEffectiveService, private val salaryRepository: SalaryRepository
private val salaryEffectiveService: SalaryEffectiveService, private val salaryRepository: SalaryRepository, private val timesheetRepository: TimesheetRepository
) {
private val logger: Log = LogFactory.getLog(javaClass)
private val DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd")
@@ -2304,14 +2305,18 @@ open class ReportService(
+ " order by g.code, s.name, cte_ts.recordDate"
)
val projectPlanStartEndMonth = projectRepository.findProjectPlanStartEndByIdAndDeletedFalse(projectId)
val minStartMonthInTimesheetByProject = timesheetRepository.findMinRecordDateByProjectId(projectId)
val compareStartMonth = YearMonth.parse(startMonth)
val compareEndMonth = YearMonth.parse(endMonth)
val actualStartMonth: YearMonth
(if (projectPlanStartEndMonth.actualStart == null) {
(if (minStartMonthInTimesheetByProject == null) {
YearMonth.now().plusMonths(1)
} else {
YearMonth.from(projectPlanStartEndMonth.actualStart)
}).also { actualStartMonth = it }
YearMonth.from(minStartMonthInTimesheetByProject)
}).also {
actualStartMonth = it
println("============= Actual Start Month $actualStartMonth ===============")
}

val queryStartMonth = if (compareStartMonth.isAfter(actualStartMonth)) compareStartMonth else actualStartMonth
val queryEndMonth = if (compareEndMonth.isAfter(YearMonth.now())) YearMonth.now() else compareEndMonth
@@ -2495,7 +2500,7 @@ open class ReportService(
val previousHourlyRate = findPreviousValue(salaryDataList, financialYear.start) { it.hourlyRate }
val previousSalaryPoint = findPreviousValue(salaryDataList, financialYear.start) { it.salaryPoint }

println("====================== staffInfo: $staffInfo ===============================")
// println("====================== staffInfo: $staffInfo ===============================")
return financialYear.copy(
hourlyRate = previousHourlyRate?.toDouble() ?: (staffInfo["hourlyRate"] as BigDecimal).toDouble(),
salaryPoint = previousSalaryPoint ?: (staffInfo["salaryPoint"] as Long).toInt()
@@ -2658,14 +2663,18 @@ open class ReportService(
val accountingStyle = workbook.createDataFormat().getFormat("_(* #,##0.00_);_(* (#,##0.00);_(* \"-\"??_);_(@_)")

val projectPlanStartEndMonth = projectRepository.findProjectPlanStartEndByIdAndDeletedFalse(projectId)
val minStartMonthInTimesheetByProject = timesheetRepository.findMinRecordDateByProjectId(projectId)
val compareStartMonth = YearMonth.parse(startMonth)
val compareEndMonth = YearMonth.parse(endMonth)
val actualStartMonth: YearMonth
(if (projectPlanStartEndMonth.actualStart == null) {
(if (minStartMonthInTimesheetByProject == null) {
YearMonth.now().plusMonths(1)
} else {
YearMonth.from(projectPlanStartEndMonth.actualStart)
}).also { actualStartMonth = it }
YearMonth.from(minStartMonthInTimesheetByProject)
}).also {
actualStartMonth = it
println("============= Actual Start Month $actualStartMonth ===============")
}

val queryStartMonth = if (compareStartMonth.isAfter(actualStartMonth)) compareStartMonth else actualStartMonth
val queryEndMonth = if (compareEndMonth.isAfter(YearMonth.now())) YearMonth.now() else compareEndMonth
@@ -2676,6 +2685,8 @@ open class ReportService(
val endDate = YearMonth.parse(queryEndMonth.toString(), DateTimeFormatter.ofPattern("yyyy-MM"))
val convertEndMonth = YearMonth.of(endDate.year, endDate.month)



val monthRange: MutableList<Map<String, Any>> = ArrayList()
val financialYears = getHalfYearFinancialPeriods(queryStartMonth, queryEndMonth, 1)

@@ -2913,7 +2924,7 @@ open class ReportService(


// Manhour Spent LOOP
println("monthRange--------------- ${monthRange}\n")
// println("monthRange--------------- ${monthRange}\n")
rowNum += 1
for (staff in staffInfoList) {
val row: Row = sheet.getRow(rowNum) ?: sheet.createRow(rowNum)
@@ -3940,8 +3951,8 @@ open class ReportService(
if (teamLeadId != null && teamLeadId > 0){
sql.append( "and p.teamLead = :teamLeadId " )
}
sql.append(" ) and t.recordDate >= p.actualStart ")
sql.append(" order by code, recordDate, staffId; ")
// sql.append("and t.recordDate >= p.actualStart ")
sql.append(") order by code, recordDate, staffId; ")


val results = jdbcDao.queryForList(sql.toString(), mapOf("teamLeadId" to teamLeadId)).map {


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

@@ -27,4 +27,8 @@ interface TimesheetRepository : AbstractRepository<Timesheet, Long> {
fun findByStaffAndRecordDateBetweenOrderByRecordDate(staff: Staff, start: LocalDate, end: LocalDate): List<Timesheet>

fun findDistinctProjectTaskByStaffAndRecordDateBetweenOrderByRecordDate(staff: Staff, start: LocalDate, end: LocalDate): List<Timesheet>

@Query("SELECT MIN(t.recordDate) AS recordDate FROM Timesheet t WHERE t.project.id = ?1")
fun findMinRecordDateByProjectId(projectId: Long): LocalDate?

}

Carregando…
Cancelar
Salvar