@stamhoofd/backend 2.59.0 → 2.60.0
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/index.ts +4 -0
- package/package.json +10 -10
- package/src/audit-logs/DocumentTemplateLogger.ts +22 -0
- package/src/audit-logs/MemberPlatformMembershipLogger.ts +6 -3
- package/src/audit-logs/ModelLogger.ts +3 -2
- package/src/audit-logs/OrderLogger.ts +1 -1
- package/src/audit-logs/OrganizationLogger.ts +1 -11
- package/src/crons/updateSetupSteps.ts +1 -1
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +3 -3
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +2 -1
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +38 -25
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +3 -11
- package/src/helpers/PeriodHelper.ts +2 -1
- package/src/helpers/SetupStepUpdater.ts +503 -0
- package/src/seeds/1726847064-setup-steps.ts +1 -1
- package/src/seeds/1733319079-fill-paying-organization-ids.ts +68 -0
- package/src/services/AuditLogService.ts +11 -14
- package/src/services/DocumentService.ts +43 -0
- package/src/services/RegistrationService.ts +2 -0
- package/src/services/diff.ts +512 -0
- package/src/sql-filters/events.ts +13 -1
- package/src/services/explainPatch.ts +0 -851
package/index.ts
CHANGED
|
@@ -16,6 +16,8 @@ import { ContextMiddleware } from './src/middleware/ContextMiddleware';
|
|
|
16
16
|
import { Platform } from '@stamhoofd/models';
|
|
17
17
|
import { AuditLogService } from './src/services/AuditLogService';
|
|
18
18
|
import { PlatformMembershipService } from './src/services/PlatformMembershipService';
|
|
19
|
+
import { DocumentService } from './src/services/DocumentService';
|
|
20
|
+
import { SetupStepUpdater } from './src/helpers/SetupStepUpdater';
|
|
19
21
|
|
|
20
22
|
process.on('unhandledRejection', (error: Error) => {
|
|
21
23
|
console.error('unhandledRejection');
|
|
@@ -189,6 +191,8 @@ const start = async () => {
|
|
|
189
191
|
|
|
190
192
|
AuditLogService.listen();
|
|
191
193
|
PlatformMembershipService.listen();
|
|
194
|
+
DocumentService.listen();
|
|
195
|
+
SetupStepUpdater.listen();
|
|
192
196
|
};
|
|
193
197
|
|
|
194
198
|
start().catch((error) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.60.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"@simonbackx/simple-encoding": "2.18.0",
|
|
38
38
|
"@simonbackx/simple-endpoints": "1.15.0",
|
|
39
39
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
40
|
-
"@stamhoofd/backend-i18n": "2.
|
|
41
|
-
"@stamhoofd/backend-middleware": "2.
|
|
42
|
-
"@stamhoofd/email": "2.
|
|
43
|
-
"@stamhoofd/models": "2.
|
|
44
|
-
"@stamhoofd/queues": "2.
|
|
45
|
-
"@stamhoofd/sql": "2.
|
|
46
|
-
"@stamhoofd/structures": "2.
|
|
47
|
-
"@stamhoofd/utility": "2.
|
|
40
|
+
"@stamhoofd/backend-i18n": "2.60.0",
|
|
41
|
+
"@stamhoofd/backend-middleware": "2.60.0",
|
|
42
|
+
"@stamhoofd/email": "2.60.0",
|
|
43
|
+
"@stamhoofd/models": "2.60.0",
|
|
44
|
+
"@stamhoofd/queues": "2.60.0",
|
|
45
|
+
"@stamhoofd/sql": "2.60.0",
|
|
46
|
+
"@stamhoofd/structures": "2.60.0",
|
|
47
|
+
"@stamhoofd/utility": "2.60.0",
|
|
48
48
|
"archiver": "^7.0.1",
|
|
49
49
|
"aws-sdk": "^2.885.0",
|
|
50
50
|
"axios": "1.6.8",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "94ec449bbd82a2e3f49471e66136b04b902587bd"
|
|
68
68
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DocumentTemplate } from '@stamhoofd/models';
|
|
2
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
3
|
+
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
4
|
+
|
|
5
|
+
export const DocumentTemplateLogger = new ModelLogger(DocumentTemplate, {
|
|
6
|
+
skipKeys: ['html'],
|
|
7
|
+
optionsGenerator: getDefaultGenerator({
|
|
8
|
+
created: AuditLogType.DocumentTemplateAdded,
|
|
9
|
+
updated: AuditLogType.DocumentTemplateEdited,
|
|
10
|
+
deleted: AuditLogType.DocumentTemplateDeleted,
|
|
11
|
+
}),
|
|
12
|
+
|
|
13
|
+
createReplacements(model) {
|
|
14
|
+
return new Map([
|
|
15
|
+
['d', AuditLogReplacement.create({
|
|
16
|
+
id: model.id,
|
|
17
|
+
value: model.settings.name,
|
|
18
|
+
type: AuditLogReplacementType.DocumentTemplate,
|
|
19
|
+
})],
|
|
20
|
+
]);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Member, MemberPlatformMembership } from '@stamhoofd/models';
|
|
2
|
-
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType
|
|
1
|
+
import { Member, MemberPlatformMembership, Platform } from '@stamhoofd/models';
|
|
2
|
+
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
3
3
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
4
|
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
5
5
|
|
|
@@ -29,6 +29,7 @@ export const MemberPlatformMembershipLogger = new ModelLogger(MemberPlatformMemb
|
|
|
29
29
|
...result,
|
|
30
30
|
data: {
|
|
31
31
|
member,
|
|
32
|
+
platform: await Platform.getSharedStruct(),
|
|
32
33
|
},
|
|
33
34
|
objectId: event.model.memberId,
|
|
34
35
|
};
|
|
@@ -39,10 +40,12 @@ export const MemberPlatformMembershipLogger = new ModelLogger(MemberPlatformMemb
|
|
|
39
40
|
},
|
|
40
41
|
|
|
41
42
|
createReplacements(model, options) {
|
|
43
|
+
const name = options.data.platform.config.membershipTypes.find(r => r.id === model.membershipTypeId)?.name;
|
|
44
|
+
|
|
42
45
|
const map = new Map([
|
|
43
46
|
['pm', AuditLogReplacement.create({
|
|
44
47
|
id: model.membershipTypeId,
|
|
45
|
-
value:
|
|
48
|
+
value: name,
|
|
46
49
|
type: AuditLogReplacementType.PlatformMembershipType,
|
|
47
50
|
})],
|
|
48
51
|
['m', AuditLogReplacement.create({
|
|
@@ -3,7 +3,7 @@ import { AuditLog } from '@stamhoofd/models';
|
|
|
3
3
|
import { AuditLogReplacement, AuditLogSource, AuditLogType } from '@stamhoofd/structures';
|
|
4
4
|
import { ContextInstance } from '../helpers/Context';
|
|
5
5
|
import { AuditLogService } from '../services/AuditLogService';
|
|
6
|
-
import {
|
|
6
|
+
import { diffUnknown } from '../services/diff';
|
|
7
7
|
|
|
8
8
|
export type ModelEventLogOptions<D> = {
|
|
9
9
|
type: AuditLogType;
|
|
@@ -150,9 +150,10 @@ export class ModelLogger<ModelType extends typeof Model, M extends InstanceType<
|
|
|
150
150
|
// Ignore relations
|
|
151
151
|
continue;
|
|
152
152
|
}
|
|
153
|
-
log.patchList.push(...
|
|
153
|
+
log.patchList.push(...diffUnknown(
|
|
154
154
|
key in oldModel ? oldModel[key] : undefined,
|
|
155
155
|
key in event.model ? event.model[key] : undefined,
|
|
156
|
+
AuditLogReplacement.key(key),
|
|
156
157
|
));
|
|
157
158
|
}
|
|
158
159
|
|
|
@@ -46,7 +46,7 @@ export const OrderLogger = new ModelLogger(Order, {
|
|
|
46
46
|
value: options.data.webshop.meta.name,
|
|
47
47
|
type: AuditLogReplacementType.Webshop,
|
|
48
48
|
})],
|
|
49
|
-
['
|
|
49
|
+
['o', AuditLogReplacement.create({
|
|
50
50
|
id: model.id,
|
|
51
51
|
value: model.number ? `bestelling #${model.number}` : `bestelling van ${model.data.customer.name}`,
|
|
52
52
|
type: AuditLogReplacementType.Order,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Organization } from '@stamhoofd/models';
|
|
2
|
+
import { AuditLogType } from '@stamhoofd/structures';
|
|
2
3
|
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
3
|
-
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
5
|
export const OrganizationLogger = new ModelLogger(Organization, {
|
|
6
6
|
skipKeys: ['searchIndex'],
|
|
@@ -10,16 +10,6 @@ export const OrganizationLogger = new ModelLogger(Organization, {
|
|
|
10
10
|
deleted: AuditLogType.OrganizationDeleted,
|
|
11
11
|
}),
|
|
12
12
|
|
|
13
|
-
createReplacements(model) {
|
|
14
|
-
return new Map([
|
|
15
|
-
['o', AuditLogReplacement.create({
|
|
16
|
-
id: model.id,
|
|
17
|
-
value: model.name,
|
|
18
|
-
type: AuditLogReplacementType.Organization,
|
|
19
|
-
})],
|
|
20
|
-
]);
|
|
21
|
-
},
|
|
22
|
-
|
|
23
13
|
postProcess(event, options, log) {
|
|
24
14
|
log.organizationId = event.model.id;
|
|
25
15
|
},
|
|
@@ -2,8 +2,8 @@ import { OneToManyRelation } from '@simonbackx/simple-database';
|
|
|
2
2
|
import { ConvertArrayToPatchableArray, Decoder, PatchableArrayAutoEncoder, PatchableArrayDecoder, StringDecoder } from '@simonbackx/simple-encoding';
|
|
3
3
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
4
4
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
5
|
-
import { BalanceItem, Document, Group, Member, MemberFactory, MemberPlatformMembership, MemberResponsibilityRecord, MemberWithRegistrations, mergeTwoMembers, Organization, Platform, RateLimiter, Registration,
|
|
6
|
-
import {
|
|
5
|
+
import { BalanceItem, Document, Group, Member, MemberFactory, MemberPlatformMembership, MemberResponsibilityRecord, MemberWithRegistrations, mergeTwoMembers, Organization, Platform, RateLimiter, Registration, User } from '@stamhoofd/models';
|
|
6
|
+
import { GroupType, MembersBlob, MemberWithRegistrationsBlob, PermissionLevel } from '@stamhoofd/structures';
|
|
7
7
|
import { Formatter } from '@stamhoofd/utility';
|
|
8
8
|
|
|
9
9
|
import { Email } from '@stamhoofd/email';
|
|
@@ -13,9 +13,9 @@ import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructure
|
|
|
13
13
|
import { Context } from '../../../helpers/Context';
|
|
14
14
|
import { MembershipCharger } from '../../../helpers/MembershipCharger';
|
|
15
15
|
import { MemberUserSyncer } from '../../../helpers/MemberUserSyncer';
|
|
16
|
-
import { AuditLogService } from '../../../services/AuditLogService';
|
|
17
16
|
import { PlatformMembershipService } from '../../../services/PlatformMembershipService';
|
|
18
17
|
import { RegistrationService } from '../../../services/RegistrationService';
|
|
18
|
+
import { SetupStepUpdater } from '../../../helpers/SetupStepUpdater';
|
|
19
19
|
|
|
20
20
|
type Params = Record<string, never>;
|
|
21
21
|
type Query = undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AutoEncoderPatchType, Decoder, isPatchableArray, patchObject } from '@simonbackx/simple-encoding';
|
|
2
2
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
3
|
-
import { Organization, Platform, RegistrationPeriod
|
|
3
|
+
import { Organization, Platform, RegistrationPeriod } from '@stamhoofd/models';
|
|
4
4
|
import { MemberResponsibility, PlatformConfig, PlatformPremiseType, Platform as PlatformStruct } from '@stamhoofd/structures';
|
|
5
5
|
|
|
6
6
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
@@ -10,6 +10,7 @@ import { MembershipCharger } from '../../../helpers/MembershipCharger';
|
|
|
10
10
|
import { PeriodHelper } from '../../../helpers/PeriodHelper';
|
|
11
11
|
import { TagHelper } from '../../../helpers/TagHelper';
|
|
12
12
|
import { PlatformMembershipService } from '../../../services/PlatformMembershipService';
|
|
13
|
+
import { SetupStepUpdater } from '../../../helpers/SetupStepUpdater';
|
|
13
14
|
|
|
14
15
|
type Params = Record<string, never>;
|
|
15
16
|
type Query = undefined;
|
|
@@ -209,6 +209,18 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
// Who is going to pay?
|
|
213
|
+
let whoWillPayNow: 'member' | 'organization' | 'nobody' = 'member'; // if this is set to 'organization', there will also be created separate balance items so the member can pay back the paying organization
|
|
214
|
+
|
|
215
|
+
if (request.body.asOrganizationId && request.body.asOrganizationId === organization.id) {
|
|
216
|
+
// Will get added to the outstanding amount of the member / already paying organization
|
|
217
|
+
whoWillPayNow = 'nobody';
|
|
218
|
+
}
|
|
219
|
+
else if (request.body.asOrganizationId && request.body.asOrganizationId !== organization.id) {
|
|
220
|
+
// The organization will pay to the organizing organization, and it will get added to the outstanding amount of the member towards the paying organization
|
|
221
|
+
whoWillPayNow = 'organization';
|
|
222
|
+
}
|
|
223
|
+
|
|
212
224
|
const registrationMemberRelation = new ManyToOneRelation(Member, 'member');
|
|
213
225
|
registrationMemberRelation.foreignKey = 'memberId';
|
|
214
226
|
|
|
@@ -264,6 +276,19 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
264
276
|
registration.options = item.options;
|
|
265
277
|
registration.recordAnswers = item.recordAnswers;
|
|
266
278
|
|
|
279
|
+
if (whoWillPayNow === 'organization' && request.body.asOrganizationId) {
|
|
280
|
+
registration.payingOrganizationId = request.body.asOrganizationId;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (whoWillPayNow === 'nobody' && item.replaceRegistrations.length > 0) {
|
|
284
|
+
// If the replace registration was paid by an organization
|
|
285
|
+
// Make sure this updated registration will also be paid by the organization, not the member
|
|
286
|
+
const paidAsOrganization = item.replaceRegistrations[0].payingOrganizationId;
|
|
287
|
+
if (paidAsOrganization) {
|
|
288
|
+
registration.payingOrganizationId = paidAsOrganization;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
267
292
|
payRegistrations.push({
|
|
268
293
|
registration,
|
|
269
294
|
item,
|
|
@@ -272,18 +297,6 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
272
297
|
registrations.push(registration);
|
|
273
298
|
}
|
|
274
299
|
|
|
275
|
-
// Who is going to pay?
|
|
276
|
-
let whoWillPayNow: 'member' | 'organization' | 'nobody' = 'member'; // if this is set to 'organization', there will also be created separate balance items so the member can pay back the paying organization
|
|
277
|
-
|
|
278
|
-
if (request.body.asOrganizationId && request.body.asOrganizationId === organization.id) {
|
|
279
|
-
// Will get added to the outstanding amount of the member
|
|
280
|
-
whoWillPayNow = 'nobody';
|
|
281
|
-
}
|
|
282
|
-
else if (request.body.asOrganizationId && request.body.asOrganizationId !== organization.id) {
|
|
283
|
-
// The organization will pay to the organizing organization, and it will get added to the outstanding amount of the member towards the paying organization
|
|
284
|
-
whoWillPayNow = 'organization';
|
|
285
|
-
}
|
|
286
|
-
|
|
287
300
|
// Validate payment method
|
|
288
301
|
if (totalPrice > 0 && whoWillPayNow !== 'nobody') {
|
|
289
302
|
const allowedPaymentMethods = organization.meta.registrationPaymentConfiguration.getAvailablePaymentMethods({
|
|
@@ -369,8 +382,13 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
369
382
|
deactivatedRegistrationGroupIds.push(existingRegistration.groupId);
|
|
370
383
|
}
|
|
371
384
|
|
|
372
|
-
async function createBalanceItem({ registration, amount, unitPrice, description, type, relations }: { amount?: number; registration: RegistrationWithMemberAndGroup; unitPrice: number; description: string; relations: Map<BalanceItemRelationType, BalanceItemRelation>; type: BalanceItemType }) {
|
|
385
|
+
async function createBalanceItem({ registration, skipZero, amount, unitPrice, description, type, relations }: { amount?: number; skipZero?: boolean; registration: RegistrationWithMemberAndGroup; unitPrice: number; description: string; relations: Map<BalanceItemRelationType, BalanceItemRelation>; type: BalanceItemType }) {
|
|
373
386
|
// NOTE: We also need to save zero-price balance items because for online payments, we need to know which registrations to activate after payment
|
|
387
|
+
if (skipZero === true) {
|
|
388
|
+
if (unitPrice === 0 || amount === 0) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
374
392
|
|
|
375
393
|
// Create balance item
|
|
376
394
|
const balanceItem = new BalanceItem();
|
|
@@ -386,11 +404,11 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
386
404
|
|
|
387
405
|
// Who is responsible for payment?
|
|
388
406
|
let balanceItem2: BalanceItem | null = null;
|
|
389
|
-
if (
|
|
407
|
+
if (registration.payingOrganizationId) {
|
|
390
408
|
// Create a separate balance item for this meber to pay back the paying organization
|
|
391
409
|
// this is not yet associated with a payment but will be added to the outstanding balance of the member
|
|
392
410
|
|
|
393
|
-
balanceItem.payingOrganizationId =
|
|
411
|
+
balanceItem.payingOrganizationId = registration.payingOrganizationId;
|
|
394
412
|
|
|
395
413
|
balanceItem2 = new BalanceItem();
|
|
396
414
|
|
|
@@ -405,7 +423,7 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
405
423
|
balanceItem2.type = type;
|
|
406
424
|
|
|
407
425
|
// Who needs to receive this money?
|
|
408
|
-
balanceItem2.organizationId =
|
|
426
|
+
balanceItem2.organizationId = registration.payingOrganizationId;
|
|
409
427
|
|
|
410
428
|
// Who is responsible for payment?
|
|
411
429
|
balanceItem2.memberId = registration.memberId;
|
|
@@ -437,26 +455,19 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
437
455
|
const { item, registration } = bundle;
|
|
438
456
|
registration.reservedUntil = null;
|
|
439
457
|
|
|
440
|
-
/* if (shouldMarkValid) {
|
|
441
|
-
await registration.markValid({ skipEmail: bundle.item.replaceRegistrations.length > 0 });
|
|
442
|
-
}
|
|
443
|
-
else { */
|
|
444
458
|
// Reserve registration for 30 minutes (if needed)
|
|
445
459
|
const group = groups.find(g => g.id === registration.groupId);
|
|
446
460
|
|
|
447
461
|
if (group && group.settings.maxMembers !== null) {
|
|
448
462
|
registration.reservedUntil = new Date(new Date().getTime() + 1000 * 60 * 30);
|
|
449
463
|
}
|
|
464
|
+
|
|
465
|
+
// Only now save the registration
|
|
450
466
|
await registration.save();
|
|
451
|
-
// }
|
|
452
467
|
|
|
453
468
|
// Note: we should always create the balance items: even when the price is zero
|
|
454
469
|
// Otherwise we don't know which registrations to activate after payment
|
|
455
470
|
|
|
456
|
-
if (shouldMarkValid && item.calculatedPrice === 0) {
|
|
457
|
-
// continue;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
471
|
// Create balance items
|
|
461
472
|
const sharedRelations: [BalanceItemRelationType, BalanceItemRelation][] = [
|
|
462
473
|
[
|
|
@@ -490,6 +501,7 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
490
501
|
registration,
|
|
491
502
|
unitPrice: item.groupPrice.price.forMember(item.member),
|
|
492
503
|
type: BalanceItemType.Registration,
|
|
504
|
+
skipZero: false, // Always create at least one balance item for each registration - even when the price is zero
|
|
493
505
|
description: `${item.member.patchedMember.name} bij ${item.group.settings.name}`,
|
|
494
506
|
relations: new Map([
|
|
495
507
|
...sharedRelations,
|
|
@@ -502,6 +514,7 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
502
514
|
registration,
|
|
503
515
|
amount: option.amount,
|
|
504
516
|
unitPrice: option.option.price.forMember(item.member),
|
|
517
|
+
skipZero: true, // Do not create for zero option prices
|
|
505
518
|
type: BalanceItemType.Registration,
|
|
506
519
|
description: `${option.optionMenu.name}: ${option.option.name}`,
|
|
507
520
|
relations: new Map([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AutoEncoderPatchType, cloneObject, Decoder, isPatchableArray, ObjectData, PatchableArrayAutoEncoder, patchObject } from '@simonbackx/simple-encoding';
|
|
2
2
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
3
3
|
import { SimpleError, SimpleErrors } from '@simonbackx/simple-errors';
|
|
4
|
-
import { Organization, OrganizationRegistrationPeriod, PayconiqPayment, Platform, RegistrationPeriod,
|
|
4
|
+
import { Organization, OrganizationRegistrationPeriod, PayconiqPayment, Platform, RegistrationPeriod, StripeAccount, Webshop } from '@stamhoofd/models';
|
|
5
5
|
import { BuckarooSettings, Company, OrganizationMetaData, OrganizationPatch, Organization as OrganizationStruct, PayconiqAccount, PaymentMethod, PaymentMethodHelper, PermissionLevel, PlatformConfig } from '@stamhoofd/structures';
|
|
6
6
|
import { Formatter } from '@stamhoofd/utility';
|
|
7
7
|
|
|
@@ -10,6 +10,7 @@ import { BuckarooHelper } from '../../../../helpers/BuckarooHelper';
|
|
|
10
10
|
import { Context } from '../../../../helpers/Context';
|
|
11
11
|
import { TagHelper } from '../../../../helpers/TagHelper';
|
|
12
12
|
import { ViesHelper } from '../../../../helpers/ViesHelper';
|
|
13
|
+
import { SetupStepUpdater } from '../../../../helpers/SetupStepUpdater';
|
|
13
14
|
|
|
14
15
|
type Params = Record<string, never>;
|
|
15
16
|
type Query = undefined;
|
|
@@ -3,9 +3,10 @@ import { GroupPrivateSettings, Group as GroupStruct, GroupType, OrganizationRegi
|
|
|
3
3
|
|
|
4
4
|
import { AutoEncoderPatchType, Decoder, PatchableArrayAutoEncoder, PatchableArrayDecoder, StringDecoder } from '@simonbackx/simple-encoding';
|
|
5
5
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
6
|
-
import { Group, Organization, OrganizationRegistrationPeriod, Platform, RegistrationPeriod
|
|
6
|
+
import { Group, Organization, OrganizationRegistrationPeriod, Platform, RegistrationPeriod } from '@stamhoofd/models';
|
|
7
7
|
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures';
|
|
8
8
|
import { Context } from '../../../../helpers/Context';
|
|
9
|
+
import { SetupStepUpdater } from '../../../../helpers/SetupStepUpdater';
|
|
9
10
|
|
|
10
11
|
type Params = Record<string, never>;
|
|
11
12
|
type Query = undefined;
|
|
@@ -303,11 +304,6 @@ export class PatchOrganizationRegistrationPeriodsEndpoint extends Endpoint<Param
|
|
|
303
304
|
throw Context.auth.error('Je hebt geen toegangsrechten om deze groep te wijzigen');
|
|
304
305
|
}
|
|
305
306
|
|
|
306
|
-
const previousProperties = {
|
|
307
|
-
deletedAt: model.deletedAt,
|
|
308
|
-
defaultAgeGroupId: model.defaultAgeGroupId,
|
|
309
|
-
};
|
|
310
|
-
|
|
311
307
|
if (struct.settings) {
|
|
312
308
|
struct.settings.period = undefined; // Not allowed to patch manually
|
|
313
309
|
model.settings.patchOrPut(struct.settings);
|
|
@@ -422,9 +418,7 @@ export class PatchOrganizationRegistrationPeriodsEndpoint extends Endpoint<Param
|
|
|
422
418
|
}
|
|
423
419
|
}
|
|
424
420
|
|
|
425
|
-
await model.updateOccupancy(
|
|
426
|
-
previousProperties,
|
|
427
|
-
});
|
|
421
|
+
await model.updateOccupancy();
|
|
428
422
|
await model.save();
|
|
429
423
|
}
|
|
430
424
|
|
|
@@ -505,8 +499,6 @@ export class PatchOrganizationRegistrationPeriodsEndpoint extends Endpoint<Param
|
|
|
505
499
|
}
|
|
506
500
|
|
|
507
501
|
await model.save();
|
|
508
|
-
await model.updateOccupancy({ isNew: true }); // Force update steps
|
|
509
|
-
|
|
510
502
|
return model;
|
|
511
503
|
}
|
|
512
504
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
2
|
-
import { Group, Member, MemberResponsibilityRecord, Organization, OrganizationRegistrationPeriod, Platform, RegistrationPeriod
|
|
2
|
+
import { Group, Member, MemberResponsibilityRecord, Organization, OrganizationRegistrationPeriod, Platform, RegistrationPeriod } from '@stamhoofd/models';
|
|
3
3
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
4
4
|
import { AuditLogSource, Group as GroupStruct, PermissionLevel } from '@stamhoofd/structures';
|
|
5
5
|
import { PatchOrganizationRegistrationPeriodsEndpoint } from '../endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint';
|
|
6
6
|
import { AuthenticatedStructures } from './AuthenticatedStructures';
|
|
7
7
|
import { MemberUserSyncer } from './MemberUserSyncer';
|
|
8
8
|
import { AuditLogService } from '../services/AuditLogService';
|
|
9
|
+
import { SetupStepUpdater } from './SetupStepUpdater';
|
|
9
10
|
|
|
10
11
|
export class PeriodHelper {
|
|
11
12
|
static async moveOrganizationToPeriod(organization: Organization, period: RegistrationPeriod) {
|