Compare commits
18 Commits
1.6.24-alp
...
developmen
Author | SHA1 | Date |
---|---|---|
|
be24ac02f7 | |
|
fd8b7cc45e | |
|
0c65754b2d | |
|
14a86343df | |
|
1e692b0b4c | |
|
99889f425a | |
|
db7bd81eac | |
|
fcf9e9459e | |
|
2c92d4b8b3 | |
|
58e062dd6c | |
|
e1d8975dda | |
|
e25ad6500f | |
|
7bb539db0c | |
|
92b54635d0 | |
|
7be4c26ef2 | |
|
23b3c31810 | |
|
b96d24de1a | |
|
5d3f9d7bff |
|
@ -52,10 +52,12 @@ export class ValidateRelationHelper<Entity> {
|
||||||
`Failed! this data already connected to ${relation.relation}`;
|
`Failed! this data already connected to ${relation.relation}`;
|
||||||
|
|
||||||
if (relation.singleQuery) {
|
if (relation.singleQuery) {
|
||||||
|
const relationObject = data[relation.relation] ?? {};
|
||||||
|
const isRelationExist = `${relation.singleQuery[0]}` in relationObject;
|
||||||
const relationColumn =
|
const relationColumn =
|
||||||
data[relation.relation]?.[`${relation.singleQuery[0]}`];
|
data[relation.relation]?.[`${relation.singleQuery[0]}`];
|
||||||
if (
|
if (
|
||||||
!!relationColumn &&
|
isRelationExist &&
|
||||||
this.mappingValidator(
|
this.mappingValidator(
|
||||||
relationColumn,
|
relationColumn,
|
||||||
relation.singleQuery[1],
|
relation.singleQuery[1],
|
||||||
|
@ -69,6 +71,7 @@ export class ValidateRelationHelper<Entity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
mappingValidator(column, operator, value) {
|
mappingValidator(column, operator, value) {
|
||||||
|
const candidates = Array.isArray(value) ? value : [value];
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case '!=':
|
case '!=':
|
||||||
return column != value;
|
return column != value;
|
||||||
|
@ -76,6 +79,12 @@ export class ValidateRelationHelper<Entity> {
|
||||||
case '==':
|
case '==':
|
||||||
return column == value;
|
return column == value;
|
||||||
|
|
||||||
|
case 'in':
|
||||||
|
return candidates.includes(column);
|
||||||
|
|
||||||
|
case 'not in':
|
||||||
|
return !candidates.includes(column);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return column == value;
|
return column == value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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")`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -21,6 +21,19 @@ export class MidtransService {
|
||||||
return diffInHours > 24;
|
return diffInHours > 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isCreatedMoreThan24HoursAgo(unixTimestamp) {
|
||||||
|
const date = moment.unix(unixTimestamp);
|
||||||
|
const now = moment();
|
||||||
|
const diffInHours = now.diff(date, 'hours');
|
||||||
|
return diffInHours > 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
isBookingDateExpired(bookingDate) {
|
||||||
|
const bookingDateMoment = moment(bookingDate);
|
||||||
|
const today = moment().startOf('day');
|
||||||
|
return bookingDateMoment.isBefore(today);
|
||||||
|
}
|
||||||
|
|
||||||
get midtransInstance() {
|
get midtransInstance() {
|
||||||
return new Snap({
|
return new Snap({
|
||||||
isProduction: false,
|
isProduction: false,
|
||||||
|
@ -38,15 +51,17 @@ export class MidtransService {
|
||||||
const responses = [];
|
const responses = [];
|
||||||
|
|
||||||
for (const transaction of pendingIds) {
|
for (const transaction of pendingIds) {
|
||||||
const { id, invoice_date } = transaction;
|
const { id, booking_date, created_at } = transaction;
|
||||||
let status;
|
let status;
|
||||||
try {
|
try {
|
||||||
status = await this.getStatus(id);
|
status = await this.getStatus(id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
status = {
|
status = {
|
||||||
order_id: id,
|
order_id: id,
|
||||||
transaction_status: this.isMoreThan24HoursAgo(invoice_date)
|
transaction_status:
|
||||||
? 'cancel'
|
this.isCreatedMoreThan24HoursAgo(created_at) ||
|
||||||
|
this.isBookingDateExpired(booking_date)
|
||||||
|
? 'expired'
|
||||||
: 'pending',
|
: 'pending',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,10 +54,12 @@ export class OtpAuthGuard implements CanActivate {
|
||||||
request.user = userLogin;
|
request.user = userLogin;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
throw new UnprocessableEntityException('Invalid OTP credentials');
|
throw new UnprocessableEntityException(
|
||||||
|
'Invalid username or password.',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new UnprocessableEntityException('Invalid OTP encoding');
|
throw new UnprocessableEntityException('Invalid username or password.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 })
|
||||||
|
|
|
@ -32,7 +32,13 @@ export class ActiveItemManager extends BaseUpdateStatusManager<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';
|
||||||
|
|
||||||
|
const validateRelations: validateRelations[] = [
|
||||||
{
|
{
|
||||||
relation: 'tenant',
|
relation: 'tenant',
|
||||||
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||||
|
@ -44,6 +50,16 @@ export class ActiveItemManager extends BaseUpdateStatusManager<ItemEntity> {
|
||||||
message: `Gagal! Terdapat item yang belum aktif`,
|
message: `Gagal! Terdapat item yang belum aktif`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (timeGroupId != null) {
|
||||||
|
validateRelations.push({
|
||||||
|
relation: relation,
|
||||||
|
singleQuery: ['time_group_id', 'not in', [timeGroupId, null]],
|
||||||
|
message: `Gagal Update! Time group item dan bundling item tidak sama`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return validateRelations;
|
||||||
}
|
}
|
||||||
|
|
||||||
get entityTarget(): any {
|
get entityTarget(): any {
|
||||||
|
|
|
@ -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,36 @@ 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', 'in', [timeGroupId, null]],
|
||||||
|
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: `((${this.tableName}.time_group_id Is Null OR ${this.tableName}.time_group_id = '${timeGroupId}'))`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
column: 'name',
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
get eventTopics(): EventTopics[] {
|
||||||
|
|
|
@ -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,37 @@ 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', 'not in', [timeGroupId, null]],
|
||||||
|
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 timeGroupId != null
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
column: 'name',
|
||||||
|
query: `((${this.tableName}.time_group_id Is Null OR ${this.tableName}.time_group_id = '${timeGroupId}'))`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
column: 'name',
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
get entityTarget(): any {
|
get entityTarget(): any {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,15 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!order) {
|
if (!order) {
|
||||||
|
// Check if id is a valid UUID format
|
||||||
|
const uuidRegex =
|
||||||
|
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||||
|
const whereCondition = !uuidRegex.test(id)
|
||||||
|
? { invoice_code: id, booking_date: new Date() }
|
||||||
|
: { id, booking_date: new Date() };
|
||||||
const { customer_name, customer_phone } =
|
const { customer_name, customer_phone } =
|
||||||
await this.transaction.findOneOrFail({
|
await this.transaction.findOneOrFail({
|
||||||
where: {
|
where: whereCondition,
|
||||||
id,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const start = moment().startOf('day').valueOf();
|
const start = moment().startOf('day').valueOf();
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
} from 'src/core/strings/constants/base.constants';
|
} from 'src/core/strings/constants/base.constants';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
||||||
import { TransactionPaymentType } from '../../constants';
|
import { TransactionPaymentType, TransactionType } from '../../constants';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TransactionReadService extends BaseReadService<TransactionEntity> {
|
export class TransactionReadService extends BaseReadService<TransactionEntity> {
|
||||||
|
@ -24,8 +24,9 @@ export class TransactionReadService extends BaseReadService<TransactionEntity> {
|
||||||
where: {
|
where: {
|
||||||
status: STATUS.PENDING,
|
status: STATUS.PENDING,
|
||||||
payment_type: TransactionPaymentType.MIDTRANS,
|
payment_type: TransactionPaymentType.MIDTRANS,
|
||||||
|
type: TransactionType.ONLINE,
|
||||||
},
|
},
|
||||||
select: ['id', 'invoice_date'],
|
select: ['id', 'invoice_date', 'created_at', 'booking_date'],
|
||||||
});
|
});
|
||||||
|
|
||||||
return transactions;
|
return transactions;
|
||||||
|
|
|
@ -324,10 +324,25 @@ 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 currentDate = moment().locale('id').format('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 +366,21 @@ export class WhatsappService {
|
||||||
parameter_name: 'booking_date',
|
parameter_name: 'booking_date',
|
||||||
text: fallbackValue,
|
text: fallbackValue,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'text',
|
||||||
|
parameter_name: 'created_date',
|
||||||
|
text: currentDate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'text',
|
||||||
|
parameter_name: 'booking_code',
|
||||||
|
text: data.code,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'text',
|
||||||
|
parameter_name: 'total',
|
||||||
|
text: formattedTotal,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue