From b45753da2a5b5dbc4e91c99004696fb00d07d6bc Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 24 Feb 2025 11:58:16 +0700 Subject: [PATCH] feat: prevent reaccept debit note --- src/controllers/09-debit-note-controller.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controllers/09-debit-note-controller.ts b/src/controllers/09-debit-note-controller.ts index 8c817aa..36fa432 100644 --- a/src/controllers/09-debit-note-controller.ts +++ b/src/controllers/09-debit-note-controller.ts @@ -843,7 +843,11 @@ export class DebitNoteActionController extends Controller { @Post("accept") @Security("keycloak", MANAGE_ROLES) async acceptDebitNote(@Request() req: RequestWithUser, @Path() debitNoteId: string) { - await this.#checkPermission(req.user, debitNoteId); + const record = await this.#checkPermission(req.user, debitNoteId); + + if (record.quotationStatus !== QuotationStatus.Issued) { + throw new HttpError(HttpStatus.BAD_REQUEST, "Already Accepted", "debitNoteAlreadyAccept"); + } return await prisma.quotation.update({ where: { id: debitNoteId }, data: { quotationStatus: QuotationStatus.Accepted },