Merge branch 'main' of git.targo.ca:Targo/targo_backend into auth-session-fullstack

Why am I constantly getting these merge messages
This commit is contained in:
Nicolas Drolet 2025-09-09 09:30:17 -04:00
commit a3d4b0cef7
19 changed files with 59 additions and 61 deletions

View File

@ -2441,7 +2441,7 @@
"example": 17.82, "example": 17.82,
"description": "amount in $ for a refund" "description": "amount in $ for a refund"
}, },
"description": { "comment": {
"type": "string", "type": "string",
"example": "Spent for mileage between A and B", "example": "Spent for mileage between A and B",
"description": "explain`s why the expense was made" "description": "explain`s why the expense was made"
@ -2463,7 +2463,7 @@
"bank_code_id", "bank_code_id",
"date", "date",
"amount", "amount",
"description", "comment",
"is_approved", "is_approved",
"supervisor_comment" "supervisor_comment"
] ]
@ -2496,7 +2496,7 @@
"example": 17.82, "example": 17.82,
"description": "amount in $ for a refund" "description": "amount in $ for a refund"
}, },
"description": { "comment": {
"type": "string", "type": "string",
"example": "Spent for mileage between A and B", "example": "Spent for mileage between A and B",
"description": "explain`s why the expense was made" "description": "explain`s why the expense was made"

View File

@ -0,0 +1,24 @@
/*
Warnings:
- You are about to drop the column `description` on the `expenses` table. All the data in the column will be lost.
- You are about to drop the column `description` on the `expenses_archive` table. All the data in the column will be lost.
- You are about to drop the column `description` on the `shifts` table. All the data in the column will be lost.
- You are about to drop the column `description` on the `shifts_archive` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "public"."expenses" DROP COLUMN "description",
ADD COLUMN "comment" TEXT;
-- AlterTable
ALTER TABLE "public"."expenses_archive" DROP COLUMN "description",
ADD COLUMN "comment" TEXT;
-- AlterTable
ALTER TABLE "public"."shifts" DROP COLUMN "description",
ADD COLUMN "comment" TEXT;
-- AlterTable
ALTER TABLE "public"."shifts_archive" DROP COLUMN "description",
ADD COLUMN "comment" TEXT;

View File

@ -181,7 +181,7 @@ async function main() {
data: { data: {
timesheet_id: ts.id, timesheet_id: ts.id,
bank_code_id: bcMorningId, bank_code_id: bcMorningId,
description: `Matin J${di + 1} (sem ${monday.toISOString().slice(0, 10)}) emp ${e.id}${bcMorningCode}`, comment: `Matin J${di + 1} (sem ${monday.toISOString().slice(0, 10)}) emp ${e.id}${bcMorningCode}`,
date, date,
start_time: timeAt(startH, startM), start_time: timeAt(startH, startM),
end_time: timeAt(lunchStartHM.h, lunchStartHM.m), end_time: timeAt(lunchStartHM.h, lunchStartHM.m),
@ -199,7 +199,7 @@ async function main() {
data: { data: {
timesheet_id: ts.id, timesheet_id: ts.id,
bank_code_id: bcAfternoonId, bank_code_id: bcAfternoonId,
description: `Après-midi J${di + 1} (sem ${monday.toISOString().slice(0, 10)}) emp ${e.id}${bcAfternoonCode}`, comment: `Après-midi J${di + 1} (sem ${monday.toISOString().slice(0, 10)}) emp ${e.id}${bcAfternoonCode}`,
date, date,
start_time: timeAt(lunchEndHM.h, lunchEndHM.m), start_time: timeAt(lunchEndHM.h, lunchEndHM.m),
end_time: timeAt(finalEndHM.h, finalEndHM.m), end_time: timeAt(finalEndHM.h, finalEndHM.m),
@ -214,7 +214,7 @@ async function main() {
data: { data: {
timesheet_id: ts.id, timesheet_id: ts.id,
bank_code_id: bcMap.get('G1')!, bank_code_id: bcMap.get('G1')!,
description: `Fallback J${di + 1} (sem ${monday.toISOString().slice(0, 10)}) emp ${e.id} — G1`, comment: `Fallback J${di + 1} (sem ${monday.toISOString().slice(0, 10)}) emp ${e.id} — G1`,
date, date,
start_time: timeAt(startH, startM), start_time: timeAt(startH, startM),
end_time: timeAt(fallbackEnd.h, fallbackEnd.m), end_time: timeAt(fallbackEnd.h, fallbackEnd.m),

View File

@ -37,7 +37,7 @@ async function main() {
data: { data: {
timesheet_id: ts.id, timesheet_id: ts.id,
bank_code_id: bc.id, bank_code_id: bc.id,
description: `Archived-era shift ${i + 1} for emp ${e.id}`, comment: `Archived-era shift ${i + 1} for emp ${e.id}`,
date, date,
start_time: timeAt(startH, 0), start_time: timeAt(startH, 0),
end_time: timeAt(endH, 0), end_time: timeAt(endH, 0),
@ -55,7 +55,7 @@ async function main() {
shift_id: s.id, shift_id: s.id,
timesheet_id: s.timesheet_id, timesheet_id: s.timesheet_id,
bank_code_id: s.bank_code_id, bank_code_id: s.bank_code_id,
description: s.description, comment: s.comment,
date: s.date, date: s.date,
start_time: s.start_time, start_time: s.start_time,
end_time: s.end_time, end_time: s.end_time,

View File

@ -144,7 +144,7 @@ async function main() {
date, date,
amount, // string "xx.yy" (2 décimales exactes) amount, // string "xx.yy" (2 décimales exactes)
attachement: null, attachement: null,
description: `Expense ${code} ${amount}$ (emp ${e.id})`, comment: `Expense ${code} ${amount}$ (emp ${e.id})`,
is_approved: Math.random() < 0.65, is_approved: Math.random() < 0.65,
supervisor_comment: Math.random() < 0.25 ? 'OK' : null, supervisor_comment: Math.random() < 0.25 ? 'OK' : null,
}, },

View File

@ -33,7 +33,7 @@ async function main() {
date: daysAgo(60 + i), date: daysAgo(60 + i),
amount: (20 + i * 3.5).toFixed(2), // ok: Decimal accepte string amount: (20 + i * 3.5).toFixed(2), // ok: Decimal accepte string
attachement: null, attachement: null,
description: `Old expense #${i + 1}`, comment: `Old expense #${i + 1}`,
is_approved: true, is_approved: true,
supervisor_comment: null, supervisor_comment: null,
}, },
@ -51,7 +51,7 @@ async function main() {
date: e.date, date: e.date,
amount: e.amount, amount: e.amount,
attachement: e.attachement, attachement: e.attachement,
description: e.description, comment: e.comment,
is_approved: e.is_approved, is_approved: e.is_approved,
supervisor_comment: e.supervisor_comment, supervisor_comment: e.supervisor_comment,
}, },

View File

@ -177,7 +177,7 @@ model Shifts {
timesheet_id Int timesheet_id Int
bank_code BankCodes @relation("ShiftBankCodes", fields: [bank_code_id], references: [id]) bank_code BankCodes @relation("ShiftBankCodes", fields: [bank_code_id], references: [id])
bank_code_id Int bank_code_id Int
description String? comment String?
date DateTime @db.Date date DateTime @db.Date
start_time DateTime @db.Time(0) start_time DateTime @db.Time(0)
end_time DateTime @db.Time(0) end_time DateTime @db.Time(0)
@ -196,7 +196,7 @@ model ShiftsArchive {
archive_at DateTime @default(now()) archive_at DateTime @default(now())
timesheet_id Int timesheet_id Int
bank_code_id Int bank_code_id Int
description String? comment String?
date DateTime @db.Date date DateTime @db.Date
start_time DateTime @db.Time(0) start_time DateTime @db.Time(0)
end_time DateTime @db.Time(0) end_time DateTime @db.Time(0)
@ -227,7 +227,7 @@ model Expenses {
date DateTime @db.Date date DateTime @db.Date
amount Decimal @db.Money amount Decimal @db.Money
attachement String? attachement String?
description String? comment String?
is_approved Boolean @default(false) is_approved Boolean @default(false)
supervisor_comment String? supervisor_comment String?
@ -246,7 +246,7 @@ model ExpensesArchive {
date DateTime @db.Date date DateTime @db.Date
amount Decimal @db.Money amount Decimal @db.Money
attachement String? attachement String?
description String? comment String?
is_approved Boolean is_approved Boolean
supervisor_comment String? supervisor_comment String?

View File

@ -46,7 +46,7 @@ export class CreateExpenseDto {
description:'explain`s why the expense was made' description:'explain`s why the expense was made'
}) })
@IsString() @IsString()
description?: string; comment?: string;
@ApiProperty({ @ApiProperty({
example: 'DENIED, APPROUVED, PENDING, etc...', example: 'DENIED, APPROUVED, PENDING, etc...',

View File

@ -14,7 +14,7 @@ export class SearchExpensesDto {
@IsOptional() @IsOptional()
@IsString() @IsString()
description_contains?: string; comment_contains?: string;
@IsOptional() @IsOptional()
@IsDateString() @IsDateString()

View File

@ -22,17 +22,4 @@ export class ExpensesCommandService extends BaseApprovalService<Expenses> {
this.updateApprovalWithTransaction(transaction, id, isApproved), this.updateApprovalWithTransaction(transaction, id, isApproved),
); );
} }
// deprecated since batch transaction are made with timesheets
// async updateManyWithTx(
// tx: Prisma.TransactionClient,
// ids: number[],
// isApproved: boolean,
// ): Promise<number> {
// const { count } = await tx.expenses.updateMany({
// where: { id: { in: ids } },
// data: { is_approved: isApproved },
// });
// return count;
// }
} }

View File

@ -16,7 +16,7 @@ export class ExpensesQueryService {
async create(dto: CreateExpenseDto): Promise<Expenses> { async create(dto: CreateExpenseDto): Promise<Expenses> {
const { timesheet_id, bank_code_id, date, amount:rawAmount, const { timesheet_id, bank_code_id, date, amount:rawAmount,
description, is_approved,supervisor_comment} = dto; comment, is_approved,supervisor_comment} = dto;
//fetches type and modifier //fetches type and modifier
@ -37,7 +37,7 @@ export class ExpensesQueryService {
} }
return this.prisma.expenses.create({ return this.prisma.expenses.create({
data: { timesheet_id, bank_code_id, date, amount: final_amount, description, is_approved, supervisor_comment}, data: { timesheet_id, bank_code_id, date, amount: final_amount, comment, is_approved, supervisor_comment},
include: { timesheet: { include: { employee: { include: { user: true }}}}, include: { timesheet: { include: { employee: { include: { user: true }}}},
bank_code: true, bank_code: true,
}, },
@ -66,7 +66,7 @@ export class ExpensesQueryService {
async update(id: number, dto: UpdateExpenseDto): Promise<Expenses> { async update(id: number, dto: UpdateExpenseDto): Promise<Expenses> {
await this.findOne(id); await this.findOne(id);
const { timesheet_id, bank_code_id, date, amount, const { timesheet_id, bank_code_id, date, amount,
description, is_approved, supervisor_comment} = dto; comment, is_approved, supervisor_comment} = dto;
return this.prisma.expenses.update({ return this.prisma.expenses.update({
where: { id }, where: { id },
data: { data: {
@ -74,7 +74,7 @@ export class ExpensesQueryService {
...(bank_code_id !== undefined && { bank_code_id }), ...(bank_code_id !== undefined && { bank_code_id }),
...(date !== undefined && { date }), ...(date !== undefined && { date }),
...(amount !== undefined && { amount }), ...(amount !== undefined && { amount }),
...(description !== undefined && { description }), ...(comment !== undefined && { comment }),
...(is_approved !== undefined && { is_approved }), ...(is_approved !== undefined && { is_approved }),
...(supervisor_comment !== undefined && { supervisor_comment }), ...(supervisor_comment !== undefined && { supervisor_comment }),
}, },
@ -122,7 +122,7 @@ export class ExpensesQueryService {
date: exp.date, date: exp.date,
amount: exp.amount, amount: exp.amount,
attachement: exp.attachement, attachement: exp.attachement,
description: exp.description, comment: exp.comment,
is_approved: exp.is_approved, is_approved: exp.is_approved,
supervisor_comment: exp.supervisor_comment, supervisor_comment: exp.supervisor_comment,
})), })),

View File

@ -48,5 +48,5 @@ export class CreateShiftDto {
end_time: string; end_time: string;
@IsString() @IsString()
description: string; comment: string;
} }

View File

@ -14,7 +14,7 @@ export class SearchShiftsDto {
@IsOptional() @IsOptional()
@IsString() @IsString()
description_contains?: string; comment_contains?: string;
@IsOptional() @IsOptional()
@IsDateString() @IsDateString()

View File

@ -20,17 +20,4 @@ export class ShiftsCommandService extends BaseApprovalService<Shifts> {
this.updateApprovalWithTransaction(transaction, id, is_approved), this.updateApprovalWithTransaction(transaction, id, is_approved),
); );
} }
// deprecated since batch transaction are made with timesheets
// async updateManyWithTx(
// tx: Prisma.TransactionClient,
// ids: number[],
// isApproved: boolean,
// ): Promise<number> {
// const { count } = await tx.shifts.updateMany({
// where: { id: { in: ids } },
// data: { is_approved: isApproved },
// });
// return count;
// }
} }

View File

@ -29,11 +29,11 @@ export class ShiftsQueryService {
) {} ) {}
async create(dto: CreateShiftDto): Promise<Shifts> { async create(dto: CreateShiftDto): Promise<Shifts> {
const { timesheet_id, bank_code_id, date, start_time, end_time, description } = dto; const { timesheet_id, bank_code_id, date, start_time, end_time, comment } = dto;
//shift creation //shift creation
const shift = await this.prisma.shifts.create({ const shift = await this.prisma.shifts.create({
data: { timesheet_id, bank_code_id, date, start_time, end_time, description }, data: { timesheet_id, bank_code_id, date, start_time, end_time, comment },
include: { timesheet: { include: { employee: { include: { user: true } } } }, include: { timesheet: { include: { employee: { include: { user: true } } } },
bank_code: true, bank_code: true,
}, },
@ -93,7 +93,7 @@ export class ShiftsQueryService {
async update(id: number, dto: UpdateShiftsDto): Promise<Shifts> { async update(id: number, dto: UpdateShiftsDto): Promise<Shifts> {
await this.findOne(id); await this.findOne(id);
const { timesheet_id, bank_code_id, date,start_time,end_time, description} = dto; const { timesheet_id, bank_code_id, date,start_time,end_time, comment} = dto;
return this.prisma.shifts.update({ return this.prisma.shifts.update({
where: { id }, where: { id },
data: { data: {
@ -102,7 +102,7 @@ export class ShiftsQueryService {
...(date !== undefined && { date }), ...(date !== undefined && { date }),
...(start_time !== undefined && { start_time }), ...(start_time !== undefined && { start_time }),
...(end_time !== undefined && { end_time }), ...(end_time !== undefined && { end_time }),
...(description !== undefined && { description }), ...(comment !== undefined && { comment }),
}, },
include: { timesheet: { include: { employee: { include: { user: true } } } }, include: { timesheet: { include: { employee: { include: { user: true } } } },
bank_code: true, bank_code: true,
@ -243,7 +243,7 @@ export class ShiftsQueryService {
shift_id: shift.id, shift_id: shift.id,
timesheet_id: shift.timesheet_id, timesheet_id: shift.timesheet_id,
bank_code_id: shift.bank_code_id, bank_code_id: shift.bank_code_id,
description: shift.description ?? undefined, comment: shift.comment ?? undefined,
date: shift.date, date: shift.date,
start_time: shift.start_time, start_time: shift.start_time,
end_time: shift.end_time, end_time: shift.end_time,

View File

@ -22,7 +22,7 @@ export class CreateTimesheetDto {
@IsOptional() @IsOptional()
@IsString() @IsString()
@Length(0,512) @Length(0,512)
description?: string; comment?: string;
} }
export class CreateWeekShiftsDto { export class CreateWeekShiftsDto {

View File

@ -12,7 +12,7 @@ export class ShiftsDto {
date: string; date: string;
start_time: string; start_time: string;
end_time: string; end_time: string;
description: string; comment: string;
is_approved: boolean; is_approved: boolean;
is_remote: boolean; is_remote: boolean;
} }
@ -22,7 +22,7 @@ export class ExpensesDto {
date: string; date: string;
amount: number; amount: number;
km: number; km: number;
description: string; comment: string;
supervisor_comment: string; supervisor_comment: string;
is_approved: boolean; is_approved: boolean;
} }

View File

@ -117,7 +117,7 @@ export class TimesheetsCommandService extends BaseApprovalService<Timesheets>{
date: date, date: date,
start_time: this.parseHHmm(shift.start_time), start_time: this.parseHHmm(shift.start_time),
end_time: this.parseHHmm(shift.end_time), end_time: this.parseHHmm(shift.end_time),
description: shift.description ?? null, comment: shift.comment ?? null,
is_approved: false, is_approved: false,
is_remote: false, is_remote: false,
}, },

View File

@ -161,7 +161,7 @@ export class TimesheetsQueryService {
date: formatDateISO(sft.date), date: formatDateISO(sft.date),
start_time: to_HH_mm(sft.start_time), start_time: to_HH_mm(sft.start_time),
end_time: to_HH_mm(sft.end_time), end_time: to_HH_mm(sft.end_time),
description: sft.description ?? '', comment: sft.comment ?? '',
is_approved: sft.is_approved ?? false, is_approved: sft.is_approved ?? false,
is_remote: sft.is_remote ?? false, is_remote: sft.is_remote ?? false,
})); }));
@ -172,7 +172,7 @@ export class TimesheetsQueryService {
date: formatDateISO(exp.date), date: formatDateISO(exp.date),
amount: Number(exp.amount) || 0, amount: Number(exp.amount) || 0,
km: 0, km: 0,
description: exp.description ?? '', comment: exp.comment ?? '',
supervisor_comment: exp.supervisor_comment ?? '', supervisor_comment: exp.supervisor_comment ?? '',
is_approved: exp.is_approved ?? false, is_approved: exp.is_approved ?? false,
})); }));