forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit.entity.ts
More file actions
82 lines (64 loc) · 2.24 KB
/
Copy pathsplit.entity.ts
File metadata and controls
82 lines (64 loc) · 2.24 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
DeleteDateColumn,
OneToMany,
} from "typeorm";
import { Item } from "./item.entity";
import { Participant } from "./participant.entity";
import { ManyToOne, JoinColumn } from "typeorm";
import { ExpenseCategory } from "../compliance/entities/expense-category.entity";
const timestampColumnType = process.env.NODE_ENV === 'test' ? 'datetime' : 'timestamp';
@Entity("splits")
export class Split {
@PrimaryGeneratedColumn("uuid")
id!: string;
@Column({ type: "decimal", precision: 10, scale: 2 })
totalAmount!: number;
@Column({ type: "decimal", precision: 10, scale: 2, default: 0 })
amountPaid!: number;
@Column({ type: "varchar", default: "active" })
status!: "active" | "completed" | "partial";
/**
* Whether the split is frozen due to an active dispute
* When frozen: no new payments, withdrawals, or distributions allowed
*/
@Column({ type: "boolean", default: false })
isFrozen!: boolean;
@Column({ type: "text", nullable: true })
description?: string;
/**
* Preferred currency for settlement (e.g., 'XLM', 'USDC:GA5Z...', 'EURC:GA5Z...')
* Defaults to 'XLM' if not specified
*/
@Column({ type: "varchar", length: 100, nullable: true, default: "XLM" })
preferredCurrency?: string;
/**
* Creator's Stellar wallet address for receiving payments
*/
@Column({ type: "varchar", length: 56, nullable: true })
creatorWalletAddress?: string;
@Column({ type: timestampColumnType, nullable: true })
dueDate?: Date;
@CreateDateColumn()
createdAt!: Date;
@UpdateDateColumn()
updatedAt!: Date;
/** Soft delete: set when removed; records with this set are excluded from default queries. */
@DeleteDateColumn({ name: "deleted_at" })
deletedAt!: Date | null;
@OneToMany(() => Item, (item) => item.split)
items?: Item[];
@OneToMany(() => Participant, (participant) => participant.split)
participants!: Participant[];
@Column({ type: "uuid", nullable: true })
categoryId?: string;
@Column({ type: timestampColumnType, nullable: true })
expiryDate?: Date;
@ManyToOne(() => ExpenseCategory, (category) => category.splits)
@JoinColumn({ name: "categoryId" })
category?: ExpenseCategory;
}