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[]; data: string[];
additional?: any[]; additional?: any[];
leftJoin?: any[]; leftJoin?: any[];
isStatus?: boolean;
} }
export interface RelationParam { export interface RelationParam {

View File

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

View File

@ -65,6 +65,11 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
get specificFilter(): Param[] { get specificFilter(): Param[] {
return [ return [
{
cols: `${this.tableName}.reconciliation_status::text`,
data: this.filterParam.statuses,
isStatus: true,
},
{ {
cols: `${this.tableName}.customer_name`, cols: `${this.tableName}.customer_name`,
data: this.filterParam.customer_names, data: this.filterParam.customer_names,
@ -115,36 +120,46 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
if (this.filterParam.payment_type) { if (this.filterParam.payment_type) {
queryBuilder.andWhere( 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) { if (this.filterParam.payment_via) {
queryBuilder.andWhere(`${this.tableName}.payment_type In (:...type)`, { queryBuilder.andWhere(
type: [this.filterParam.payment_via], `${this.tableName}.payment_type::text In (:...type)`,
}); {
type: [`%${this.filterParam.payment_via}%`],
},
);
} }
if (this.filterParam.payment_bank) { if (this.filterParam.payment_bank) {
queryBuilder.andWhere( 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) { 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( new BetweenQueryHelper(
queryBuilder, queryBuilder,
this.tableName, this.tableName,
'payment_date', 'reconciliation_confirm_date',
this.filterParam.confirmation_date_from, confirmationDateFrom,
this.filterParam.confirmation_date_to, confirmationDateTo,
'payment_created', 'reconciliation_confirm_dated',
).getQuery(); ).getQuery();
} }