Payment Integration
Payment methods in the Sistema de Ventas are used across different transaction types. Each sale (venta) and purchase (compra) includes a reference to a payment method.
Sales Payment Structure
When creating a sale, the payment method is specified using the formapagoId field:
{
"id" : 1 ,
"serie" : "ABC" ,
"numero" : "001234" ,
"descripcion" : "Venta de productos" ,
"clienteId" : 5 ,
"formapagoId" : 1 ,
"fechaVenta" : "2024-01-15T10:30:00" ,
"baseImponible" : 100.00 ,
"igv" : 18.00 ,
"total" : 118.00 ,
"detalle" : [
{
"productoId" : 10 ,
"cantidad" : 2 ,
"precio" : 50.00
}
]
}
Purchase Payment Structure
Purchases follow the same pattern with formapagoId:
{
"id" : 1 ,
"serie" : "XYZ" ,
"numero" : "005678" ,
"descripcion" : "Compra de inventario" ,
"proveedorId" : 3 ,
"formapagoId" : 2 ,
"fechaCompra" : "2024-01-14T14:20:00" ,
"baseImponible" : 500.00 ,
"igv" : 90.00 ,
"total" : 590.00 ,
"detalle" : [
{
"productoId" : 15 ,
"cantidad" : 10 ,
"precio" : 50.00
}
]
}
Payment Fields
ID of the payment method used for the transaction
Payment method details (populated when retrieving transaction details) Show formaPago properties
Tax Calculation
All transactions in the system automatically calculate IGV (Peru’s Value Added Tax):
Taxable base amount (sum of all line items before tax)
IGV tax amount (18% in Peru)
Total amount including tax (baseImponible + igv)
Querying Payment History
To view payment history for transactions:
Sales with Payment Method
curl -X GET https://api.example.com/venta/1
{
"id" : 1 ,
"serie" : "ABC" ,
"numero" : "001234" ,
"descripcion" : "Venta de productos" ,
"clienteId" : 5 ,
"cliente" : {
"id" : 5 ,
"dni" : "12345678" ,
"nombre" : "Juan" ,
"apellido" : "Pérez" ,
"email" : "[email protected] "
},
"formapagoId" : 1 ,
"formaPago" : {
"id" : 1 ,
"nombre" : "Efectivo"
},
"fechaVenta" : "2024-01-15T10:30:00" ,
"baseImponible" : 100.00 ,
"igv" : 18.00 ,
"total" : 118.00 ,
"detalle" : [
{
"id" : 1 ,
"productoId" : 10 ,
"cantidad" : 2 ,
"precio" : 50.00 ,
"baseImponible" : 100.00 ,
"igv" : 18.00 ,
"total" : 118.00
}
]
}
Purchases with Payment Method
curl -X GET https://api.example.com/compra/1
{
"id" : 1 ,
"serie" : "XYZ" ,
"numero" : "005678" ,
"descripcion" : "Compra de inventario" ,
"proveedorId" : 3 ,
"proveedor" : {
"id" : 3 ,
"ruc" : "20123456789" ,
"nombre" : "Distribuidora ABC S.A.C." ,
"correo" : "[email protected] "
},
"formapagoId" : 2 ,
"formaPago" : {
"id" : 2 ,
"nombre" : "Transferencia Bancaria"
},
"fechaCompra" : "2024-01-14T14:20:00" ,
"baseImponible" : 500.00 ,
"igv" : 90.00 ,
"total" : 590.00 ,
"detalle" : [
{
"id" : 1 ,
"productoId" : 15 ,
"cantidad" : 10 ,
"precio" : 50.00 ,
"baseImponible" : 500.00 ,
"igv" : 90.00 ,
"total" : 590.00
}
]
}
Transaction Numbers
Each transaction is automatically assigned a unique identifier:
Three-letter series code (e.g., “ABC”, “XYZ”). Auto-generated if not provided.
Six-digit transaction number (e.g., “001234”). Auto-generated if not provided.
Series and numbers are automatically generated using secure random values if not explicitly provided during transaction creation.
For complete transaction management, see: