Compare commits
4 Commits
1.6.25-alp
...
developmen
Author | SHA1 | Date |
---|---|---|
|
e1d8975dda | |
|
e25ad6500f | |
|
7bb539db0c | |
|
92b54635d0 |
|
@ -52,13 +52,12 @@ export class CreateItemManager extends BaseCreateManager<ItemEntity> {
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
column: 'name',
|
column: 'name',
|
||||||
query: `(status = '${STATUS.ACTIVE}' AND (${this.tableName}.time_group_id Is Null OR ${this.tableName}.time_group_id = '${timeGroupId}'))`,
|
query: `((${this.tableName}.time_group_id Is Null OR ${this.tableName}.time_group_id = '${timeGroupId}'))`,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
column: 'name',
|
column: 'name',
|
||||||
query: `(status = '${STATUS.ACTIVE}')`,
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ export class UpdateItemManager extends BaseUpdateManager<ItemEntity> {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
column: 'name',
|
column: 'name',
|
||||||
query: `(status = '${STATUS.ACTIVE}' AND (${this.tableName}.time_group_id Is Null OR ${this.tableName}.time_group_id = '${timeGroupId}'))`,
|
query: `((${this.tableName}.time_group_id Is Null OR ${this.tableName}.time_group_id = '${timeGroupId}'))`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import {
|
||||||
Param,
|
Param,
|
||||||
RelationParam,
|
RelationParam,
|
||||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||||
|
import * as moment from 'moment';
|
||||||
|
import { ORDER_TYPE } from 'src/core/strings/constants/base.constants';
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// Implementasikan filter by start_time, end_timen, dan max_usage_time
|
// Implementasikan filter by start_time, end_timen, dan max_usage_time
|
||||||
|
@ -13,6 +15,10 @@ import {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class IndexPublicTimeGroupManager extends BaseIndexManager<TimeGroupEntity> {
|
export class IndexPublicTimeGroupManager extends BaseIndexManager<TimeGroupEntity> {
|
||||||
async prepareData(): Promise<void> {
|
async prepareData(): Promise<void> {
|
||||||
|
Object.assign(this.filterParam, {
|
||||||
|
order_by: `${this.tableName}.start_time`,
|
||||||
|
order_type: ORDER_TYPE.ASC,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +66,15 @@ export class IndexPublicTimeGroupManager extends BaseIndexManager<TimeGroupEntit
|
||||||
queryBuilder: SelectQueryBuilder<TimeGroupEntity>,
|
queryBuilder: SelectQueryBuilder<TimeGroupEntity>,
|
||||||
): SelectQueryBuilder<TimeGroupEntity> {
|
): SelectQueryBuilder<TimeGroupEntity> {
|
||||||
queryBuilder.andWhere(`items.id is not null`);
|
queryBuilder.andWhere(`items.id is not null`);
|
||||||
|
|
||||||
|
if (!this.filterParam.date) {
|
||||||
|
const currentTime = moment().utcOffset('+07:00').format('HH:mm:ss');
|
||||||
|
|
||||||
|
queryBuilder.andWhere(`${this.tableName}.end_time >= :current_time`, {
|
||||||
|
current_time: currentTime,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return queryBuilder;
|
return queryBuilder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,12 @@ export class FilterTimeGroupDto
|
||||||
@ApiProperty({ type: 'string', required: false })
|
@ApiProperty({ type: 'string', required: false })
|
||||||
@ValidateIf((body) => body.max_usage_time_to)
|
@ValidateIf((body) => body.max_usage_time_to)
|
||||||
max_usage_time_to: string;
|
max_usage_time_to: string;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: Date,
|
||||||
|
required: false,
|
||||||
|
example: '2024-01-01',
|
||||||
|
})
|
||||||
|
@ValidateIf((body) => body.date)
|
||||||
|
date: Date;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
|
||||||
await this.transaction.findOneOrFail({
|
await this.transaction.findOneOrFail({
|
||||||
where: {
|
where: {
|
||||||
id,
|
id,
|
||||||
|
booking_date: new Date(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ export class QueueOrchestrator {
|
||||||
return order;
|
return order;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new UnauthorizedException({
|
throw new UnauthorizedException({
|
||||||
message: 'Invoice tidak ditemukan',
|
message: 'Invoice tidak ditemukan untuk tanggal hari ini',
|
||||||
error: 'INVOICE_NOT_FOUND',
|
error: 'INVOICE_NOT_FOUND',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ export class GenerateQueueManager {
|
||||||
async generate(transaction: TransactionModel) {
|
async generate(transaction: TransactionModel) {
|
||||||
const date = transaction.booking_date ?? transaction.invoice_date;
|
const date = transaction.booking_date ?? transaction.invoice_date;
|
||||||
const queue_date = moment(date, 'YYYY-MM-DD').unix();
|
const queue_date = moment(date, 'YYYY-MM-DD').unix();
|
||||||
|
const isToday = moment(date, 'YYYY-MM-DD').isSame(moment(), 'day');
|
||||||
|
|
||||||
const { id, customer_name, customer_phone, invoice_code } = transaction;
|
const { id, customer_name, customer_phone, invoice_code } = transaction;
|
||||||
|
|
||||||
|
@ -40,10 +41,9 @@ export class GenerateQueueManager {
|
||||||
|
|
||||||
const items = this.generateItems(transaction.items);
|
const items = this.generateItems(transaction.items);
|
||||||
|
|
||||||
const existTicket = await this.ticketService.ticketByUser(
|
const existTicket = isToday
|
||||||
customer_name,
|
? await this.ticketService.ticketByUser(customer_name, customer_phone)
|
||||||
customer_phone,
|
: null;
|
||||||
);
|
|
||||||
|
|
||||||
const insertTickets: QueueTicket[] = [];
|
const insertTickets: QueueTicket[] = [];
|
||||||
if (customer_name && customer_phone && existTicket) {
|
if (customer_name && customer_phone && existTicket) {
|
||||||
|
|
Loading…
Reference in New Issue