diff --git a/src/modules/transaction/transaction/domain/entities/filter-transaction.entity.ts b/src/modules/transaction/transaction/domain/entities/filter-transaction.entity.ts index 719a7fb..8340ea6 100644 --- a/src/modules/transaction/transaction/domain/entities/filter-transaction.entity.ts +++ b/src/modules/transaction/transaction/domain/entities/filter-transaction.entity.ts @@ -33,4 +33,6 @@ export interface FilterTransactionEntity extends BaseFilterEntity { invoice_date_to?: Date; settlement_date_from?: Date; settlement_date_to?: Date; + request_refund_date_from?: Date; + request_refund_date_to?: Date; } diff --git a/src/modules/transaction/transaction/domain/usecases/managers/index-transaction.manager.ts b/src/modules/transaction/transaction/domain/usecases/managers/index-transaction.manager.ts index 7160db2..4b0abfb 100644 --- a/src/modules/transaction/transaction/domain/usecases/managers/index-transaction.manager.ts +++ b/src/modules/transaction/transaction/domain/usecases/managers/index-transaction.manager.ts @@ -6,6 +6,7 @@ import { Param, RelationParam, } from 'src/core/modules/domain/entities/base-filter.entity'; +import { BetweenQueryHelper } from 'src/core/helpers/query/between-query.helper'; @Injectable() export class IndexTransactionManager extends BaseIndexManager { @@ -75,14 +76,43 @@ export class IndexTransactionManager extends BaseIndexManager `refund.id`, `refund.code`, `refund.refund_date`, + `refund.request_date`, ]; } get specificFilter(): Param[] { return [ { - cols: `${this.tableName}.name`, - data: this.filterParam.names, + cols: `${this.tableName}.invoice_code`, + data: this.filterParam.invoice_codes, + }, + { + cols: `${this.tableName}.type`, + data: this.filterParam.types, + }, + { + cols: `${this.tableName}.customer_type`, + data: this.filterParam.customer_types, + }, + { + cols: `${this.tableName}.customer_name`, + data: this.filterParam.customer_names, + }, + { + cols: `${this.tableName}.payment_type`, + data: this.filterParam.payment_types, + }, + { + cols: `${this.tableName}.payment_bank`, + data: this.filterParam.payment_banks, + }, + { + cols: `refund.code`, + data: this.filterParam.refund_codes, + }, + { + cols: `${this.tableName}.creator_name`, + data: this.filterParam.creator_names, }, ]; } @@ -90,6 +120,49 @@ export class IndexTransactionManager extends BaseIndexManager setQueryFilter( queryBuilder: SelectQueryBuilder, ): SelectQueryBuilder { + if (this.filterParam.booking_date_from) { + new BetweenQueryHelper( + queryBuilder, + this.tableName, + 'booking_date', + this.filterParam.booking_date_from, + this.filterParam.booking_date_to, + 'booking_date', + ).getQuery(); + } + + if (this.filterParam.invoice_date_from) { + new BetweenQueryHelper( + queryBuilder, + this.tableName, + 'invoice_date', + this.filterParam.invoice_date_from, + this.filterParam.invoice_date_to, + 'invoice_date', + ).getQuery(); + } + + if (this.filterParam.settlement_date_from) { + new BetweenQueryHelper( + queryBuilder, + this.tableName, + 'settlement_date', + this.filterParam.settlement_date_from, + this.filterParam.settlement_date_to, + 'settlement_date', + ).getQuery(); + } + + if (this.filterParam.request_refund_date_from) { + new BetweenQueryHelper( + queryBuilder, + this.tableName, + 'request_refund_date', + this.filterParam.request_refund_date_from, + this.filterParam.request_refund_date_to, + 'request_refund', + ).getQuery(); + } queryBuilder.andWhere(`${this.tableName}.is_recap_transaction is false`); return queryBuilder; }