Overview
The Payments API manages payment records (pagos) for sales operations. Payments can be linked to:
- Sales/Separations: General payments for a sale
- Cuotas: Specific installment payments from amortization plan
Model Structure
Pago Model
Table:pagosPrimary Key:
id_pago (auto-increment)
Attributes
Primary key, auto-increment
Payment date and time
Foreign key to
ventas table. The sale this payment belongs to.Payment reference number (transaction ID, check number, etc.). Max 60 characters.
Foreign key to
conceptos_pago table. Payment concept/purpose.Foreign key to
medios_pago table. Payment method used.Additional payment notes or description
Payment amount
Optional. Foreign key to
planes_amortizacion_cuota table. Links payment to specific installment.Record creation timestamp
Last update timestamp
Relationships
The sale this payment is for. Includes client and property details.
Payment concept details (e.g., “Cuota Inicial”, “Abono”, “Separación”)
Payment method details (e.g., “Efectivo”, “Transferencia”, “Cheque”)
Optional. Specific installment from payment plan this payment covers.
List All Payments
Query Parameters
Filter payments by sale ID
Filter payments by client document
Filter by payment concept
Filter by payment method
Filter payments from this date (format: YYYY-MM-DD)
Filter payments until this date (format: YYYY-MM-DD)
Response
Get Payment by ID
Path Parameters
Payment ID (id_pago)
Create Payment
Request Body
Payment date and time. Defaults to current timestamp if not provided.
Sale ID this payment belongs to
Payment reference number (transaction ID, check number, etc.). Max 60 characters.
Payment concept ID. Common concepts:
- Cuota Inicial (Down Payment)
- Abono (Partial Payment)
- Separación (Separation Fee)
- Saldo Final (Final Balance)
Payment method ID. Common methods:
- Efectivo (Cash)
- Transferencia Bancaria (Bank Transfer)
- Cheque (Check)
- Tarjeta de Crédito (Credit Card)
- Consignación (Bank Deposit)
Additional payment notes or description
Payment amount (must be > 0)
Optional. Links this payment to a specific installment from the amortization plan.
Validation Rules
- fecha: Optional datetime. Defaults to
now()if not provided - id_venta: Required, must exist in
ventastable - referencia_pago: Optional string, max 60 characters
- id_concepto_pago: Optional, must exist in
conceptos_pagotable - id_medio_pago: Optional, must exist in
medios_pagotable - descripcion: Optional text field
- valor: Required, numeric, must be ≥ 0
- id_cuota: Optional, must exist in
planes_amortizacion_cuotatable
Response
Error Responses
Validation errors:
- Sale not found (invalid id_venta)
- Invalid concepto_pago or medio_pago ID
- Invalid cuota ID
- Invalid amount (negative or zero)
Update Payment
Path Parameters
Payment ID to update
Delete Payment
Path Parameters
Payment ID to delete
Response
Payment Concepts
ConceptoPago Model
Table:conceptos_pagoPrimary Key:
id_concepto_pago
Common Payment Concepts
Down payment installments
Separation/reservation fee
Partial payment or advance
Final balance payment
Interest payment
Late payment fee
List Payment Concepts
Payment Methods
MedioPago Model
Table:medios_pagoPrimary Key:
id_medio_pago
Common Payment Methods
Cash payment
Bank transfer
Check payment
Credit card
Debit card
Bank deposit
List Payment Methods
Business Logic
Payment to Sale
Payments are always linked to a sale (id_venta). The sale contains:
- Client information
- Property details
- Total amount
- Payment terms
Payment to Cuota
Optionally, payments can be linked to specific installments (id_cuota) from the amortization plan:
Payment Tracking
To calculate paid amount for a sale:Cuota Status Management
When a payment is linked to a cuota, update the cuota status:Audit Trail
Payments provide an audit trail:referencia_pago: External transaction referencefecha: When payment was receivedmedio_pago: How payment was madeconcepto_pago: What payment was fordescripcion: Additional notes
Payments are typically NOT deleted. If a payment is voided or reversed, create a negative payment or use a “Reversión” concept.
Reporting Queries
Payments by Date Range
Payments by Client
Payments by Project
Payments by Payment Method
Related Endpoints
- Sales API - Sales that receive payments
- Amortization API - Payment schedules and cuotas
- Clients API - Client making payments