60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
|
import { STATUS } from 'src/core/strings/constants/base.constants';
|
|
import {
|
|
EventTopics,
|
|
validateRelations,
|
|
} from 'src/core/strings/constants/interface.constants';
|
|
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
|
import { TransactionChangeStatusEvent } from 'src/modules/transaction/transaction/domain/entities/event/transaction-change-status.event';
|
|
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
|
|
import { generateInvoiceCodeHelper } from 'src/modules/transaction/transaction/domain/usecases/managers/helpers/generate-invoice-code.helper';
|
|
|
|
@Injectable()
|
|
export class ConfirmReconciliationManager extends BaseUpdateStatusManager<TransactionEntity> {
|
|
getResult(): string {
|
|
return `Success active data ${this.result.id}`;
|
|
}
|
|
|
|
async validateProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
async beforeProcess(): Promise<void> {
|
|
Object.assign(this.data, {
|
|
reconciliation_confirm_by: this.user.name,
|
|
reconciliation_confirm_date: new Date().getTime(),
|
|
status: STATUS.SETTLED,
|
|
reconciliation_status: this.dataStatus,
|
|
payment_code: await generateInvoiceCodeHelper(this.dataService, 'PMY'),
|
|
settlement_date:
|
|
this.dataStatus === STATUS.CONFIRMED
|
|
? this.data.payment_date
|
|
: this.data.settlement_date,
|
|
payment_date_bank: this.data.payment_date_bank ?? new Date(),
|
|
});
|
|
|
|
return;
|
|
}
|
|
|
|
async afterProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
get validateRelations(): validateRelations[] {
|
|
return [];
|
|
}
|
|
|
|
get entityTarget(): any {
|
|
return TransactionModel;
|
|
}
|
|
|
|
get eventTopics(): EventTopics[] {
|
|
return [
|
|
{
|
|
topic: TransactionChangeStatusEvent,
|
|
},
|
|
];
|
|
}
|
|
}
|