diff --git a/src/controllers/08-credit-note-controller.ts b/src/controllers/08-credit-note-controller.ts index d2fd827..6839050 100644 --- a/src/controllers/08-credit-note-controller.ts +++ b/src/controllers/08-credit-note-controller.ts @@ -621,4 +621,44 @@ export class CreditNoteAttachmentController extends Controller { await this.#checkPermission(req.user, creditNoteId); return await deleteFile(fileLocation.creditNote.attachment(creditNoteId, name)); } + + @Get("file-slip") + @Security("keycloak") + async listSlip(@Request() req: RequestWithUser, @Path() creditNoteId: string) { + await this.#checkPermission(req.user, creditNoteId); + return await listFile(fileLocation.creditNote.slip(creditNoteId)); + } + + @Get("file-slip/{name}") + @Security("keycloak") + async getSlip(@Path() creditNoteId: string, @Path() name: string) { + return await getFile(fileLocation.creditNote.slip(creditNoteId, name)); + } + + @Head("file-slip/{name}") + async headSlip(@Path() creditNoteId: string, @Path() name: string) { + return await getPresigned("head", fileLocation.creditNote.slip(creditNoteId, name)); + } + + @Put("file-slip/{name}") + @Security("keycloak") + async putSlip( + @Request() req: RequestWithUser, + @Path() creditNoteId: string, + @Path() name: string, + ) { + await this.#checkPermission(req.user, creditNoteId); + return await setFile(fileLocation.creditNote.slip(creditNoteId, name)); + } + + @Delete("filel-slip/{name}") + @Security("keycloak") + async delSlip( + @Request() req: RequestWithUser, + @Path() creditNoteId: string, + @Path() name: string, + ) { + await this.#checkPermission(req.user, creditNoteId); + return await deleteFile(fileLocation.creditNote.slip(creditNoteId, name)); + } } diff --git a/src/utils/minio.ts b/src/utils/minio.ts index 7ec0a3b..f5f37e6 100644 --- a/src/utils/minio.ts +++ b/src/utils/minio.ts @@ -113,6 +113,8 @@ export const fileLocation = { attachment: (taskId: string, name?: string) => `task/attachment-${taskId}/${name || ""}`, }, creditNote: { - attachment: (taskId: string, name?: string) => `credit-note/attachment-${taskId}/${name || ""}`, + slip: (creditNoteId: string, name?: string) => `credit-note/slip-${creditNoteId}/${name || ""}`, + attachment: (creditNoteId: string, name?: string) => + `credit-note/attachment-${creditNoteId}/${name || ""}`, }, };