diff --git a/docs/swagger/swagger-spec.json b/docs/swagger/swagger-spec.json index 99f16ad..68cdc3d 100644 --- a/docs/swagger/swagger-spec.json +++ b/docs/swagger/swagger-spec.json @@ -654,6 +654,52 @@ ] } }, + "/Expenses/upsert/{email}/{date}": { + "put": { + "operationId": "ExpensesController_upsert_by_date", + "parameters": [ + { + "name": "email", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + }, + { + "name": "date", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpsertExpenseDto" + } + } + } + }, + "responses": { + "200": { + "description": "" + } + }, + "security": [ + { + "access-token": [] + } + ], + "tags": [ + "Expenses" + ] + } + }, "/Expenses": { "post": { "operationId": "ExpensesController_create", @@ -2459,6 +2505,10 @@ "type": "object", "properties": {} }, + "UpsertExpenseDto": { + "type": "object", + "properties": {} + }, "CreateExpenseDto": { "type": "object", "properties": { diff --git a/prisma/mock-seeds-scripts/12-expenses.ts b/prisma/mock-seeds-scripts/12-expenses.ts index c0641a8..00f6f0c 100644 --- a/prisma/mock-seeds-scripts/12-expenses.ts +++ b/prisma/mock-seeds-scripts/12-expenses.ts @@ -143,7 +143,7 @@ async function main() { bank_code_id, date, amount, // string "xx.yy" (2 décimales exactes) - attachement: null, + attachment: null, comment: `Expense ${code} ${amount}$ (emp ${e.id})`, is_approved: Math.random() < 0.65, supervisor_comment: Math.random() < 0.25 ? 'OK' : null, diff --git a/prisma/mock-seeds-scripts/13-expenses-archive.ts b/prisma/mock-seeds-scripts/13-expenses-archive.ts index 86d2c3b..d8e35a2 100644 --- a/prisma/mock-seeds-scripts/13-expenses-archive.ts +++ b/prisma/mock-seeds-scripts/13-expenses-archive.ts @@ -32,7 +32,7 @@ async function main() { bank_code_id: bc.id, date: daysAgo(60 + i), amount: (20 + i * 3.5).toFixed(2), // ok: Decimal accepte string - attachement: null, + attachment: null, comment: `Old expense #${i + 1}`, is_approved: true, supervisor_comment: null, @@ -50,7 +50,7 @@ async function main() { bank_code_id: e.bank_code_id, date: e.date, amount: e.amount, - attachement: e.attachement, + attachment: e.attachment, comment: e.comment, is_approved: e.is_approved, supervisor_comment: e.supervisor_comment, diff --git a/src/modules/expenses/expenses.module.ts b/src/modules/expenses/expenses.module.ts index 2cbd302..3948e70 100644 --- a/src/modules/expenses/expenses.module.ts +++ b/src/modules/expenses/expenses.module.ts @@ -17,7 +17,12 @@ import { EmployeesRepo } from "./repos/employee.repo"; TimesheetsRepo, EmployeesRepo, ], - exports: [ ExpensesQueryService ], + exports: [ + ExpensesQueryService, + BankCodesRepo, + TimesheetsRepo, + EmployeesRepo, + ], }) export class ExpensesModule {} \ No newline at end of file diff --git a/src/modules/expenses/services/expenses-command.service.ts b/src/modules/expenses/services/expenses-command.service.ts index 41fd316..973171b 100644 --- a/src/modules/expenses/services/expenses-command.service.ts +++ b/src/modules/expenses/services/expenses-command.service.ts @@ -1,14 +1,14 @@ import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common"; -import { Expenses, Prisma } from "@prisma/client"; import { BaseApprovalService } from "src/common/shared/base-approval.service"; -import { PrismaService } from "src/prisma/prisma.service"; -import { UpsertExpenseDto } from "../dtos/upsert-expense.dto"; -import { BankCodesRepo } from "../repos/bank-codes.repo"; -import { TimesheetsRepo } from "../repos/timesheets.repo"; -import { EmployeesRepo } from "../repos/employee.repo"; +import { Expenses, Prisma } from "@prisma/client"; +import { PrismaService } from "src/prisma/prisma.service"; +import { UpsertExpenseDto } from "../dtos/upsert-expense.dto"; +import { BankCodesRepo } from "../repos/bank-codes.repo"; +import { TimesheetsRepo } from "../repos/timesheets.repo"; +import { EmployeesRepo } from "../repos/employee.repo"; +import { toDateOnlyUTC } from "src/modules/shifts/helpers/shifts-date-time-helpers"; import { assertAndTrimComment, computeMileageAmount, mapDbExpenseToDayResponse, normalizeType as normalizeTypeUtil } from "../utils/expenses.utils"; import { DayExpenseResponse, UpsertAction } from "../types and interfaces/expenses.types.interfaces"; -import { toDateOnlyUTC } from "src/modules/shifts/helpers/shifts-date-time-helpers"; @Injectable() export class ExpensesCommandService extends BaseApprovalService { diff --git a/src/modules/pay-periods/pay-periods.module.ts b/src/modules/pay-periods/pay-periods.module.ts index 6772529..fd9106b 100644 --- a/src/modules/pay-periods/pay-periods.module.ts +++ b/src/modules/pay-periods/pay-periods.module.ts @@ -7,6 +7,9 @@ import { TimesheetsModule } from "../timesheets/timesheets.module"; import { TimesheetsCommandService } from "../timesheets/services/timesheets-command.service"; import { ExpensesCommandService } from "../expenses/services/expenses-command.service"; import { ShiftsCommandService } from "../shifts/services/shifts-command.service"; +import { BankCodesRepo } from "../expenses/repos/bank-codes.repo"; +import { EmployeesRepo } from "../expenses/repos/employee.repo"; +import { TimesheetsRepo } from "../expenses/repos/timesheets.repo"; @Module({ imports: [PrismaModule, TimesheetsModule], @@ -16,12 +19,14 @@ import { ShiftsCommandService } from "../shifts/services/shifts-command.service" TimesheetsCommandService, ExpensesCommandService, ShiftsCommandService, + BankCodesRepo, + TimesheetsRepo, + EmployeesRepo, ], controllers: [PayPeriodsController], exports: [ PayPeriodsQueryService, PayPeriodsCommandService, - PayPeriodsQueryService, ] }) diff --git a/src/modules/timesheets/timesheets.module.ts b/src/modules/timesheets/timesheets.module.ts index cbfc001..b957fe6 100644 --- a/src/modules/timesheets/timesheets.module.ts +++ b/src/modules/timesheets/timesheets.module.ts @@ -5,6 +5,9 @@ import { BusinessLogicsModule } from 'src/modules/business-logics/business-logic import { TimesheetsCommandService } from './services/timesheets-command.service'; import { ShiftsCommandService } from '../shifts/services/shifts-command.service'; import { ExpensesCommandService } from '../expenses/services/expenses-command.service'; +import { BankCodesRepo } from '../expenses/repos/bank-codes.repo'; +import { TimesheetsRepo } from '../expenses/repos/timesheets.repo'; +import { EmployeesRepo } from '../expenses/repos/employee.repo'; @Module({ imports: [BusinessLogicsModule], @@ -13,7 +16,10 @@ import { ExpensesCommandService } from '../expenses/services/expenses-command.se TimesheetsQueryService, TimesheetsCommandService, ShiftsCommandService, - ExpensesCommandService + ExpensesCommandService, + BankCodesRepo, + TimesheetsRepo, + EmployeesRepo, ], exports: [TimesheetsQueryService], })