Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/corpentunida-org/corpen/llms.txt

Use this file to discover all available pages before exploring further.

The Credits module manages every stage of a cooperative loan — from the parametric setup of credit product lines through origination, document attachment, payment recording, and final notification. Credits (cre_creditos) are the central entity referenced by the Portfolio module’s agreements and payment vouchers, and by the Collections and Treasury modules when recording disbursements and receipts. All credit routes are secured with the auth middleware. Credits themselves are registered directly under the top-level creditos resource (no prefix), while their sub-resources (credit lines, guarantees, documents, etc.) are managed via their own controllers within the App\Http\Controllers\Creditos namespace.

Sub-module overview

Credit Lines

Define the available loan products with terms, rates, age limits, and collateral type. Stored in cre_lineas_creditos.

Credits

Individual loan records linked to a member (MaeTerceros), a credit line, and a lifecycle state. Stored in cre_creditos.

States & Stages

Credits progress through cre_etapas and cre_estados. Stage 16 is the default active filter in the index view.

Guarantees

Collateral records attached to a credit line. Managed by GarantiaController and stored in cre_garantias.

Documents

Generic document attachments (DocumentoController) and specialised legal instruments: escrituras (EscrituraController) and pagarés (PagareController).

Notifications & Observations

NotificacionController triggers alerts on credit events. ObservacionController records operator notes traceable via User::observacionesRegistradas().

Credit lines (cre_lineas_creditos)

Credit lines are the product catalogue — they define the parameters that govern every loan issued under that product. A line must exist before any credit can be originated.

cre_lineas_creditos schema

ColumnTypeNotes
idbigint (PK)Auto-increment
nombrestringDisplay name of the credit line
cuentaintegerAccounting account code
tasa_interesdecimal (8,2)Annual interest rate (percentage)
plazo_minimointegerMinimum term in months
plazo_maximointegerMaximum term in months
edad_minimaintegerMinimum member age
edad_maximaintegerMaximum member age
monto_maximointegerMaximum disbursement amount
monto_minimointegerMinimum disbursement amount
seguro_todo_riesgointegerAll-risk insurance rate or code
fecha_aperturadateDate the product was opened
fecha_cierredate (nullable)Date the product was closed (null = still active)
observaciontext (nullable)Additional product notes
cre_garantias_idFK → cre_garantiasRequired collateral type
cre_tipos_creditos_idFK → cre_tipos_creditosCredit product category
The LineaCreditoController loads garantia and tipoCredito via Eager Loading on every read operation. Deleting a credit line that has existing credits associated will be blocked:
if ($lineas_credito->creditos()->count() > 0) {
    return redirect()->route('lineas_credito.index')
        ->with('error', 'No se puede eliminar la línea porque está siendo utilizada en créditos existentes.');
}

Credits (cre_creditos)

The cre_creditos table stores each individual loan record.

cre_creditos schema

ColumnTypeNotes
idbigint (PK)Auto-increment
printeger (unique)Loan identifier / PR number
pagareinteger (unique)Promissory-note number
valordecimal (15,2)Disbursed amount
cuotasintegerNumber of instalments
fecha_desembolsodateDisbursement date
cre_estados_idFK → cre_estadosCurrent lifecycle state
cre_lineas_creditos_idFK → cre_lineas_creditosProduct line
mae_terceros_cod_terbigintFK → MaeTerceros.cod_ter (member)
The index view filters to state ID 16 by default (where('cre_estados_id', 16)) and supports a nombre query parameter that searches across the related MaeTerceros.nom_ter field:
$query->whereHas('tercero', function ($subQuery) use ($nombre) {
    $subQuery->where('nom_ter', 'like', "%{$nombre}%");
});
Results are paginated at 10 per page and include the tercero, lineaCredito.tipoCredito, and estado.etapa relationships via Eager Loading. The show view loads the full detail chain:
$credito->load([
    'estado',
    'lineaCredito',
    'tercero',
    'pagareRelacionado',
    'escritura',
    'notificaciones',
]);

Originating a new credit

1

Ensure a credit line exists

Verify that the desired product line exists in cre_lineas_creditos with the correct rate, term, and guarantee type. The LineaCreditoController manages these records; its routes follow the lineas_credito resource convention but are not yet registered in routes/web.php. A credit line requires at least one Garantia record and one TipoCredito record to be selectable in the credit creation form.
2

Open the credit creation form

Go to GET /creditos/create. The form loads three datasets:
  • $estados — all records from cre_estados
  • $lineasCredito — all records from cre_lineas_creditos
  • $terceros — all records from MaeTerceros
3

Fill in the credit details

Complete the required fields validated by StoreCreditoRequest:
  • pr — unique PR loan number
  • pagare — unique promissory-note number
  • valor — disbursed amount
  • cuotas — number of instalments
  • fecha_desembolso — disbursement date
  • cre_estados_id — initial state
  • cre_lineas_creditos_id — product line
  • mae_terceros_cod_ter — member’s cod_ter
4

Attach guarantees and documents

After the credit record is created, attach the required collateral via GarantiaController, upload legal documents via DocumentoController, and register the promissory note via PagareController or the public deed via EscrituraController. These sub-resources all reference cre_creditos_id.
5

Record disbursement in Treasury

Once the credit is approved, register the outgoing disbursement payment in the Treasury module (see Treasury). The Treasury tes_pagos table links back to cre_creditos_id.
6

Monitor notifications and observations

Payment events and state transitions trigger notifications managed by NotificacionController. Operator notes are stored via ObservacionController. Both are accessible from the credit detail view.
The User model exposes observacionesRegistradas(): HasMany — all ObservacionController-managed notes created by a given user. Use $user->observacionesRegistradas to audit which agents have documented activity on active credits.

Controller inventory

ControllerRoute (convention)Description
CreditoControllercreditos resourceCredit CRUD
LineaCreditoControllerlineas_credito resourceCredit line CRUD
TipoCreditoControllerparamétricoCredit type master
EstadoControllerparamétricoLifecycle states
EtapaControllerparamétricoLifecycle stages
GarantiaControllergarantias resourceCollateral records
DocumentoControllerdocumentos resourceGeneric document attachments
EscrituraControllerescrituras resourcePublic deeds
PagareControllerpagares resourcePromissory notes
NotificacionControllernotificaciones resourceCredit event notifications
ObservacionControllerobservaciones resourceOperator notes

Relationships with other modules

  • PortfolioCarComprobantePago and Acuerdo both reference cre_creditos_id.
  • Collectionsrec_pagos stores instalment payments against cre_creditos_id.
  • Treasurytes_pagos records disbursements against cre_creditos_id.

Build docs developers (and LLMs) love