import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, } from 'typeorm'; /** * سجل التدقيق المالي (docs/17 — I7؛ مكافئ `admin_audit_log` عند سيرو). * الجدول: tripz_audit_log. **append-only** — لا تحديث ولا حذف. * * يجيب عن سؤال واحد عند كل نزاع: **من فعل ماذا ومتى ومن أين؟** */ @Entity('audit_log') @Index(['tenant_id', 'created_at']) @Index(['tenant_id', 'subject_type', 'subject_id']) export class AuditLog { @PrimaryGeneratedColumn('increment') id: string; @Column({ type: 'uuid' }) tenant_id: string; /** من نفّذ الفعل — قد يكون السائق نفسه أو أدمن أو `null` للنظام. */ @Column({ type: 'uuid', nullable: true }) actor_user_id: string | null; @Column({ type: 'varchar', nullable: true }) actor_role: string | null; /** payout.request · payout.confirm · payout.complete · payout.fail · credit.topup … */ @Column() action: string; @Column({ type: 'varchar', nullable: true }) subject_type: string | null; // payout | credit | wallet @Column({ type: 'varchar', nullable: true }) subject_id: string | null; @Column({ type: 'numeric', precision: 12, scale: 3, nullable: true }) amount: number | null; @Column({ type: 'varchar', nullable: true }) currency: string | null; @Column({ type: 'jsonb', default: {} }) meta: Record; @Column({ type: 'varchar', nullable: true }) ip: string | null; @CreateDateColumn() created_at: Date; }