@stamhoofd/backend 2.79.5 → 2.79.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stamhoofd/backend",
3
- "version": "2.79.5",
3
+ "version": "2.79.7",
4
4
  "main": "./dist/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -38,14 +38,14 @@
38
38
  "@simonbackx/simple-encoding": "2.21.0",
39
39
  "@simonbackx/simple-endpoints": "1.19.1",
40
40
  "@simonbackx/simple-logging": "^1.0.1",
41
- "@stamhoofd/backend-i18n": "2.79.5",
42
- "@stamhoofd/backend-middleware": "2.79.5",
43
- "@stamhoofd/email": "2.79.5",
44
- "@stamhoofd/models": "2.79.5",
45
- "@stamhoofd/queues": "2.79.5",
46
- "@stamhoofd/sql": "2.79.5",
47
- "@stamhoofd/structures": "2.79.5",
48
- "@stamhoofd/utility": "2.79.5",
41
+ "@stamhoofd/backend-i18n": "2.79.7",
42
+ "@stamhoofd/backend-middleware": "2.79.7",
43
+ "@stamhoofd/email": "2.79.7",
44
+ "@stamhoofd/models": "2.79.7",
45
+ "@stamhoofd/queues": "2.79.7",
46
+ "@stamhoofd/sql": "2.79.7",
47
+ "@stamhoofd/structures": "2.79.7",
48
+ "@stamhoofd/utility": "2.79.7",
49
49
  "archiver": "^7.0.1",
50
50
  "aws-sdk": "^2.885.0",
51
51
  "axios": "1.6.8",
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "d48b5e7157491c9a62c43c572958785eea132f48"
68
+ "gitHead": "d8675cbc91c2fcdcc6bbd3b3925ccd8063b15522"
69
69
  }
@@ -2213,7 +2213,7 @@ describe('Endpoint.RegisterMembers', () => {
2213
2213
  // #endregion
2214
2214
 
2215
2215
  // #region act and assert
2216
- await expect(async () => await post(body, organization, token)).rejects.toThrow(new RegExp('Je hebt geen toegangsrechten om deze inschrijving te verwijderen'));
2216
+ await expect(async () => await post(body, organization, token)).rejects.toThrow(/No permission to delete this registration/);
2217
2217
  // #endregion
2218
2218
  });
2219
2219
 
@@ -2343,7 +2343,7 @@ describe('Endpoint.RegisterMembers', () => {
2343
2343
 
2344
2344
  // #region act and assert
2345
2345
  await post(body1, organization, token);
2346
- await expect(async () => await post(body2, organization, token)).rejects.toThrow(new RegExp('Oeps, één of meerdere inschrijvingen die je probeert te verwijderen was al verwijderd. Herlaad de pagina en probeer opnieuw'));
2346
+ await expect(async () => await post(body2, organization, token)).rejects.toThrow(/No permission to delete this registration/);
2347
2347
  // #endregion
2348
2348
  });
2349
2349
  });
@@ -400,7 +400,8 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
400
400
  if (!await Context.auth.canAccessRegistration(existingRegistration, PermissionLevel.Write)) {
401
401
  throw new SimpleError({
402
402
  code: 'forbidden',
403
- message: 'Je hebt geen toegangsrechten om deze inschrijving te verwijderen.',
403
+ message: 'No permission to delete this registration',
404
+ human: 'Je hebt geen toegangsrechten om deze inschrijving te verwijderen.',
404
405
  statusCode: 403,
405
406
  });
406
407
  }
@@ -408,7 +409,8 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
408
409
  if (existingRegistration.deactivatedAt || !existingRegistration.registeredAt) {
409
410
  throw new SimpleError({
410
411
  code: 'invalid_data',
411
- message: 'Oeps, één of meerdere inschrijvingen die je probeert te verwijderen was al verwijderd. Herlaad de pagina en probeer opnieuw.',
412
+ message: 'Cannot delete inactive registration',
413
+ human: 'Oeps, één of meerdere inschrijvingen die je probeert te verwijderen was al verwijderd. Herlaad de pagina en probeer opnieuw.',
412
414
  });
413
415
  }
414
416
 
