ecedf9119e
- Use string-based @OneToMany relations in parent entities (wallet, ticket, service-plan) to break circular import chains that confused VS Code TS language server - Add .vscode/settings.json to suppress Tailwind CSS @tailwindcss unknownAtRules warnings - Reorder imports in child entities for consistency
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
ManyToOne,
|
|
JoinColumn,
|
|
CreateDateColumn,
|
|
} from 'typeorm';
|
|
import { Wallet } from './wallet.entity';
|
|
import { TransactionType } from '../../common/enums';
|
|
|
|
@Entity('wallet_transactions')
|
|
export class WalletTransaction {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ type: 'enum', enum: TransactionType })
|
|
type: TransactionType;
|
|
|
|
@Column({ type: 'decimal', precision: 14, scale: 2 })
|
|
amount: number; // Amount in Toman (positive)
|
|
|
|
@Column({ type: 'decimal', precision: 14, scale: 2 })
|
|
balanceAfter: number; // Balance after this transaction
|
|
|
|
@Column({ nullable: true })
|
|
description: string; // e.g. "Charge via admin", "Payment for app: my-app (monthly)"
|
|
|
|
@Column({ nullable: true })
|
|
applicationId: string; // Linked application (for deductions)
|
|
|
|
@ManyToOne(() => Wallet, (wallet: Wallet) => wallet.transactions, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'walletId' })
|
|
wallet: Wallet;
|
|
|
|
@Column()
|
|
walletId: string;
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
}
|