fix(display): fix the display of amount, mileage and hours to use only 2 decimals and no more

This commit is contained in:
Matthieu Haineault 2025-12-19 15:46:10 -05:00
parent 681779345e
commit 581a4252cd

View File

@ -303,26 +303,26 @@ export class PayPeriodsQueryService {
const hours = computeHours(shift.start_time, shift.end_time);
const type = (shift.bank_code?.type ?? '').toUpperCase();
switch (type) {
case "EVENING": record.other_hours.evening_hours += hours;
record.total_hours += hours;
case "EVENING": record.other_hours.evening_hours = Number((record.other_hours.evening_hours += hours).toFixed(2));
record.total_hours = Number((record.total_hours += hours).toFixed(2));
break;
case "EMERGENCY": record.other_hours.emergency_hours += hours;
record.total_hours += hours;
case "EMERGENCY": record.other_hours.emergency_hours = Number((record.other_hours.emergency_hours += hours).toFixed(2));
record.total_hours = Number((record.total_hours += hours).toFixed(2));
break;
case "OVERTIME": record.other_hours.overtime_hours += hours;
record.total_hours += hours;
case "OVERTIME": record.other_hours.overtime_hours = Number((record.other_hours.overtime_hours += hours).toFixed(2));
record.total_hours = Number((record.total_hours += hours).toFixed(2));
break;
case "SICK": record.other_hours.sick_hours += hours;
record.total_hours += hours;
case "SICK": record.other_hours.sick_hours = Number((record.other_hours.sick_hours += hours).toFixed(2));
record.total_hours = Number((record.total_hours += hours).toFixed(2));
break;
case "HOLIDAY": record.other_hours.holiday_hours += hours;
record.total_hours += hours;
case "HOLIDAY": record.other_hours.holiday_hours = Number((record.other_hours.holiday_hours += hours).toFixed(2));
record.total_hours = Number((record.total_hours += hours).toFixed(2));
break;
case "VACATION": record.other_hours.vacation_hours += hours;
record.total_hours += hours;
case "VACATION": record.other_hours.vacation_hours = Number(record.other_hours.vacation_hours += hours);
record.total_hours = Number((record.total_hours += hours).toFixed(2));
break;
case "REGULAR": record.regular_hours += hours;
record.total_hours += hours;
case "REGULAR": record.regular_hours = Number((record.regular_hours += hours).toFixed(2));
record.total_hours = Number((record.total_hours += hours).toFixed(2));
break;
}
@ -336,12 +336,12 @@ export class PayPeriodsQueryService {
const record = ensure(exp.id, name, exp.user.email);
const amount = toMoney(expense.amount);
record.expenses += amount;
record.expenses = Number((record.expenses += amount).toFixed(2));
const type = (expense.bank_code?.type || "").toUpperCase();
const rate = expense.bank_code?.modifier ?? 0;
if (type === "MILEAGE" && rate > 0) {
record.mileage += Math.round((amount / rate) * 100) / 100;
record.mileage = Number((record.mileage += Math.round((amount / rate) * 100) / 100).toFixed(2));
}
record.is_approved = record.is_approved && expense.timesheet.is_approved;
}