Merge pull request 'fix/data' (#32) from fix/data into development
continuous-integration/drone/tag Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
Reviewed-on: #32pull/34/head devel_10.6.21
commit
41f4773df6
|
@ -13,9 +13,11 @@ export abstract class BaseReadService<Entity> {
|
|||
queryBuilder: SelectQueryBuilder<Entity>,
|
||||
params: BaseFilterEntity,
|
||||
): Promise<PaginationResponse<Entity>> {
|
||||
const limit = params.limit ?? 10;
|
||||
const page = params.page ?? 1;
|
||||
const [data, total] = await queryBuilder
|
||||
.take(+params.limit)
|
||||
.skip(+params.limit * +params.page - +params.limit)
|
||||
.take(+limit)
|
||||
.skip(+limit * +page - +limit)
|
||||
.getManyAndCount();
|
||||
|
||||
return {
|
||||
|
|
|
@ -6,10 +6,7 @@ import { Global, Module } from '@nestjs/common';
|
|||
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(),
|
||||
CqrsModule,
|
||||
],
|
||||
imports: [ConfigModule.forRoot(), CqrsModule],
|
||||
controllers: [MidtransController],
|
||||
providers: [MidtransService],
|
||||
exports: [MidtransService],
|
||||
|
|
|
@ -124,8 +124,6 @@ export class IndexItemRateManager extends BaseIndexManager<ItemEntity> {
|
|||
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
|
||||
tenantIds: this.filterParam.tenant_ids,
|
||||
});
|
||||
} else if (!this.filterParam.all_item) {
|
||||
queryBuilder.andWhere(`${this.tableName}.tenant_id Is Null`);
|
||||
}
|
||||
|
||||
return queryBuilder;
|
||||
|
|
|
@ -72,17 +72,17 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
}
|
||||
|
||||
if (this.filterParam.season_period_ids) {
|
||||
queryBuilder.andWhere(`season_period.id In (:...itemIds)`, {
|
||||
itemIds: this.filterParam.season_period_ids,
|
||||
queryBuilder.andWhere(`season_period.id In (:...seasonIdss)`, {
|
||||
seasonIdss: this.filterParam.season_period_ids,
|
||||
});
|
||||
}
|
||||
|
||||
if (this.filterParam.start_date) {
|
||||
queryBuilder.andWhere(`season_period.start_date < :inputStartDate`, {
|
||||
queryBuilder.andWhere(`season_period.start_date <= :inputStartDate`, {
|
||||
inputStartDate: this.filterParam.end_date,
|
||||
});
|
||||
|
||||
queryBuilder.andWhere(`season_period.end_date > :inputEndDate`, {
|
||||
queryBuilder.andWhere(`season_period.end_date >= :inputEndDate`, {
|
||||
inputEndDate: this.filterParam.start_date,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -85,8 +85,6 @@ export class IndexItemManager extends BaseIndexManager<ItemEntity> {
|
|||
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
|
||||
tenantIds: this.filterParam.tenant_ids,
|
||||
});
|
||||
} else if (!this.filterParam.all_item) {
|
||||
queryBuilder.andWhere(`${this.tableName}.tenant_id Is Null`);
|
||||
}
|
||||
|
||||
return queryBuilder;
|
||||
|
|
|
@ -69,13 +69,12 @@ export class CurrentSeasonPeriodManager extends BaseIndexManager<SeasonPeriodEnt
|
|||
setQueryFilter(
|
||||
queryBuilder: SelectQueryBuilder<SeasonPeriodEntity>,
|
||||
): SelectQueryBuilder<SeasonPeriodEntity> {
|
||||
queryBuilder.andWhere(
|
||||
`${this.tableName}.start_date BETWEEN :from AND :to`,
|
||||
{
|
||||
from: this.filterParam.date ?? new Date().toLocaleDateString(),
|
||||
to: this.filterParam.date ?? new Date().toLocaleDateString(),
|
||||
},
|
||||
);
|
||||
queryBuilder.andWhere(`${this.tableName}.start_date <= :date`, {
|
||||
date: this.filterParam.date ?? new Date().toLocaleDateString(),
|
||||
});
|
||||
queryBuilder.andWhere(`${this.tableName}.end_date >= :date`, {
|
||||
date: this.filterParam.date ?? new Date().toLocaleDateString(),
|
||||
});
|
||||
|
||||
queryBuilder.andWhere(`${this.tableName}.status In (:...statuses)`, {
|
||||
statuses: [STATUS.ACTIVE],
|
||||
|
|
|
@ -38,10 +38,10 @@ export async function ValidateSeasonPeriodHelper(dataService, data) {
|
|||
|
||||
let datas = await query
|
||||
.andWhere('data.priority = :priority', { priority: priority })
|
||||
.andWhere(`data.start_date < :inputStartDate`, {
|
||||
.andWhere(`data.start_date <= :inputStartDate`, {
|
||||
inputStartDate: data.end_date,
|
||||
})
|
||||
.andWhere(`data.end_date > :inputEndDate`, {
|
||||
.andWhere(`data.end_date >= :inputEndDate`, {
|
||||
inputEndDate: data.start_date,
|
||||
})
|
||||
.getMany();
|
||||
|
|
|
@ -87,11 +87,11 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
|
|||
data: this.filterParam.invoice_codes,
|
||||
},
|
||||
{
|
||||
cols: `${this.tableName}.type`,
|
||||
cols: `${this.tableName}.type::text`,
|
||||
data: this.filterParam.types,
|
||||
},
|
||||
{
|
||||
cols: `${this.tableName}.customer_type`,
|
||||
cols: `${this.tableName}.customer_type::text`,
|
||||
data: this.filterParam.customer_types,
|
||||
},
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
|
|||
data: this.filterParam.customer_names,
|
||||
},
|
||||
{
|
||||
cols: `${this.tableName}.payment_type`,
|
||||
cols: `${this.tableName}.payment_type::text`,
|
||||
data: this.filterParam.payment_types,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -6,10 +6,13 @@ import {
|
|||
Param,
|
||||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
import { ORDER_TYPE } from 'src/core/strings/constants/base.constants';
|
||||
|
||||
@Injectable()
|
||||
export class IndexFaqManager extends BaseIndexManager<FaqEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
this.filterParam.order_by = `${this.tableName}.sort_order`;
|
||||
this.filterParam.order_type = ORDER_TYPE.ASC;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,6 +41,7 @@ export class IndexFaqManager extends BaseIndexManager<FaqEntity> {
|
|||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.sort_order`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.updated_at`,
|
||||
|
|
|
@ -6,10 +6,13 @@ import {
|
|||
Param,
|
||||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
import { ORDER_TYPE } from 'src/core/strings/constants/base.constants';
|
||||
|
||||
@Injectable()
|
||||
export class IndexTermConditionManager extends BaseIndexManager<TermConditionEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
this.filterParam.order_by = `${this.tableName}.sort_order`;
|
||||
this.filterParam.order_type = ORDER_TYPE.ASC;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,6 +41,7 @@ export class IndexTermConditionManager extends BaseIndexManager<TermConditionEnt
|
|||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.sort_order`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.updated_at`,
|
||||
|
|
Loading…
Reference in New Issue