Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DanielRivera03/SistemaBancario/llms.txt

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

CashMan H.A. uses standard loan amortization formulas to calculate monthly installments, additional fees, and total disbursement amounts for each credit product type. All calculations are performed at the time a credit application is submitted and stored in the database. Subsequent installment payments update the remaining balance using a trigger (RecalcularSaldoFinal_CreditosClientes) that recalculates the credit balance after each payment is recorded.

Monthly Installment Formula

CashMan H.A. uses the standard amortization (declining-balance) formula to calculate the fixed monthly payment that fully amortizes a loan over its term.
M = P × [ i × (1 + i)^n ] / [ (1 + i)^n - 1 ]

Where:
  P = loan principal amount          (montocredito)
  i = monthly interest rate          (interescredito / 100)
  n = loan term in months            (plazocredito)
  M = monthly installment amount     (cuotamensual)

Example

A personal loan of $8,000.00 at 5% monthly interest over 36 months:
P = 8000
i = 0.05
n = 36

(1 + i)^n = (1.05)^36 ≈ 5.7918

M = 8000 × [ 0.05 × 5.7918 ] / [ 5.7918 - 1 ]
M = 8000 × [ 0.28959 ] / [ 4.7918 ]
M ≈ 8000 × 0.06044
M ≈ $483.52 per month
The monthly interest rate i is stored as a percentage in the database column interescredito. The formula always divides by 100 before use: i = interescredito / 100. Ensure this conversion is applied consistently in any custom reporting queries or exports.

Additional Fees

Beyond the base installment, three types of fees may apply to a credit. These are calculated per product type and configured based on the credit amount range.

Debt Insurance Fee (Seguro de Deuda)

A monthly protection fee added to each installment. It functions as unemployment/disability insurance for the borrower and is expressed as a percentage of the outstanding credit balance or a fixed amount per bracket.
  • Applies to: Personal, Mortgage, and Vehicle loans
  • Added to: Monthly installment (cuotamensual)
  • Purpose: Unemployment protection — covers payments if the client loses their income source

Administrative Fee (Gastos Administrativos)

A one-time fee deducted from the principal at the moment of disbursement. The client receives less than the face value of the approved loan.
  • Applies to: Personal, Mortgage, and Vehicle loans
  • Timing: Deducted at disbursement (not spread across installments)
  • Effect on installment: The monthly payment is calculated on the full approved principal P, not the disbursed net amount

GPS Service Fee (Servicio GPS)

A monthly fee for the GPS tracking device installed on the financed vehicle.
  • Applies to: Vehicle loans only
  • Added to: Monthly installment (cuotamensual), in addition to the debt insurance fee
  • Purpose: Enables the lender to locate collateral in the event of non-payment

Total Disbursement Amount

The actual cash amount received by the client after all upfront deductions:
Total Disbursement = Principal - Administrative Fee - GPS Fee (if applicable)

For personal and mortgage loans:
  Disbursed = P - Administrative Fee

For vehicle loans:
  Disbursed = P - Administrative Fee - GPS Setup Fee (if any one-time component exists)
The GPS monthly service fee is added to installments, not deducted from disbursement. Only any one-time GPS setup component (if configured in the product) would reduce the disbursed amount.

Fee Summary by Product

FeePersonalMortgageVehicle
Debt Insurance✅ Added to installment✅ Added to installment✅ Added to installment
Administrative Fee✅ Deducted at disbursement✅ Deducted at disbursement✅ Deducted at disbursement
GPS Monthly Fee✅ Added to installment

Delinquency (Mora) Calculation

When a client misses an installment payment, a daily late fee accumulates on the overdue installment. The system standard is:
Daily Mora Charge = $5.99 per day of non-payment
A database event runs automatically to detect overdue installments and apply this charge. The consulta-listado-morosos route (accessible to Roles 1 and 3) lists all clients with outstanding delinquency balances.
The $5.99 daily mora charge is a system-level default configured in the database trigger/event logic. Changing this value requires modifying the relevant database event or trigger — it is not a configurable application setting.

Credit Balance Precision Fix

The saldocredito field that tracks the remaining credit balance uses decimal(15,6) precision. This was increased from the original decimal(9,2) to fix a precision bug where the RecalcularSaldoFinal_CreditosClientes trigger produced incorrect residual balances after multiple payment cycles — particularly on large mortgage amounts or high-precision amortization schedules.If you cloned the repository before this correction was published, update the trigger variable declaration manually:
-- Old (incorrect):
DECLARE _saldocredito decimal(9,2);

-- New (correct):
DECLARE _saldocredito decimal(15,6);
New clones of the repository already include this fix.

Number-to-Words Conversion for Contracts

Legal contract PDFs require monetary amounts written out in Spanish. CashMan H.A. uses the luecano/numero-a-letras Composer package for this conversion:
use Luecano\NumeroALetras\NumeroALetras;

$formatter = new NumeroALetras();
$words = $formatter->toMoney(5000.00, 2, 'Dólares', 'Centavos');
// Result: "Cinco Mil Dólares con 00/100"
The converted text is embedded in the FPDF-generated contract body alongside the numeric amount, fulfilling the legal requirement that contract values appear in written form.

PDF Contract Generation Flow

1

Credit Approved

Once Presidencia grants final approval, the system marks habilitarsistema = 1 for the client and generates installment records.
2

Contract Data Assembled

The controller fetches the credit details, client personal data, and product information via stored procedure calls.
3

Monetary Conversion

NumeroALetras converts the principal, total interest, and total payment amounts to Spanish text.
4

PDF Rendered

FPDF (FPDF/fpdf.php) builds the contract layout, embeds the client’s digital signature image from vista/images/fotofirmas/, and outputs the PDF.
5

Contract Stored

The completed PDF is saved to vista/copiacontratosclientes/ with a unique filename. The client and staff can view or download it from within their respective portals.

Build docs developers (and LLMs) love