Quotes (presupuestos) let you propose prices to clients before any fiscal document is issued. In Eme2App, a quote follows its own lifecycle and can be converted into a draft invoice with a single API call, carrying over all line items, taxes, and client data automatically. This tight integration means you never need to re-enter data — the transition from quote to invoice is atomic and auditable.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eme2dev/Eme2App/llms.txt
Use this file to discover all available pages before exploring further.
Quote Lifecycle
| Estado | Meaning |
|---|---|
borrador | Draft — fully editable |
emitida | Sent to the client (set manually via PUT /:id/estado) |
pagada | Marked as accepted and paid (set manually via PUT /:id/estado) |
cancelada | Cancelled (set manually via PUT /:id/estado) |
aceptada | Client accepted; a draft invoice has been generated automatically |
convertida | Converted to a delivery note (albarán) instead of an invoice |
A quote in
cancelada, aceptada, or convertida state cannot be accepted again. These states are terminal. The aceptada and convertida states are set automatically by the system — they cannot be assigned via PUT /:id/estado.Auto-Numbering
Retrieve the next available quote number before creating:(empresa_id, numero), so quote numbers are scoped per company and do not use series.
Creating a Quote
POST /api/presupuestos
All presupuesto routes require a valid JWT. The empresa_id is injected from the authenticated session.
Required fields:
| Field | Type | Notes |
|---|---|---|
cliente_id | string | Must belong to the company |
numero | integer | Unique within the company |
detalles | array | At least one line |
fecha, notas, incluir_impuestos (default true).
Detail line fields:
| Field | Type | Notes |
|---|---|---|
articulo_id | string | Required for non-comment lines |
descripcion | string | Free-text description |
cantidad | number | Quantity |
precio_unitario | number | Unit price |
es_comentario | boolean | Text-only line when true |
linea_orden | integer | Display order (auto-assigned if omitted) |
incluir_impuestos is true (the default), the backend resolves the VAT rate from articulo.iva_id and applies recargo de equivalencia for REC/SIM regime clients. The irpf_monto is also calculated from the client’s regimen_irpf. All totals are stored server-side in presupuestos.subtotal, iva_monto, irpf_monto, and total.
Updating a Quote
PUT /api/presupuestos/:id
Only quotes in borrador state can be updated. The request body follows the same shape as the create call. All existing detail lines are replaced atomically — send the complete updated set of lines.
Updating Quote Status
PUT /api/presupuestos/:id/estado
Use this endpoint to manually advance the quote state (e.g. to mark it as sent, rejected, or expired):
Sending a Quote by Email
POST /api/presupuestos/:id/enviar-email
The frontend generates the PDF and sends it as Base64:
estado_emision field — if you want to track that the quote was sent, update the status to emitida manually after the email call.
Accepting a Quote → Draft Invoice
POST /api/presupuestos/:id/aceptar
This is the key conversion endpoint. When accepted, Eme2App:
- Validates the quote is not in
cancelada,aceptada, orconvertidastate. - Resolves the invoice number, series, date, and payment method from the request body.
- Creates a new
facturasrow inborradorstate, linked viapresupuesto_origen_id. - Copies all non-comment detail lines from the quote, recalculating taxes for the invoice context (including recargo de equivalencia if the client’s regime requires it).
- Marks the presupuesto as
aceptada.
| Field | Type | Notes |
|---|---|---|
numero | integer | Target invoice number — must not already exist |
fecha | string | Invoice date (YYYY-MM-DD) |
serie_id, serie, forma_pago_id (falls back to cliente.forma_pago_defecto_id).
Deleting a Quote
DELETE /api/presupuestos/:id
Only quotes in borrador state can be deleted.
Typical Workflow
Get the next number
Call
GET /api/presupuestos/proximo-numero to retrieve the auto-incremented number.Create the quote
Call
POST /api/presupuestos with the client, number, date, optional notes, and all detail lines.Send to the client
Generate the PDF in the frontend and call
POST /api/presupuestos/:id/enviar-email. Update state to emitida with PUT /api/presupuestos/:id/estado.Client accepts
Call
POST /api/presupuestos/:id/aceptar with a valid invoice number, date, and series. A draft invoice is created automatically.API Quick Reference
| Method | Endpoint | Description |
|---|---|---|
GET | /api/presupuestos/proximo-numero | Next available quote number |
GET | /api/presupuestos | Paginated list of quotes |
GET | /api/presupuestos/:id | Quote detail |
POST | /api/presupuestos | Create a quote |
PUT | /api/presupuestos/:id | Update a quote (borrador only) |
PUT | /api/presupuestos/:id/estado | Update quote status |
POST | /api/presupuestos/:id/aceptar | Accept quote → create draft invoice |
POST | /api/presupuestos/:id/enviar-email | Send PDF by email |
DELETE | /api/presupuestos/:id | Delete a quote (borrador only) |