@stamhoofd/models 2.115.1 → 2.117.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/dist/src/factories/MemberFactory.d.ts +3 -3
- package/dist/src/factories/MemberFactory.d.ts.map +1 -1
- package/dist/src/factories/MemberFactory.js.map +1 -1
- package/dist/src/helpers/Handlebars.d.ts.map +1 -1
- package/dist/src/helpers/Handlebars.js +4 -0
- package/dist/src/helpers/Handlebars.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/migrations/1770917406-create-cached-balances-global-index.sql +2 -0
- package/dist/src/migrations/1770917407-create-member-name-ordering-index.sql +2 -0
- package/dist/src/migrations/1770917408-create-member-name-ordering-index-desc.sql +2 -0
- package/dist/src/migrations/1770917409-create-member-age-ordering-index.sql +2 -0
- package/dist/src/migrations/1770917410-create-member-age-ordering-index-desc.sql +2 -0
- package/dist/src/migrations/1770917411-drop-duplicate-member-indexes.sql +3 -0
- package/dist/src/migrations/1771510518-events-index-organization-id-start-date.sql +2 -0
- package/dist/src/migrations/1771918307-membership-active-filter-index.sql +2 -0
- package/dist/src/migrations/1772033555-balance-item-package-id.sql +3 -0
- package/dist/src/migrations/1772033715-balance-item-start-end-date.sql +3 -0
- package/dist/src/models/AuditLog.d.ts +1 -0
- package/dist/src/models/AuditLog.d.ts.map +1 -1
- package/dist/src/models/AuditLog.js +8 -0
- package/dist/src/models/AuditLog.js.map +1 -1
- package/dist/src/models/BalanceItem.d.ts +22 -2
- package/dist/src/models/BalanceItem.d.ts.map +1 -1
- package/dist/src/models/BalanceItem.js +32 -0
- package/dist/src/models/BalanceItem.js.map +1 -1
- package/dist/src/models/Document.d.ts +3 -3
- package/dist/src/models/Document.d.ts.map +1 -1
- package/dist/src/models/Document.js +11 -7
- package/dist/src/models/Document.js.map +1 -1
- package/dist/src/models/DocumentTemplate.d.ts +4 -0
- package/dist/src/models/DocumentTemplate.d.ts.map +1 -1
- package/dist/src/models/DocumentTemplate.js +33 -12
- package/dist/src/models/DocumentTemplate.js.map +1 -1
- package/dist/src/models/Group.d.ts +1 -5
- package/dist/src/models/Group.d.ts.map +1 -1
- package/dist/src/models/Group.js +1 -55
- package/dist/src/models/Group.js.map +1 -1
- package/dist/src/models/Invoice.d.ts +1 -4
- package/dist/src/models/Invoice.d.ts.map +1 -1
- package/dist/src/models/Invoice.js +0 -45
- package/dist/src/models/Invoice.js.map +1 -1
- package/dist/src/models/Member.d.ts +51 -10
- package/dist/src/models/Member.d.ts.map +1 -1
- package/dist/src/models/Member.js +209 -126
- package/dist/src/models/Member.js.map +1 -1
- package/dist/src/models/Organization.d.ts +19 -1
- package/dist/src/models/Organization.d.ts.map +1 -1
- package/dist/src/models/Organization.js +28 -3
- package/dist/src/models/Organization.js.map +1 -1
- package/dist/src/models/Platform.test.js +3 -3
- package/dist/src/models/Platform.test.js.map +1 -1
- package/dist/src/models/Registration.d.ts +1 -2
- package/dist/src/models/Registration.d.ts.map +1 -1
- package/dist/src/models/Registration.js +12 -88
- package/dist/src/models/Registration.js.map +1 -1
- package/dist/src/models/RegistrationPeriod.d.ts +1 -0
- package/dist/src/models/RegistrationPeriod.d.ts.map +1 -1
- package/dist/src/models/RegistrationPeriod.js +5 -0
- package/dist/src/models/RegistrationPeriod.js.map +1 -1
- package/dist/src/models/STPackage.d.ts +1 -5
- package/dist/src/models/STPackage.d.ts.map +1 -1
- package/dist/src/models/STPackage.js +0 -41
- package/dist/src/models/STPackage.js.map +1 -1
- package/dist/src/models/User.d.ts.map +1 -1
- package/dist/src/models/User.js +1 -0
- package/dist/src/models/User.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/factories/MemberFactory.ts +3 -3
- package/src/helpers/Handlebars.ts +4 -0
- package/src/index.ts +0 -1
- package/src/migrations/1770917406-create-cached-balances-global-index.sql +2 -0
- package/src/migrations/1770917407-create-member-name-ordering-index.sql +2 -0
- package/src/migrations/1770917408-create-member-name-ordering-index-desc.sql +2 -0
- package/src/migrations/1770917409-create-member-age-ordering-index.sql +2 -0
- package/src/migrations/1770917410-create-member-age-ordering-index-desc.sql +2 -0
- package/src/migrations/1770917411-drop-duplicate-member-indexes.sql +3 -0
- package/src/migrations/1771510518-events-index-organization-id-start-date.sql +2 -0
- package/src/migrations/1771918307-membership-active-filter-index.sql +2 -0
- package/src/migrations/1772033555-balance-item-package-id.sql +3 -0
- package/src/migrations/1772033715-balance-item-start-end-date.sql +3 -0
- package/src/models/AuditLog.ts +10 -1
- package/src/models/BalanceItem.ts +32 -2
- package/src/models/Document.ts +13 -10
- package/src/models/DocumentTemplate.ts +37 -13
- package/src/models/Group.ts +4 -71
- package/src/models/Invoice.ts +0 -57
- package/src/models/Member.ts +262 -156
- package/src/models/Organization.ts +34 -4
- package/src/models/Platform.test.ts +3 -3
- package/src/models/Registration.ts +21 -99
- package/src/models/RegistrationPeriod.ts +6 -0
- package/src/models/STPackage.ts +0 -50
- package/src/models/User.ts +2 -1
- package/dist/src/helpers/GroupBuilder.d.ts +0 -9
- package/dist/src/helpers/GroupBuilder.d.ts.map +0 -1
- package/dist/src/helpers/GroupBuilder.js +0 -382
- package/dist/src/helpers/GroupBuilder.js.map +0 -1
- package/src/helpers/GroupBuilder.ts +0 -415
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { column,
|
|
2
|
-
import { AppliedRegistrationDiscount, EmailTemplateType, GroupPrice,
|
|
3
|
-
import { Formatter } from '@stamhoofd/utility';
|
|
1
|
+
import { column, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
|
+
import { AppliedRegistrationDiscount, EmailTemplateType, GroupPrice, Recipient, RecordAnswer, RecordAnswerDecoder, RegisterItemOption, Registration as RegistrationStructure, Replacement, StockReservation } from '@stamhoofd/structures';
|
|
4
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
4
|
|
|
6
5
|
import { ArrayDecoder, MapDecoder, StringDecoder } from '@simonbackx/simple-encoding';
|
|
7
|
-
import { QueryableModel } from '@stamhoofd/sql';
|
|
6
|
+
import { QueryableModel, SQL } from '@stamhoofd/sql';
|
|
8
7
|
import { sendEmailTemplate } from '../helpers/EmailBuilder.js';
|
|
9
|
-
import { Group, Organization
|
|
8
|
+
import { Group, Organization } from './index.js';
|
|
10
9
|
|
|
11
10
|
export class Registration extends QueryableModel {
|
|
12
11
|
static table = 'registrations';
|
|
@@ -169,27 +168,29 @@ export class Registration extends QueryableModel {
|
|
|
169
168
|
* This is used for billing
|
|
170
169
|
*/
|
|
171
170
|
static async getActiveMembers(organizationId: string): Promise<number> {
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
WHERE \`groups\`.organizationId = ? AND \`${Registration.table}\`.cycle = \`groups\`.cycle AND \`groups\`.deletedAt is null AND \`${Registration.table}\`.registeredAt is not null AND \`${Registration.table}\`.deactivatedAt is null`;
|
|
176
|
-
|
|
177
|
-
const [results] = await Database.select(query, [organizationId]);
|
|
178
|
-
const count = results[0]['']['c'];
|
|
179
|
-
|
|
180
|
-
if (Number.isInteger(count)) {
|
|
181
|
-
return count as number;
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
console.error('Unexpected result for occupancy', results);
|
|
185
|
-
throw new Error('Query failed');
|
|
171
|
+
const organization = await Organization.getByID(organizationId);
|
|
172
|
+
if (!organization) {
|
|
173
|
+
return 0;
|
|
186
174
|
}
|
|
175
|
+
|
|
176
|
+
return await this.select()
|
|
177
|
+
.join(
|
|
178
|
+
SQL.join(Group.table)
|
|
179
|
+
.where(SQL.column('id'), SQL.parentColumn('groupId')),
|
|
180
|
+
)
|
|
181
|
+
.where('periodId', organization.periodId)
|
|
182
|
+
.where('deactivatedAt', null)
|
|
183
|
+
.where('registeredAt', '!=', null)
|
|
184
|
+
.where(SQL.column(Group.table, 'deletedAt'), null)
|
|
185
|
+
.count(
|
|
186
|
+
SQL.distinct(SQL.column('memberId')),
|
|
187
|
+
);
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
async getRecipients(organization: Organization, group: import('./').Group) {
|
|
190
191
|
const { Member } = await import('./Member.js');
|
|
191
192
|
|
|
192
|
-
const member = await Member.
|
|
193
|
+
const member = await Member.getByIdWithUsers(this.memberId);
|
|
193
194
|
|
|
194
195
|
if (!member) {
|
|
195
196
|
return [];
|
|
@@ -251,85 +252,6 @@ export class Registration extends QueryableModel {
|
|
|
251
252
|
});
|
|
252
253
|
}
|
|
253
254
|
|
|
254
|
-
static async sendTransferEmail(user: User, organization: Organization, payment: import('./').Payment) {
|
|
255
|
-
const paymentGeneral = await payment.getGeneralStructure();
|
|
256
|
-
const groupIds = paymentGeneral.groupIds;
|
|
257
|
-
|
|
258
|
-
const recipients = [
|
|
259
|
-
Recipient.create({
|
|
260
|
-
firstName: user.firstName,
|
|
261
|
-
lastName: user.lastName,
|
|
262
|
-
email: user.email,
|
|
263
|
-
userId: user.id,
|
|
264
|
-
replacements: [
|
|
265
|
-
Replacement.create({
|
|
266
|
-
token: 'priceToPay',
|
|
267
|
-
value: Formatter.price(payment.price),
|
|
268
|
-
}),
|
|
269
|
-
Replacement.create({
|
|
270
|
-
token: 'paymentMethod',
|
|
271
|
-
value: PaymentMethodHelper.getName(payment.method ?? PaymentMethod.Unknown),
|
|
272
|
-
}),
|
|
273
|
-
Replacement.create({
|
|
274
|
-
token: 'transferDescription',
|
|
275
|
-
value: (payment.transferDescription ?? ''),
|
|
276
|
-
}),
|
|
277
|
-
Replacement.create({
|
|
278
|
-
token: 'transferBankAccount',
|
|
279
|
-
value: payment.transferSettings?.iban ?? '',
|
|
280
|
-
}),
|
|
281
|
-
Replacement.create({
|
|
282
|
-
token: 'transferBankCreditor',
|
|
283
|
-
value: payment.transferSettings?.creditor ?? organization.name,
|
|
284
|
-
}),
|
|
285
|
-
Replacement.create({
|
|
286
|
-
token: 'overviewContext',
|
|
287
|
-
value: $t(`01d5fd7e-2960-4eb4-ab3a-2ac6dcb2e39c`) + ' ' + paymentGeneral.memberNames,
|
|
288
|
-
}),
|
|
289
|
-
Replacement.create({
|
|
290
|
-
token: 'memberNames',
|
|
291
|
-
value: paymentGeneral.memberNames,
|
|
292
|
-
}),
|
|
293
|
-
Replacement.create({
|
|
294
|
-
token: 'overviewTable',
|
|
295
|
-
value: '',
|
|
296
|
-
html: paymentGeneral.getDetailsHTMLTable(),
|
|
297
|
-
}),
|
|
298
|
-
Replacement.create({
|
|
299
|
-
token: 'paymentTable',
|
|
300
|
-
value: '',
|
|
301
|
-
html: paymentGeneral.getHTMLTable(),
|
|
302
|
-
}),
|
|
303
|
-
Replacement.create({
|
|
304
|
-
token: 'registerUrl',
|
|
305
|
-
value: 'https://' + organization.getHost(),
|
|
306
|
-
}),
|
|
307
|
-
Replacement.create({
|
|
308
|
-
token: 'organizationName',
|
|
309
|
-
value: organization.name,
|
|
310
|
-
}),
|
|
311
|
-
],
|
|
312
|
-
}),
|
|
313
|
-
];
|
|
314
|
-
|
|
315
|
-
let group: Group | undefined | null = null;
|
|
316
|
-
|
|
317
|
-
if (groupIds.length == 1) {
|
|
318
|
-
const Group = (await import('./index.js')).Group;
|
|
319
|
-
group = await Group.getByID(groupIds[0]);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// Create e-mail builder
|
|
323
|
-
await sendEmailTemplate(organization, {
|
|
324
|
-
template: {
|
|
325
|
-
type: EmailTemplateType.RegistrationTransferDetails,
|
|
326
|
-
group,
|
|
327
|
-
},
|
|
328
|
-
type: 'transactional',
|
|
329
|
-
recipients,
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
|
|
333
255
|
shouldIncludeStock() {
|
|
334
256
|
return (this.registeredAt !== null && this.deactivatedAt === null) || this.canRegister || (this.reservedUntil && this.reservedUntil > new Date());
|
|
335
257
|
}
|
|
@@ -68,6 +68,12 @@ export class RegistrationPeriod extends QueryableModel {
|
|
|
68
68
|
return RegistrationPeriodStruct.create(this);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
configureForNewOrganization() {
|
|
72
|
+
this.settings = RegistrationPeriodSettings.create({});
|
|
73
|
+
this.startDate = new Date();
|
|
74
|
+
this.endDate = new Date(Date.now() + 1000 * 60 * 60 * 24 * 31); // 1 month
|
|
75
|
+
}
|
|
76
|
+
|
|
71
77
|
static async getByDate(date: Date, organizationId: string | null): Promise<RegistrationPeriod | null> {
|
|
72
78
|
if (STAMHOOFD.userMode === 'organization' && organizationId === null) {
|
|
73
79
|
throw new SimpleError({
|
package/src/models/STPackage.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
6
6
|
|
|
7
7
|
import { QueryableModel } from '@stamhoofd/sql';
|
|
8
8
|
import { sendEmailTemplate } from '../helpers/EmailBuilder.js';
|
|
9
|
-
import { GroupBuilder } from '../helpers/GroupBuilder.js';
|
|
10
9
|
import { Organization } from './index.js';
|
|
11
10
|
|
|
12
11
|
export class STPackage extends QueryableModel {
|
|
@@ -66,55 +65,6 @@ export class STPackage extends QueryableModel {
|
|
|
66
65
|
@column({ type: 'datetime', nullable: true })
|
|
67
66
|
lastEmailAt: Date | null = null;
|
|
68
67
|
|
|
69
|
-
static async getForOrganization(organizationId: string) {
|
|
70
|
-
const pack1 = await STPackage.where({ organizationId, validAt: { sign: '!=', value: null }, removeAt: { sign: '>', value: new Date() } });
|
|
71
|
-
const pack2 = await STPackage.where({ organizationId, validAt: { sign: '!=', value: null }, removeAt: null });
|
|
72
|
-
|
|
73
|
-
return [...pack1, ...pack2];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static async getForOrganizationIncludingExpired(organizationId: string) {
|
|
77
|
-
return await STPackage.where({ organizationId, validAt: { sign: '!=', value: null } }, { sort: [{ column: 'validAt', direction: 'DESC' }] });
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static async getOrganizationPackagesMap(organizationId: string): Promise<Map<STPackageType, STPackageStatus>> {
|
|
81
|
-
const packages = await this.getForOrganizationIncludingExpired(organizationId);
|
|
82
|
-
|
|
83
|
-
const map = new Map<STPackageType, STPackageStatus>();
|
|
84
|
-
for (const pack of packages) {
|
|
85
|
-
const exist = map.get(pack.meta.type);
|
|
86
|
-
if (exist) {
|
|
87
|
-
exist.merge(pack.createStatus());
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
map.set(pack.meta.type, pack.createStatus());
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return map;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
static async updateOrganizationPackages(organizationId: string) {
|
|
98
|
-
console.log('Updating packages for organization ' + organizationId);
|
|
99
|
-
const map = await this.getOrganizationPackagesMap(organizationId);
|
|
100
|
-
|
|
101
|
-
const organization = await Organization.getByID(organizationId);
|
|
102
|
-
if (organization) {
|
|
103
|
-
const didUseMembers = organization.meta.packages.useMembers && organization.meta.packages.useActivities;
|
|
104
|
-
organization.meta.packages.packages = map;
|
|
105
|
-
await organization.save();
|
|
106
|
-
|
|
107
|
-
if (!didUseMembers && organization.meta.packages.useMembers && organization.meta.packages.useActivities) {
|
|
108
|
-
console.log('Building groups and categories for ' + organization.id);
|
|
109
|
-
const builder = new GroupBuilder(organization);
|
|
110
|
-
await builder.build();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
console.error("Couldn't find organization when updating packages " + organizationId);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
68
|
async activate() {
|
|
119
69
|
if (this.validAt !== null) {
|
|
120
70
|
return;
|
package/src/models/User.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { column, Database, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
2
|
import { EmailInterfaceRecipient } from '@stamhoofd/email';
|
|
3
|
-
import { QueryableModel, SQL, SQLJSONNull } from '@stamhoofd/sql';
|
|
3
|
+
import { ModelCache, QueryableModel, SQL, SQLJSONNull } from '@stamhoofd/sql';
|
|
4
4
|
import { LoginProviderType, NewUser, Permissions, Recipient, Replacement, UserMeta, UserPermissions, User as UserStruct } from '@stamhoofd/structures';
|
|
5
5
|
import argon2 from 'argon2';
|
|
6
6
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -11,6 +11,7 @@ import { Organization } from './index.js';
|
|
|
11
11
|
|
|
12
12
|
export class User extends QueryableModel {
|
|
13
13
|
static table = 'users';
|
|
14
|
+
// static cache = new ModelCache<User>();
|
|
14
15
|
|
|
15
16
|
// Columns
|
|
16
17
|
@column({
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Group, Organization } from '../models/index.js';
|
|
2
|
-
export declare class GroupBuilder {
|
|
3
|
-
organization: Organization;
|
|
4
|
-
constructor(organization: Organization);
|
|
5
|
-
build(): Promise<void>;
|
|
6
|
-
createSGVGroups(): Promise<Group[]>;
|
|
7
|
-
createChiroGroups(): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=GroupBuilder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GroupBuilder.d.ts","sourceRoot":"","sources":["../../../src/helpers/GroupBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEzD,qBAAa,YAAY;IACrB,YAAY,EAAE,YAAY,CAAC;gBAEf,YAAY,EAAE,YAAY;IAIhC,KAAK;IAgEL,eAAe;IA2Kf,iBAAiB;CAyK1B"}
|
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GroupBuilder = void 0;
|
|
4
|
-
const structures_1 = require("@stamhoofd/structures");
|
|
5
|
-
const index_js_1 = require("../models/index.js");
|
|
6
|
-
class GroupBuilder {
|
|
7
|
-
organization;
|
|
8
|
-
constructor(organization) {
|
|
9
|
-
this.organization = organization;
|
|
10
|
-
}
|
|
11
|
-
async build() {
|
|
12
|
-
const oldGroups = await index_js_1.Group.getAll(this.organization.id, this.organization.periodId);
|
|
13
|
-
if (oldGroups.length === 0) {
|
|
14
|
-
// Setup default groups if possible
|
|
15
|
-
if (this.organization.meta.type == structures_1.OrganizationType.Youth && this.organization.meta.umbrellaOrganization == structures_1.UmbrellaOrganization.ScoutsEnGidsenVlaanderen) {
|
|
16
|
-
await this.createSGVGroups();
|
|
17
|
-
}
|
|
18
|
-
else if (this.organization.meta.type == structures_1.OrganizationType.Youth && this.organization.meta.umbrellaOrganization == structures_1.UmbrellaOrganization.ChiroNationaal) {
|
|
19
|
-
await this.createChiroGroups();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// Reload
|
|
23
|
-
const groups = await index_js_1.Group.getAll(this.organization.id, this.organization.periodId);
|
|
24
|
-
// Setup default root groups
|
|
25
|
-
if (this.organization.meta.categories.length <= 2) {
|
|
26
|
-
const sortedGroupIds = groups.map(g => structures_1.Group.create(Object.assign({}, g, { privateSettings: null }))).sort(structures_1.Group.defaultSort).map(g => g.id);
|
|
27
|
-
const defaults = this.organization.meta.packages.useActivities ? structures_1.OrganizationTypeHelper.getDefaultGroupCategories(this.organization.meta.type, this.organization.meta.umbrellaOrganization ?? undefined) : structures_1.OrganizationTypeHelper.getDefaultGroupCategoriesWithoutActivities(this.organization.meta.type, this.organization.meta.umbrellaOrganization ?? undefined);
|
|
28
|
-
if (sortedGroupIds.length > 0 && defaults.length == 0) {
|
|
29
|
-
defaults.push(structures_1.GroupCategory.create({
|
|
30
|
-
settings: structures_1.GroupCategorySettings.create({
|
|
31
|
-
name: 'Leeftijdsgroepen',
|
|
32
|
-
maximumRegistrations: 1,
|
|
33
|
-
}),
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
this.organization.meta.categories = [structures_1.GroupCategory.create({ id: 'root' }), ...defaults];
|
|
37
|
-
this.organization.meta.rootCategoryId = 'root';
|
|
38
|
-
// Set category ID of the root category
|
|
39
|
-
const filter = defaults.flatMap(d => d.categoryIds);
|
|
40
|
-
this.organization.meta.rootCategory.categoryIds = defaults.map(d => d.id).filter(id => !filter.includes(id));
|
|
41
|
-
if (defaults.length > 0) {
|
|
42
|
-
defaults[0].groupIds.push(...sortedGroupIds);
|
|
43
|
-
}
|
|
44
|
-
await this.organization.save();
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
const newGroups = groups.filter(g => !oldGroups.find(gg => gg.id === g.id));
|
|
48
|
-
const sortedGroupIds = newGroups.map(g => structures_1.Group.create(Object.assign({}, g, { privateSettings: null }))).sort(structures_1.Group.defaultSort).map(g => g.id);
|
|
49
|
-
let root = this.organization.meta.rootCategory;
|
|
50
|
-
if (root.categoryIds.length > 0) {
|
|
51
|
-
for (const id of root.categoryIds) {
|
|
52
|
-
const f = this.organization.meta.categories.find(c => c.id === id);
|
|
53
|
-
if (f) {
|
|
54
|
-
root = f;
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (newGroups.length > 0) {
|
|
60
|
-
root.groupIds.push(...sortedGroupIds);
|
|
61
|
-
await this.organization.save();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async createSGVGroups() {
|
|
66
|
-
const createdGroups = [];
|
|
67
|
-
const mixedType = this.organization.meta.genderType == structures_1.OrganizationGenderType.OnlyMale
|
|
68
|
-
? structures_1.GroupGenderType.OnlyMale
|
|
69
|
-
: (this.organization.meta.genderType == structures_1.OrganizationGenderType.OnlyFemale
|
|
70
|
-
? structures_1.GroupGenderType.OnlyFemale
|
|
71
|
-
: structures_1.GroupGenderType.Mixed);
|
|
72
|
-
const kapoenen = new index_js_1.Group();
|
|
73
|
-
kapoenen.organizationId = this.organization.id;
|
|
74
|
-
kapoenen.periodId = this.organization.periodId;
|
|
75
|
-
kapoenen.settings = structures_1.GroupSettings.create({
|
|
76
|
-
name: new structures_1.TranslatedString('Kapoenen'),
|
|
77
|
-
genderType: mixedType,
|
|
78
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
79
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
80
|
-
minAge: 6,
|
|
81
|
-
maxAge: 7,
|
|
82
|
-
});
|
|
83
|
-
await kapoenen.save();
|
|
84
|
-
createdGroups.push(kapoenen);
|
|
85
|
-
const jin = new index_js_1.Group();
|
|
86
|
-
jin.organizationId = this.organization.id;
|
|
87
|
-
jin.periodId = this.organization.periodId;
|
|
88
|
-
jin.settings = structures_1.GroupSettings.create({
|
|
89
|
-
name: new structures_1.TranslatedString('Jin'),
|
|
90
|
-
genderType: mixedType,
|
|
91
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
92
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
93
|
-
minAge: 17,
|
|
94
|
-
maxAge: 17,
|
|
95
|
-
});
|
|
96
|
-
await jin.save();
|
|
97
|
-
createdGroups.push(jin);
|
|
98
|
-
if (this.organization.meta.genderType == structures_1.OrganizationGenderType.Mixed) {
|
|
99
|
-
const wouters = new index_js_1.Group();
|
|
100
|
-
wouters.organizationId = this.organization.id;
|
|
101
|
-
wouters.periodId = this.organization.periodId;
|
|
102
|
-
wouters.settings = structures_1.GroupSettings.create({
|
|
103
|
-
name: new structures_1.TranslatedString('Wouters'),
|
|
104
|
-
genderType: structures_1.GroupGenderType.Mixed,
|
|
105
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
106
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
107
|
-
minAge: 8,
|
|
108
|
-
maxAge: 10,
|
|
109
|
-
});
|
|
110
|
-
await wouters.save();
|
|
111
|
-
createdGroups.push(wouters);
|
|
112
|
-
const jonggivers = new index_js_1.Group();
|
|
113
|
-
jonggivers.organizationId = this.organization.id;
|
|
114
|
-
jonggivers.periodId = this.organization.periodId;
|
|
115
|
-
jonggivers.settings = structures_1.GroupSettings.create({
|
|
116
|
-
name: new structures_1.TranslatedString('Jonggivers'),
|
|
117
|
-
genderType: structures_1.GroupGenderType.Mixed,
|
|
118
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
119
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
120
|
-
minAge: 11,
|
|
121
|
-
maxAge: 13,
|
|
122
|
-
});
|
|
123
|
-
await jonggivers.save();
|
|
124
|
-
createdGroups.push(jonggivers);
|
|
125
|
-
const givers = new index_js_1.Group();
|
|
126
|
-
givers.organizationId = this.organization.id;
|
|
127
|
-
givers.periodId = this.organization.periodId;
|
|
128
|
-
givers.settings = structures_1.GroupSettings.create({
|
|
129
|
-
name: new structures_1.TranslatedString('Givers'),
|
|
130
|
-
genderType: structures_1.GroupGenderType.Mixed,
|
|
131
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
132
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
133
|
-
minAge: 14,
|
|
134
|
-
maxAge: 16,
|
|
135
|
-
});
|
|
136
|
-
await givers.save();
|
|
137
|
-
createdGroups.push(givers);
|
|
138
|
-
}
|
|
139
|
-
if (this.organization.meta.genderType == structures_1.OrganizationGenderType.OnlyFemale || this.organization.meta.genderType == structures_1.OrganizationGenderType.Separated) {
|
|
140
|
-
const wouters = new index_js_1.Group();
|
|
141
|
-
wouters.organizationId = this.organization.id;
|
|
142
|
-
wouters.periodId = this.organization.periodId;
|
|
143
|
-
wouters.settings = structures_1.GroupSettings.create({
|
|
144
|
-
name: new structures_1.TranslatedString('Kabouters'),
|
|
145
|
-
genderType: structures_1.GroupGenderType.OnlyFemale,
|
|
146
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
147
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
148
|
-
minAge: 8,
|
|
149
|
-
maxAge: 10,
|
|
150
|
-
});
|
|
151
|
-
await wouters.save();
|
|
152
|
-
createdGroups.push(wouters);
|
|
153
|
-
const jonggivers = new index_js_1.Group();
|
|
154
|
-
jonggivers.organizationId = this.organization.id;
|
|
155
|
-
jonggivers.periodId = this.organization.periodId;
|
|
156
|
-
jonggivers.settings = structures_1.GroupSettings.create({
|
|
157
|
-
name: new structures_1.TranslatedString('Jonggidsen'),
|
|
158
|
-
genderType: structures_1.GroupGenderType.OnlyFemale,
|
|
159
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
160
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
161
|
-
minAge: 11,
|
|
162
|
-
maxAge: 13,
|
|
163
|
-
});
|
|
164
|
-
await jonggivers.save();
|
|
165
|
-
createdGroups.push(jonggivers);
|
|
166
|
-
const givers = new index_js_1.Group();
|
|
167
|
-
givers.organizationId = this.organization.id;
|
|
168
|
-
givers.periodId = this.organization.periodId;
|
|
169
|
-
givers.settings = structures_1.GroupSettings.create({
|
|
170
|
-
name: new structures_1.TranslatedString('Gidsen'),
|
|
171
|
-
genderType: structures_1.GroupGenderType.OnlyFemale,
|
|
172
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
173
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
174
|
-
minAge: 14,
|
|
175
|
-
maxAge: 16,
|
|
176
|
-
});
|
|
177
|
-
await givers.save();
|
|
178
|
-
createdGroups.push(givers);
|
|
179
|
-
}
|
|
180
|
-
if (this.organization.meta.genderType == structures_1.OrganizationGenderType.OnlyMale || this.organization.meta.genderType == structures_1.OrganizationGenderType.Separated) {
|
|
181
|
-
const wouters = new index_js_1.Group();
|
|
182
|
-
wouters.organizationId = this.organization.id;
|
|
183
|
-
wouters.periodId = this.organization.periodId;
|
|
184
|
-
wouters.settings = structures_1.GroupSettings.create({
|
|
185
|
-
name: new structures_1.TranslatedString('Welpen'),
|
|
186
|
-
genderType: structures_1.GroupGenderType.OnlyMale,
|
|
187
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
188
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
189
|
-
minAge: 8,
|
|
190
|
-
maxAge: 10,
|
|
191
|
-
});
|
|
192
|
-
await wouters.save();
|
|
193
|
-
createdGroups.push(wouters);
|
|
194
|
-
const jonggivers = new index_js_1.Group();
|
|
195
|
-
jonggivers.organizationId = this.organization.id;
|
|
196
|
-
jonggivers.periodId = this.organization.periodId;
|
|
197
|
-
jonggivers.settings = structures_1.GroupSettings.create({
|
|
198
|
-
name: new structures_1.TranslatedString('Jongverkenners'),
|
|
199
|
-
genderType: structures_1.GroupGenderType.OnlyMale,
|
|
200
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
201
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
202
|
-
minAge: 11,
|
|
203
|
-
maxAge: 13,
|
|
204
|
-
});
|
|
205
|
-
await jonggivers.save();
|
|
206
|
-
createdGroups.push(jonggivers);
|
|
207
|
-
const givers = new index_js_1.Group();
|
|
208
|
-
givers.organizationId = this.organization.id;
|
|
209
|
-
givers.periodId = this.organization.periodId;
|
|
210
|
-
givers.settings = structures_1.GroupSettings.create({
|
|
211
|
-
name: new structures_1.TranslatedString('Verkenners'),
|
|
212
|
-
genderType: structures_1.GroupGenderType.OnlyMale,
|
|
213
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
214
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
215
|
-
minAge: 14,
|
|
216
|
-
maxAge: 16,
|
|
217
|
-
});
|
|
218
|
-
await givers.save();
|
|
219
|
-
createdGroups.push(givers);
|
|
220
|
-
}
|
|
221
|
-
return createdGroups;
|
|
222
|
-
}
|
|
223
|
-
async createChiroGroups() {
|
|
224
|
-
const mixedType = this.organization.meta.genderType == structures_1.OrganizationGenderType.OnlyMale
|
|
225
|
-
? structures_1.GroupGenderType.OnlyMale
|
|
226
|
-
: (this.organization.meta.genderType == structures_1.OrganizationGenderType.OnlyFemale
|
|
227
|
-
? structures_1.GroupGenderType.OnlyFemale
|
|
228
|
-
: structures_1.GroupGenderType.Mixed);
|
|
229
|
-
const ribbels = new index_js_1.Group();
|
|
230
|
-
ribbels.organizationId = this.organization.id;
|
|
231
|
-
ribbels.periodId = this.organization.periodId;
|
|
232
|
-
ribbels.settings = structures_1.GroupSettings.create({
|
|
233
|
-
name: new structures_1.TranslatedString('Ribbels'),
|
|
234
|
-
genderType: mixedType,
|
|
235
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
236
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
237
|
-
minAge: 6,
|
|
238
|
-
maxAge: 7,
|
|
239
|
-
});
|
|
240
|
-
await ribbels.save();
|
|
241
|
-
const speelclub = new index_js_1.Group();
|
|
242
|
-
speelclub.organizationId = this.organization.id;
|
|
243
|
-
speelclub.periodId = this.organization.periodId;
|
|
244
|
-
speelclub.settings = structures_1.GroupSettings.create({
|
|
245
|
-
name: new structures_1.TranslatedString('Speelclub'),
|
|
246
|
-
genderType: mixedType,
|
|
247
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
248
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
249
|
-
minAge: 8,
|
|
250
|
-
maxAge: 9,
|
|
251
|
-
});
|
|
252
|
-
await speelclub.save();
|
|
253
|
-
const aspis = new index_js_1.Group();
|
|
254
|
-
aspis.organizationId = this.organization.id;
|
|
255
|
-
aspis.periodId = this.organization.periodId;
|
|
256
|
-
aspis.settings = structures_1.GroupSettings.create({
|
|
257
|
-
name: new structures_1.TranslatedString("Aspi's"),
|
|
258
|
-
genderType: mixedType,
|
|
259
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
260
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
261
|
-
minAge: 16,
|
|
262
|
-
maxAge: 17,
|
|
263
|
-
});
|
|
264
|
-
await aspis.save();
|
|
265
|
-
if (this.organization.meta.genderType == structures_1.OrganizationGenderType.Mixed) {
|
|
266
|
-
const rakwis = new index_js_1.Group();
|
|
267
|
-
rakwis.organizationId = this.organization.id;
|
|
268
|
-
rakwis.periodId = this.organization.periodId;
|
|
269
|
-
rakwis.settings = structures_1.GroupSettings.create({
|
|
270
|
-
name: new structures_1.TranslatedString("Rakwi's"),
|
|
271
|
-
genderType: structures_1.GroupGenderType.Mixed,
|
|
272
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
273
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
274
|
-
minAge: 10,
|
|
275
|
-
maxAge: 11,
|
|
276
|
-
});
|
|
277
|
-
await rakwis.save();
|
|
278
|
-
const titos = new index_js_1.Group();
|
|
279
|
-
titos.organizationId = this.organization.id;
|
|
280
|
-
titos.periodId = this.organization.periodId;
|
|
281
|
-
titos.settings = structures_1.GroupSettings.create({
|
|
282
|
-
name: new structures_1.TranslatedString("Tito's"),
|
|
283
|
-
genderType: structures_1.GroupGenderType.Mixed,
|
|
284
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
285
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
286
|
-
minAge: 12,
|
|
287
|
-
maxAge: 13,
|
|
288
|
-
});
|
|
289
|
-
await titos.save();
|
|
290
|
-
const ketis = new index_js_1.Group();
|
|
291
|
-
ketis.organizationId = this.organization.id;
|
|
292
|
-
ketis.periodId = this.organization.periodId;
|
|
293
|
-
ketis.settings = structures_1.GroupSettings.create({
|
|
294
|
-
name: new structures_1.TranslatedString("Keti's"),
|
|
295
|
-
genderType: structures_1.GroupGenderType.Mixed,
|
|
296
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
297
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
298
|
-
minAge: 14,
|
|
299
|
-
maxAge: 15,
|
|
300
|
-
});
|
|
301
|
-
await ketis.save();
|
|
302
|
-
}
|
|
303
|
-
if (this.organization.meta.genderType == structures_1.OrganizationGenderType.OnlyFemale || this.organization.meta.genderType == structures_1.OrganizationGenderType.Separated) {
|
|
304
|
-
const rakwis = new index_js_1.Group();
|
|
305
|
-
rakwis.organizationId = this.organization.id;
|
|
306
|
-
rakwis.periodId = this.organization.periodId;
|
|
307
|
-
rakwis.settings = structures_1.GroupSettings.create({
|
|
308
|
-
name: new structures_1.TranslatedString('Kwiks'),
|
|
309
|
-
genderType: structures_1.GroupGenderType.OnlyFemale,
|
|
310
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
311
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
312
|
-
minAge: 10,
|
|
313
|
-
maxAge: 11,
|
|
314
|
-
});
|
|
315
|
-
await rakwis.save();
|
|
316
|
-
const titos = new index_js_1.Group();
|
|
317
|
-
titos.organizationId = this.organization.id;
|
|
318
|
-
titos.periodId = this.organization.periodId;
|
|
319
|
-
titos.settings = structures_1.GroupSettings.create({
|
|
320
|
-
name: new structures_1.TranslatedString('Toppers'),
|
|
321
|
-
genderType: structures_1.GroupGenderType.OnlyFemale,
|
|
322
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
323
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
324
|
-
minAge: 12,
|
|
325
|
-
maxAge: 13,
|
|
326
|
-
});
|
|
327
|
-
await titos.save();
|
|
328
|
-
const ketis = new index_js_1.Group();
|
|
329
|
-
ketis.organizationId = this.organization.id;
|
|
330
|
-
ketis.periodId = this.organization.periodId;
|
|
331
|
-
ketis.settings = structures_1.GroupSettings.create({
|
|
332
|
-
name: new structures_1.TranslatedString('Tiptiens'),
|
|
333
|
-
genderType: structures_1.GroupGenderType.OnlyFemale,
|
|
334
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
335
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
336
|
-
minAge: 14,
|
|
337
|
-
maxAge: 15,
|
|
338
|
-
});
|
|
339
|
-
await ketis.save();
|
|
340
|
-
}
|
|
341
|
-
if (this.organization.meta.genderType == structures_1.OrganizationGenderType.OnlyMale || this.organization.meta.genderType == structures_1.OrganizationGenderType.Separated) {
|
|
342
|
-
const rakwis = new index_js_1.Group();
|
|
343
|
-
rakwis.organizationId = this.organization.id;
|
|
344
|
-
rakwis.periodId = this.organization.periodId;
|
|
345
|
-
rakwis.settings = structures_1.GroupSettings.create({
|
|
346
|
-
name: new structures_1.TranslatedString('Rakkers'),
|
|
347
|
-
genderType: structures_1.GroupGenderType.OnlyMale,
|
|
348
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
349
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
350
|
-
minAge: 10,
|
|
351
|
-
maxAge: 11,
|
|
352
|
-
});
|
|
353
|
-
await rakwis.save();
|
|
354
|
-
const titos = new index_js_1.Group();
|
|
355
|
-
titos.organizationId = this.organization.id;
|
|
356
|
-
titos.periodId = this.organization.periodId;
|
|
357
|
-
titos.settings = structures_1.GroupSettings.create({
|
|
358
|
-
name: new structures_1.TranslatedString('Tippers'),
|
|
359
|
-
genderType: structures_1.GroupGenderType.OnlyMale,
|
|
360
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
361
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
362
|
-
minAge: 12,
|
|
363
|
-
maxAge: 13,
|
|
364
|
-
});
|
|
365
|
-
await titos.save();
|
|
366
|
-
const ketis = new index_js_1.Group();
|
|
367
|
-
ketis.organizationId = this.organization.id;
|
|
368
|
-
ketis.periodId = this.organization.periodId;
|
|
369
|
-
ketis.settings = structures_1.GroupSettings.create({
|
|
370
|
-
name: new structures_1.TranslatedString('Kerels'),
|
|
371
|
-
genderType: structures_1.GroupGenderType.OnlyMale,
|
|
372
|
-
startDate: this.organization.meta.defaultStartDate,
|
|
373
|
-
endDate: this.organization.meta.defaultEndDate,
|
|
374
|
-
minAge: 14,
|
|
375
|
-
maxAge: 15,
|
|
376
|
-
});
|
|
377
|
-
await ketis.save();
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
exports.GroupBuilder = GroupBuilder;
|
|
382
|
-
//# sourceMappingURL=GroupBuilder.js.map
|