diff --git a/src/controllers/08-credit-note-controller.ts b/src/controllers/08-credit-note-controller.ts index 3bd9427..9dfd915 100644 --- a/src/controllers/08-credit-note-controller.ts +++ b/src/controllers/08-credit-note-controller.ts @@ -418,17 +418,20 @@ export class CreditNoteController extends Controller { const requestWork = await prisma.requestWork.findMany({ where: { - OR: [{ creditNote: null }, { creditNoteId }], request: { - quotation: { - id: body.quotationId, - }, + quotation: { id: body.quotationId }, }, - stepStatus: { - some: { - workStatus: RequestWorkStatus.Canceled, + AND: [ + { + OR: [{ creditNote: null }, { creditNoteId }], }, - }, + { + OR: [ + { request: { requestDataStatus: RequestDataStatus.Canceled } }, + { stepStatus: { some: { workStatus: RequestWorkStatus.Canceled } } }, + ], + }, + ], id: { in: body.requestWorkId }, }, include: {