diff --git a/src/main/java/com/ffii/tsms/modules/data/service/SalaryEffectiveService.kt b/src/main/java/com/ffii/tsms/modules/data/service/SalaryEffectiveService.kt index 041d310..6186df6 100644 --- a/src/main/java/com/ffii/tsms/modules/data/service/SalaryEffectiveService.kt +++ b/src/main/java/com/ffii/tsms/modules/data/service/SalaryEffectiveService.kt @@ -159,8 +159,10 @@ open class SalaryEffectiveService( open fun getMonthlyStaffSalaryData(startDate: LocalDate, endDate: LocalDate): List { val salaryEffective = salaryEffectiveRepository.findAll() - .groupBy { Pair(it.date.year, it.date.month) } - .map { (_, se) -> se.maxByOrNull { it.date }!!} + .groupBy { Triple(it.staff.id, it.date.year, it.date.month) } + .map { (_, se) -> + se.maxByOrNull { it.date }!! + } salaryEffective.sortedWith(compareBy({it.staff.staffId}, {it.date})) val staffs = staffRepository.findAll().sortedBy { it.staffId }.filter { it.deleted == false } @@ -168,15 +170,23 @@ open class SalaryEffectiveService( val result = mutableListOf() val dateList = (0..ChronoUnit.MONTHS.between(startDate, endDate)).map { startDate.withDayOfMonth(1).plusMonths(it) } +// logger.info(dateList) staffs.forEach { staff -> dateList.forEach{ date -> val staffSalaryEffective = salaryEffective.filter { it.staff.staffId.equals(staff.staffId) } - var currentHourlyRate = staffSalaryEffective.filter { date.isEqual(it.date.withDayOfMonth(1)) || date.isAfter(it.date.withDayOfMonth(1)) }.minByOrNull { it.date } + + var currentHourlyRate = staffSalaryEffective.filter { + date.isEqual(it.date.withDayOfMonth(1)) || date.isAfter(it.date.withDayOfMonth(1)) + }.maxByOrNull { it.date } if (currentHourlyRate == null) { currentHourlyRate = staffSalaryEffective.minByOrNull { it.date } } +// if (staff.staffId == "B374") { +// logger.info("date:${date} | hourlyRate:${currentHourlyRate?.salary?.hourlyRate}") +// } + result += MonthlyStaffSalaryData( staff = staff, date = date, diff --git a/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt b/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt index 904f186..3f00eea 100644 --- a/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt +++ b/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt @@ -769,12 +769,12 @@ open class ReportService( rowIndex = 10 sheet.getRow(rowIndex).apply { createCell(1).apply { - setCellValue(if (project.expectedTotalFee != null) project.expectedTotalFee!! * 0.8 else 0.0) + setCellValue(if (project.expectedTotalFee != null) (project.expectedTotalFee!! - (project.subContractFee ?: 0.0)) * 0.8 else 0.0) cellStyle.dataFormat = accountingStyle } createCell(2).apply { - setCellValue(project.expectedTotalFee ?: 0.0) + setCellValue((project.expectedTotalFee ?: 0.0) - (project.subContractFee ?: 0.0)) cellStyle.dataFormat = accountingStyle } }