fix(item) perbaikan item price
parent
4840abf18e
commit
908834cdd9
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue