-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor earnings calculations in WorkdayService and CompensationCalculator to use BigDecimal for precision and apply consistent rounding #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,10 @@ import java.time.* | |
| */ | ||
| @Service | ||
| class CompensationCalculator { | ||
| companion object { | ||
| private const val MONEY_SCALE = 10 | ||
| } | ||
|
|
||
| /** | ||
| * 주어진 기간의 기준 근무 시간을 계산합니다. | ||
| * | ||
|
|
@@ -151,7 +155,7 @@ class CompensationCalculator { | |
|
|
||
| if (workDaysCount == 0) return BigDecimal.ZERO | ||
|
|
||
| return monthlySalary.divide(BigDecimal(workDaysCount), 0, RoundingMode.HALF_UP) | ||
| return monthlySalary.divide(BigDecimal(workDaysCount), MONEY_SCALE, RoundingMode.HALF_UP) | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -171,8 +175,9 @@ class CompensationCalculator { | |
| actualWorkMinutes: Long, | ||
| ): BigDecimal { | ||
| if (policyWorkMinutes <= 0) return dailyRate | ||
| val minuteRate = dailyRate.divide(BigDecimal(policyWorkMinutes), 10, RoundingMode.HALF_UP) | ||
| return minuteRate.multiply(BigDecimal(actualWorkMinutes)).setScale(0, RoundingMode.HALF_UP) | ||
| if (actualWorkMinutes == policyWorkMinutes) return dailyRate | ||
| val minuteRate = dailyRate.divide(BigDecimal(policyWorkMinutes), MONEY_SCALE, RoundingMode.HALF_UP) | ||
| return minuteRate.multiply(BigDecimal(actualWorkMinutes)) | ||
|
Comment on lines
176
to
+180
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.