Commit Graph

23 Commits

Author SHA1 Message Date
Adrian Flores Cortes
494a5f2306 fix: Update finance controllers
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 14:14:19 -06:00
Adrian Flores Cortes
61c61e4c2f [TS-FIX] fix: Fix TypeScript errors in finance module services
- Fix PaginatedResult to use flat format instead of meta wrapper
- Replace debitAmount/creditAmount with debit/credit (entity property names)
- Replace currencyCode with currency on AccountingEntry
- Replace partnerId/partnerName with supplierId/supplierName on AccountPayable
- Replace balanceAmount with balance on AccountPayable
- Replace reversalEntryId with reversedEntryId
- Replace acceptsMovements with allowsDirectPosting on ChartOfAccounts
- Fix APPayment properties: amount, currency, remove non-existent properties
- Remove unused imports (Between, In, LessThan, PaymentStatus)
- Fix unused dataSource parameter in constructors

Errors reduced from 507 to 443 (13% reduction in this commit)
Total reduction from initial ~730: 287 errors (39%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:38:46 -06:00
Adrian Flores Cortes
a36a44d5e7 [TS-FIX] fix: Fix TypeScript errors in ai and budgets modules
AI module:
- Remove unused imports (DataSource, ERP_ROLES, LessThan, MoreThanOrEqual)
- Fix AIUsageLog properties (promptTokens, completionTokens)
- Fix AIModel property (modelId, inputCostPer1k)
- Add types to API response parsing

Budgets module (partial):
- Convert ConceptoService from extends BaseService to standalone
- Fix concepto.controller pagination format

Remaining: presupuesto.service needs conversion to standalone

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:19:18 -06:00
Adrian Flores Cortes
78c30d315d [TS-FIX] fix: Fix TypeScript errors in ai module
- Remove unused imports (DataSource, ERP_ROLES, LessThan, MoreThanOrEqual)
- Fix AIUsageLog properties (promptTokens, completionTokens instead of inputTokens, outputTokens)
- Fix AIModel property (modelId instead of externalId, inputCostPer1k instead of inputCostPer1m)
- Add types to API response parsing
- Prefix unused parameters with underscore

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:17:00 -06:00
Adrian Flores Cortes
99064f5f24 [TS-FIX] fix: Fix TypeScript errors in admin and bidding modules
- Add ServiceContext interface to base.service.ts
- Fix admin module: audit-log, backup, cost-center, system-setting
  - Define ServiceContext and PaginatedResult locally
  - Convert services from extends BaseService to standalone
  - Change PaginatedResult from meta format to flat format
  - Fix controllers to use flat pagination format
- Fix bidding module: bid, bid-budget, opportunity
  - Change PaginatedResult from meta format to flat format
  - Fix controllers to use flat pagination format

Modules with remaining errors: finance, payment-terminals, estimates,
mcp, reports, progress, budgets, ai, hse (563 errors total)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:10:00 -06:00
Adrian Flores Cortes
f14829d2ce [MAE-015] fix: Fix TypeScript errors in assets module
- Fix controllers to use Promise<void> return types
- Replace 'return res.status()' with 'res.status(); return;'
- Add NextFunction parameter to handlers
- Fix enum-style references with string literals
- Replace 'deletedAt: null' with 'IsNull()' for TypeORM
- Remove unused parameters and imports
- Fix grouped object initialization in getByStatus
- Remove non-existent 'updatedBy' property from WorkOrderPart

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:51:01 -06:00
Adrian Flores Cortes
e441e9c626 [MAE-016] feat: Complete documents module with REST controller
- Convert services from NestJS to Express pattern
- Remove unused ServiceContext interfaces
- Add DocumentController with full CRUD endpoints:
  - GET /documents (list with filters)
  - GET /documents/:id (get by ID)
  - GET /documents/statistics
  - GET /documents/generate-code
  - GET /documents/project/:projectId
  - GET /documents/:id/access-history
  - GET /documents/:id/versions
  - GET /documents/:id/versions/statistics
  - POST /documents (create)
  - POST /documents/:id/versions (create version)
  - POST /documents/:id/status (change status)
  - POST /documents/:id/lock
  - POST /documents/:id/unlock
  - POST /documents/versions/:versionId/set-current
  - POST /documents/versions/:versionId/archive
  - PUT /documents/:id (update)
  - DELETE /documents/:id (soft delete)
- Add controllers/index.ts export

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:31:21 -06:00
Adrian Flores Cortes
24c2931209 [MAI-012] feat: Complete contracts module with schema fixes
- Fix 3 entities schema from 'contracts' to 'construction' to match DDL
- Create ContractPartida entity for contrato_partidas table
- Fix ContractService and SubcontractorService to use local ServiceContext
- Fix ContractController and SubcontractorController pagination structure
- Update entities/index.ts to export ContractPartida

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:08:31 -06:00
Adrian Flores Cortes
60782a3cac [MAI-009] feat: Complete quality module with schema fixes and ChecklistService
- Fix 8 entities schema from 'quality' to 'construction' to match DDL
- Create ChecklistService with full CRUD, duplication, item management
- Fix InspectionService and TicketService to use local ServiceContext
- Fix InspectionController and TicketController pagination structure
- Update services/index.ts to export ChecklistService

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:54:18 -06:00
Adrian Flores Cortes
63013bb2f4 [MAI-004] feat(purchase): Add construction extensions for purchase orders and suppliers
- Add PurchaseOrderConstruction entity for delivery and quality tracking
- Add SupplierConstruction entity for ratings, specialties and credit terms
- Add PurchaseOrderConstructionService with reception and quality workflows
- Add SupplierConstructionService with evaluation and statistics features
- Update entities and services index files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:40:36 -06:00
Adrian Flores Cortes
22b9692e3a [MAE-016] feat: Add Documents module (Gestion Documental)
- Create 11 entities matching DDL:
  - DocumentCategory: Hierarchical categories
  - Document: Main document registry
  - DocumentVersion: Version control with files
  - DocumentPermission: Granular permissions
  - ApprovalWorkflow: Workflow definitions
  - ApprovalInstance: Active workflow instances
  - ApprovalStep: Steps per instance
  - ApprovalActionEntity: Actions taken
  - Annotation: Comments and markups
  - AccessLog: Access history
  - DocumentShare: External sharing links
- Create DocumentService with full CRUD
- Create DocumentVersionService for version management
- All entities follow ERP-Construction patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:22:49 -06:00
Adrian Flores Cortes
881e7e40f2 [SYNC] Synchronize payment-terminals module from erp-core canonical
Source: erp-core (checksum: c9040e545cf55beb87d3e437a4998855)
Priority: P1 - HIGH
Context: TASK-2026-01-25-SISTEMA-REUTILIZACION

Before: Diverged version (one of 3 different versions)
After: Synced with canonical

Changes:
- Complete payment-terminals module synchronized from erp-core
- 21 TypeScript files updated
- Unified payment terminal integration (MercadoPago + Clip)
- Consistent webhook handling across all ERP projects

Benefits:
- Single source of truth for payment terminals functionality
- Consistent TPV integration behavior
- Reduced maintenance burden (~4,000 lines saved)
- Unified webhook processing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 06:52:08 -06:00
Adrian Flores Cortes
c3200bc53e [SYNC] BaseService synchronized from erp-core canonical
Source: erp-core (checksum: 900be2ee48f2faf72ce5253aeab27c88)
Priority: P1 - HIGH (architectural gap resolution)
Context: TASK-2026-01-25-SISTEMA-REUTILIZACION

Before: "Diverged version"
After: Synced with canonical

Changes:
- BaseService "synchronized" from erp-core
- Checksum: 900be2ee48f2faf72ce5253aeab27c88
- Provides base CRUD operations for all services

Benefits:
- Unified service architecture
- Consistent error handling and validation
- Reduced code duplication in service implementations
- Standard pagination and filtering patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 06:43:25 -06:00
Adrian Flores Cortes
49f9359b0b [SYNC] Synchronize ai module from erp-core canonical
Source: erp-core (checksum: 39a6e229055a21158b63cc4eb4dd232f)
Priority: P0 - CRITICAL divergence resolution
Context: TASK-2026-01-25-SISTEMA-REUTILIZACION

Before: Diverged version with project-specific adaptations
After: Synced with canonical

Changes:
- Complete ai module synchronized from erp-core
- 24 TypeScript files updated
- Unified role-based AI configuration
- Consistent AI behavior across all ERP projects

Note: Project-specific role adaptations (if needed) can be
re-applied as documented extensions after this sync.

Benefits:
- Single source of truth for AI functionality
- Reduced maintenance burden
- Token savings from code reuse
- Consistent behavior baseline

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 06:36:11 -06:00
Adrian Flores Cortes
5f9c30d268 [MAE-015] feat: Implement assets module backend
Complete implementation of the Assets/Machinery/Maintenance module:

Entities (10):
- AssetCategory: Hierarchical asset categorization with depreciation config
- Asset: Main asset entity (machinery, vehicles, tools, equipment)
- AssetAssignment: Asset-to-project assignments tracking
- WorkOrder: Maintenance work orders with workflow
- WorkOrderPart: Parts/materials used in work orders
- MaintenancePlan: Preventive maintenance plans
- MaintenanceHistory: Historical maintenance records
- FuelLog: Fuel consumption tracking with efficiency calculation
- AssetCost: TCO (Total Cost of Ownership) tracking

Services (3):
- AssetService: CRUD, assignments, categories, statistics
- WorkOrderService: CRUD, workflow (start/hold/resume/complete/cancel), parts
- FuelLogService: CRUD, efficiency calculation, statistics

Controllers (3):
- AssetController: REST API for assets, assignments, categories
- WorkOrderController: REST API for work orders, workflow, plans
- FuelLogController: REST API for fuel logs, statistics

Features:
- Multi-tenant support with tenant_id
- Complete workflow for work orders (draft→scheduled→in_progress→completed)
- Automatic efficiency calculation for fuel consumption
- Asset assignment history tracking
- Maintenance plan generation
- TCO tracking by cost type

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 05:41:54 -06:00
Adrian Flores Cortes
bdf8c878e8 [PROP-CORE-004] feat: Register payment-terminals module in app
- Added PaymentTerminalsModule import and initialization
- Registered routes: /api/v1/payment-terminals, /api/v1/mercadopago, /api/v1/clip
- Registered webhooks: /webhooks/mercadopago, /webhooks/clip
- Updated API info with new endpoints

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 03:13:46 -06:00
Adrian Flores Cortes
3f54669dde [PROP-CORE-004] fix: Remove external entity references from payment-terminals
Fixed getEntities() to only reference own entities, avoiding require errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 03:08:24 -06:00
Adrian Flores Cortes
058f42a4d1 [PROP-CORE-004] feat: Adapt AI roles for construction domain
- Roles: ADMIN, SUPERVISOR_OBRA, RESIDENTE, ALMACENISTA
- Domain-specific tools (projects, progress, materials)
- Construction industry terminology

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 02:57:45 -06:00
Adrian Flores Cortes
0493d4b8bd [PROP-CORE-004] feat: Add Phase 6 modules from erp-core
Propagated modules:
- payment-terminals: MercadoPago + Clip TPV
- ai: Role-based AI access (ADMIN, SUPERVISOR_OBRA, RESIDENTE, ALMACENISTA)
- mcp: 18 ERP tools for AI assistants

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 02:45:03 -06:00
Adrian Flores Cortes
9a3f43ed2e chore: Update package-lock.json 2026-01-25 02:27:58 -06:00
81b847ce8a chore: Add .gitignore for clean repository
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 07:31:35 -06:00
7c1480a819 Migración desde erp-construccion/backend - Estándar multi-repo v2
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:11:14 -06:00
aeb201d7f6 Initial commit 2026-01-16 14:04:08 +00:00