feat: delete quotation endpoints
This commit is contained in:
parent
fbf7f6c968
commit
c13eeb9b14
1 changed files with 21 additions and 1 deletions
|
|
@ -496,5 +496,25 @@ export class QuotationController extends Controller {
|
|||
|
||||
@Delete("{quotationId}")
|
||||
@Security("keycloak")
|
||||
async deleteQuotationById(@Request() req: RequestWithUser, @Path() quotationId: string) {}
|
||||
async deleteQuotationById(@Request() req: RequestWithUser, @Path() quotationId: string) {
|
||||
const record = await prisma.quotation.findUnique({
|
||||
where: { id: quotationId },
|
||||
});
|
||||
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Quotation not found.", "quotationNotFound");
|
||||
}
|
||||
|
||||
if (record.status !== Status.CREATED) {
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, "Quotation is in used.", "quotationInUsed");
|
||||
}
|
||||
|
||||
return await prisma.quotation.delete({
|
||||
include: {
|
||||
createdBy: true,
|
||||
updatedBy: true,
|
||||
},
|
||||
where: { id: quotationId },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue