Commit Graph

7 Commits

Author SHA1 Message Date
Adrian Flores Cortes
6a12ff0844 [TASK-2026-02-05-EJECUCION-REMEDIATION-ERP-CORE] feat: Complete Sprint 0-4 data modeling remediation
Sprint 0: Updated inventories (MASTER/BACKEND/DATABASE) with verified baseline
Sprint 1: Fixed 8 P0 blockers - CFDI entities (schema cfdi→fiscal), auth base DDL,
  billing duplication (→operations), 5 project entities, PaymentInvoiceAllocation,
  core.companies DDL, recreate-database.sh array
Sprint 2: 4 new auth entities, session/role/permission DDL reconciliation,
  CFDI PAC+StampQueue, partner address+contact alignment
Sprint 3: CFDI service+controller+routes, mobile service+controller+routes,
  inventory extended DDL (7 tables)
Sprint 4: timestamp→timestamptz (40 files), field divergences, token/roles/permissions
  service alignment with new DDL-aligned entities

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 21:51:55 -06:00
Adrian Flores Cortes
7a957a69c7 refactor: Consolidate duplicate services and normalize module structure
- Partners: Moved services to services/ directory, consolidated duplicates,
  kept singleton pattern version with ranking service
- Products: Moved service to services/, removed duplicate class-based version,
  kept singleton with deletedAt filtering
- Reports: Moved service to services/, kept raw SQL version for active controller
- Warehouses: Moved service to services/, removed duplicate class-based version,
  kept singleton with proper tenant isolation

All modules now follow consistent structure:
- services/*.service.ts for business logic
- services/index.ts for exports
- Controllers import from ./services/index.js

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 04:40:16 -06:00
Adrian Flores Cortes
98fc0cf944 [RBAC-002] feat: Migrate all routes from requireRoles to requireAccess
Phase 2 of RBAC propagation - migrates 18 route files to use hybrid
requireAccess() middleware for permission-based authorization:

P1 Routes (auth/billing):
- users.routes.ts (11 occurrences)
- roles.routes.ts (11 occurrences)
- permissions.routes.ts (8 occurrences)
- invoices.routes.ts (9 occurrences)
- financial.routes.ts (42 occurrences)

P2 Routes (business):
- partners.routes.ts (16 occurrences)
- sales.routes.ts (32 occurrences)
- purchases.routes.ts (21 occurrences)

P3 Routes (operations):
- inventory.routes.ts (28 occurrences)
- hr.routes.ts (28 occurrences)
- crm.routes.ts (23 occurrences)
- core.routes.ts (21 occurrences)
- tenants.routes.ts (12 occurrences)
- companies.routes.ts (9 occurrences)
- warehouses.routes.ts (6 occurrences)
- products.routes.ts (6 occurrences)
- projects.routes.ts (6 occurrences)
- system.routes.ts (2 occurrences)

Total: ~271 route protections migrated to permission-based access

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 01:43:05 -06:00
8d201c5b58 [TASK-2026-01-20-005] feat: Add multi-tenancy to UOM entities
EPIC-P2-005: UOM Multi-tenancy Sync
- Add tenant_id field to Uom entity
- Add tenant_id field to UomCategory entity
- Add Tenant relation to both entities
- Add UpdateDateColumn for updated_at
- Update indexes for tenant-based unique constraints

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 04:32:10 -06:00
d809e23b5c feat(core): Add States, CurrencyRates, and UoM conversion (MGN-005)
- State entity and service with CRUD operations
- CurrencyRate entity and service with conversion support
- UoM conversion methods (convertQuantity, getConversionTable)
- New API endpoints for states, currency rates, UoM conversions
- Updated controller and routes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 08:57:21 -06:00
6054102774 [BACKEND] feat: EPIC-001 & EPIC-002 - Core module completion and entity consolidation
EPIC-001: Complete Core Module
- Add PaymentTerm entity with multi-line support (30/60/90 days, early payment discounts)
- Add PaymentTerms service with calculateDueDate() functionality
- Add DiscountRule entity with volume/time-based conditions
- Add DiscountRules service with applyDiscounts() and rule combination logic
- Add REST endpoints for payment-terms and discount-rules in core module
- Register new entities in TypeORM configuration

EPIC-002: Entity Consolidation
- Add inventoryProductId FK to products.products for linking to inventory module
- Consolidate Warehouse entity in warehouses module as canonical source
- Add companyId and Location relation to canonical Warehouse
- Update inventory module to re-export Warehouse from warehouses module
- Remove deprecated warehouse.entity.ts from inventory module
- Update inventory/warehouses.service.ts to use canonical Warehouse

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 05:13:34 -06:00
12fb6eeee8 Initial commit - erp-core-backend 2026-01-04 06:40:14 -06:00