Compare commits

..

12 Commits

Author SHA1 Message Date
shancheas 7bb539db0c fix(SPG-1266): Penyesuaian time zone server untuk field pilih waktu - meminimalisasi timezone user/ client 2025-06-25 16:39:01 +07:00
shancheas 92b54635d0 fix(SPG-1262): ONLINE BOOKING - Redirect ke antrian jika tidak sama dengan today - seharusnya diarahkan ke halaman login jika invoice tidak sama dengan today 2025-06-25 15:48:59 +07:00
shancheas 7be4c26ef2 fix(SPG-1270): Pada Invoice/ tagihan booking tambahkan kode booking nya dan informasi booking date dan jumlah yang harus dibayarkan 2025-06-25 15:19:59 +07:00
shancheas 23b3c31810 refactor(SPG-1199): remove unique constraint on item name and update validation logic in item managers 2025-06-25 14:52:41 +07:00
shancheas b96d24de1a feat: add query filter for active booking items in BookingItemManager 2025-06-24 12:44:00 +07:00
shancheas 5d3f9d7bff fix(SPG-1254): ONLINE BOOKING wahana tenant tidak muncul pada catalog online booking 2025-06-24 11:51:43 +07:00
shancheas 831593e743 Merge branch 'development' of ssh://git.eigen.co.id:2222/eigen/pos-be into development 2025-06-20 14:48:55 +07:00
shancheas 162bd0918f fix: ensure safe access to season period IDs in booking item pricing logic 2025-06-20 14:48:45 +07:00
firmanr 13b5838393 Merge pull request 'feat(SPG-1137): add time group at booking and refund detail' (#161) from feat/otp-cancel into development
Reviewed-on: #161
2025-06-19 18:43:57 +07:00
Firman Ramdhani 63bb55b04b feat(SPG-1137): add time group at booking and refund detail 2025-06-19 18:30:07 +07:00
firmanr 9d1c240b6b Merge pull request 'feat(SPG-1236): setup otp checker guard' (#160) from feat/otp-cancel into development
Reviewed-on: #160
2025-06-19 17:10:07 +07:00
Firman Ramdhani 83f3377465 feat(SPG-1236): setup otp checker guard 2025-06-19 17:09:42 +07:00
17 changed files with 168 additions and 29 deletions

View File

@ -48,7 +48,7 @@ export class OtpCheckerGuard implements CanActivate {
}); });
} }
console.log({ dataIdentity, otpCode, otpData }); // console.log({ dataIdentity, otpCode, otpData });
if (otpData && otpData?.verified_at) return true; if (otpData && otpData?.verified_at) return true;
} }

View File

@ -55,7 +55,7 @@ export class ValidateRelationHelper<Entity> {
const relationColumn = const relationColumn =
data[relation.relation]?.[`${relation.singleQuery[0]}`]; data[relation.relation]?.[`${relation.singleQuery[0]}`];
if ( if (
!!relationColumn && // !!relationColumn &&
this.mappingValidator( this.mappingValidator(
relationColumn, relationColumn,
relation.singleQuery[1], relation.singleQuery[1],

View File

@ -0,0 +1,17 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class RemoveItemNameUnique1750834308368 implements MigrationInterface {
name = 'RemoveItemNameUnique1750834308368';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "items" DROP CONSTRAINT "UQ_213736582899b3599acaade2cd1"`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "items" ADD CONSTRAINT "UQ_213736582899b3599acaade2cd1" UNIQUE ("name")`,
);
}
}

View File

@ -43,7 +43,7 @@ export class BookingItemManager extends IndexItemManager {
const hasRates = (this.filterParam.season_period_ids?.length ?? 0) > 0; const hasRates = (this.filterParam.season_period_ids?.length ?? 0) > 0;
const items = data.map((item) => { const items = data.map((item) => {
const currentRate = item.item_rates.find((rate) => const currentRate = item.item_rates.find((rate) =>
this.filterParam.season_period_ids.includes(rate.season_period_id), this.filterParam.season_period_ids?.includes(rate.season_period_id),
); );
const { item_rates, ...rest } = item; const { item_rates, ...rest } = item;
const rate = currentRate?.['price'] ?? rest.base_price; const rate = currentRate?.['price'] ?? rest.base_price;
@ -54,4 +54,14 @@ export class BookingItemManager extends IndexItemManager {
}); });
return { total, data: items }; return { total, data: items };
} }
setQueryFilter(
queryBuilder: SelectQueryBuilder<ItemEntity>,
): SelectQueryBuilder<ItemEntity> {
const query = super.setQueryFilter(queryBuilder);
query.andWhere(`${this.tableName}.status = 'active'`);
return query;
}
} }

View File

@ -57,6 +57,7 @@ export class CreateBookingManager extends CreateTransactionManager {
time: this.data.booking_date, time: this.data.booking_date,
id: this.data.id, id: this.data.id,
}, },
this.data.payment_total,
`snap/v4/redirection/${this.data.payment_midtrans_token}`, `snap/v4/redirection/${this.data.payment_midtrans_token}`,
); );
} }

