feat: un miembro puede pertenecer a más de un grupo

- Nuevo modelo `Person` (`people`): contacto y notas por profe, con
  teléfono único (índice parcial `people_owner_phone_key`). `Attendee`
  pasa a ser la membresía (`group_id` + `person_id`, único por grupo).
- La cuenta de la app de alumnos se vincula a la persona
  (`student_account_people`): una sola cuenta ve todos sus grupos.
- Migración unifica attendees del mismo profe y teléfono, y fusiona sus
  cuentas de alumno (conserva la usada más recientemente).
- `POST /groups/:gid/attendees/:aid/add-to-group` y
  `GET /people/lookup` para detectar personas existentes al cargar;
  el alta responde `409 person_exists` y acepta `personId`. Bulk, lista
  de espera y preinscripciones vinculan solas.
- El límite del plan cuenta personas con al menos un grupo activo.
- Web: "Agregar a otro grupo", sección "También está en" en la ficha y
  aviso "Ya tenés a esta persona" en el alta individual.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-11-03 09:46:37 -03:00
parent f1829fb5a9
commit d21e1c3730
84 changed files with 1981 additions and 423 deletions

View File

@@ -19,15 +19,30 @@ import { attendeesRoutes } from '@/modules/attendees';
const app = new Hono();
app.route('/attendees', attendeesRoutes);
const attendeeRow = {
id: 'attendee-1',
groupId: 'group-1',
const personSelect = {
id: true,
fullName: true,
email: true,
phone: true,
guardianName: true,
guardianPhone: true,
notes: true,
};
const person = {
id: 'person-1',
fullName: 'Ana Pérez',
email: 'ana@example.com',
phone: null,
guardianName: 'Luis Pérez',
guardianPhone: null,
notes: null,
};
const attendeeRow = {
id: 'attendee-1',
groupId: 'group-1',
personId: 'person-1',
notifyToken: null,
createdAt: new Date('2026-08-01T10:00:00.000Z'),
updatedAt: new Date('2026-08-01T10:00:00.000Z'),
@@ -36,6 +51,7 @@ const attendeeRow = {
// What the Prisma mock returns: the row plus the summary relations.
const attendee = {
...attendeeRow,
person,
attendances: [{ status: 'ABSENT' }, { status: 'PRESENT' }, { status: 'PRESENT' }],
payments: [{ status: 'OVERDUE', dueDate: new Date('2026-09-10T00:00:00.000Z') }],
};
@@ -56,6 +72,12 @@ describe('attendees routes', () => {
data: [
{
...attendeeRow,
fullName: person.fullName,
email: person.email,
phone: person.phone,
guardianName: person.guardianName,
guardianPhone: person.guardianPhone,
notes: person.notes,
createdAt: attendeeRow.createdAt.toISOString(),
updatedAt: attendeeRow.updatedAt.toISOString(),
// The query comes most recent first; the row shows them
@@ -71,6 +93,7 @@ describe('attendees routes', () => {
take: 10,
orderBy: { createdAt: 'desc' },
include: {
person: { select: personSelect },
attendances: {
orderBy: { classSession: { startsAt: 'desc' } },
take: RECENT_ATTENDANCE_LIMIT,