feat: add accept endpoint debit note

This commit is contained in:
Methapon2001 2025-02-24 11:39:08 +07:00
parent da8cca2ee4
commit feffe6d52f

View file

@ -823,6 +823,34 @@ export class DebitNoteController extends Controller {
}
}
@Route("api/v1/debit-note/{debitNoteId}")
@Tags("Debit Note")
export class DebitNoteActionController extends Controller {
async #checkPermission(user: RequestWithUser["user"], id: string) {
const data = await prisma.quotation.findUnique({
include: {
registeredBranch: {
include: branchRelationPermInclude(user),
},
},
where: { id, isDebitNote: true },
});
if (!data) throw notFoundError("Debit Note");
await permissionCheck(user, data.registeredBranch);
return data;
}
@Post("accept")
@Security("keycloak", MANAGE_ROLES)
async acceptDebitNote(@Request() req: RequestWithUser, @Path() debitNoteId: string) {
await this.#checkPermission(req.user, debitNoteId);
return await prisma.quotation.update({
where: { id: debitNoteId },
data: { quotationStatus: QuotationStatus.Accepted },
});
}
}
@Route("api/v1/debit-note/{debitNoteId}")
@Tags("Debit Note")
export class DebitNoteFileController extends Controller {