View File

@ -23,6 +23,7 @@ export class ItemController {
): Promise<PaginationResponse<ItemEntity>> { ): Promise<PaginationResponse<ItemEntity>> {
params.limit = 1000; params.limit = 1000;
params.show_to_booking = true; params.show_to_booking = true;
params.all_item = true;
this.indexManager.setFilterParam(params); this.indexManager.setFilterParam(params);
this.indexManager.setService(this.serviceData, TABLE_NAME.ITEM); this.indexManager.setService(this.serviceData, TABLE_NAME.ITEM);
await this.indexManager.execute(); await this.indexManager.execute();

View File

@ -25,7 +25,7 @@ export class ItemModel
extends BaseStatusModel<ItemEntity> extends BaseStatusModel<ItemEntity>
implements ItemEntity implements ItemEntity
{ {
@Column('varchar', { name: 'name', unique: true }) @Column('varchar', { name: 'name' })
name: string; name: string;
@Column('text', { name: 'booking_description', nullable: true }) @Column('text', { name: 'booking_description', nullable: true })

View File

@ -8,6 +8,7 @@ import { ItemEntity } from '../../entities/item.entity';
import { ItemModel } from '../../../data/models/item.model'; import { ItemModel } from '../../../data/models/item.model';
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager'; import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
import { ItemCreatedEvent } from '../../entities/event/item-created.event'; import { ItemCreatedEvent } from '../../entities/event/item-created.event';
import { STATUS } from 'src/core/strings/constants/base.constants';
@Injectable() @Injectable()
export class CreateItemManager extends BaseCreateManager<ItemEntity> { export class CreateItemManager extends BaseCreateManager<ItemEntity> {
@ -29,11 +30,37 @@ export class CreateItemManager extends BaseCreateManager<ItemEntity> {
} }
get validateRelations(): validateRelations[] { get validateRelations(): validateRelations[] {
return []; const timeGroupId = this.data.time_group_id ?? this.data.time_group?.id;
const relation =
this.data.bundling_items?.length > 0
? 'bundling_items'
: 'bundling_parents';
return timeGroupId != null
? [
{
relation: relation,
singleQuery: ['time_group_id', '!=', timeGroupId],
message: `Gagal Update! Time group item dan bundling item tidak sama`,
},
]
: [];
} }
get uniqueColumns(): columnUniques[] { get uniqueColumns(): columnUniques[] {
return [{ column: 'name' }]; const timeGroupId = this.data.time_group_id ?? this.data.time_group?.id;
return timeGroupId != null
? [
{
column: 'name',
query: `(status = '${STATUS.ACTIVE}' AND (${this.tableName}.time_group_id Is Null OR ${this.tableName}.time_group_id = '${timeGroupId}'))`,
},
]
: [
{
column: 'name',
query: `(status = '${STATUS.ACTIVE}')`,
},
];
} }
get eventTopics(): EventTopics[] { get eventTopics(): EventTopics[] {

View File

@ -8,6 +8,7 @@ import {
columnUniques, columnUniques,
validateRelations, validateRelations,
} from 'src/core/strings/constants/interface.constants'; } from 'src/core/strings/constants/interface.constants';
import { STATUS } from 'src/core/strings/constants/base.constants';
@Injectable() @Injectable()
export class UpdateItemManager extends BaseUpdateManager<ItemEntity> { export class UpdateItemManager extends BaseUpdateManager<ItemEntity> {
@ -39,11 +40,31 @@ export class UpdateItemManager extends BaseUpdateManager<ItemEntity> {
} }
get validateRelations(): validateRelations[] { get validateRelations(): validateRelations[] {
return []; const timeGroupId = this.data.time_group_id ?? this.data.time_group?.id;
const relation =
this.data.bundling_items?.length > 0
? 'bundling_items'
: 'bundling_parents';
return timeGroupId != null
? [
{
relation: relation,
singleQuery: ['time_group_id', '!=', timeGroupId],
message: `Gagal Update! Time group item dan bundling item tidak sama`,
},
]
: [];
} }
get uniqueColumns(): columnUniques[] { get uniqueColumns(): columnUniques[] {
return []; const timeGroupId = this.data.time_group_id ?? this.data.time_group?.id;
return [
{
column: 'name',
query: `(status = '${STATUS.ACTIVE}' AND (${this.tableName}.time_group_id Is Null OR ${this.tableName}.time_group_id = '${timeGroupId}'))`,
},
];
} }
get entityTarget(): any { get entityTarget(): any {

View File

@ -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;
} }
} }

View File

@ -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;
} }

View File

@ -51,27 +51,27 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
], ],
}); });
if (!order) { // if (!order) {
const { customer_name, customer_phone } = // const { customer_name, customer_phone } =
await this.transaction.findOneOrFail({ // await this.transaction.findOneOrFail({
where: { // where: {
id, // id,
}, // },
}); // });
const start = moment().startOf('day').valueOf(); // const start = moment().startOf('day').valueOf();
const end = moment().endOf('day').valueOf(); // const end = moment().endOf('day').valueOf();
const order = this.order.findOneOrFail({ // const order = this.order.findOneOrFail({
relations: ['tickets'], // relations: ['tickets'],
where: { // where: {
customer: customer_name, // customer: customer_name,
phone: customer_phone, // phone: customer_phone,
date: Between(start, end), // date: Between(start, end),
}, // },
}); // });
return order; // return order;
} // }
return order; return order;
} }

