52 lines
1.3 KiB
TypeScript
52 lines
1.3 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 { 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_total,
|
|
});
|
|
|
|
return;
|
|
}
|
|
|
|
async afterProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
get validateRelations(): validateRelations[] {
|
|
return [];
|
|
}
|
|
|
|
get uniqueColumns(): columnUniques[] {
|
|
return [];
|
|
}
|
|
|
|
get entityTarget(): any {
|
|
return TransactionModel;
|
|
}
|
|
|
|
get eventTopics(): EventTopics[] {
|
|
return [];
|
|
}
|
|
}
|