erp-transportistas-backend-v2/src/modules/reports/entities/custom-report.entity.ts
Adrian Flores Cortes ec59053bbe feat: Propagate entities from erp-construccion
Modules added (entities only):
- biometrics (4 entities)
- feature-flags (3 entities)
- hr (8 entities)
- invoices (4 entities)
- products (7 entities)
- profiles (5 entities)
- projects (1 entity)
- purchase (11 entities)
- reports (13 entities)
- sales (4 entities)
- settings (4 entities)
- storage (7 entities)
- warehouses (3 entities)
- webhooks (6 entities)
- whatsapp (10 entities)

Total: 90 new entity files
Source: erp-construccion (validated, build clean)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 09:06:31 -06:00

68 lines
1.8 KiB
TypeScript

import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
Index,
ManyToOne,
JoinColumn,
} from 'typeorm';
import { Report } from './report.entity';
/**
* Custom Report Entity (schema: reports.custom_reports)
*
* User-personalized reports based on existing definitions.
* Stores custom columns, filters, grouping, and sorting preferences.
*/
@Entity({ name: 'custom_reports', schema: 'reports' })
export class CustomReport {
@PrimaryGeneratedColumn('uuid')
id: string;
@Index()
@Column({ name: 'tenant_id', type: 'uuid' })
tenantId: string;
@Index()
@Column({ name: 'owner_id', type: 'uuid' })
ownerId: string;
@Column({ name: 'base_definition_id', type: 'uuid', nullable: true })
baseDefinitionId: string | null;
@Column({ name: 'name', type: 'varchar', length: 255 })
name: string;
@Column({ name: 'description', type: 'text', nullable: true })
description: string | null;
@Column({ name: 'custom_columns', type: 'jsonb', default: '[]' })
customColumns: Record<string, any>[];
@Column({ name: 'custom_filters', type: 'jsonb', default: '[]' })
customFilters: Record<string, any>[];
@Column({ name: 'custom_grouping', type: 'jsonb', default: '[]' })
customGrouping: Record<string, any>[];
@Column({ name: 'custom_sorting', type: 'jsonb', default: '[]' })
customSorting: Record<string, any>[];
@Index()
@Column({ name: 'is_favorite', type: 'boolean', default: false })
isFavorite: boolean;
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
updatedAt: Date;
// Relations
@ManyToOne(() => Report, { onDelete: 'SET NULL' })
@JoinColumn({ name: 'base_definition_id' })
baseDefinition: Report | null;
}