Overview
The Invoices API provides endpoints for creating, updating, searching, and generating PDF invoices. All endpoints require authentication via session.Add Product to Invoice (Temporary)
Product ID to add to invoice
Quantity of product
Sale price per unit
Returns HTML table showing current invoice items in temporary storage (
tmp table) with:- Product code and name
- Quantity
- Unit price
- Total price
- Subtotal, tax (IVA), and grand total
This endpoint adds products to a temporary session-based storage before the invoice is finalized. Products are stored in the
tmp table with the current session ID.Remove Product from Invoice (Temporary)
Temporary item ID (
id_tmp) to remove from invoiceReturns updated HTML table with remaining invoice items
Update Invoice
Client ID associated with the invoice
Vendor/salesperson user ID
Payment terms/conditions code
Invoice status:
1 for paid, 0 for pendingReturns HTML alert with message: “Factura ha sido actualizada satisfactoriamente.”
Returns HTML alert with error message if validation fails
The invoice ID is retrieved from the session variable
$_SESSION['id_factura']. You must set this session variable before calling this endpoint.Add Product to Existing Invoice
Product ID to add to invoice
Quantity of product
Sale price per unit
Returns HTML table showing updated invoice line items with:
- Product details
- Quantities and prices
- Subtotal, tax, and total
- Updates the
total_ventafield in thefacturastable
This endpoint adds products to an existing invoice (stored in
detalle_factura table). The invoice number is retrieved from $_SESSION['numero_factura'].Remove Product from Existing Invoice
Detail ID (
id_detalle) to remove from invoiceReturns updated HTML table with remaining invoice line items and recalculated totals
Search Invoices
Must be set to
"ajax" to trigger searchSearch term to filter invoices by client name or invoice number. Leave empty to return all invoices.
Page number for pagination (default: 1, 10 results per page)
Returns HTML table with invoice data including:
numero_factura- Invoice numberfecha_factura- Invoice datenombre_cliente- Client name (with phone and email in tooltip)firstname/lastname- Vendor nameestado_factura- Status (1 = Paid, 0 = Pending)total_venta- Total sale amount- Action buttons for edit, download, and delete
Delete Invoice
Invoice number (
numero_factura) to deleteReturns success alert if invoice and all associated line items are deleted
Returns error alert if deletion fails
Deleting an invoice will also delete all associated line items from the
detalle_factura table.Generate Invoice PDF
Client ID for the invoice
Vendor/salesperson user ID
Payment terms/conditions
Returns PDF file named “Factura.pdf” with:
- Company information from
perfiltable - Client information
- Invoice items from session’s
tmptable - Calculated subtotal, tax (IVA), and total
This endpoint:
- Creates a new invoice record in the
facturastable - Generates a new invoice number (auto-increment from last invoice)
- Uses products stored in session’s
tmptable - Returns a PDF document using the HTML2PDF library
- Will display alert and close window if no products are in temporary storage
