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:
@@ -81,8 +81,8 @@ describe('create payments batch', () => {
|
||||
prisma.group.findUnique.mockResolvedValue(groupOwner);
|
||||
prisma.user.findUnique.mockResolvedValue({ id: userId, country: 'AR' });
|
||||
prisma.attendee.findMany.mockResolvedValue([
|
||||
{ id: 'att-1', fullName: 'Juana' },
|
||||
{ id: 'att-2', fullName: 'Pedro' },
|
||||
{ id: 'att-1', person: { fullName: 'Juana' } },
|
||||
{ id: 'att-2', person: { fullName: 'Pedro' } },
|
||||
]);
|
||||
prisma.payment.create
|
||||
.mockResolvedValueOnce({ id: 'pay-1' })
|
||||
@@ -149,7 +149,7 @@ describe('create payments batch', () => {
|
||||
it('derives the currency from the owner country and defaults when there is none', async () => {
|
||||
prisma.group.findUnique.mockResolvedValue({ ...groupOwner, price: { toString: () => '80.00' } });
|
||||
prisma.user.findUnique.mockResolvedValue({ id: userId, country: null });
|
||||
prisma.attendee.findMany.mockResolvedValue([{ id: 'att-2', fullName: 'Pedro' }]);
|
||||
prisma.attendee.findMany.mockResolvedValue([{ id: 'att-2', person: { fullName: 'Pedro' } }]);
|
||||
prisma.payment.create.mockResolvedValueOnce({ id: 'pay-2' });
|
||||
const useCase = batchUseCase();
|
||||
createPreference.mockResolvedValueOnce({
|
||||
@@ -169,13 +169,14 @@ describe('create payments batch', () => {
|
||||
expect(result.value.items[0]).toMatchObject({ attendeeId: 'att-2', currency: 'ARS' });
|
||||
expect(prisma.attendee.findMany).toHaveBeenCalledWith({
|
||||
where: { groupId: 'group-1', status: 'ACTIVE', id: { in: ['att-2'] } },
|
||||
include: { person: { select: { fullName: true } } },
|
||||
});
|
||||
});
|
||||
|
||||
it('propagates the not-connected problem and creates no rows', async () => {
|
||||
prisma.group.findUnique.mockResolvedValue(groupOwner);
|
||||
prisma.user.findUnique.mockResolvedValue({ id: userId, country: 'AR' });
|
||||
prisma.attendee.findMany.mockResolvedValue([{ id: 'att-1', fullName: 'Juana' }]);
|
||||
prisma.attendee.findMany.mockResolvedValue([{ id: 'att-1', person: { fullName: 'Juana' } }]);
|
||||
getToken = mock(async () => ({
|
||||
ok: false,
|
||||
error: {
|
||||
@@ -203,7 +204,7 @@ describe('create payments batch', () => {
|
||||
it('answers 409 over HTTP when the owner has no linked account', async () => {
|
||||
prisma.group.findUnique.mockResolvedValue(groupOwner);
|
||||
prisma.user.findUnique.mockResolvedValue({ id: userId, country: 'AR' });
|
||||
prisma.attendee.findMany.mockResolvedValue([{ id: 'att-1', fullName: 'Juana' }]);
|
||||
prisma.attendee.findMany.mockResolvedValue([{ id: 'att-1', person: { fullName: 'Juana' } }]);
|
||||
prisma.mpAccount.findUnique.mockResolvedValue(null);
|
||||
|
||||
const res = await makeApp({ id: userId }).request('/groups/group-1/payments/batch', {
|
||||
|
||||
Reference in New Issue
Block a user