Compare commits
No commits in common. "9802d983bb241bf376428dd56d323cc59058dff2" and "4ef139b2f570ee40b9da15b251a32fb14cbc9f79" have entirely different histories.
9802d983bb
...
4ef139b2f5
|
@ -7,12 +7,7 @@ import {
|
||||||
import { TransactionModel } from '../../../data/models/transaction.model';
|
import { TransactionModel } from '../../../data/models/transaction.model';
|
||||||
import { TransactionDeletedEvent } from '../../entities/event/transaction-deleted.event';
|
import { TransactionDeletedEvent } from '../../entities/event/transaction-deleted.event';
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
import {
|
import { Injectable } from '@nestjs/common';
|
||||||
HttpStatus,
|
|
||||||
Injectable,
|
|
||||||
UnprocessableEntityException,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BatchDeleteTransactionManager extends BaseBatchDeleteManager<TransactionEntity> {
|
export class BatchDeleteTransactionManager extends BaseBatchDeleteManager<TransactionEntity> {
|
||||||
|
@ -21,21 +16,6 @@ export class BatchDeleteTransactionManager extends BaseBatchDeleteManager<Transa
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateData(data: TransactionEntity): Promise<void> {
|
async validateData(data: TransactionEntity): Promise<void> {
|
||||||
const allowDelete = [
|
|
||||||
STATUS.DRAFT,
|
|
||||||
STATUS.ACTIVE,
|
|
||||||
STATUS.CANCEL,
|
|
||||||
STATUS.PENDING,
|
|
||||||
STATUS.EXPIRED,
|
|
||||||
].includes(data.status);
|
|
||||||
|
|
||||||
if (!allowDelete) {
|
|
||||||
throw new UnprocessableEntityException({
|
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
||||||
message: `Gagal! data dengan status ${data.status} tidak bisa di hapus!`,
|
|
||||||
error: 'Unprocessable Entity',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
import {
|
import { Injectable } from '@nestjs/common';
|
||||||
HttpStatus,
|
|
||||||
Injectable,
|
|
||||||
UnprocessableEntityException,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||||
import { TransactionEntity } from '../../entities/transaction.entity';
|
import { TransactionEntity } from '../../entities/transaction.entity';
|
||||||
import {
|
import {
|
||||||
|
@ -11,7 +7,6 @@ import {
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
import { TransactionModel } from '../../../data/models/transaction.model';
|
import { TransactionModel } from '../../../data/models/transaction.model';
|
||||||
import { TransactionDeletedEvent } from '../../entities/event/transaction-deleted.event';
|
import { TransactionDeletedEvent } from '../../entities/event/transaction-deleted.event';
|
||||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DeleteTransactionManager extends BaseDeleteManager<TransactionEntity> {
|
export class DeleteTransactionManager extends BaseDeleteManager<TransactionEntity> {
|
||||||
|
@ -20,21 +15,6 @@ export class DeleteTransactionManager extends BaseDeleteManager<TransactionEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
async validateProcess(): Promise<void> {
|
||||||
const allowDelete = [
|
|
||||||
STATUS.DRAFT,
|
|
||||||
STATUS.ACTIVE,
|
|
||||||
STATUS.CANCEL,
|
|
||||||
STATUS.PENDING,
|
|
||||||
STATUS.EXPIRED,
|
|
||||||
].includes(this.data.status);
|
|
||||||
|
|
||||||
if (!allowDelete) {
|
|
||||||
throw new UnprocessableEntityException({
|
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
||||||
message: `Gagal! data dengan status ${this.data.status} tidak bisa di hapus!`,
|
|
||||||
error: 'Unprocessable Entity',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue