feat: prevent reaccept debit note

This commit is contained in:
Methapon2001 2025-02-24 11:58:16 +07:00
parent feffe6d52f
commit b45753da2a

View file

@ -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 },