fix(findAll): fix loop for week_shifts
This commit is contained in:
parent
770ed8cf64
commit
eefe82153f
|
|
@ -1,4 +1,4 @@
|
||||||
import { DayExpensesDto, DayShiftsDto, DetailedShifts, ShiftDto, TimesheetPeriodDto, WeekDto } from "../dtos/timesheet-period.dto";
|
import { DayExpensesDto, DetailedShifts, ShiftDto, TimesheetPeriodDto, WeekDto } from "../dtos/timesheet-period.dto";
|
||||||
|
|
||||||
//makes the strings indexes for arrays
|
//makes the strings indexes for arrays
|
||||||
export const DAY_KEYS = ['sun','mon','tue','wed','thu','fri','sat'] as const;
|
export const DAY_KEYS = ['sun','mon','tue','wed','thu','fri','sat'] as const;
|
||||||
|
|
@ -151,7 +151,7 @@ export function buildWeek(
|
||||||
|
|
||||||
//regroup hours per type of shifts
|
//regroup hours per type of shifts
|
||||||
const week_shifts = shifts.filter(shift => isBetweenUTC(shift.date, week_start, week_end));
|
const week_shifts = shifts.filter(shift => isBetweenUTC(shift.date, week_start, week_end));
|
||||||
for (const shift of shifts) {
|
for (const shift of week_shifts) {
|
||||||
const key = dayKeyFromDate(shift.date, true);
|
const key = dayKeyFromDate(shift.date, true);
|
||||||
week.shifts[key].shifts.push({
|
week.shifts[key].shifts.push({
|
||||||
start: toTimeString(shift.start_time),
|
start: toTimeString(shift.start_time),
|
||||||
|
|
@ -164,7 +164,7 @@ export function buildWeek(
|
||||||
const duration = Math.max(0, (shift.end_time.getTime() - shift.start_time.getTime())/ MS_PER_HOUR);
|
const duration = Math.max(0, (shift.end_time.getTime() - shift.start_time.getTime())/ MS_PER_HOUR);
|
||||||
const type = (shift.type || '').toUpperCase();
|
const type = (shift.type || '').toUpperCase();
|
||||||
|
|
||||||
if (type === SHIFT_TYPES.REGULAR) day_hours[key].regular += duration;
|
if ( type === SHIFT_TYPES.REGULAR) day_hours[key].regular += duration;
|
||||||
else if( type === SHIFT_TYPES.EVENING) day_hours[key].evening += duration;
|
else if( type === SHIFT_TYPES.EVENING) day_hours[key].evening += duration;
|
||||||
else if( type === SHIFT_TYPES.EMERGENCY) day_hours[key].emergency += duration;
|
else if( type === SHIFT_TYPES.EMERGENCY) day_hours[key].emergency += duration;
|
||||||
else if( type === SHIFT_TYPES.OVERTIME) day_hours[key].overtime += duration;
|
else if( type === SHIFT_TYPES.OVERTIME) day_hours[key].overtime += duration;
|
||||||
|
|
@ -220,7 +220,7 @@ export function buildWeek(
|
||||||
//daily totals
|
//daily totals
|
||||||
const totals = day_amounts[key];
|
const totals = day_amounts[key];
|
||||||
const total_mileage = totals.mileage;
|
const total_mileage = totals.mileage;
|
||||||
const total_expense = totals.expense + totals.per_diem + totals.commission + totals.prime_dispo + totals.expense;
|
const total_expense = totals.expense + totals.per_diem + totals.commission + totals.prime_dispo;
|
||||||
|
|
||||||
//pushing mileage rows
|
//pushing mileage rows
|
||||||
for(const row of dayExpenseRows[key].km) {
|
for(const row of dayExpenseRows[key].km) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user