fix(PTO): Fix incorrect module access allowed for PTO GET Totals route
This commit is contained in:
parent
9f0ce738c2
commit
8fdc2baf21
|
|
@ -1,8 +1,7 @@
|
|||
import { Body, Controller, Param, Post, Res, StreamableFile } from "@nestjs/common";
|
||||
import { Body, Controller, Param, Post, StreamableFile } from "@nestjs/common";
|
||||
import { CsvExportService } from "./services/csv-exports.service";
|
||||
import { ModuleAccessAllowed } from "src/common/decorators/modules-guard.decorators";
|
||||
import { Modules as ModulesEnum } from "prisma/postgres/generated/prisma/client/postgres/client";
|
||||
// import { Response } from "express";
|
||||
import { CsvGeneratorService } from "src/time-and-attendance/exports/services/csv-builder.service";
|
||||
import type { CsvFilters } from "src/time-and-attendance/exports/export-csv-options.dto";
|
||||
|
||||
|
|
@ -20,7 +19,6 @@ export class CsvExportController {
|
|||
@Param('year') year: number,
|
||||
@Param('period_no') period_no: number,
|
||||
@Body() filters: CsvFilters,
|
||||
// @Res() response: Response,
|
||||
) {
|
||||
const rows = await this.csvService.collectTransaction(year, period_no, filters);
|
||||
const buffer = this.generator.generateCsv(rows);
|
||||
|
|
@ -28,13 +26,6 @@ export class CsvExportController {
|
|||
return new StreamableFile(buffer, {
|
||||
type: 'text/csv',
|
||||
disposition: 'attachment; filename=export.csv'
|
||||
})
|
||||
|
||||
// response.set({
|
||||
// 'Content-Type': 'text/csv',
|
||||
// 'Content-Disposition': 'attachment; filename="export.csv"',
|
||||
// });
|
||||
|
||||
// response.send(blob);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ export class PaidTimeOffController {
|
|||
) { }
|
||||
|
||||
@Get('totals')
|
||||
@ModuleAccessAllowed('timesheets', 'timesheets_approval', 'employee_management')
|
||||
@ModuleAccessAllowed('timesheets')
|
||||
async getPaidTimeOffTotalsForOneEmployee(
|
||||
@Access('email') email: string,
|
||||
@Query('email') employee_email?: string,
|
||||
|
|
|
|||
|
|
@ -146,13 +146,7 @@ export class GetOverviewService {
|
|||
|
||||
switch (type) {
|
||||
case "EVENING":
|
||||
if (total_weekly_hours + hours <= 40) {
|
||||
record.other_hours.evening_hours += Math.min(hours, 8 - daily_hours);
|
||||
record.other_hours.overtime_hours += Math.max(daily_hours + hours - 8, 0);
|
||||
} else {
|
||||
record.other_hours.evening_hours += Math.max(40 - total_weekly_hours, 0);
|
||||
record.other_hours.overtime_hours += Math.min(total_weekly_hours + hours - 40, hours);
|
||||
}
|
||||
total_weekly_hours += hours;
|
||||
record.total_hours += hours;
|
||||
break;
|
||||
|
|
@ -169,12 +163,16 @@ export class GetOverviewService {
|
|||
record.total_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
break;
|
||||
case "VACATION": record.other_hours.vacation_hours += hours;
|
||||
case "VACATION":
|
||||
record.other_hours.vacation_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
break;
|
||||
case "REGULAR":
|
||||
if (total_weekly_hours + hours <= 40) {
|
||||
record.regular_hours += Math.min(hours, 8 - daily_hours);
|
||||
record.other_hours.overtime_hours += Math.max(daily_hours + hours - 8, 0);
|
||||
record.regular_hours += hours;
|
||||
// TODO: ADD DAILY OVERTIME CHECK HERE
|
||||
// record.regular_hours += Math.min(hours, 8 - daily_hours);
|
||||
// record.other_hours.overtime_hours += Math.max(daily_hours + hours - 8, 0);
|
||||
} else {
|
||||
record.regular_hours += Math.max(40 - total_weekly_hours, 0);
|
||||
record.other_hours.overtime_hours += Math.min(total_weekly_hours + hours - 40, hours);
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ export const mapOneTimesheet = (
|
|||
weekly_hours[subgroup] += hours;
|
||||
}
|
||||
|
||||
// TODO: ADD DAILY OVERTIME CHECK HERE
|
||||
// const dailyOvertimeOwed = Math.max(daily_hours.regular - timesheet.employee.daily_expected_hours, 0)
|
||||
// daily_hours.overtime = dailyOvertimeOwed;
|
||||
// daily_hours.regular -= dailyOvertimeOwed;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user