2026-05-07 19:11:14 +03:30
|
|
|
import {
|
|
|
|
|
Column,
|
|
|
|
|
CreateDateColumn,
|
|
|
|
|
Entity,
|
|
|
|
|
JoinColumn,
|
|
|
|
|
ManyToOne,
|
|
|
|
|
PrimaryGeneratedColumn,
|
|
|
|
|
UpdateDateColumn,
|
|
|
|
|
} from 'typeorm';
|
|
|
|
|
import { BusinessEntity } from './business.entity';
|
|
|
|
|
import { BusinessServiceEntity } from './business-service.entity';
|
2026-05-31 21:36:19 +03:30
|
|
|
import { BusinessServiceClassEntity } from './business-service-class.entity';
|
2026-05-07 19:11:14 +03:30
|
|
|
import { UserEntity } from './user.entity';
|
|
|
|
|
|
|
|
|
|
export enum BookingStatus {
|
|
|
|
|
PENDING = 'pending',
|
2026-06-29 15:46:24 +03:30
|
|
|
AWAITING_PAYMENT = 'awaiting_payment',
|
2026-05-07 19:11:14 +03:30
|
|
|
CONFIRMED = 'confirmed',
|
|
|
|
|
CANCELLED = 'cancelled',
|
|
|
|
|
COMPLETED = 'completed',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Entity('bookings')
|
|
|
|
|
export class BookingEntity {
|
|
|
|
|
@PrimaryGeneratedColumn('uuid')
|
|
|
|
|
id!: string;
|
|
|
|
|
|
|
|
|
|
@ManyToOne(() => UserEntity, (user) => user.bookings, { onDelete: 'RESTRICT' })
|
|
|
|
|
@JoinColumn({ name: 'customerId' })
|
|
|
|
|
customer!: UserEntity;
|
|
|
|
|
|
|
|
|
|
@Column('uuid')
|
|
|
|
|
customerId!: string;
|
|
|
|
|
|
|
|
|
|
@ManyToOne(() => BusinessEntity, (business) => business.bookings, { onDelete: 'RESTRICT' })
|
|
|
|
|
@JoinColumn({ name: 'businessId' })
|
|
|
|
|
business!: BusinessEntity;
|
|
|
|
|
|
|
|
|
|
@Column('uuid')
|
|
|
|
|
businessId!: string;
|
|
|
|
|
|
|
|
|
|
@ManyToOne(() => BusinessServiceEntity, (service) => service.bookings, {
|
|
|
|
|
onDelete: 'RESTRICT',
|
|
|
|
|
})
|
|
|
|
|
@JoinColumn({ name: 'businessServiceId' })
|
|
|
|
|
businessService!: BusinessServiceEntity;
|
|
|
|
|
|
|
|
|
|
@Column('uuid')
|
|
|
|
|
businessServiceId!: string;
|
|
|
|
|
|
2026-05-31 21:36:19 +03:30
|
|
|
@ManyToOne(() => BusinessServiceClassEntity, { nullable: true, onDelete: 'RESTRICT' })
|
|
|
|
|
@JoinColumn({ name: 'serviceClassId' })
|
|
|
|
|
serviceClass!: BusinessServiceClassEntity | null;
|
|
|
|
|
|
|
|
|
|
@Column({ type: 'uuid', nullable: true })
|
|
|
|
|
serviceClassId!: string | null;
|
|
|
|
|
|
|
|
|
|
@Column({ type: 'uuid', nullable: true })
|
|
|
|
|
bookingGroupId!: string | null;
|
|
|
|
|
|
2026-05-07 19:11:14 +03:30
|
|
|
@Column({ type: 'timestamptz' })
|
|
|
|
|
scheduledAt!: Date;
|
|
|
|
|
|
|
|
|
|
@Column({ type: 'enum', enum: BookingStatus, default: BookingStatus.PENDING })
|
|
|
|
|
status!: BookingStatus;
|
|
|
|
|
|
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
|
|
|
note!: string | null;
|
|
|
|
|
|
2026-06-13 13:42:52 +03:30
|
|
|
@Column({ type: 'text', nullable: true })
|
|
|
|
|
cancellationReason!: string | null;
|
|
|
|
|
|
2026-06-29 15:46:24 +03:30
|
|
|
/** Shared token for paying a booking group (or single booking). */
|
|
|
|
|
@Column({ type: 'varchar', nullable: true, length: 64 })
|
|
|
|
|
paymentToken!: string | null;
|
|
|
|
|
|
|
|
|
|
@Column({ type: 'decimal', precision: 12, scale: 0, nullable: true })
|
|
|
|
|
paymentAmount!: string | null;
|
|
|
|
|
|
|
|
|
|
@Column({ type: 'varchar', nullable: true, length: 64 })
|
|
|
|
|
paymentAuthority!: string | null;
|
|
|
|
|
|
2026-06-29 19:31:26 +03:30
|
|
|
@Column({ type: 'timestamptz', nullable: true })
|
|
|
|
|
completedAt!: Date | null;
|
|
|
|
|
|
|
|
|
|
@Column({ type: 'timestamptz', nullable: true })
|
|
|
|
|
reviewPromptedAt!: Date | null;
|
|
|
|
|
|
2026-05-07 19:11:14 +03:30
|
|
|
@CreateDateColumn()
|
|
|
|
|
createdAt!: Date;
|
|
|
|
|
|
|
|
|
|
@UpdateDateColumn()
|
|
|
|
|
updatedAt!: Date;
|
|
|
|
|
}
|