Commit Graph

7 Commits

Author SHA1 Message Date
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
Adrian Flores Cortes
01c5d98c54 [TASK-010] test: Add projects integration and unit tests
- projects-flow.integration.test.ts: Full project lifecycle tests
- timesheets.service.test.ts: Timesheet unit tests
- Coverage: Project -> Tasks -> Time registration, billing, progress

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 19:25:22 -06:00
24b6ba9b38 [PROJECTS] feat: Add Timesheet entity and DTOs
Add TypeORM entity and DTOs for Projects timesheets feature:
- TimesheetEntity with all fields matching DDL schema
- Extended DTOs for bulk operations (submit, approve, reject)
- Summary types for reporting (by project, user, task)
- Updated module exports to include new files

Complements existing timesheets.service.ts implementation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 04:28:19 -06:00
edadaf3180 [FASE 3-4] feat: Complete Financial, Inventory, CRM, and Projects modules
EPIC-005 - Financial Module:
- Add AccountMapping entity for GL account configuration
- Create GLPostingService for automatic journal entries
- Integrate GL posting with invoice validation
- Fix tax calculation in invoice lines

EPIC-006 - Inventory Automation:
- Integrate FIFO valuation with pickings
- Create ReorderAlertsService for stock monitoring
- Add lot validation for tracked products
- Integrate valuation with inventory adjustments

EPIC-007 - CRM Improvements:
- Create ActivitiesService for activity management
- Create ForecastingService for pipeline analytics
- Add win/loss reporting and user performance metrics

EPIC-008 - Project Billing:
- Create BillingService with billing rate management
- Add getUnbilledTimesheets and createInvoiceFromTimesheets
- Support grouping options for invoice generation

EPIC-009 - HR-Projects Integration:
- Create HRIntegrationService for employee-user linking
- Add employee cost rate management
- Implement project profitability calculations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 05:49:20 -06:00
a7bf403367 test(fase3): Add unit tests for business modules
Add comprehensive unit tests for FASE 3 modules:
- Sales: quotations.service (15 tests), orders.service (27 tests)
- Purchases: purchases.service (21 tests), rfqs.service (39 tests)
- CRM: leads.service (25 tests), opportunities.service (23 tests), stages.service (19 tests)
- Projects: projects.service (15 tests), tasks.service (19 tests)

Updated helpers.ts with factory functions for all new entity types.
Total: 203 new tests (348 tests total, all passing)

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