From 3178084158da1d6f0ae5401e956f872c47bb1216 Mon Sep 17 00:00:00 2001 From: jeyong Date: Tue, 10 Mar 2026 22:49:37 +0900 Subject: [PATCH 1/2] Troubleshoot overflow by changing integer type to long type in payroll calculation logic --- src/main/kotlin/com/moa/controller/HomeController.kt | 2 -- src/main/kotlin/com/moa/service/EarningsCalculator.kt | 6 +++--- src/main/kotlin/com/moa/service/WorkdayService.kt | 2 +- .../kotlin/com/moa/service/dto/MonthlyEarningsResponse.kt | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/moa/controller/HomeController.kt b/src/main/kotlin/com/moa/controller/HomeController.kt index d1283a0..f8aca84 100644 --- a/src/main/kotlin/com/moa/controller/HomeController.kt +++ b/src/main/kotlin/com/moa/controller/HomeController.kt @@ -4,7 +4,6 @@ import com.moa.common.auth.Auth import com.moa.common.auth.AuthMemberInfo import com.moa.common.response.ApiResponse import com.moa.service.ProfileService -import com.moa.service.WorkPolicyService import com.moa.service.WorkdayService import com.moa.service.dto.HomeResponse import io.swagger.v3.oas.annotations.tags.Tag @@ -17,7 +16,6 @@ import java.time.LocalDate class HomeController( private val profileService: ProfileService, private val workdayService: WorkdayService, - private val workPolicyService: WorkPolicyService, ) { @GetMapping("/api/v1/home") diff --git a/src/main/kotlin/com/moa/service/EarningsCalculator.kt b/src/main/kotlin/com/moa/service/EarningsCalculator.kt index b85509d..8cc3b10 100644 --- a/src/main/kotlin/com/moa/service/EarningsCalculator.kt +++ b/src/main/kotlin/com/moa/service/EarningsCalculator.kt @@ -31,7 +31,7 @@ class EarningsCalculator( * @param date 기준 날짜 (이 날짜가 속한 월의 마지막 날을 기준으로 유효한 급여 정책을 적용합니다) * @return 계산된 기본 월급 금액. 적용할 수 있는 급여 정보가 존재하지 않으면 `null`을 반환합니다. */ - fun getDefaultMonthlySalary(memberId: Long, date: LocalDate): Int? { + fun getDefaultMonthlySalary(memberId: Long, date: LocalDate): Long? { val lastDayOfMonth = YearMonth.from(date).atEndOfMonth() val payroll = payrollVersionRepository .findTopByMemberIdAndEffectiveFromLessThanEqualOrderByEffectiveFromDesc( @@ -40,9 +40,9 @@ class EarningsCalculator( return when (SalaryType.from(payroll.salaryInputType)) { SalaryType.YEARLY -> payroll.salaryAmount.toBigDecimal() - .divide(BigDecimal(12), 0, RoundingMode.HALF_UP).toInt() + .divide(BigDecimal(12), 0, RoundingMode.HALF_UP).toLong() - SalaryType.MONTHLY -> payroll.salaryAmount.toInt() + SalaryType.MONTHLY -> payroll.salaryAmount } } diff --git a/src/main/kotlin/com/moa/service/WorkdayService.kt b/src/main/kotlin/com/moa/service/WorkdayService.kt index ba569c6..0508541 100644 --- a/src/main/kotlin/com/moa/service/WorkdayService.kt +++ b/src/main/kotlin/com/moa/service/WorkdayService.kt @@ -220,7 +220,7 @@ class WorkdayService( } return MonthlyEarningsResponse( - workedEarnings = totalEarnings.toInt(), + workedEarnings = totalEarnings.toLong(), standardSalary = defaultSalary, workedMinutes = workedMinutes, standardMinutes = standardMinutes, diff --git a/src/main/kotlin/com/moa/service/dto/MonthlyEarningsResponse.kt b/src/main/kotlin/com/moa/service/dto/MonthlyEarningsResponse.kt index 1891144..dc7c8e7 100644 --- a/src/main/kotlin/com/moa/service/dto/MonthlyEarningsResponse.kt +++ b/src/main/kotlin/com/moa/service/dto/MonthlyEarningsResponse.kt @@ -1,8 +1,8 @@ package com.moa.service.dto data class MonthlyEarningsResponse( - val workedEarnings: Int, - val standardSalary: Int, + val workedEarnings: Long, + val standardSalary: Long, val workedMinutes: Long, val standardMinutes: Long, ) From adf01c5648c129dc55efd7e4a13381ef8cacff48 Mon Sep 17 00:00:00 2001 From: jeyong Date: Tue, 10 Mar 2026 22:57:50 +0900 Subject: [PATCH 2/2] Troubleshoot overflow by changing integer type to long type in import calculation logic --- src/main/kotlin/com/moa/service/dto/HomeResponse.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/moa/service/dto/HomeResponse.kt b/src/main/kotlin/com/moa/service/dto/HomeResponse.kt index 3283296..9a21f81 100644 --- a/src/main/kotlin/com/moa/service/dto/HomeResponse.kt +++ b/src/main/kotlin/com/moa/service/dto/HomeResponse.kt @@ -6,8 +6,8 @@ import java.time.LocalTime data class HomeResponse( val workplace: String?, - val workedEarnings: Int, - val standardSalary: Int, + val workedEarnings: Long, + val standardSalary: Long, val dailyPay: Int, val type: DailyWorkScheduleType, @field:JsonFormat(pattern = "HH:mm")