View File

@ -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',
}); });
} }

View File

@ -31,6 +31,10 @@ export class DetailRefundManager extends BaseDetailManager<RefundEntity> {
'items.bundling_items', 'items.bundling_items',
'items.refunds item_refunds', 'items.refunds item_refunds',
'item_refunds.refund item_refunds_refund', 'item_refunds.refund item_refunds_refund',
'transaction.items transaction_items',
'transaction_items.item transaction_items_item',
'transaction_items_item.time_group transaction_items_item_time_group',
], ],
// relation yang hanya ingin dihitung (akan return number) // relation yang hanya ingin dihitung (akan return number)
@ -65,6 +69,10 @@ export class DetailRefundManager extends BaseDetailManager<RefundEntity> {
'item_refunds', 'item_refunds',
'item_refunds_refund.id', 'item_refunds_refund.id',
'item_refunds_refund.status', 'item_refunds_refund.status',
'transaction_items',
'transaction_items_item',
'transaction_items_item_time_group',
]; ];
} }

View File

@ -31,6 +31,9 @@ export class DetailTransactionManager extends BaseDetailManager<TransactionEntit
'items.refunds item_refunds', 'items.refunds item_refunds',
'item_refunds.refund item_refunds_refund', 'item_refunds.refund item_refunds_refund',
'refunds', 'refunds',
'items.item items_item',
'items_item.time_group items_item_time_group',
], ],
// relation yang hanya ingin dihitung (akan return number) // relation yang hanya ingin dihitung (akan return number)
@ -92,6 +95,8 @@ export class DetailTransactionManager extends BaseDetailManager<TransactionEntit
'item_refunds_refund.status', 'item_refunds_refund.status',
'refunds', 'refunds',
'items_item',
'items_item_time_group',
]; ];
} }

View File

@ -43,6 +43,8 @@ export function mappingTransaction(data, refundId?: string) {
if (refundId) if (refundId)
refund = itemData.refunds?.find((item) => item.refund.id == refundId); refund = itemData.refunds?.find((item) => item.refund.id == refundId);
const timeGroup = itemData?.item?.time_group;
return { return {
item: { item: {
id: itemData.item_id, id: itemData.item_id,
@ -57,6 +59,7 @@ export function mappingTransaction(data, refundId?: string) {
}, },
breakdown_bundling: itemData.breakdown_bundling, breakdown_bundling: itemData.breakdown_bundling,
bundling_items: itemData.bundling_items, bundling_items: itemData.bundling_items,
time_group: timeGroup,
}, },
id: itemData.id, id: itemData.id,
refund: refund, refund: refund,

View File

@ -324,10 +324,23 @@ export class WhatsappService {
); );
} }
async bookingRegister(data: WhatsappBookingCreate, paymentUrl: string) { async bookingRegister(
data: WhatsappBookingCreate,
total: number,
paymentUrl: string,
) {
const momentDate = moment(data.time); const momentDate = moment(data.time);
const fallbackValue = momentDate.locale('id').format('dddd, DD MMMM YYYY'); const fallbackValue = momentDate.locale('id').format('dddd, DD MMMM YYYY');
const formattedTotal = new Intl.NumberFormat('id-ID', {
style: 'currency',
currency: 'IDR',
minimumFractionDigits: 0,
maximumFractionDigits: 0,
})
.format(total)
.replace('IDR', 'Rp');
const payload = { const payload = {
messaging_product: 'whatsapp', messaging_product: 'whatsapp',
to: phoneNumberOnly(data.phone), // recipient's phone number to: phoneNumberOnly(data.phone), // recipient's phone number
@ -351,6 +364,16 @@ export class WhatsappService {
parameter_name: 'booking_date', parameter_name: 'booking_date',
text: fallbackValue, text: fallbackValue,
}, },
{
type: 'text',
parameter_name: 'booking_code',
text: data.code,
},
{
type: 'text',
parameter_name: 'total',
text: formattedTotal,
},
], ],
}, },
{ {