feat: add accept endpoint debit note
This commit is contained in:
parent
da8cca2ee4
commit
feffe6d52f
1 changed files with 28 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue