Overview
The Investment Opportunities feature allows administrators to create investment products by bundling multiple invoices into attractive investment packages. Each opportunity represents a collection of invoices that investors can fund, with defined returns (rendimiento) and internal rate of return (TIR) calculations.Key Capabilities
Bundle Invoices
Combine multiple invoices into a single investment opportunity with automated tracking
Track Funding
Monitor funding progress with real-time monto recaudado (collected amount) updates
Lifecycle Management
Manage opportunity status from creation through activation to completion
Risk Assessment
Calculate and display TIR and rendimiento for investor decision-making
Data Model
TheOportunidadInversion entity contains the following key fields:
| Field | Type | Description |
|---|---|---|
idOportunidad | int | Unique identifier (auto-generated) |
rendimiento | double | Expected return percentage |
tir | double | Internal Rate of Return (Tasa Interna de Retorno) |
monto | Double | Target investment amount |
montoRecaudado | Double | Amount collected so far |
fechaCaducidad | Date | Opportunity expiration date |
fechaRegistro | Date | Creation date |
fechaPago | Date | Calculated payout date (2 months before fechaCaducidad) |
enable | String | Status: “Activo” or “No Activo” |
idEmpresa | int | Associated company ID |
idUsu | long | Creator user ID |
The
fechaPago is automatically calculated as 2 months before the fechaCaducidad to ensure timely payment processing.Workflow
Creating an Investment Opportunity
The creation process follows these steps:-
Add Invoices to Temporary List
- Admin selects active invoices
- Invoices are validated and added to a session-scoped list
- Duplicate prevention ensures each invoice appears only once
-
Submit Opportunity Details
- Define rendimiento and TIR
- Set target monto and fechaCaducidad
- Associate with a company
-
Automatic Processing
- System sets
montoRecaudadoto 0.0 - Status automatically set to “Activo”
fechaPagocalculated (fechaCaducidad - 2 months)- Each invoice linked via
OportunidadFacturajunction table - Linked invoices marked as “No Activo” (no longer available for other opportunities)
- System sets
See Code Example: Creating an Opportunity
See Code Example: Creating an Opportunity
Main API Endpoints
Admin Endpoints
- List Opportunities
- Create Opportunity
- Update Opportunity
- Delete Opportunity
Invoice Management for Opportunities
Add Invoice to Opportunity
Add Invoice to Opportunity
OportunidadInversionController.java:72-101Remove Invoice from List
Remove Invoice from List
id- Invoice ID to remove
OportunidadInversionController.java:103-131Clear Invoice List
Clear Invoice List
OportunidadInversionController.java:63-70User Endpoints
- List Active Opportunities
- Paginated List
- Get Opportunity Details
OportunidadInversionController.java:133-138Related Endpoints
OportunidadFactura junction table.
See implementation at OportunidadInversionController.java:54-59
Access Patterns
Admin Access
- Full CRUD operations on investment opportunities
- Can create opportunities by bundling invoices
- Can update opportunity parameters (rendimiento, TIR, monto, dates)
- Can soft-delete opportunities (mark as “No Activo”)
- Manages the invoice selection list during opportunity creation
User (Inversionista) Access
- Read-only access to active opportunities
- Can view detailed information including:
- Expected returns (rendimiento)
- TIR calculations
- Funding progress (monto vs montoRecaudado)
- Associated company information
- Payment dates
- Can filter and paginate through available opportunities
Use Cases
Use Case 1: Creating a New Investment Opportunity
Scenario: An admin wants to create an investment opportunity for Company XYZ’s invoices.- Admin searches for available invoices from Company XYZ
- Admin adds 3 invoices totaling $50,000 using
POST /api/addFactura - Admin sets rendimiento to 8.5%, TIR to 12.3%, and expiration date to Dec 31, 2026
- Admin submits via
POST /api/insertaOportunidadInversion - System:
- Creates opportunity with status “Activo”
- Sets montoRecaudado to 0
- Calculates fechaPago as Oct 31, 2026 (2 months before expiration)
- Links the 3 invoices to the opportunity
- Marks those invoices as “No Activo” (unavailable for other opportunities)
- Clears the temporary invoice list
Use Case 2: Investor Browsing Opportunities
Scenario: An investor wants to find attractive investment opportunities.- Investor calls
GET /api/user/listarOportunidadInversion/page/0 - System returns first 8 active opportunities with:
- Expected returns (rendimiento and TIR)
- Target vs collected amounts
- Company information
- Payment dates
- Investor clicks on opportunity #5 to see details
- Investor calls
GET /api/detalleOportunidadInversion/5 - Investor views complete information and decides whether to invest
Use Case 3: Monitoring Funding Progress
Scenario: Admin wants to check which opportunities are close to being fully funded.- Admin calls
GET /api/admin/listarOportunidadInversion - System returns all active opportunities with current
montoRecaudado - Admin identifies opportunities where
montoRecaudadois close tomonto - Admin can take action (e.g., promote heavily-funded opportunities or adjust terms for under-funded ones)
Best Practices
Invoice Validation
Always verify invoices are active and not already assigned before adding them to opportunities.
Date Management
Ensure fechaCaducidad provides sufficient time for funding. The system automatically calculates fechaPago 2 months prior.
Return Calculations
Calculate rendimiento and TIR accurately based on invoice values and timeframes to ensure investor trust.
Status Monitoring
Regularly monitor montoRecaudado to track funding progress and make timely adjustments.
Related Features
- Invoice Management - Manage the invoices that feed into opportunities
- Wallet Transactions - Handle investor funding and payouts
- User Management - Control admin and investor access