Overview
The Accounts Receivable module tracks all credit sales and manages customer payment obligations. The system automatically monitors payment schedules, calculates outstanding balances, and provides real-time visibility into customer accounts.Database View: vw_EstadoCuenta
The account statement view (vw_EstadoCuenta) aggregates all credit sales and their payment status:
View Filters
Credit Sales Only
Credit Sales Only
The view filters for
tipoPago = 'CREDITO' to include only credit transactions, excluding cash sales which don’t generate receivables.Active Sales Only
Active Sales Only
Sales marked as void (
nula = 1) are excluded from the accounts receivable tracking through the condition v.nula = 0.View Model Properties
TheVwEstadoCuentum class in TechCore.Models represents the account statement data:
The unique order number for the credit sale
Customer name from the
clientes tableOriginal total amount of the sale including IVA (tax)
Current outstanding balance after payments. Updated automatically by the
TR_ActualizarSaldo trigger when payments are posted to abonosVentasNumber of months in the payment plan. Null for sales without installment plans
Sum of all payments made against this sale from the
abonosVentas table. Returns 0 if no payments have been madeHow Accounts Receivable Tracking Works
Credit Sale Creation
When a sale is created withtipoPago = 'CREDITO':
- Initial State: The
saldofield is set equal to thetotalamount - Payment Plan: If installments are required, records are created in the
planPagostable with:numeroCuota: Installment number (1, 2, 3, etc.)fechaVencimiento: Due date for each installmentmontoCuota: Amount due for each installmentpagada: Initially set to0(unpaid)
Payment Processing
When a customer makes a payment:-
A record is inserted into the
abonosVentastable with:norden: The order numberfecha: Payment datemonto: Payment amountnumeroCuota: The installment number being paid
-
The
TR_ActualizarSaldotrigger automatically:- Reduces the
saldoin theventastable by the payment amount - Marks the corresponding installment as paid (
pagada = 1) inplanPagos
- Reduces the
The trigger ensures data consistency by automatically updating both the sale balance and installment status in a single transaction.
Balance Calculation
The account statement view calculates:- Total: Original sale amount (unchanged)
- TotalAbonado: Sum of all payments from
abonosVentas - Saldo: Remaining balance = Total - TotalAbonado
Usage Examples
Query All Outstanding Receivables
Calculate Total Accounts Receivable
Get Customer Payment History
Related Tables
ventas
Main sales table containing credit transaction details including total amount and current balance
planPagos
Payment schedule with installment amounts and due dates for credit sales
abonosVentas
Payment records tracking all customer payments against credit sales
clientes
Customer master data including contact information and account status
See Also
- Overdue Payments - Track late payments and calculate penalties
- Account Statements - Generate detailed customer statements