mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 05:42:27 +00:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { AllowanceChangeRequestStatus } from '../enums';
|
|
import { Allowance } from './allowance.entity';
|
|
|
|
@Entity('allowance_change_requests')
|
|
export class AllowanceChangeRequest {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ type: 'text', name: 'reason' })
|
|
reason!: string;
|
|
|
|
@Column({
|
|
type: 'decimal',
|
|
precision: 10,
|
|
scale: 2,
|
|
name: 'amount',
|
|
transformer: { to: (value: number) => value, from: (value: string) => parseFloat(value) },
|
|
})
|
|
amount!: number;
|
|
|
|
@Column({ type: 'varchar', length: 255, name: 'status', default: AllowanceChangeRequestStatus.PENDING })
|
|
status!: AllowanceChangeRequestStatus;
|
|
|
|
@Column({ type: 'uuid', name: 'allowance_id' })
|
|
allowanceId!: string;
|
|
|
|
@ManyToOne(() => Allowance, (allowance) => allowance.changeRequests)
|
|
@JoinColumn({ name: 'allowance_id' })
|
|
allowance!: Allowance;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' })
|
|
updatedAt!: Date;
|
|
}
|