diff --git a/src/modules/transaction/refund/domain/usecases/managers/create-refund.manager.ts b/src/modules/transaction/refund/domain/usecases/managers/create-refund.manager.ts index 5b630e8..8e65106 100644 --- a/src/modules/transaction/refund/domain/usecases/managers/create-refund.manager.ts +++ b/src/modules/transaction/refund/domain/usecases/managers/create-refund.manager.ts @@ -30,6 +30,19 @@ export class CreateRefundManager extends BaseCreateManager { refund_items: refund_items, }); + const exist = await this.dataService.getOneByOptions({ + where: { + transaction_id: this.data.transaction.id, + }, + }); + if (exist) { + throw new UnprocessableEntityException({ + statusCode: HttpStatus.UNPROCESSABLE_ENTITY, + message: `Failed! refund transaction with invoice ${this.data.transaction.invoice_code} already exist`, + error: 'Unprocessable Entity', + }); + } + const transaction = await this.dataServiceFirstOpt.getOneByOptions({ where: { id: this.data.transaction.id,