Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/azahel79/Spartans-gym/llms.txt

Use this file to discover all available pages before exploring further.

Every financial event in Spartans Gym creates a transaction record — whether a client renews their membership or a product is sold at the counter. The History screen surfaces these records in a filterable, paginated list and lets you export the current view to a CSV file for external reporting. Two distinct transaction types keep membership income and retail revenue clearly separated.

Transaction Types

MEMBRESIA

Recorded when a client pays for a membership plan — either on registration or at renewal. The transaction is linked to the client via clienteId and uses the client’s name and surname.

PRODUCTO

Recorded when a sale is finalized from the Point of Sale screen. The concepto field is built automatically from the purchased product names and quantities.
MEMBRESIA transactions are created automatically by the system when a new client is registered or an existing client renews their plan. You do not need to create them manually from the History view.

Transaction Data Model

FieldTypeDescription
idIntAuto-incremented primary key
fechaStringFormatted date string, e.g. "15 ene. 2025"
horaStringTime in 12-hour format, e.g. "10:30 AM"
nombreStringFirst name of the client or "Venta" for POS sales with no linked client
apellidosStringLast name or "Mostrador" for POS sales
clienteIdString?UUID of the linked client, or null for product sales
conceptoStringDescription — product names for PRODUCTO, plan name for MEMBRESIA
montoDecimal(10,2)Amount charged in MXN
metodoPaymentMethodEfectivo, Tarjeta, or Transferencia
tipoTransactionTypeMEMBRESIA or PRODUCTO
createdAtDateTimeUTC timestamp used for date filtering

Viewing Transactions

The History view is split into three tabs: PLANES (MEMBRESIA transactions), PUNTO DE VENTA (PRODUCTO transactions), and ASISTENCIAS (attendance records). Only the first two tabs display transaction data; the Asistencias tab is separate. Transactions are paginated at 10 items per page. Each row shows the date, time, client name (PLANES only), concept, payment method, and amount. An individual receipt can be reprinted by clicking the ticket icon on any row.

Fetching Transactions

The frontend fetches GET /api/transactions and passes filters as query parameters:
GET /api/transactions?tipo=MEMBRESIA&fechaInicio=2025-01-01&fechaFin=2025-01-31
Supported query parameters:
ParameterFormatDescription
tipoMEMBRESIA | PRODUCTOFilter by transaction type
metodoEfectivo | Tarjeta | TransferenciaFilter by payment method
fechaInicioYYYY-MM-DDStart of the date range (inclusive)
fechaFinYYYY-MM-DDEnd of the date range (inclusive)
The history endpoint GET /api/transactions/history returns the last 100 records with no filters applied — useful for a quick audit of recent activity.
Date filtering uses the Mexico City timezone (UTC−6). When fechaInicio=2025-01-15 is provided, the backend converts it to 2025-01-15T06:00:00Z2025-01-16T05:59:59.999Z in UTC before querying createdAt. This ensures that transactions recorded during Mexican business hours always fall on the correct calendar day.

Filters and Date Presets

The filter bar above the transaction table includes quick-select date presets and granular controls:
  • Hoy — current calendar day
  • Ayer — previous calendar day
  • 7 días — last seven days including today
  • Mes — from the first of the current month to today
  • Todos — clears date filters and loads all available transactions
Selecting any preset automatically populates the start and end date inputs. You can then adjust the inputs manually; doing so switches the active preset to “custom.”
A dropdown with options Todos, Efectivo, Tarjeta, and Transferencia. Filtering is applied client-side after the transactions are fetched from the API.
In the PLANES tab this dropdown lets you narrow results to a specific plan type: Mensual, Trimestral, Semestral, or Anual. In the PUNTO DE VENTA tab it filters by product category keyword found in the concepto field: Suplementos, Bebidas, Snacks, Merchandising, or Accesorios.
Click Limpiar at any time to reset all filters to their defaults (today’s date, all payment methods, any category).

Creating a Transaction

Send POST /api/transactions with a JSON body. The required fields differ by type:
{
  "tipo": "PRODUCTO",
  "metodo": "Tarjeta",
  "monto": 280.00,
  "clienteId": null,
  "productos": [
    { "id": 3, "quantity": 1 },
    { "id": 7, "quantity": 2 }
  ]
}
The backend resolves each product ID to its name, decrements stock for each item, and builds the concepto string automatically — e.g., "Whey Protein, Agua 600ml (x2)". The nombre and apellidos fields are set to "Venta" and "Mostrador" respectively since no client is linked.

CSV Export

Clicking Exportar CSV downloads a file containing every transaction currently visible after filters are applied. The exported file respects whatever date range, payment method, category, and search term are active at the time of the click. The CSV columns for transaction exports are:
ID, Fecha, Hora, Cliente ID, Nombre, Apellidos, Concepto, Metodo, Monto, Tipo
The file is named automatically based on the active view and date range, for example: historial_planes_2025-01-01_2025-01-31.csv or historial_punto_de_venta_2025-01-15_2025-01-15.csv The file is UTF-8 encoded with a BOM so it opens correctly in Excel and Google Sheets without garbled special characters.

Summary Bar

Below the transaction table a summary bar shows:
  • Filtered record count — number of transactions matching the current filters
  • Total loaded — total number of transactions returned by the last API call
  • Ingresos del Filtro — sum of monto across all filtered transactions (not just the current page), displayed prominently so staff can quickly total revenue for any period

Build docs developers (and LLMs) love