@@ -455,41 +457,9 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
455
457
  balanceItem.organizationId = organization.id;
456
458
 
457
459
  // Who is responsible for payment?
458
- let balanceItem2: BalanceItem | null = null;
459
460
  if (registration.payingOrganizationId) {
460
- // Create a separate balance item for this meber to pay back the paying organization
461
- // this is not yet associated with a payment but will be added to the outstanding balance of the member
462
-
461
+ // We no longer also charge the member. This has been removed, ref STA-288
463
462
  balanceItem.payingOrganizationId = registration.payingOrganizationId;
464
-
465
- balanceItem2 = new BalanceItem();
466
-
467
- // NOTE: we don't connect the registrationId here
468
- // because otherwise the total price and pricePaid for the registration would be incorrect
469
- // balanceItem2.registrationId = registration.id;
470
-
471
- balanceItem2.unitPrice = unitPrice;
472
- balanceItem2.amount = amount ?? 1;
473
- balanceItem2.description = description;
474
- balanceItem2.relations = relations;
475
- balanceItem2.type = type;
476
-
477
- // Who needs to receive this money?
478
- balanceItem2.organizationId = registration.payingOrganizationId;
479
-
480
- // Who is responsible for payment?
481
- balanceItem2.memberId = registration.memberId;
482
-
483
- if (registration.trialUntil) {
484
- balanceItem2.dueAt = registration.trialUntil;
485
- }
486
-
487
- // If the paying organization hasn't paid yet, this should be hidden and move to pending as soon as the paying organization has paid
488
- balanceItem2.status = BalanceItemStatus.Hidden;
489
- await balanceItem2.save();
490
-
491
- // do not add to createdBalanceItems array because we don't want to add this to the payment if we create a payment
492
- unrelatedCreatedBalanceItems.push(balanceItem2);
493
463
  }
494
464
  else {
495
465
  balanceItem.memberId = registration.memberId;
@@ -499,9 +469,6 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
499
469
  balanceItem.status = BalanceItemStatus.Hidden;
500
470
  balanceItem.pricePaid = 0;
501
471
 
502
- // Connect the 'pay back' balance item to this balance item. As soon as this balance item is paid, we'll mark the other one as pending so the outstanding balance for the member increases
503
- balanceItem.dependingBalanceItemId = balanceItem2?.id ?? null;
504
-
505
472
  if (registration.trialUntil) {
506
473
  balanceItem.dueAt = registration.trialUntil;
507
474
  }
@@ -344,6 +344,11 @@ export class AdminPermissionChecker {
344
344
  * Note: only checks admin permissions. Users that 'own' this member can also access it but that does not use the AdminPermissionChecker
345
345
  */
346
346
  async canAccessRegistration(registration: Registration, permissionLevel: PermissionLevel = PermissionLevel.Read) {
347
+ if (registration.deactivatedAt || !registration.registeredAt) {
348
+ // No full access: cannot access deactivated registrations
349
+ return false;
350
+ }
351
+
347
352
  const organizationPermissions = await this.getOrganizationPermissions(registration.organizationId);
348
353
 
349
354
  if (!organizationPermissions) {
@@ -355,11 +360,6 @@ export class AdminPermissionChecker {
355
360
  return true;
356
361
  }
357
362
 
358
- if (registration.deactivatedAt || !registration.registeredAt) {
359
- // No full access: cannot access deactivated registrations
360
- return false;
361
- }
362
-
363
363
  const allGroups = await this.getOrganizationGroups(registration.organizationId);
364
364
  const group = allGroups.find(g => g.id === registration.groupId);
365
365
  if (!group || group.deletedAt) {
@@ -391,7 +391,7 @@ export class AuthenticatedStructures {
391
391
  const organizations = new Map<string, Organization>();
392
392
 
393
393
  const registrationIds = Formatter.uniqueArray(members.flatMap(m => m.registrations.map(r => r.id)));
394
- const balances = await CachedBalance.getForObjects(registrationIds, Context.organization?.id ?? null);
394
+ const balances = await CachedBalance.getForObjects(registrationIds, null);
395
395
 
396
396
  if (includeUser) {
397
397
  for (const organizationId of includeUser.permissions?.organizationPermissions.keys() ?? []) {