- Add deprecation notice to inventory/warehouse.entity.ts - Duplicated with warehouses/warehouse.entity.ts (same table) - Plan unification in warehouses module with all fields and relations - Document that Product entities are NOT duplicates - products.products: Commerce/retail focused (SAT, pricing, dimensions) - inventory.products: Warehouse management focused (Odoo-style, valuation) - Intentionally separate by domain
80 lines
2.3 KiB
TypeScript
80 lines
2.3 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
Index,
|
|
ManyToOne,
|
|
OneToMany,
|
|
JoinColumn,
|
|
} from 'typeorm';
|
|
import { Company } from '../../auth/entities/company.entity.js';
|
|
import { Location } from './location.entity.js';
|
|
|
|
/**
|
|
* @deprecated This entity is duplicated with warehouses/entities/warehouse.entity.ts
|
|
* Both map to inventory.warehouses table but have different column definitions.
|
|
*
|
|
* PLANNED UNIFICATION:
|
|
* - The warehouses module version has more comprehensive fields (address, capacity, settings)
|
|
* - This version has Company and Location relations
|
|
* - Future: Merge into single entity in warehouses module with all fields and relations
|
|
*
|
|
* For new code, prefer using: import { Warehouse } from '@modules/warehouses/entities'
|
|
*/
|
|
@Entity({ schema: 'inventory', name: 'warehouses' })
|
|
@Index('idx_warehouses_tenant_id', ['tenantId'])
|
|
@Index('idx_warehouses_company_id', ['companyId'])
|
|
@Index('idx_warehouses_code_company', ['companyId', 'code'], { unique: true })
|
|
export class Warehouse {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ type: 'uuid', nullable: false, name: 'tenant_id' })
|
|
tenantId: string;
|
|
|
|
@Column({ type: 'uuid', nullable: false, name: 'company_id' })
|
|
companyId: string;
|
|
|
|
@Column({ type: 'varchar', length: 255, nullable: false })
|
|
name: string;
|
|
|
|
@Column({ type: 'varchar', length: 20, nullable: false })
|
|
code: string;
|
|
|
|
@Column({ type: 'uuid', nullable: true, name: 'address_id' })
|
|
addressId: string | null;
|
|
|
|
@Column({ type: 'boolean', default: false, nullable: false, name: 'is_default' })
|
|
isDefault: boolean;
|
|
|
|
@Column({ type: 'boolean', default: true, nullable: false })
|
|
active: boolean;
|
|
|
|
// Relations
|
|
@ManyToOne(() => Company)
|
|
@JoinColumn({ name: 'company_id' })
|
|
company: Company;
|
|
|
|
@OneToMany(() => Location, (location) => location.warehouse)
|
|
locations: Location[];
|
|
|
|
// Auditoría
|
|
@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;
|
|
}
|