58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
|
import {
|
|
EventTopics,
|
|
columnUniques,
|
|
validateRelations,
|
|
} from 'src/core/strings/constants/interface.constants';
|
|
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
|
import { TransactionUpdatedEvent } from 'src/modules/transaction/transaction/domain/entities/event/transaction-updated.event';
|
|
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
|
|
|
|
@Injectable()
|
|
export class UpdateReconciliationManager extends BaseUpdateManager<TransactionEntity> {
|
|
async validateProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
async beforeProcess(): Promise<void> {
|
|
const net_profit = this.data.reconciliation_mdr
|
|
? Number(this.oldData.payment_total) -
|
|
Number(this.data.reconciliation_mdr)
|
|
: null;
|
|
|
|
Object.assign(this.data, {
|
|
reconciliation_mdr: this.data.reconciliation_mdr ?? null,
|
|
payment_total_net_profit: net_profit,
|
|
payment_date: this.data.payment_date ?? this.oldData.payment_date,
|
|
payment_date_bank: this.data.payment_date_bank ?? null,
|
|
});
|
|
|
|
return;
|
|
}
|
|
|
|
async afterProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
get validateRelations(): validateRelations[] {
|
|
return [];
|
|
}
|
|
|
|
get uniqueColumns(): columnUniques[] {
|
|
return [];
|
|
}
|
|
|
|
get entityTarget(): any {
|
|
return TransactionModel;
|
|
}
|
|
|
|
get eventTopics(): EventTopics[] {
|
|
return [
|
|
{
|
|
topic: TransactionUpdatedEvent,
|
|
},
|
|
];
|
|
}
|
|
}
|