fix(SPG-600) Filter Sumber, Tipe, Kontak pada index booking belum berjalan

pull/28/head
Aswin Ashar Abdullah 2024-07-15 12:43:17 +07:00
parent 2a8d5e87cf
commit 001f371244
2 changed files with 77 additions and 2 deletions

View File

@ -33,4 +33,6 @@ export interface FilterTransactionEntity extends BaseFilterEntity {
invoice_date_to?: Date; invoice_date_to?: Date;
settlement_date_from?: Date; settlement_date_from?: Date;
settlement_date_to?: Date; settlement_date_to?: Date;
request_refund_date_from?: Date;
request_refund_date_to?: Date;
} }

View File

@ -6,6 +6,7 @@ import {
Param, Param,
RelationParam, RelationParam,
} from 'src/core/modules/domain/entities/base-filter.entity'; } from 'src/core/modules/domain/entities/base-filter.entity';
import { BetweenQueryHelper } from 'src/core/helpers/query/between-query.helper';
@Injectable() @Injectable()
export class IndexTransactionManager extends BaseIndexManager<TransactionEntity> { export class IndexTransactionManager extends BaseIndexManager<TransactionEntity> {
@ -75,14 +76,43 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
`refund.id`, `refund.id`,
`refund.code`, `refund.code`,
`refund.refund_date`, `refund.refund_date`,
`refund.request_date`,
]; ];
} }
get specificFilter(): Param[] { get specificFilter(): Param[] {
return [ return [
{ {
cols: `${this.tableName}.name`, cols: `${this.tableName}.invoice_code`,
data: this.filterParam.names, 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<TransactionEntity>
setQueryFilter( setQueryFilter(
queryBuilder: SelectQueryBuilder<TransactionEntity>, queryBuilder: SelectQueryBuilder<TransactionEntity>,
): SelectQueryBuilder<TransactionEntity> { ): SelectQueryBuilder<TransactionEntity> {
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`); queryBuilder.andWhere(`${this.tableName}.is_recap_transaction is false`);
return queryBuilder; return queryBuilder;
} }