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

85 lines
2.4 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'], this.dataId);
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.bundling_items',
'items.refunds item_refunds',
'item_refunds.refund item_refunds_refund',
'transaction.items transaction_items',
'transaction_items.item transaction_items_item',
'transaction_items_item.time_group transaction_items_item_time_group',
],
// 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}.refund_reason`,
`${this.tableName}.refund_reason_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',
'bundling_items',
'item_refunds',
'item_refunds_refund.id',
'item_refunds_refund.status',
'transaction_items',
'transaction_items_item',
'transaction_items_item_time_group',
];
}
get setFindProperties(): any {
return {
id: this.dataId,
};
}
}