feat(construccion): Add construction module entities

- Add Fraccionamiento entity
- Add Proyecto entity
- Add entities index export

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rckrdmrd 2025-12-08 10:46:28 -06:00
parent 436aafae62
commit 94371c0e75
3 changed files with 185 additions and 0 deletions

View File

@ -0,0 +1,90 @@
/**
* Fraccionamiento Entity
* Obras/fraccionamientos dentro de un proyecto
*
* @module Construction
* @table construction.fraccionamientos
* @ddl schemas/01-construction-schema-ddl.sql
*/
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToOne,
JoinColumn,
Index,
} from 'typeorm';
import { Tenant } from '../../core/entities/tenant.entity';
import { User } from '../../core/entities/user.entity';
import { Proyecto } from './proyecto.entity';
export type EstadoFraccionamiento = 'activo' | 'pausado' | 'completado' | 'cancelado';
@Entity({ schema: 'construction', name: 'fraccionamientos' })
@Index(['tenantId', 'codigo'], { unique: true })
export class Fraccionamiento {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ name: 'tenant_id', type: 'uuid' })
tenantId: string;
@Column({ name: 'proyecto_id', type: 'uuid' })
proyectoId: string;
@Column({ type: 'varchar', length: 20 })
codigo: string;
@Column({ type: 'varchar', length: 200 })
nombre: string;
@Column({ type: 'text', nullable: true })
descripcion: string;
@Column({ type: 'text', nullable: true })
direccion: string;
// PostGIS geometry - stored as GeoJSON for TypeORM compatibility
@Column({
name: 'ubicacion_geo',
type: 'geometry',
spatialFeatureType: 'Point',
srid: 4326,
nullable: true
})
ubicacionGeo: string;
@Column({ name: 'fecha_inicio', type: 'date', nullable: true })
fechaInicio: Date;
@Column({ name: 'fecha_fin_estimada', type: 'date', nullable: true })
fechaFinEstimada: Date;
@Column({ type: 'varchar', length: 20, default: 'activo' })
estado: EstadoFraccionamiento;
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
updatedAt: Date;
@Column({ name: 'created_by', type: 'uuid', nullable: true })
createdById: string;
// Relations
@ManyToOne(() => Tenant)
@JoinColumn({ name: 'tenant_id' })
tenant: Tenant;
@ManyToOne(() => Proyecto, (p) => p.fraccionamientos)
@JoinColumn({ name: 'proyecto_id' })
proyecto: Proyecto;
@ManyToOne(() => User)
@JoinColumn({ name: 'created_by' })
createdBy: User;
}

View File

@ -0,0 +1,7 @@
/**
* Construction Entities Index
* @module Construction
*/
export * from './proyecto.entity';
export * from './fraccionamiento.entity';

View File

@ -0,0 +1,88 @@
/**
* Proyecto Entity
* Proyectos de desarrollo inmobiliario
*
* @module Construction
* @table construction.proyectos
* @ddl schemas/01-construction-schema-ddl.sql
*/
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToOne,
OneToMany,
JoinColumn,
Index,
} from 'typeorm';
import { Tenant } from '../../core/entities/tenant.entity';
import { User } from '../../core/entities/user.entity';
import { Fraccionamiento } from './fraccionamiento.entity';
export type EstadoProyecto = 'activo' | 'pausado' | 'completado' | 'cancelado';
@Entity({ schema: 'construction', name: 'proyectos' })
@Index(['tenantId', 'codigo'], { unique: true })
export class Proyecto {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ name: 'tenant_id', type: 'uuid' })
tenantId: string;
@Column({ type: 'varchar', length: 20 })
codigo: string;
@Column({ type: 'varchar', length: 200 })
nombre: string;
@Column({ type: 'text', nullable: true })
descripcion: string;
@Column({ type: 'text', nullable: true })
direccion: string;
@Column({ type: 'varchar', length: 100, nullable: true })
ciudad: string;
@Column({ type: 'varchar', length: 100, nullable: true })
estado: string;
@Column({ name: 'fecha_inicio', type: 'date', nullable: true })
fechaInicio: Date;
@Column({ name: 'fecha_fin_estimada', type: 'date', nullable: true })
fechaFinEstimada: Date;
@Column({
name: 'estado_proyecto',
type: 'varchar',
length: 20,
default: 'activo'
})
estadoProyecto: EstadoProyecto;
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
updatedAt: Date;
@Column({ name: 'created_by', type: 'uuid', nullable: true })
createdById: string;
// Relations
@ManyToOne(() => Tenant)
@JoinColumn({ name: 'tenant_id' })
tenant: Tenant;
@ManyToOne(() => User)
@JoinColumn({ name: 'created_by' })
createdBy: User;
@OneToMany(() => Fraccionamiento, (f) => f.proyecto)
fraccionamientos: Fraccionamiento[];
}