Membership plans are the foundation of how Spartans Gym charges its members. Every client is linked to exactly one plan at any given time. Plans are managed centrally by admins, and their pricing is surfaced throughout the application — in the reception enrollment modal, the renewal dialog, and the Config → Planes y Membresías tab.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.
Plan Data Model
| Field | Type | Notes |
|---|---|---|
id | String (UUID) | Auto-generated on creation. |
name | String (unique) | Display name, e.g. "Mensual" or "Anual". Must be unique across all plans. |
price | Decimal (MXN) | The amount charged to members on enrollment or renewal. |
period | String | Duration string: "Mes", "3 Meses", "6 Meses", or "Año". Defaults to "Mes". |
color | String | A CSS class used for UI badge colouring. Defaults to "bg-primary". |
isActive | Boolean | Whether the plan is available for new enrollments. Defaults to true. |
createdAt | DateTime | Set by the database on insert. |
updatedAt | DateTime | Updated automatically on every change. |
Period-to-Months Mapping
When calculating a membership expiry date (at enrollment or renewal), the backend’sgetPlanMonths function converts the plan’s period string into a number of calendar months to add to the base date.
| Period value in DB | Resolved months |
|---|---|
"Mes" | 1 |
"3 Meses" | 3 |
"trimestral" (case-insensitive) | 3 |
"6 Meses" | 6 |
"semestral" (case-insensitive) | 6 |
"Año" | 12 |
"anual" (case-insensitive) | 12 |
"2 meses" before falling back to keyword detection, so custom period strings containing a number followed by "mes" or "meses" also resolve correctly. If no pattern matches, the function defaults to 1 month.
Creating a Plan
Plans are created by admins viaPOST /api/plans. The request body requires at minimum a name and a price. period defaults to "Mes" if omitted.
HTTP 201 with the new plan object including its auto-generated UUID.
Plans are listed and managed in the Config → Planes y Membresías tab of the application settings. Pricing changes made here take effect immediately for any new enrollment or renewal processed after the update.
Soft Deleting a Plan
Deleting a plan viaDELETE /api/plans/:id performs a soft delete: it sets isActive = false on the record rather than removing it from the database.
Why soft delete?
Why soft delete?
Existing client records store the plan name as a plain string rather than a foreign key. Permanently deleting a plan would not break existing records, but it would remove the plan from pricing lookups. Soft deletion keeps the plan data available for historical reporting and prevents accidental loss of configuration while ensuring the plan no longer appears in enrollment or renewal dropdowns.
plan field value and their existing expiry date. They can still renew, but staff must select a currently active plan when processing the renewal.
Renewal Logic
Membership renewals are processed viaPOST /api/clients/:id/renew with the following body:
Determine the base date
Compare the client’s current
vencimiento date to today’s date.- If
vencimientois in the future → usevencimientoas the base date (extends from the end of the current period). - If
vencimientois today or in the past → use today as the base date (starts a fresh period from now).
Add the plan period
Call
calculateExpiryDate(baseDate, newPlan, plan.period), which adds the resolved number of months to the base date using JavaScript’s setMonth.plan, monto, vencimiento, and status fields:
A transaction record is created automatically on renewal, which feeds into the Dashboard’s Ingresos Totales del Mes and Actividad Reciente sections.
Seed Plans
On first deploy the seed script populates theplans table with a set of sample plans so the application is usable immediately without manual configuration. These plans cover the standard monthly, quarterly, semi-annual, and annual periods.
You can view and modify seeded plans at any time from the Config → Planes y Membresías tab, or delete them (soft delete) and replace them with your own pricing structure.