Overview
Payment plans enable customers to pay for sales over time through monthly installments. When a sale is created withTipoPago = 'CREDITO', the system automatically generates a payment schedule based on the number of months and interest rate specified.
Payment Plan Entity
ThePlanPago entity represents a single installment within a payment schedule.
Entity Fields
Auto-generated installment identifier (primary key)
Sale order reference (foreign key to
ventas)Installment number (1, 2, 3, etc.)
Due date for this installment
Amount due for this installment
Payment status (false = pending, true = paid)
Relationships
- NordenNavigation: Parent sale record (
Venta)
Generating a Payment Plan
Verify Credit Sale
Ensure the sale has:
TipoPago = 'CREDITO'Meses> 0 (number of monthly installments)TasaInteres>= 0 (interest rate percentage)
Calculate Total with Interest
Apply the interest rate to the sale total:For example, a $1,000 sale with 5% interest:
Calculate Installment Amount
Divide the total with interest by the number of months:Continuing the example with 6 months:
Payment Plan Example
A sale created on January 15, 2026:- Total: $1,200.00
- Interest Rate: 3%
- Months: 4
| Installment | Due Date | Amount | Status |
|---|---|---|---|
| 1 | Feb 15, 2026 | $309.00 | Pending |
| 2 | Mar 15, 2026 | $309.00 | Pending |
| 3 | Apr 15, 2026 | $309.00 | Pending |
| 4 | May 15, 2026 | $309.00 | Pending |
Tracking Installment Status
ThePagada field indicates whether an installment has been paid:
- false (0): Installment is pending payment
- true (1): Installment has been paid
AbonosVenta) is recorded with a NumeroCuota, the corresponding installment is automatically marked as paid via the TR_ActualizarSaldo trigger.
Overdue Installments
The system provides a view to identify overdue installments:vw_CuotasVencidas
This view shows unpaid installments past their due date:- diasAtraso: Number of days past due
- moraCalculada: Late fee (2% of installment amount × days overdue)
Upcoming Installments
vw_CuotasPorVencer
This view shows unpaid installments not yet due:- Send payment reminders to customers
- Plan cash flow forecasts
- Identify upcoming collections
Account Status
vw_EstadoCuenta
This view summarizes the payment status for each credit sale:- Display customer account balance
- Track total payments received
- Calculate remaining balance
Cascade Deletion
Payment plans are configured withON DELETE CASCADE:
- Deleting a sale automatically deletes all associated payment plan records
- Ensures referential integrity
- Simplifies data cleanup for voided sales
Database Schema
Performance Optimization
The database includes optimized indexes:Best Practices
Interest Rate Validation
Interest Rate Validation
Validate interest rates before generating payment plans:
Installment Count Limits
Installment Count Limits
Set reasonable limits on installment periods:
Rounding Adjustments
Rounding Adjustments
Handle rounding differences in the final installment: