erp-construccion-backend-v2/src/modules/auth/entities/company.entity.ts
Adrian Flores Cortes 598c3215e1 feat(FASE-4A): Complete vertical modules for construction
- MAI-018 Bidding module: entities, services, controllers, DTOs
  - Opportunity, Tender, Proposal, Vendor management
  - Bid calendar, documents, analytics
- Earned Value Management: Curva S, SPI/CPI reports
  - earned-value.service.ts with EV, PV, AC calculations
  - earned-value.controller.ts with 9 endpoints
- DTOs for modules: assets, contracts, documents, purchase, quality
  - 28 new DTO files with class-validator decorators
- Storage module: service and controller implementation
  - Multi-provider support (local, S3, GCS, Azure)
  - File management, upload/download URLs
- Multiple entity and service fixes

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

80 lines
2.2 KiB
TypeScript

/**
* Company Entity
* Soporte multi-empresa dentro de un tenant
* Compatible con erp-core company.entity
*
* @module Auth
*/
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
Index,
ManyToOne,
JoinColumn,
} from 'typeorm';
import { Tenant } from '../../core/entities/tenant.entity';
@Entity({ schema: 'auth', name: 'companies' })
@Index('idx_companies_tenant_id', ['tenantId'])
@Index('idx_companies_parent_company_id', ['parentCompanyId'])
@Index('idx_companies_active', ['tenantId'], { where: 'deleted_at IS NULL' })
@Index('idx_companies_tax_id', ['taxId'])
export class Company {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'uuid', nullable: false, name: 'tenant_id' })
tenantId: string;
@Column({ type: 'varchar', length: 255, nullable: false })
name: string;
@Column({ type: 'varchar', length: 255, nullable: true, name: 'legal_name' })
legalName: string | null;
@Column({ type: 'varchar', length: 50, nullable: true, name: 'tax_id' })
taxId: string | null;
@Column({ type: 'uuid', nullable: true, name: 'currency_id' })
currencyId: string | null;
@Column({ type: 'uuid', nullable: true, name: 'parent_company_id' })
parentCompanyId: string | null;
@Column({ type: 'uuid', nullable: true, name: 'partner_id' })
partnerId: string | null;
@Column({ type: 'jsonb', default: {} })
settings: Record<string, any>;
@ManyToOne(() => Tenant, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'tenant_id' })
tenant: Tenant;
@ManyToOne(() => Company, { nullable: true })
@JoinColumn({ name: 'parent_company_id' })
parentCompany: Company | null;
@CreateDateColumn({ name: 'created_at', type: 'timestamp' })
createdAt: Date;
@Column({ type: 'uuid', nullable: true, name: 'created_by' })
createdBy: string | null;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp', nullable: true })
updatedAt: Date | null;
@Column({ type: 'uuid', nullable: true, name: 'updated_by' })
updatedBy: string | null;
@Column({ type: 'timestamp', nullable: true, name: 'deleted_at' })
deletedAt: Date | null;
@Column({ type: 'uuid', nullable: true, name: 'deleted_by' })
deletedBy: string | null;
}