Merge pull request #18 from Frappet/feat/customer-request-cancel
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 6s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 6s
feat: customer request cancel endpoint
This commit is contained in:
commit
1add3f3ba0
2 changed files with 72 additions and 0 deletions
|
|
@ -1442,6 +1442,9 @@ model RequestData {
|
||||||
|
|
||||||
requestDataStatus RequestDataStatus @default(Pending)
|
requestDataStatus RequestDataStatus @default(Pending)
|
||||||
|
|
||||||
|
customerRequestCancel Boolean?
|
||||||
|
customerRequestCancelReason String?
|
||||||
|
|
||||||
flow Json?
|
flow Json?
|
||||||
|
|
||||||
requestWork RequestWork[]
|
requestWork RequestWork[]
|
||||||
|
|
@ -1477,6 +1480,9 @@ model RequestWork {
|
||||||
|
|
||||||
stepStatus RequestWorkStepStatus[]
|
stepStatus RequestWorkStepStatus[]
|
||||||
|
|
||||||
|
customerRequestCancel Boolean?
|
||||||
|
customerRequestCancelReason String?
|
||||||
|
|
||||||
creditNote CreditNote? @relation(fields: [creditNoteId], references: [id], onDelete: SetNull)
|
creditNote CreditNote? @relation(fields: [creditNoteId], references: [id], onDelete: SetNull)
|
||||||
creditNoteId String?
|
creditNoteId String?
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import {
|
import {
|
||||||
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
Head,
|
Head,
|
||||||
Path,
|
Path,
|
||||||
|
Post,
|
||||||
Put,
|
Put,
|
||||||
Query,
|
Query,
|
||||||
Request,
|
Request,
|
||||||
|
|
@ -776,6 +778,70 @@ export class LineController extends Controller {
|
||||||
|
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post("request/{requestDataId}/request-cancel")
|
||||||
|
@Security("line")
|
||||||
|
async customerRequestCancel(
|
||||||
|
@Path() requestDataId: string,
|
||||||
|
@Request() req: RequestWithLineUser,
|
||||||
|
@Body() body: { reason: string },
|
||||||
|
) {
|
||||||
|
const result = await prisma.requestData.updateMany({
|
||||||
|
where: {
|
||||||
|
id: requestDataId,
|
||||||
|
quotation: {
|
||||||
|
customerBranch: {
|
||||||
|
OR: [
|
||||||
|
{ userId: req.user.sub },
|
||||||
|
{
|
||||||
|
customer: {
|
||||||
|
branch: { some: { userId: req.user.sub } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
customerRequestCancel: true,
|
||||||
|
customerRequestCancelReason: body.reason,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (result.count <= 0) throw notFoundError("Request Data");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("request-work/{requestWorkId}/request-cancel")
|
||||||
|
@Security("line")
|
||||||
|
async customerRequestCancelWork(
|
||||||
|
@Path() requestWorkId: string,
|
||||||
|
@Request() req: RequestWithLineUser,
|
||||||
|
@Body() body: { reason: string },
|
||||||
|
) {
|
||||||
|
const result = await prisma.requestWork.updateMany({
|
||||||
|
where: {
|
||||||
|
id: requestWorkId,
|
||||||
|
request: {
|
||||||
|
quotation: {
|
||||||
|
customerBranch: {
|
||||||
|
OR: [
|
||||||
|
{ userId: req.user.sub },
|
||||||
|
{
|
||||||
|
customer: {
|
||||||
|
branch: { some: { userId: req.user.sub } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
customerRequestCancel: true,
|
||||||
|
customerRequestCancelReason: body.reason,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (result.count <= 0) throw notFoundError("Request Data");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Route("api/v1/line/customer-branch/{branchId}")
|
@Route("api/v1/line/customer-branch/{branchId}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue