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; }