erp-construccion-backend/src/modules/inventory/inventory.module.ts
rckrdmrd f3515d4f38 [SYNC] feat: Sincronizar módulos de erp-core (parcial)
Módulos copiados:
- partners/ (20 archivos)
- sales/ (19 archivos)
- crm/ (11 archivos)
- inventory/ (32 archivos nuevos)
- financial/taxes.service.ts

Infraestructura copiada:
- shared/errors/
- shared/middleware/
- shared/types/
- shared/utils/

Entidades core copiadas:
- country, currency, discount-rule, payment-term
- product-category, sequence, state, uom

Dependencias instaladas:
- zod
- winston

Estado: PARCIAL - Build no pasa por incompatibilidades
de imports. Ver SYNC-ERPC-CORE-STATUS.md para detalles.

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

46 lines
1.3 KiB
TypeScript

import { Router } from 'express';
import { DataSource } from 'typeorm';
import { InventoryService } from './services';
import { InventoryController } from './controllers';
import { StockLevel, StockMovement } from './entities';
export interface InventoryModuleOptions {
dataSource: DataSource;
basePath?: string;
}
export class InventoryModule {
public router: Router;
public inventoryService: InventoryService;
private dataSource: DataSource;
private basePath: string;
constructor(options: InventoryModuleOptions) {
this.dataSource = options.dataSource;
this.basePath = options.basePath || '';
this.router = Router();
this.initializeServices();
this.initializeRoutes();
}
private initializeServices(): void {
const stockLevelRepository = this.dataSource.getRepository(StockLevel);
const movementRepository = this.dataSource.getRepository(StockMovement);
this.inventoryService = new InventoryService(
stockLevelRepository,
movementRepository,
this.dataSource
);
}
private initializeRoutes(): void {
const inventoryController = new InventoryController(this.inventoryService);
this.router.use(`${this.basePath}/inventory`, inventoryController.router);
}
static getEntities(): Function[] {
return [StockLevel, StockMovement];
}
}