fix(timesheets): typing fix
This commit is contained in:
parent
96490563c6
commit
2003b5357d
|
|
@ -1,4 +1,4 @@
|
|||
import { Prisma } from "@prisma/client";
|
||||
// import { BankCodeEntity } from "src/modules/bank-codes/dtos/bank-code-entity";
|
||||
|
||||
export class ExpenseEntity {
|
||||
id: number;
|
||||
|
|
@ -6,9 +6,10 @@ export class ExpenseEntity {
|
|||
bank_code_id: number;
|
||||
attachment?:number | null;
|
||||
date: Date;
|
||||
amount?: number | Prisma.Decimal | null;
|
||||
mileage?:number | Prisma.Decimal | null;
|
||||
amount?: number | null;
|
||||
mileage?:number | null;
|
||||
comment: string;
|
||||
supervisor_comment?:string | null;
|
||||
is_approved: boolean;
|
||||
// bank_code?: BankCodeEntity;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
export class ShiftEntity {
|
||||
id: number;
|
||||
timesheet_id: number;
|
||||
bank_code_id: number;
|
||||
date: Date;
|
||||
start_time: Date;
|
||||
end_time: Date;
|
||||
is_remote: boolean;
|
||||
is_approved: boolean;
|
||||
comment?: string | null ;
|
||||
}
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
import { Result } from "src/common/errors/result-error.factory";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
import { ShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-create.dto";
|
||||
import { toDateFromString, toHHmmFromString, toStringFromHHmm, toStringFromDate, overlaps } from "src/time-and-attendance/utils/date-time.utils";
|
||||
import { BankCodesResolver } from "src/time-and-attendance/utils/resolve-bank-type-id.utils";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
import { shift_select } from "src/time-and-attendance/utils/selects.utils";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { Normalized } from "src/time-and-attendance/utils/type.utils";
|
||||
import { ShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-create.dto";
|
||||
import { Result } from "src/common/errors/result-error.factory";
|
||||
|
||||
@Injectable()
|
||||
export class ShiftsUpdateDeleteService {
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
|
|
|
|||
|
|
@ -3,11 +3,9 @@ import { NUMBER_OF_TIMESHEETS_TO_RETURN } from "src/time-and-attendance/utils/co
|
|||
import { Injectable } from "@nestjs/common";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
import { EmailToIdResolver } from "src/time-and-attendance/utils/resolve-email-id.utils";
|
||||
import { Timesheet, TimesheetEntity, Timesheets } from "src/time-and-attendance/time-tracker/timesheets/dtos/timesheet.dto";
|
||||
import { Timesheet, Timesheets } from "src/time-and-attendance/time-tracker/timesheets/dtos/timesheet.dto";
|
||||
import { Result } from "src/common/errors/result-error.factory";
|
||||
import { Prisma, Users } from "@prisma/client";
|
||||
import { ShiftEntity } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-entity.dto";
|
||||
import { ExpenseEntity } from "src/time-and-attendance/expenses/dtos/expense-entity.dto";
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
export type TotalHours = {
|
||||
regular: number;
|
||||
|
|
@ -117,7 +115,7 @@ export class GetTimesheetsOverviewService {
|
|||
const day_dates = sevenDaysFrom(start);
|
||||
|
||||
//map of shifts by days
|
||||
const shifts_by_date = new Map<string, any[]>();
|
||||
const shifts_by_date = new Map<string, Prisma.ShiftsGetPayload<{ include: { bank_code } }>[]>();
|
||||
for (const shift of timesheet.shift) {
|
||||
const date_string = toStringFromDate(shift.date);
|
||||
const arr = shifts_by_date.get(date_string) ?? [];
|
||||
|
|
@ -125,7 +123,7 @@ export class GetTimesheetsOverviewService {
|
|||
shifts_by_date.set(date_string, arr);
|
||||
}
|
||||
//map of expenses by days
|
||||
const expenses_by_date = new Map<string, any[]>();
|
||||
const expenses_by_date = new Map<string, Prisma.ExpensesGetPayload<{ include: { bank_code: {}, attachment_record } }>[]>();
|
||||
for (const expense of timesheet.expense) {
|
||||
const date_string = toStringFromDate(expense.date);
|
||||
const arr = expenses_by_date.get(date_string) ?? [];
|
||||
|
|
@ -165,7 +163,7 @@ export class GetTimesheetsOverviewService {
|
|||
is_approved: expense.is_approved ?? false,
|
||||
comment: expense.comment ?? '',
|
||||
supervisor_comment: expense.supervisor_comment,
|
||||
type: expense.type,
|
||||
type: expense.bank_code.type,
|
||||
}));
|
||||
|
||||
//daily totals
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { Prisma } from "@prisma/client";
|
||||
|
||||
export type Normalized = {
|
||||
date: Date;
|
||||
start_time: Date;
|
||||
|
|
@ -9,8 +11,8 @@ export type NormalizedExpense = {
|
|||
date: Date;
|
||||
comment: string;
|
||||
supervisor_comment?: string;
|
||||
parsed_amount?: number;
|
||||
parsed_mileage?: number;
|
||||
parsed_amount?: number | Prisma.Decimal | null;
|
||||
parsed_mileage?: number | Prisma.Decimal | null;
|
||||
parsed_attachment?: number;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user