fix(SPG-742) Filter status, sumber, tipe pembayaran, pembayaran via, bank, tgl konfirmasi belum jalan

fix/data
Aswin Ashar Abdullah 2024-08-02 15:16:43 +07:00
parent 1636f6b930
commit e401a1bf4c
3 changed files with 35 additions and 15 deletions

View File

@ -22,6 +22,7 @@ export interface Param {
data: string[];
additional?: any[];
leftJoin?: any[];
isStatus?: boolean;
}
export interface RelationParam {

View File

@ -52,11 +52,15 @@ export abstract class BaseIndexManager<Entity> extends BaseReadManager {
// ? karena jika tidak, ketika dia search "active" maka "inactive" juga ikut
return `'${STATUS[statusData.toUpperCase()]}'` ?? `'%${statusData}%'`;
});
const exist = specificFilter.find((item) => item.isStatus);
if (!exist) {
specificFilter.push({
cols: `${this.tableName}.status::text`,
data: data,
});
}
}
new SpecificSearchFilter<Entity>(
this.queryBuilder,

View File

@ -65,6 +65,11 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
get specificFilter(): Param[] {
return [
{
cols: `${this.tableName}.reconciliation_status::text`,
data: this.filterParam.statuses,
isStatus: true,
},
{
cols: `${this.tableName}.customer_name`,
data: this.filterParam.customer_names,
@ -115,36 +120,46 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
if (this.filterParam.payment_type) {
queryBuilder.andWhere(
`${this.tableName}.creator_counter_no In (:...counters)`,
`${this.tableName}.payment_type::text In (:...paymentType)`,
{
counters: [this.filterParam.couner_no],
paymentType: [this.filterParam.payment_type],
},
);
}
if (this.filterParam.payment_via) {
queryBuilder.andWhere(`${this.tableName}.payment_type In (:...type)`, {
type: [this.filterParam.payment_via],
});
queryBuilder.andWhere(
`${this.tableName}.payment_type::text In (:...type)`,
{
type: [`%${this.filterParam.payment_via}%`],
},
);
}
if (this.filterParam.payment_bank) {
queryBuilder.andWhere(
`${this.tableName}.payment_type_method_name In (:...banks)`,
`${this.tableName}.payment_type_method_name::text In (:...banks)`,
{
banks: [this.filterParam.payment_bank],
banks: [`%${this.filterParam.payment_bank}%`],
},
);
}
if (this.filterParam.confirmation_date_from) {
const confirmationDateFrom = new Date(
this.filterParam?.confirmation_date_from,
).getTime();
const confirmationDateTo = new Date(
`${this.filterParam?.confirmation_date_to?.split(' ')[0]} 23:59:59`,
).getTime();
new BetweenQueryHelper(
queryBuilder,
this.tableName,
'payment_date',
this.filterParam.confirmation_date_from,
this.filterParam.confirmation_date_to,
'payment_created',
'reconciliation_confirm_date',
confirmationDateFrom,
confirmationDateTo,
'reconciliation_confirm_dated',
).getQuery();
}