60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import {
|
|
HttpStatus,
|
|
Injectable,
|
|
UnprocessableEntityException,
|
|
} from '@nestjs/common';
|
|
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
|
import {
|
|
EventTopics,
|
|
validateRelations,
|
|
} from 'src/core/strings/constants/interface.constants';
|
|
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
|
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
|
|
|
|
@Injectable()
|
|
export class CancelReconciliationManager extends BaseUpdateStatusManager<TransactionEntity> {
|
|
getResult(): string {
|
|
return `Success active data ${this.result.id}`;
|
|
}
|
|
|
|
async validateProcess(): Promise<void> {
|
|
if (this.data.is_recap_transaction) {
|
|
throw new UnprocessableEntityException({
|
|
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
message: `Failed! cant cancel recap data`,
|
|
error: 'Unprocessable Entity',
|
|
});
|
|
}
|
|
return;
|
|
}
|
|
|
|
async beforeProcess(): Promise<void> {
|
|
Object.assign(this.data, {
|
|
reconciliation_mdr: this.data.reconciliation_mdr ?? null,
|
|
reconciliation_confirm_by: this.user.name,
|
|
reconciliation_confirm_date: new Date().getTime(),
|
|
status: this.dataStatus,
|
|
reconciliation_status: this.dataStatus,
|
|
payment_date: this.data.payment_date,
|
|
});
|
|
|
|
return;
|
|
}
|
|
|
|
async afterProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
get validateRelations(): validateRelations[] {
|
|
return [];
|
|
}
|
|
|
|
get entityTarget(): any {
|
|
return TransactionModel;
|
|
}
|
|
|
|
get eventTopics(): EventTopics[] {
|
|
return [];
|
|
}
|
|
}
|