/** * Base Entity - Common fields for all entities in ERP-Suite * * @module @erp-suite/core/entities */ import { PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, } from 'typeorm'; /** * Base entity with common audit fields * * All entities in ERP-Suite should extend this class to inherit: * - id: UUID primary key * - tenantId: Multi-tenancy isolation * - Audit fields (created, updated, deleted) * - Soft delete support * * @example * ```typescript * @Entity('partners', { schema: 'erp' }) * export class Partner extends BaseEntity { * @Column() * name: string; * } * ``` */ export abstract class BaseEntity { @PrimaryGeneratedColumn('uuid') id: string; @Column({ name: 'tenant_id', type: 'uuid' }) tenantId: string; @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt: Date; @Column({ name: 'created_by_id', type: 'uuid', nullable: true }) createdById?: string; @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' }) updatedAt: Date; @Column({ name: 'updated_by_id', type: 'uuid', nullable: true }) updatedById?: string; @DeleteDateColumn({ name: 'deleted_at', type: 'timestamptz', nullable: true }) deletedAt?: Date; @Column({ name: 'deleted_by_id', type: 'uuid', nullable: true }) deletedById?: string; }