pos-be/src/modules/transaction/refund/domain/usecases/managers/detail-refund.manager.ts

66 lines
1.8 KiB
TypeScript

import { Injectable } from '@nestjs/common';
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
import { RefundEntity } from '../../entities/refund.entity';
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';
import { mappingTransaction } from 'src/modules/transaction/transaction/domain/usecases/managers/helpers/mapping-transaction.helper';
@Injectable()
export class DetailRefundManager extends BaseDetailManager<RefundEntity> {
async prepareData(): Promise<void> {
return;
}
async beforeProcess(): Promise<void> {
return;
}
async afterProcess(): Promise<void> {
mappingTransaction(this.result['transaction']);
return;
}
get relations(): RelationParam {
return {
// relation only join (for query purpose)
joinRelations: [],
// relation join and select (relasi yang ingin ditampilkan),
selectRelations: ['transaction', 'transaction.items', 'items.refund'],
// relation yang hanya ingin dihitung (akan return number)
countRelations: [],
};
}
get selects(): string[] {
return [
`${this.tableName}.id`,
`${this.tableName}.code`,
`${this.tableName}.status`,
`${this.tableName}.type`,
`${this.tableName}.request_date`,
`${this.tableName}.refund_date`,
`${this.tableName}.created_at`,
`${this.tableName}.updated_at`,
`${this.tableName}.creator_name`,
`${this.tableName}.editor_name`,
`${this.tableName}.refund_total`,
`${this.tableName}.bank_name`,
`${this.tableName}.bank_account_name`,
`${this.tableName}.bank_account_number`,
'transaction',
'items',
'refund',
];
}
get setFindProperties(): any {
return {
id: this.dataId,
};
}
}