Fix deduction value from 2.0 to 1.0 across all files for consistency

Co-authored-by: Kenearos <86194771+Kenearos@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-12 12:04:38 +00:00
parent 89862e918c
commit a2cc8340ee
12 changed files with 51 additions and 50 deletions

View file

@ -123,7 +123,7 @@ Edit `PayrollCalculator.kt` and modify the constants:
- `RATE_WT`: Weekday rate (default 250€)
- `RATE_WE`: Weekend rate (default 450€)
- `WE_THRESHOLD`: Threshold for WE compensation (default 2.0)
- `DEDUCTION_AFTER_THRESHOLD`: Deduction amount (default 2.0)
- `DEDUCTION_AFTER_THRESHOLD`: Deduction amount (default 1.0)
### Adding Holidays

View file

@ -12,11 +12,11 @@ import kotlin.math.min
* Business rules:
* - WE-Tag (Weekend/Holiday): Friday, Saturday, Sunday, public holiday, day before public holiday
* - WT-Tag (Weekday): All other days
* - WT compensation: Always 250 per unit
* - WT compensation: 250 per unit (only if threshold reached)
* - WE compensation: Only paid if monthly total >= 2.0 WE units (threshold)
* - If threshold reached: 450 per WE unit, then deduct exactly 2.0 WE units
* - If threshold reached: 450 per WE unit, then deduct exactly 1.0 WE unit
* - Deduction priority: Friday first, then other WE days
* - Below threshold: 0 for WE shifts (NOT converted to WT)
* - Below threshold: 0 for all shifts (neither WT nor WE)
*/
class PayrollCalculator {
@ -24,7 +24,7 @@ class PayrollCalculator {
private const val RATE_WT = 250.0 // Satz_WT
private const val RATE_WE = 450.0 // Satz_WE
private const val WE_THRESHOLD = 2.0 // WE_Schwelle
private const val DEDUCTION_AFTER_THRESHOLD = 2.0 // Abzug_nach_WE_Schwelle
private const val DEDUCTION_AFTER_THRESHOLD = 1.0 // Abzug_nach_WE_Schwelle
private const val TOLERANCE = 0.0001 // For floating-point comparisons
}

View file

@ -52,7 +52,7 @@ class PayrollCalculatorTest {
/**
* Test Case 2: Exactly at threshold (2.0 WE)
* Expected: WE payout = 0 (0.0 units after deduction), threshold reached
* Expected: WE payout = 450 (1.0 unit after deduction), threshold reached
*/
@Test
fun testExactlyAtThreshold() {
@ -67,14 +67,14 @@ class PayrollCalculatorTest {
val result = results[0]
assertEquals(2.0, result.weTotal, 0.001)
assertTrue(result.thresholdReached)
assertEquals(2.0, result.deductionTotal, 0.001)
assertEquals(0.0, result.wePaid, 0.001)
assertEquals(0.0, result.payoutWE, 0.001)
assertEquals(1.0, result.deductionTotal, 0.001)
assertEquals(1.0, result.wePaid, 0.001)
assertEquals(450.0, result.payoutWE, 0.001)
}
/**
* Test Case 3: Over threshold (3.5 WE)
* Expected: WE payout = 675 (1.5 units after deduction)
* Expected: WE payout = 1125 (2.5 units after 1.0 deduction)
*/
@Test
fun testOverThreshold() {
@ -91,8 +91,8 @@ class PayrollCalculatorTest {
val result = results[0]
assertEquals(3.5, result.weTotal, 0.001)
assertTrue(result.thresholdReached)
assertEquals(1.5, result.wePaid, 0.001)
assertEquals(675.0, result.payoutWE, 0.001)
assertEquals(2.5, result.wePaid, 0.001)
assertEquals(1125.0, result.payoutWE, 0.001)
}
/**
@ -115,8 +115,9 @@ class PayrollCalculatorTest {
assertEquals(0.4, result.weFriday, 0.001)
assertEquals(1.6, result.weOther, 0.001)
assertEquals(0.4, result.deductionFriday, 0.001) // All Friday deducted first
assertEquals(1.6, result.deductionOther, 0.001) // Rest from other (1.6 to reach 2.0 total)
assertEquals(0.0, result.wePaid, 0.001)
assertEquals(0.6, result.deductionOther, 0.001) // Rest from other (0.6 to reach 1.0 total)
assertEquals(1.0, result.wePaid, 0.001)
assertEquals(450.0, result.payoutWE, 0.001)
}
/**
@ -147,8 +148,8 @@ class PayrollCalculatorTest {
// B: above threshold
assertTrue(resultB.thresholdReached)
assertEquals(2.5, resultB.weTotal, 0.001)
assertEquals(0.5, resultB.wePaid, 0.001)
assertEquals(225.0, resultB.payoutWE, 0.001)
assertEquals(1.5, resultB.wePaid, 0.001)
assertEquals(675.0, resultB.payoutWE, 0.001)
}
private fun parseDate(dateString: String): Date {