Address code review feedback: use constants for deduction values

Co-authored-by: Kenearos <86194771+Kenearos@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-12 12:11:07 +00:00
parent f5d300bfed
commit feb9c9f712
3 changed files with 12 additions and 11 deletions

View file

@ -1301,12 +1301,12 @@ class DienstplanApp {
let note = ''; let note = '';
if (!thresholdReached) { if (!thresholdReached) {
note = `<b>${safeName}</b> erreicht die Mindestschwelle nicht (${we_total.toFixed(1)} von 2,0 WE-Einheiten) und erhält daher keine Bonuszahlung.`; note = `<b>${safeName}</b> erreicht die Mindestschwelle nicht (${we_total.toFixed(1)} von ${CONFIG.THRESHOLD.toFixed(1)} WE-Einheiten) und erhält daher keine Bonuszahlung.`;
} else { } else {
const paid_we = we_total - 1.0; const paid_we = we_total - CONFIG.DEDUCTION;
let breakdown = []; let breakdown = [];
if (data.wt > 0) breakdown.push(`${data.wt.toFixed(1)} WT-Einheiten à 250 €`); if (data.wt > 0) breakdown.push(`${data.wt.toFixed(1)} WT-Einheiten à ${CONFIG.RATE_WT} €`);
if (paid_we > 0) breakdown.push(`${paid_we.toFixed(1)} WE-Einheiten à 450 €`); if (paid_we > 0) breakdown.push(`${paid_we.toFixed(1)} WE-Einheiten à ${CONFIG.RATE_WE} €`);
note = `<b>${safeName}</b> erhält eine Bonuszahlung von <span style="color: #28a745; font-weight: bold;">${this.formatCurrency(bonus)}</span>`; note = `<b>${safeName}</b> erhält eine Bonuszahlung von <span style="color: #28a745; font-weight: bold;">${this.formatCurrency(bonus)}</span>`;
if (breakdown.length > 0) { if (breakdown.length > 0) {

View file

@ -738,7 +738,7 @@ class DienstplanApp {
if (thresholdReached) { if (thresholdReached) {
const wt_pay = data.wt * this.calculator.RATE_NORMAL; const wt_pay = data.wt * this.calculator.RATE_NORMAL;
let deduct = 1.0; let deduct = this.calculator.DEDUCTION_AMOUNT;
const deduct_fr = Math.min(deduct, data.we_fr); const deduct_fr = Math.min(deduct, data.we_fr);
const deduct_other = Math.max(0, deduct - deduct_fr); const deduct_other = Math.max(0, deduct - deduct_fr);
const paid_fr = Math.max(0, data.we_fr - deduct_fr); const paid_fr = Math.max(0, data.we_fr - deduct_fr);
@ -762,12 +762,12 @@ class DienstplanApp {
let note = ''; let note = '';
if (!thresholdReached) { if (!thresholdReached) {
note = `<b>${safeName}</b> erreicht die Mindestschwelle nicht (${we_total.toFixed(1)} von 2,0 WE-Einheiten) und erhält daher keine Bonuszahlung.`; note = `<b>${safeName}</b> erreicht die Mindestschwelle nicht (${we_total.toFixed(1)} von ${this.calculator.MIN_QUALIFYING_DAYS.toFixed(1)} WE-Einheiten) und erhält daher keine Bonuszahlung.`;
} else { } else {
const paid_we = we_total - 1.0; const paid_we = we_total - this.calculator.DEDUCTION_AMOUNT;
let breakdown = []; let breakdown = [];
if (data.wt > 0) breakdown.push(`${data.wt.toFixed(1)} WT-Einheiten à 250`); if (data.wt > 0) breakdown.push(`${data.wt.toFixed(1)} WT-Einheiten à ${this.calculator.RATE_NORMAL}`);
if (paid_we > 0) breakdown.push(`${paid_we.toFixed(1)} WE-Einheiten à 450`); if (paid_we > 0) breakdown.push(`${paid_we.toFixed(1)} WE-Einheiten à ${this.calculator.RATE_WEEKEND}`);
note = `<b>${safeName}</b> erhält eine Bonuszahlung von <span style="color: #28a745; font-weight: bold;">${this.calculator.formatCurrency(bonus)}</span>`; note = `<b>${safeName}</b> erhält eine Bonuszahlung von <span style="color: #28a745; font-weight: bold;">${this.calculator.formatCurrency(bonus)}</span>`;
if (breakdown.length > 0) { if (breakdown.length > 0) {

View file

@ -8,6 +8,7 @@ class BonusCalculator {
this.RATE_NORMAL = 250; // Normal day rate (not weekend/holiday) this.RATE_NORMAL = 250; // Normal day rate (not weekend/holiday)
this.RATE_WEEKEND = 450; // Weekend/holiday rate this.RATE_WEEKEND = 450; // Weekend/holiday rate
this.MIN_QUALIFYING_DAYS = 2.0; // Minimum qualifying days to trigger bonus this.MIN_QUALIFYING_DAYS = 2.0; // Minimum qualifying days to trigger bonus
this.DEDUCTION_AMOUNT = 1.0; // Deduction after reaching threshold
} }
/** /**
@ -108,8 +109,8 @@ class BonusCalculator {
let totalDeduction = 0; let totalDeduction = 0;
if (thresholdReached) { if (thresholdReached) {
// Deduct 1.0 qualifying day with Friday priority // Deduct qualifying days with Friday priority
totalDeduction = 1.0; totalDeduction = this.DEDUCTION_AMOUNT;
// First deduct from Friday // First deduct from Friday
deductionFromFriday = Math.min(totalDeduction, qualifyingDaysFriday); deductionFromFriday = Math.min(totalDeduction, qualifyingDaysFriday);