46 lines
2.0 KiB
TypeScript
46 lines
2.0 KiB
TypeScript
// import { EXPENSE_ASC_ORDER, EXPENSE_SELECT } from "../../../shared/selects/expenses.select";
|
|
// import { Injectable, NotFoundException } from "@nestjs/common";
|
|
// import { SHIFT_ASC_ORDER, SHIFT_SELECT } from "../../../shared/selects/shifts.select";
|
|
// import { PAY_PERIOD_SELECT } from "../../../shared/selects/pay-periods.select";
|
|
// import { PrismaService } from "src/prisma/prisma.service";
|
|
|
|
// @Injectable()
|
|
// export class TimesheetSelectorsService {
|
|
// constructor(readonly prisma: PrismaService){}
|
|
|
|
// async getPayPeriod(pay_year: number, pay_period_no: number) {
|
|
// const period = await this.prisma.payPeriods.findFirst({
|
|
// where: { pay_year, pay_period_no },
|
|
// select: PAY_PERIOD_SELECT ,
|
|
// });
|
|
// if(!period) throw new NotFoundException(`period ${pay_year}-${pay_period_no} not found`);
|
|
// return period;
|
|
// }
|
|
|
|
// async getShifts(employee_id: number, from: Date, to: Date) {
|
|
// return this.prisma.shifts.findMany({
|
|
// where: {timesheet: { is: { employee_id } }, date: { gte: from, lte: to } },
|
|
// select: SHIFT_SELECT,
|
|
// orderBy: SHIFT_ASC_ORDER,
|
|
// });
|
|
// }
|
|
|
|
// async getExpenses(employee_id: number, from: Date, to: Date) {
|
|
// return this.prisma.expenses.findMany({
|
|
// where: { timesheet: {is: { employee_id } }, date: { gte: from, lte: to } },
|
|
// select: EXPENSE_SELECT,
|
|
// orderBy: EXPENSE_ASC_ORDER,
|
|
// });
|
|
// }
|
|
|
|
// async getTimesheetWithShiftsAndExpenses(employee_id: number, start_date_week: Date) {
|
|
// return this.prisma.timesheets.findUnique({
|
|
// where: { employee_id_start_date: { employee_id, start_date: start_date_week } },
|
|
// select: {
|
|
// is_approved: true,
|
|
// shift: { select: SHIFT_SELECT, orderBy: SHIFT_ASC_ORDER },
|
|
// expense: { select: EXPENSE_SELECT, orderBy: EXPENSE_ASC_ORDER },
|
|
// },
|
|
// });
|
|
// }
|
|
// }
|