forked from MergeFi/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayment.entity.ts
More file actions
63 lines (50 loc) · 1.69 KB
/
Copy pathpayment.entity.ts
File metadata and controls
63 lines (50 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { Escrow } from './escrow.entity';
import { User } from './user.entity';
import { AssetType, PaymentStatus } from '../enums';
/** A single payout leg from an escrow release — one per recipient (team splits produce many). */
@Entity('payments')
export class Payment {
@PrimaryGeneratedColumn('uuid')
id: string;
// RESTRICT, not CASCADE: a Payment is a record of money that actually
// moved. Deleting its parent Escrow must never silently delete that
// payout record too — the database refuses the delete instead. See #27.
@ManyToOne(() => Escrow, (escrow) => escrow.payments, {
onDelete: 'RESTRICT',
})
@JoinColumn()
escrow: Escrow;
@Column()
escrowId: string;
@ManyToOne(() => User, { onDelete: 'SET NULL', nullable: true })
@JoinColumn()
recipient: User | null;
@Column({ type: 'varchar', nullable: true })
recipientId: string | null;
@Column({ type: 'varchar', nullable: true })
recipientAddress: string | null;
@Column({ type: 'decimal', precision: 20, scale: 7 })
amount: string;
@Column({ type: 'enum', enum: AssetType, default: AssetType.USDC })
asset: AssetType;
/** Percentage of the parent escrow this payment represents (team splits). */
@Column({ type: 'decimal', precision: 5, scale: 2, nullable: true })
splitPercentage: string | null;
@Column({ type: 'enum', enum: PaymentStatus, default: PaymentStatus.PENDING })
status: PaymentStatus;
@Column({ type: 'varchar', nullable: true })
txHash: string | null;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
}