feat: add reject request cancel endpoint
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 8s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 8s
This commit is contained in:
parent
e76abd787c
commit
b64cd5d1a6
3 changed files with 72 additions and 2 deletions
|
|
@ -1464,6 +1464,8 @@ model RequestData {
|
||||||
|
|
||||||
customerRequestCancel Boolean?
|
customerRequestCancel Boolean?
|
||||||
customerRequestCancelReason String?
|
customerRequestCancelReason String?
|
||||||
|
rejectRequestCancel Boolean?
|
||||||
|
rejectRequestCancelReason String?
|
||||||
|
|
||||||
flow Json?
|
flow Json?
|
||||||
|
|
||||||
|
|
@ -1502,6 +1504,8 @@ model RequestWork {
|
||||||
|
|
||||||
customerRequestCancel Boolean?
|
customerRequestCancel Boolean?
|
||||||
customerRequestCancelReason String?
|
customerRequestCancelReason String?
|
||||||
|
rejectRequestCancel Boolean?
|
||||||
|
rejectRequestCancelReason String?
|
||||||
|
|
||||||
creditNote CreditNote? @relation(fields: [creditNoteId], references: [id], onDelete: SetNull)
|
creditNote CreditNote? @relation(fields: [creditNoteId], references: [id], onDelete: SetNull)
|
||||||
creditNoteId String?
|
creditNoteId String?
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,68 @@ export class RequestDataController extends Controller {
|
||||||
@Route("/api/v1/request-data/{requestDataId}")
|
@Route("/api/v1/request-data/{requestDataId}")
|
||||||
@Tags("Request List")
|
@Tags("Request List")
|
||||||
export class RequestDataActionController extends Controller {
|
export class RequestDataActionController extends Controller {
|
||||||
|
@Post("reject-request-cancel")
|
||||||
|
@Security("keycloak")
|
||||||
|
async rejectRequestCancel(
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
@Path() requestDataId: string,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
reason?: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const result = await prisma.requestData.updateManyAndReturn({
|
||||||
|
where: {
|
||||||
|
id: requestDataId,
|
||||||
|
quotation: {
|
||||||
|
registeredBranch: {
|
||||||
|
OR: permissionCond(req.user),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
rejectRequestCancel: true,
|
||||||
|
rejectRequestCancelReason: body.reason || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.length <= 0) throw notFoundError("Request Data");
|
||||||
|
|
||||||
|
return result[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("request-work/${requestWorkId}/reject-request-cancel")
|
||||||
|
@Security("keycloak")
|
||||||
|
async rejectWorkRequestCancel(
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
@Path() requestWorkId: string,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
reason?: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const result = await prisma.requestWork.updateManyAndReturn({
|
||||||
|
where: {
|
||||||
|
id: requestWorkId,
|
||||||
|
request: {
|
||||||
|
quotation: {
|
||||||
|
registeredBranch: {
|
||||||
|
OR: permissionCond(req.user),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
rejectRequestCancel: true,
|
||||||
|
rejectRequestCancelReason: body.reason || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.length <= 0) throw notFoundError("Request Data");
|
||||||
|
|
||||||
|
return result[0];
|
||||||
|
}
|
||||||
|
|
||||||
@Post("cancel")
|
@Post("cancel")
|
||||||
@Security("keycloak")
|
@Security("keycloak")
|
||||||
async cancelRequestData(@Path() requestDataId: string) {
|
async cancelRequestData(@Path() requestDataId: string) {
|
||||||
|
|
|
||||||
|
|
@ -804,7 +804,9 @@ export class LineController extends Controller {
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
customerRequestCancel: body.cancel,
|
customerRequestCancel: body.cancel,
|
||||||
customerRequestCancelReason: body.reason || "",
|
customerRequestCancelReason: body.reason || null,
|
||||||
|
rejectRequestCancel: false,
|
||||||
|
rejectRequestCancelReason: null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (result.count <= 0) throw notFoundError("Request Data");
|
if (result.count <= 0) throw notFoundError("Request Data");
|
||||||
|
|
@ -837,7 +839,9 @@ export class LineController extends Controller {
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
customerRequestCancel: body.cancel,
|
customerRequestCancel: body.cancel,
|
||||||
customerRequestCancelReason: body.reason || "",
|
customerRequestCancelReason: body.reason || null,
|
||||||
|
rejectRequestCancel: false,
|
||||||
|
rejectRequestCancelReason: null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (result.count <= 0) throw notFoundError("Request Data");
|
if (result.count <= 0) throw notFoundError("Request Data");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue