@stamhoofd/backend 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/migrations.ts +1 -1
- package/package.json +10 -10
- package/src/audit-logs/DocumentTemplateLogger.ts +1 -1
- package/src/audit-logs/EmailAddressLogger.ts +1 -1
- package/src/audit-logs/EmailLogger.ts +1 -1
- package/src/audit-logs/EmailTemplateLogger.ts +1 -1
- package/src/audit-logs/EventLogger.ts +1 -1
- package/src/audit-logs/GroupLogger.ts +1 -1
- package/src/audit-logs/MemberLogger.ts +1 -1
- package/src/audit-logs/MemberPlatformMembershipLogger.ts +1 -1
- package/src/audit-logs/MemberResponsibilityRecordLogger.ts +1 -1
- package/src/audit-logs/ModelLogger.ts +27 -19
- package/src/audit-logs/OrderLogger.ts +1 -1
- package/src/audit-logs/OrganizationLogger.ts +23 -3
- package/src/audit-logs/OrganizationRegistrationPeriodLogger.ts +1 -1
- package/src/audit-logs/PaymentLogger.ts +1 -1
- package/src/audit-logs/PlatformLogger.ts +1 -1
- package/src/audit-logs/RegistrationLogger.ts +1 -1
- package/src/audit-logs/RegistrationPeriodLogger.ts +1 -1
- package/src/audit-logs/StripeAccountLogger.ts +1 -1
- package/src/audit-logs/UserLogger.ts +1 -1
- package/src/audit-logs/WebshopLogger.ts +1 -1
- package/src/audit-logs/init.ts +40 -0
- package/src/boot.ts +6 -4
- package/src/crons/amazon-ses.ts +1 -1
- package/src/crons/balance-emails.ts +1 -1
- package/src/crons/clearExcelCache.test.ts +1 -1
- package/src/crons/delete-archived-data.ts +47 -0
- package/src/crons/endFunctionsOfUsersWithoutRegistration.ts +1 -1
- package/src/crons/index.ts +1 -0
- package/src/crons.ts +3 -3
- package/src/debug.ts +230 -0
- package/src/email-recipient-loaders/documents.ts +1 -1
- package/src/email-recipient-loaders/members.ts +1 -1
- package/src/email-recipient-loaders/orders.ts +3 -3
- package/src/email-recipient-loaders/payments.ts +118 -353
- package/src/email-replacements/getEmailReplacementsForPayment.ts +321 -0
- package/src/endpoints/admin/members/ChargeMembersEndpoint.ts +9 -7
- package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +2 -2
- package/src/endpoints/admin/memberships/GetChargeMembershipsSummaryEndpoint.ts +1 -1
- package/src/endpoints/admin/organizations/ChargeOrganizationsEndpoint.ts +16 -50
- package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +2 -2
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +4 -4
- package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +21 -6
- package/src/endpoints/admin/registrations/ChargeRegistrationsEndpoint.ts +9 -7
- package/src/endpoints/auth/CreateAdminEndpoint.ts +2 -2
- package/src/endpoints/auth/CreateTokenEndpoint.test.ts +2 -2
- package/src/endpoints/auth/CreateTokenEndpoint.ts +1 -1
- package/src/endpoints/auth/DeleteTokenEndpoint.ts +1 -1
- package/src/endpoints/auth/DeleteUserEndpoint.ts +1 -1
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +1 -1
- package/src/endpoints/auth/GetOtherUserEndpoint.ts +2 -2
- package/src/endpoints/auth/GetUserEndpoint.test.ts +2 -2
- package/src/endpoints/auth/GetUserEndpoint.ts +2 -2
- package/src/endpoints/auth/OpenIDConnectAuthTokenEndpoint.ts +2 -2
- package/src/endpoints/auth/OpenIDConnectCallbackEndpoint.ts +2 -2
- package/src/endpoints/auth/OpenIDConnectStartEndpoint.ts +2 -2
- package/src/endpoints/auth/PatchUserEndpoint.ts +4 -4
- package/src/endpoints/auth/PollEmailVerificationEndpoint.ts +1 -1
- package/src/endpoints/auth/RetryEmailVerificationEndpoint.ts +1 -1
- package/src/endpoints/auth/SignupEndpoint.ts +1 -1
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +1 -1
- package/src/endpoints/global/addresses/ValidateAddressEndpoint.ts +1 -1
- package/src/endpoints/global/audit-logs/GetAuditLogsEndpoint.ts +4 -4
- package/src/endpoints/global/billing/ActivatePackagesEndpoint.ts +191 -7
- package/src/endpoints/global/billing/DeactivatePackageEndpoint.ts +64 -0
- package/src/endpoints/global/email/GetAdminEmailsEndpoint.test.ts +2 -2
- package/src/endpoints/global/email/GetAdminEmailsEndpoint.ts +3 -3
- package/src/endpoints/global/email/GetEmailAddressEndpoint.ts +1 -1
- package/src/endpoints/global/email/GetEmailEndpoint.ts +1 -1
- package/src/endpoints/global/email/GetUserEmailsEndpoint.test.ts +2 -2
- package/src/endpoints/global/email/GetUserEmailsEndpoint.ts +3 -3
- package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +62 -16
- package/src/endpoints/global/email/PatchEmailEndpoint.test.ts +6 -6
- package/src/endpoints/global/email-recipients/GetEmailRecipientsCountEndpoint.ts +2 -2
- package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.test.ts +2 -2
- package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.ts +4 -4
- package/src/endpoints/global/email-recipients/RetryEmailRecipientEndpoint.ts +1 -1
- package/src/endpoints/global/email-recipients/helpers/validateEmailRecipientFilter.ts +1 -1
- package/src/endpoints/global/events/GetEventNotificationsCountEndpoint.ts +2 -2
- package/src/endpoints/global/events/GetEventNotificationsEndpoint.ts +4 -4
- package/src/endpoints/global/events/GetEventsEndpoint.ts +4 -4
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.test.ts +2 -2
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.ts +3 -3
- package/src/endpoints/global/events/PatchEventsEndpoint.test.ts +2 -2
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +5 -5
- package/src/endpoints/global/files/ExportToExcelEndpoint.ts +4 -4
- package/src/endpoints/global/files/GetFileCache.ts +2 -2
- package/src/endpoints/global/files/UploadFile.ts +2 -2
- package/src/endpoints/global/files/UploadImage.ts +1 -1
- package/src/endpoints/global/groups/GetGroupsEndpoint.test.ts +3 -3
- package/src/endpoints/global/groups/GetGroupsEndpoint.ts +4 -4
- package/src/endpoints/global/members/GetMemberFamilyEndpoint.ts +4 -4
- package/src/endpoints/global/members/GetMembersEndpoint.test.ts +3 -3
- package/src/endpoints/global/members/GetMembersEndpoint.ts +4 -16
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +8 -7
- package/src/endpoints/global/members/helpers/validateGroupFilter.ts +1 -1
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.test.ts +2 -2
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +23 -12
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.test.ts +2 -2
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.ts +1 -1
- package/src/endpoints/global/organizations/GetOrganizationFromUriEndpoint.ts +1 -1
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.test.ts +2 -2
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.ts +1 -1
- package/src/endpoints/global/payments/StripeWebhookEndpoint.ts +3 -3
- package/src/endpoints/global/platform/GetPlatformAdminsEndpoint.ts +1 -1
- package/src/endpoints/global/platform/GetPlatformEndpoint.test.ts +2 -2
- package/src/endpoints/global/platform/GetPlatformEndpoint.ts +1 -1
- package/src/endpoints/global/platform/PatchPlatformEnpoint.test.ts +2 -2
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +7 -7
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.test.ts +2 -2
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.ts +1 -2
- package/src/endpoints/global/registration/GetUserDetailedPayableBalanceEndpoint.ts +2 -2
- package/src/endpoints/global/registration/GetUserDocumentsEndpoint.ts +2 -2
- package/src/endpoints/global/registration/GetUserMembersEndpoint.ts +2 -2
- package/src/endpoints/global/registration/GetUserPayableBalanceEndpoint.ts +2 -2
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +2 -2
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +24 -389
- package/src/endpoints/global/registration-periods/GetRegistrationPeriodsEndpoint.ts +3 -3
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +2 -2
- package/src/endpoints/global/sso/GetSSOEndpoint.ts +2 -2
- package/src/endpoints/global/sso/SetSSOEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemEndpoint.ts +55 -0
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsCountEndpoint.ts +43 -0
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsEndpoint.ts +160 -0
- package/src/endpoints/organization/dashboard/{payments → balance-items}/PatchBalanceItemsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/billing/GetOrganizationDetailedPayableBalanceEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/billing/GetOrganizationPayableBalanceEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.test.ts +3 -3
- package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplateXML.ts +1 -1
- package/src/endpoints/organization/dashboard/documents/GetDocumentsCountEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/documents/PatchDocumentEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +37 -6
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/invoices/PatchInvoicesEndpoint.ts +53 -0
- package/src/endpoints/organization/dashboard/mollie/CheckMollieEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/mollie/ConnectMollieEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/mollie/DisconnectMollieEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/mollie/GetMollieDashboardEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/nolt/CreateNoltTokenEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/organization/GetOrganizationArchivedGroups.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/GetOrganizationDeletedGroups.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/GetUitpasClientIdEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +12 -1
- package/src/endpoints/organization/dashboard/organization/SearchUitpasOrganizersEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/SetUitpasClientCredentialsEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/payments/GetPaymentsCountEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +4 -4
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalanceEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesCountEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.ts +4 -4
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.ts +4 -4
- package/src/endpoints/organization/dashboard/registration-periods/MoveRegistrationPeriods.test.ts +2 -2
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/registration-periods/SetupStepReviewEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/stripe/ConnectStripeEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/stripe/DeleteStripeAccountEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountLinkEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/stripe/GetStripeLoginLinkEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/stripe/UpdateStripeAccountEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.test.ts +3 -3
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/users/DeleteUserEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/users/GetApiUsersEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/users/GetOrganizationAdminsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/users/PatchApiUserEndpoint.test.ts +3 -3
- package/src/endpoints/organization/dashboard/users/PatchApiUserEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/DeleteWebshopEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/webshops/GetDiscountCodesEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersCountEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +5 -5
- package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +5 -5
- package/src/endpoints/organization/dashboard/webshops/GetWebshopUriAvailabilityEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/PatchDiscountCodesEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopTicketsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/SearchUitpasEventsEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/webshops/VerifyWebshopDomainEndpoint.ts +1 -1
- package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +3 -3
- package/src/endpoints/organization/shared/GetDocumentHtml.ts +1 -1
- package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +2 -2
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.test.ts +2 -2
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.ts +2 -2
- package/src/endpoints/organization/webshops/CheckWebshopDiscountCodesEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.test.ts +2 -2
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +2 -2
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.test.ts +4 -4
- package/src/excel-loaders/balance-items.ts +268 -0
- package/src/excel-loaders/event-notifications.ts +3 -3
- package/src/excel-loaders/index.ts +6 -5
- package/src/excel-loaders/organizations.ts +4 -4
- package/src/excel-loaders/payments.ts +11 -3
- package/src/excel-loaders/receivable-balances.ts +2 -2
- package/src/helpers/AddressValidator.test.ts +1 -1
- package/src/helpers/AddressValidator.ts +1 -1
- package/src/helpers/AdminPermissionChecker.ts +20 -17
- package/src/helpers/AuthenticatedStructures.ts +194 -109
- package/src/helpers/Context.ts +2 -0
- package/src/helpers/EmailResumer.ts +1 -1
- package/src/helpers/FlagMomentCleanup.ts +1 -1
- package/src/helpers/ForwardHandler.test.ts +1 -1
- package/src/helpers/ForwardHandler.ts +1 -1
- package/src/helpers/GlobalHelper.ts +4 -4
- package/src/helpers/GroupBuilder.ts +417 -0
- package/src/helpers/GroupedThrottledQueue.test.ts +1 -1
- package/src/helpers/GroupedThrottledQueue.ts +1 -1
- package/src/helpers/MemberUserSyncer.test.ts +1 -1
- package/src/helpers/MemberUserSyncer.ts +1 -1
- package/src/helpers/PeriodHelper.ts +5 -45
- package/src/helpers/ServiceFeeHelper.ts +5 -1
- package/src/helpers/SetupStepUpdater.ts +5 -4
- package/src/helpers/TagHelper.ts +1 -1
- package/src/helpers/ThrottledQueue.test.ts +1 -1
- package/src/helpers/ViesHelper.ts +9 -0
- package/src/helpers/email-html-helpers.ts +0 -41
- package/src/helpers/outstandingBalanceJoin.ts +3 -1
- package/src/middleware/ContextMiddleware.ts +1 -1
- package/src/seeds/1726572303-schedule-stock-updates.ts +1 -1
- package/src/seeds/1726847064-setup-steps.ts +1 -1
- package/src/seeds/1728928974-update-cached-outstanding-balance-from-items.ts +1 -1
- package/src/seeds/1740046783-update-membership.ts +1 -1
- package/src/seeds/1754560914-groups-prices.test.ts +1 -1
- package/src/seeds/1755876819-remove-duplicate-members.ts +1 -1
- package/src/seeds/1760702454-update-cached-outstanding-balance-from-items.ts +1 -1
- package/src/seeds/1761665607-sync-member-users.ts +1 -1
- package/src/seeds/data/default-email-templates.sql +1 -1
- package/src/seeds-temporary/1732117645-move-rrn.ts +1 -1
- package/src/services/AuditLogService.ts +1 -41
- package/src/services/BalanceItemPaymentService.ts +1 -1
- package/src/services/BalanceItemService.ts +12 -5
- package/src/services/EventNotificationService.ts +3 -3
- package/src/services/InvoiceService.ts +131 -17
- package/src/services/MemberRecordStore.ts +1 -1
- package/src/services/PaymentReallocationService.test.ts +9 -10
- package/src/services/PaymentReallocationService.ts +1 -1
- package/src/services/PaymentService.ts +560 -18
- package/src/services/PlatformMembershipService.ts +3 -3
- package/src/services/RegistrationService.ts +3 -3
- package/src/services/SSOService.ts +2 -2
- package/src/services/STPackageService.ts +241 -0
- package/src/services/uitpas/UitpasService.test.ts +1 -1
- package/src/sql-filters/balance-items.ts +56 -0
- package/src/sql-filters/emails.ts +1 -1
- package/src/sql-filters/event-notifications.ts +2 -2
- package/src/sql-filters/events.ts +51 -0
- package/src/sql-filters/members.ts +38 -2
- package/src/sql-filters/receivable-balances.ts +3 -3
- package/src/sql-filters/users.ts +10 -0
- package/src/sql-sorters/balance-items.ts +36 -0
- package/src/sql-sorters/document-templates.ts +2 -2
- package/src/sql-sorters/documents.ts +2 -2
- package/src/sql-sorters/event-notifications.ts +1 -1
- package/src/sql-sorters/members.ts +2 -2
- package/src/sql-sorters/orders.ts +2 -2
- package/src/sql-sorters/tickets.ts +2 -2
- package/tests/actions/patchOrganizationMember.ts +3 -3
- package/tests/actions/patchPaymentStatus.ts +3 -3
- package/tests/actions/patchUserMember.ts +2 -2
- package/tests/assertions/assertBalances.ts +1 -1
- package/tests/e2e/api-rate-limits.test.ts +3 -3
- package/tests/e2e/charge-members.test.ts +14 -14
- package/tests/e2e/documents.test.ts +8 -8
- package/tests/e2e/private-files.test.ts +4 -4
- package/tests/e2e/register.test.ts +10 -10
- package/tests/e2e/stock.test.ts +4 -4
- package/tests/e2e/tickets.test.ts +4 -4
- package/tests/helpers/TestServer.ts +2 -2
- package/tests/init/index.ts +7 -7
- package/tests/init/initAdmin.ts +1 -1
- package/src/endpoints/global/registration/GetPaymentRegistrations.ts +0 -67
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { GroupCategory, GroupCategorySettings, GroupGenderType, GroupSettings, Group as GroupStruct, OrganizationGenderType, OrganizationType, OrganizationTypeHelper, TranslatedString, UmbrellaOrganization } from '@stamhoofd/structures';
|
|
2
|
+
import { Group, Organization, OrganizationRegistrationPeriod, RegistrationPeriod } from '@stamhoofd/models';
|
|
3
|
+
|
|
4
|
+
export class GroupBuilder {
|
|
5
|
+
organization: Organization;
|
|
6
|
+
|
|
7
|
+
constructor(organization: Organization) {
|
|
8
|
+
this.organization = organization;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async build() {
|
|
12
|
+
const oldGroups = await Group.getAll(this.organization.id, this.organization.periodId);
|
|
13
|
+
const period = await RegistrationPeriod.getByID(this.organization.periodId, true);
|
|
14
|
+
const organizationPeriod = await OrganizationRegistrationPeriod.select().where('organizationId', this.organization.id).where('periodId', this.organization.periodId).first(true);
|
|
15
|
+
|
|
16
|
+
if (oldGroups.length === 0) {
|
|
17
|
+
// Setup default groups if possible
|
|
18
|
+
if (this.organization.meta.type === OrganizationType.Youth && this.organization.meta.umbrellaOrganization === UmbrellaOrganization.ScoutsEnGidsenVlaanderen) {
|
|
19
|
+
await this.createSGVGroups(period);
|
|
20
|
+
}
|
|
21
|
+
else if (this.organization.meta.type === OrganizationType.Youth && this.organization.meta.umbrellaOrganization === UmbrellaOrganization.ChiroNationaal) {
|
|
22
|
+
await this.createChiroGroups(period);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Reload
|
|
27
|
+
const groups = oldGroups.length === 0 ? await Group.getAll(this.organization.id, this.organization.periodId) : oldGroups.slice();
|
|
28
|
+
|
|
29
|
+
// Setup default root groups
|
|
30
|
+
if (organizationPeriod.settings.categories.length <= 2) {
|
|
31
|
+
const sortedGroupIds = groups.map(g => GroupStruct.create(Object.assign({}, g, { privateSettings: null }))).sort(GroupStruct.defaultSort).map(g => g.id);
|
|
32
|
+
|
|
33
|
+
const defaults = this.organization.meta.packages.useActivities ? OrganizationTypeHelper.getDefaultGroupCategories(this.organization.meta.type, this.organization.meta.umbrellaOrganization ?? undefined) : OrganizationTypeHelper.getDefaultGroupCategoriesWithoutActivities(this.organization.meta.type, this.organization.meta.umbrellaOrganization ?? undefined);
|
|
34
|
+
|
|
35
|
+
if (sortedGroupIds.length > 0 && defaults.length === 0) {
|
|
36
|
+
defaults.push(GroupCategory.create({
|
|
37
|
+
settings: GroupCategorySettings.create({
|
|
38
|
+
name: 'Leeftijdsgroepen',
|
|
39
|
+
maximumRegistrations: 1,
|
|
40
|
+
}),
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
organizationPeriod.settings.categories = [GroupCategory.create({ id: 'root' }), ...defaults];
|
|
44
|
+
organizationPeriod.settings.rootCategoryId = 'root';
|
|
45
|
+
|
|
46
|
+
// Set category ID of the root category
|
|
47
|
+
const filter = defaults.flatMap(d => d.categoryIds);
|
|
48
|
+
organizationPeriod.settings.rootCategory!.categoryIds = defaults.map(d => d.id).filter(id => !filter.includes(id));
|
|
49
|
+
|
|
50
|
+
if (defaults.length > 0) {
|
|
51
|
+
defaults[0].groupIds.push(...sortedGroupIds);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
await organizationPeriod.save();
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const newGroups = groups.filter(g => !oldGroups.find(gg => gg.id === g.id));
|
|
58
|
+
const sortedGroupIds = newGroups.map(g => GroupStruct.create(Object.assign({}, g, { privateSettings: null }))).sort(GroupStruct.defaultSort).map(g => g.id);
|
|
59
|
+
let root = organizationPeriod.settings.rootCategory!;
|
|
60
|
+
if (root.categoryIds.length > 0) {
|
|
61
|
+
for (const id of root.categoryIds) {
|
|
62
|
+
const f = organizationPeriod.settings.categories.find(c => c.id === id);
|
|
63
|
+
if (f) {
|
|
64
|
+
root = f;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (newGroups.length > 0) {
|
|
71
|
+
root.groupIds.push(...sortedGroupIds);
|
|
72
|
+
await organizationPeriod.save();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async createSGVGroups(period: RegistrationPeriod) {
|
|
78
|
+
const createdGroups: Group[] = [];
|
|
79
|
+
const mixedType = this.organization.meta.genderType == OrganizationGenderType.OnlyMale
|
|
80
|
+
? GroupGenderType.OnlyMale
|
|
81
|
+
: (this.organization.meta.genderType === OrganizationGenderType.OnlyFemale
|
|
82
|
+
? GroupGenderType.OnlyFemale
|
|
83
|
+
: GroupGenderType.Mixed);
|
|
84
|
+
|
|
85
|
+
const kapoenen = new Group();
|
|
86
|
+
kapoenen.organizationId = this.organization.id;
|
|
87
|
+
kapoenen.periodId = this.organization.periodId;
|
|
88
|
+
kapoenen.settings = GroupSettings.create({
|
|
89
|
+
name: new TranslatedString('Kapoenen'),
|
|
90
|
+
genderType: mixedType,
|
|
91
|
+
startDate: period.startDate,
|
|
92
|
+
endDate: period.endDate,
|
|
93
|
+
minAge: 6,
|
|
94
|
+
maxAge: 7,
|
|
95
|
+
});
|
|
96
|
+
await kapoenen.save();
|
|
97
|
+
createdGroups.push(kapoenen);
|
|
98
|
+
|
|
99
|
+
const jin = new Group();
|
|
100
|
+
jin.organizationId = this.organization.id;
|
|
101
|
+
jin.periodId = this.organization.periodId;
|
|
102
|
+
jin.settings = GroupSettings.create({
|
|
103
|
+
name: new TranslatedString('Jin'),
|
|
104
|
+
genderType: mixedType,
|
|
105
|
+
startDate: period.startDate,
|
|
106
|
+
endDate: period.endDate,
|
|
107
|
+
minAge: 17,
|
|
108
|
+
maxAge: 17,
|
|
109
|
+
});
|
|
110
|
+
await jin.save();
|
|
111
|
+
createdGroups.push(jin);
|
|
112
|
+
|
|
113
|
+
if (this.organization.meta.genderType == OrganizationGenderType.Mixed) {
|
|
114
|
+
const wouters = new Group();
|
|
115
|
+
wouters.organizationId = this.organization.id;
|
|
116
|
+
wouters.periodId = this.organization.periodId;
|
|
117
|
+
wouters.settings = GroupSettings.create({
|
|
118
|
+
name: new TranslatedString('Wouters'),
|
|
119
|
+
genderType: GroupGenderType.Mixed,
|
|
120
|
+
startDate: period.startDate,
|
|
121
|
+
endDate: period.endDate,
|
|
122
|
+
minAge: 8,
|
|
123
|
+
maxAge: 10,
|
|
124
|
+
});
|
|
125
|
+
await wouters.save();
|
|
126
|
+
createdGroups.push(wouters);
|
|
127
|
+
|
|
128
|
+
const jonggivers = new Group();
|
|
129
|
+
jonggivers.organizationId = this.organization.id;
|
|
130
|
+
jonggivers.periodId = this.organization.periodId;
|
|
131
|
+
jonggivers.settings = GroupSettings.create({
|
|
132
|
+
name: new TranslatedString('Jonggivers'),
|
|
133
|
+
genderType: GroupGenderType.Mixed,
|
|
134
|
+
startDate: period.startDate,
|
|
135
|
+
endDate: period.endDate,
|
|
136
|
+
minAge: 11,
|
|
137
|
+
maxAge: 13,
|
|
138
|
+
});
|
|
139
|
+
await jonggivers.save();
|
|
140
|
+
createdGroups.push(jonggivers);
|
|
141
|
+
|
|
142
|
+
const givers = new Group();
|
|
143
|
+
givers.organizationId = this.organization.id;
|
|
144
|
+
givers.periodId = this.organization.periodId;
|
|
145
|
+
givers.settings = GroupSettings.create({
|
|
146
|
+
name: new TranslatedString('Givers'),
|
|
147
|
+
genderType: GroupGenderType.Mixed,
|
|
148
|
+
startDate: period.startDate,
|
|
149
|
+
endDate: period.endDate,
|
|
150
|
+
minAge: 14,
|
|
151
|
+
maxAge: 16,
|
|
152
|
+
});
|
|
153
|
+
await givers.save();
|
|
154
|
+
createdGroups.push(givers);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (this.organization.meta.genderType == OrganizationGenderType.OnlyFemale || this.organization.meta.genderType == OrganizationGenderType.Separated) {
|
|
158
|
+
const wouters = new Group();
|
|
159
|
+
wouters.organizationId = this.organization.id;
|
|
160
|
+
wouters.periodId = this.organization.periodId;
|
|
161
|
+
wouters.settings = GroupSettings.create({
|
|
162
|
+
name: new TranslatedString('Kabouters'),
|
|
163
|
+
genderType: GroupGenderType.OnlyFemale,
|
|
164
|
+
startDate: period.startDate,
|
|
165
|
+
endDate: period.endDate,
|
|
166
|
+
minAge: 8,
|
|
167
|
+
maxAge: 10,
|
|
168
|
+
});
|
|
169
|
+
await wouters.save();
|
|
170
|
+
createdGroups.push(wouters);
|
|
171
|
+
|
|
172
|
+
const jonggivers = new Group();
|
|
173
|
+
jonggivers.organizationId = this.organization.id;
|
|
174
|
+
jonggivers.periodId = this.organization.periodId;
|
|
175
|
+
jonggivers.settings = GroupSettings.create({
|
|
176
|
+
name: new TranslatedString('Jonggidsen'),
|
|
177
|
+
genderType: GroupGenderType.OnlyFemale,
|
|
178
|
+
startDate: period.startDate,
|
|
179
|
+
endDate: period.endDate,
|
|
180
|
+
minAge: 11,
|
|
181
|
+
maxAge: 13,
|
|
182
|
+
});
|
|
183
|
+
await jonggivers.save();
|
|
184
|
+
createdGroups.push(jonggivers);
|
|
185
|
+
|
|
186
|
+
const givers = new Group();
|
|
187
|
+
givers.organizationId = this.organization.id;
|
|
188
|
+
givers.periodId = this.organization.periodId;
|
|
189
|
+
givers.settings = GroupSettings.create({
|
|
190
|
+
name: new TranslatedString('Gidsen'),
|
|
191
|
+
genderType: GroupGenderType.OnlyFemale,
|
|
192
|
+
startDate: period.startDate,
|
|
193
|
+
endDate: period.endDate,
|
|
194
|
+
minAge: 14,
|
|
195
|
+
maxAge: 16,
|
|
196
|
+
});
|
|
197
|
+
await givers.save();
|
|
198
|
+
createdGroups.push(givers);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (this.organization.meta.genderType == OrganizationGenderType.OnlyMale || this.organization.meta.genderType == OrganizationGenderType.Separated) {
|
|
202
|
+
const wouters = new Group();
|
|
203
|
+
wouters.organizationId = this.organization.id;
|
|
204
|
+
wouters.periodId = this.organization.periodId;
|
|
205
|
+
wouters.settings = GroupSettings.create({
|
|
206
|
+
name: new TranslatedString('Welpen'),
|
|
207
|
+
genderType: GroupGenderType.OnlyMale,
|
|
208
|
+
startDate: period.startDate,
|
|
209
|
+
endDate: period.endDate,
|
|
210
|
+
minAge: 8,
|
|
211
|
+
maxAge: 10,
|
|
212
|
+
});
|
|
213
|
+
await wouters.save();
|
|
214
|
+
createdGroups.push(wouters);
|
|
215
|
+
|
|
216
|
+
const jonggivers = new Group();
|
|
217
|
+
jonggivers.organizationId = this.organization.id;
|
|
218
|
+
jonggivers.periodId = this.organization.periodId;
|
|
219
|
+
jonggivers.settings = GroupSettings.create({
|
|
220
|
+
name: new TranslatedString('Jongverkenners'),
|
|
221
|
+
genderType: GroupGenderType.OnlyMale,
|
|
222
|
+
startDate: period.startDate,
|
|
223
|
+
endDate: period.endDate,
|
|
224
|
+
minAge: 11,
|
|
225
|
+
maxAge: 13,
|
|
226
|
+
});
|
|
227
|
+
await jonggivers.save();
|
|
228
|
+
createdGroups.push(jonggivers);
|
|
229
|
+
|
|
230
|
+
const givers = new Group();
|
|
231
|
+
givers.organizationId = this.organization.id;
|
|
232
|
+
givers.periodId = this.organization.periodId;
|
|
233
|
+
givers.settings = GroupSettings.create({
|
|
234
|
+
name: new TranslatedString('Verkenners'),
|
|
235
|
+
genderType: GroupGenderType.OnlyMale,
|
|
236
|
+
startDate: period.startDate,
|
|
237
|
+
endDate: period.endDate,
|
|
238
|
+
minAge: 14,
|
|
239
|
+
maxAge: 16,
|
|
240
|
+
});
|
|
241
|
+
await givers.save();
|
|
242
|
+
createdGroups.push(givers);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return createdGroups;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async createChiroGroups(period: RegistrationPeriod) {
|
|
249
|
+
const mixedType = this.organization.meta.genderType === OrganizationGenderType.OnlyMale
|
|
250
|
+
? GroupGenderType.OnlyMale
|
|
251
|
+
: (this.organization.meta.genderType === OrganizationGenderType.OnlyFemale
|
|
252
|
+
? GroupGenderType.OnlyFemale
|
|
253
|
+
: GroupGenderType.Mixed);
|
|
254
|
+
|
|
255
|
+
const ribbels = new Group();
|
|
256
|
+
ribbels.organizationId = this.organization.id;
|
|
257
|
+
ribbels.periodId = this.organization.periodId;
|
|
258
|
+
ribbels.settings = GroupSettings.create({
|
|
259
|
+
name: new TranslatedString('Ribbels'),
|
|
260
|
+
genderType: mixedType,
|
|
261
|
+
startDate: period.startDate,
|
|
262
|
+
endDate: period.endDate,
|
|
263
|
+
minAge: 6,
|
|
264
|
+
maxAge: 7,
|
|
265
|
+
});
|
|
266
|
+
await ribbels.save();
|
|
267
|
+
|
|
268
|
+
const speelclub = new Group();
|
|
269
|
+
speelclub.organizationId = this.organization.id;
|
|
270
|
+
speelclub.periodId = this.organization.periodId;
|
|
271
|
+
speelclub.settings = GroupSettings.create({
|
|
272
|
+
name: new TranslatedString('Speelclub'),
|
|
273
|
+
genderType: mixedType,
|
|
274
|
+
startDate: period.startDate,
|
|
275
|
+
endDate: period.endDate,
|
|
276
|
+
minAge: 8,
|
|
277
|
+
maxAge: 9,
|
|
278
|
+
});
|
|
279
|
+
await speelclub.save();
|
|
280
|
+
|
|
281
|
+
const aspis = new Group();
|
|
282
|
+
aspis.organizationId = this.organization.id;
|
|
283
|
+
aspis.periodId = this.organization.periodId;
|
|
284
|
+
aspis.settings = GroupSettings.create({
|
|
285
|
+
name: new TranslatedString("Aspi's"),
|
|
286
|
+
genderType: mixedType,
|
|
287
|
+
startDate: period.startDate,
|
|
288
|
+
endDate: period.endDate,
|
|
289
|
+
minAge: 16,
|
|
290
|
+
maxAge: 17,
|
|
291
|
+
});
|
|
292
|
+
await aspis.save();
|
|
293
|
+
|
|
294
|
+
if (this.organization.meta.genderType == OrganizationGenderType.Mixed) {
|
|
295
|
+
const rakwis = new Group();
|
|
296
|
+
rakwis.organizationId = this.organization.id;
|
|
297
|
+
rakwis.periodId = this.organization.periodId;
|
|
298
|
+
rakwis.settings = GroupSettings.create({
|
|
299
|
+
name: new TranslatedString("Rakwi's"),
|
|
300
|
+
genderType: GroupGenderType.Mixed,
|
|
301
|
+
startDate: period.startDate,
|
|
302
|
+
endDate: period.endDate,
|
|
303
|
+
minAge: 10,
|
|
304
|
+
maxAge: 11,
|
|
305
|
+
});
|
|
306
|
+
await rakwis.save();
|
|
307
|
+
|
|
308
|
+
const titos = new Group();
|
|
309
|
+
titos.organizationId = this.organization.id;
|
|
310
|
+
titos.periodId = this.organization.periodId;
|
|
311
|
+
titos.settings = GroupSettings.create({
|
|
312
|
+
name: new TranslatedString("Tito's"),
|
|
313
|
+
genderType: GroupGenderType.Mixed,
|
|
314
|
+
startDate: period.startDate,
|
|
315
|
+
endDate: period.endDate,
|
|
316
|
+
minAge: 12,
|
|
317
|
+
maxAge: 13,
|
|
318
|
+
});
|
|
319
|
+
await titos.save();
|
|
320
|
+
|
|
321
|
+
const ketis = new Group();
|
|
322
|
+
ketis.organizationId = this.organization.id;
|
|
323
|
+
ketis.periodId = this.organization.periodId;
|
|
324
|
+
ketis.settings = GroupSettings.create({
|
|
325
|
+
name: new TranslatedString("Keti's"),
|
|
326
|
+
genderType: GroupGenderType.Mixed,
|
|
327
|
+
startDate: period.startDate,
|
|
328
|
+
endDate: period.endDate,
|
|
329
|
+
minAge: 14,
|
|
330
|
+
maxAge: 15,
|
|
331
|
+
});
|
|
332
|
+
await ketis.save();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (this.organization.meta.genderType == OrganizationGenderType.OnlyFemale || this.organization.meta.genderType == OrganizationGenderType.Separated) {
|
|
336
|
+
const rakwis = new Group();
|
|
337
|
+
rakwis.organizationId = this.organization.id;
|
|
338
|
+
rakwis.periodId = this.organization.periodId;
|
|
339
|
+
rakwis.settings = GroupSettings.create({
|
|
340
|
+
name: new TranslatedString('Kwiks'),
|
|
341
|
+
genderType: GroupGenderType.OnlyFemale,
|
|
342
|
+
startDate: period.startDate,
|
|
343
|
+
endDate: period.endDate,
|
|
344
|
+
minAge: 10,
|
|
345
|
+
maxAge: 11,
|
|
346
|
+
});
|
|
347
|
+
await rakwis.save();
|
|
348
|
+
|
|
349
|
+
const titos = new Group();
|
|
350
|
+
titos.organizationId = this.organization.id;
|
|
351
|
+
titos.periodId = this.organization.periodId;
|
|
352
|
+
titos.settings = GroupSettings.create({
|
|
353
|
+
name: new TranslatedString('Toppers'),
|
|
354
|
+
genderType: GroupGenderType.OnlyFemale,
|
|
355
|
+
startDate: period.startDate,
|
|
356
|
+
endDate: period.endDate,
|
|
357
|
+
minAge: 12,
|
|
358
|
+
maxAge: 13,
|
|
359
|
+
});
|
|
360
|
+
await titos.save();
|
|
361
|
+
|
|
362
|
+
const ketis = new Group();
|
|
363
|
+
ketis.organizationId = this.organization.id;
|
|
364
|
+
ketis.periodId = this.organization.periodId;
|
|
365
|
+
ketis.settings = GroupSettings.create({
|
|
366
|
+
name: new TranslatedString('Tiptiens'),
|
|
367
|
+
genderType: GroupGenderType.OnlyFemale,
|
|
368
|
+
startDate: period.startDate,
|
|
369
|
+
endDate: period.endDate,
|
|
370
|
+
minAge: 14,
|
|
371
|
+
maxAge: 15,
|
|
372
|
+
});
|
|
373
|
+
await ketis.save();
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (this.organization.meta.genderType == OrganizationGenderType.OnlyMale || this.organization.meta.genderType == OrganizationGenderType.Separated) {
|
|
377
|
+
const rakwis = new Group();
|
|
378
|
+
rakwis.organizationId = this.organization.id;
|
|
379
|
+
rakwis.periodId = this.organization.periodId;
|
|
380
|
+
rakwis.settings = GroupSettings.create({
|
|
381
|
+
name: new TranslatedString('Rakkers'),
|
|
382
|
+
genderType: GroupGenderType.OnlyMale,
|
|
383
|
+
startDate: period.startDate,
|
|
384
|
+
endDate: period.endDate,
|
|
385
|
+
minAge: 10,
|
|
386
|
+
maxAge: 11,
|
|
387
|
+
});
|
|
388
|
+
await rakwis.save();
|
|
389
|
+
|
|
390
|
+
const titos = new Group();
|
|
391
|
+
titos.organizationId = this.organization.id;
|
|
392
|
+
titos.periodId = this.organization.periodId;
|
|
393
|
+
titos.settings = GroupSettings.create({
|
|
394
|
+
name: new TranslatedString('Tippers'),
|
|
395
|
+
genderType: GroupGenderType.OnlyMale,
|
|
396
|
+
startDate: period.startDate,
|
|
397
|
+
endDate: period.endDate,
|
|
398
|
+
minAge: 12,
|
|
399
|
+
maxAge: 13,
|
|
400
|
+
});
|
|
401
|
+
await titos.save();
|
|
402
|
+
|
|
403
|
+
const ketis = new Group();
|
|
404
|
+
ketis.organizationId = this.organization.id;
|
|
405
|
+
ketis.periodId = this.organization.periodId;
|
|
406
|
+
ketis.settings = GroupSettings.create({
|
|
407
|
+
name: new TranslatedString('Kerels'),
|
|
408
|
+
genderType: GroupGenderType.OnlyMale,
|
|
409
|
+
startDate: period.startDate,
|
|
410
|
+
endDate: period.endDate,
|
|
411
|
+
minAge: 14,
|
|
412
|
+
maxAge: 15,
|
|
413
|
+
});
|
|
414
|
+
await ketis.save();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
@@ -2,7 +2,7 @@ import { Database } from '@simonbackx/simple-database';
|
|
|
2
2
|
import { Member, MemberFactory, MemberResponsibilityRecordFactory, User, UserFactory } from '@stamhoofd/models';
|
|
3
3
|
import { BooleanStatus, MemberDetails, Parent, UserPermissions } from '@stamhoofd/structures';
|
|
4
4
|
import { TestUtils } from '@stamhoofd/test-utils';
|
|
5
|
-
import { MemberUserSyncer } from './MemberUserSyncer';
|
|
5
|
+
import { MemberUserSyncer } from './MemberUserSyncer.js';
|
|
6
6
|
|
|
7
7
|
describe('Helpers.MemberUserSyncer', () => {
|
|
8
8
|
beforeEach(async () => {
|
|
@@ -5,7 +5,7 @@ import { AuditLogSource, MemberDetails, PermissionRole, Permissions, ReceivableB
|
|
|
5
5
|
import { Formatter } from '@stamhoofd/utility';
|
|
6
6
|
import basex from 'base-x';
|
|
7
7
|
import crypto from 'crypto';
|
|
8
|
-
import { AuditLogService } from '../services/AuditLogService';
|
|
8
|
+
import { AuditLogService } from '../services/AuditLogService.js';
|
|
9
9
|
|
|
10
10
|
const ALPHABET = '123456789ABCDEFGHJKMNPQRSTUVWXYZ'; // Note: we removed 0, O, I and l to make it easier for humans
|
|
11
11
|
const customBase = basex(ALPHABET);
|
|
@@ -2,11 +2,11 @@ import { SimpleError } from '@simonbackx/simple-errors';
|
|
|
2
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
|
-
import { PatchOrganizationRegistrationPeriodsEndpoint } from '../endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint';
|
|
6
|
-
import { AuditLogService } from '../services/AuditLogService';
|
|
7
|
-
import { AuthenticatedStructures } from './AuthenticatedStructures';
|
|
8
|
-
import { MemberUserSyncer } from './MemberUserSyncer';
|
|
9
|
-
import { SetupStepUpdater } from './SetupStepUpdater';
|
|
5
|
+
import { PatchOrganizationRegistrationPeriodsEndpoint } from '../endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.js';
|
|
6
|
+
import { AuditLogService } from '../services/AuditLogService.js';
|
|
7
|
+
import { AuthenticatedStructures } from './AuthenticatedStructures.js';
|
|
8
|
+
import { MemberUserSyncer } from './MemberUserSyncer.js';
|
|
9
|
+
import { SetupStepUpdater } from './SetupStepUpdater.js';
|
|
10
10
|
|
|
11
11
|
export class PeriodHelper {
|
|
12
12
|
static async moveOrganizationToPeriod(organization: Organization, period: RegistrationPeriod) {
|
|
@@ -60,46 +60,6 @@ export class PeriodHelper {
|
|
|
60
60
|
console.log('Done: stopped all responsibilities: ' + c);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
static async syncAllMemberUsers() {
|
|
64
|
-
console.log('Syncing all members');
|
|
65
|
-
|
|
66
|
-
let c = 0;
|
|
67
|
-
let lastId: string = '';
|
|
68
|
-
|
|
69
|
-
while (true) {
|
|
70
|
-
const rawMembers = await Member.where({
|
|
71
|
-
id: {
|
|
72
|
-
value: lastId,
|
|
73
|
-
sign: '>',
|
|
74
|
-
},
|
|
75
|
-
}, { limit: 500, sort: ['id'] });
|
|
76
|
-
|
|
77
|
-
if (rawMembers.length === 0) {
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const membersWithRegistrations = await Member.getBlobByIds(...rawMembers.map(m => m.id));
|
|
82
|
-
|
|
83
|
-
const promises: Promise<any>[] = [];
|
|
84
|
-
|
|
85
|
-
for (const memberWithRegistrations of membersWithRegistrations) {
|
|
86
|
-
promises.push((async () => {
|
|
87
|
-
await MemberUserSyncer.onChangeMember(memberWithRegistrations);
|
|
88
|
-
c++;
|
|
89
|
-
|
|
90
|
-
if (c % 10000 === 0) {
|
|
91
|
-
console.log('Synced ' + c + ' members');
|
|
92
|
-
}
|
|
93
|
-
})());
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
await Promise.all(promises);
|
|
97
|
-
lastId = rawMembers[rawMembers.length - 1].id;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
console.log('Done: synced all members: ' + c);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
63
|
static async createOrganizationPeriodForPeriod(organization: Organization, period: RegistrationPeriod) {
|
|
104
64
|
const oPeriods = await OrganizationRegistrationPeriod.where({ periodId: period.id, organizationId: organization.id }, { limit: 1 });
|
|
105
65
|
|
|
@@ -2,7 +2,11 @@ import { Organization, Payment } from '@stamhoofd/models';
|
|
|
2
2
|
import { calculateVATPercentage, PaymentProvider, STPackageType } from '@stamhoofd/structures';
|
|
3
3
|
|
|
4
4
|
export class ServiceFeeHelper {
|
|
5
|
-
static setServiceFee(payment: Payment, organization: Organization, type: 'webshop' | 'members' | 'tickets', itemPrices: number[]): void {
|
|
5
|
+
static setServiceFee(payment: Payment, organization: Organization, type: 'webshop' | 'members' | 'tickets' | 'system', itemPrices: number[]): void {
|
|
6
|
+
if (type === 'system') {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
let vat = 0;
|
|
7
11
|
|
|
8
12
|
// Calculate item count
|
|
@@ -21,9 +21,9 @@ import {
|
|
|
21
21
|
SetupSteps,
|
|
22
22
|
} from '@stamhoofd/structures';
|
|
23
23
|
import { Formatter } from '@stamhoofd/utility';
|
|
24
|
-
import { AuditLogService } from '../services/AuditLogService';
|
|
25
|
-
import { GroupedThrottledQueue } from './GroupedThrottledQueue';
|
|
26
|
-
import { AuthenticatedStructures } from './AuthenticatedStructures';
|
|
24
|
+
import { AuditLogService } from '../services/AuditLogService.js';
|
|
25
|
+
import { GroupedThrottledQueue } from './GroupedThrottledQueue.js';
|
|
26
|
+
import { AuthenticatedStructures } from './AuthenticatedStructures.js';
|
|
27
27
|
|
|
28
28
|
type SetupStepOperation = (setupSteps: SetupSteps, organization: Organization, platform: PlatformStruct) => void | Promise<void>;
|
|
29
29
|
|
|
@@ -381,7 +381,8 @@ export class SetupStepUpdater {
|
|
|
381
381
|
|
|
382
382
|
// Remove invalid responsibilities: members that are not registered in the current period
|
|
383
383
|
const memberIds = Formatter.uniqueArray(allRecords.map(r => r.memberId));
|
|
384
|
-
const
|
|
384
|
+
const _members = await Member.getByIDs(...memberIds);
|
|
385
|
+
const members = await Member.loadRegistrations(_members, true);
|
|
385
386
|
const validMembers = members.filter(m => m.registrations.some(r => r.organizationId === organization.id && r.periodId === organization.periodId && r.group.defaultAgeGroupId && r.group.type === GroupType.Membership && r.deactivatedAt === null && r.registeredAt !== null));
|
|
386
387
|
const invalidMembers = members.filter(m => !m.registrations.some(r => r.organizationId === organization.id && r.periodId === organization.periodId && r.group.defaultAgeGroupId && r.group.type === GroupType.Membership && r.deactivatedAt === null && r.registeredAt !== null));
|
|
387
388
|
|
package/src/helpers/TagHelper.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Organization, Platform } from '@stamhoofd/models';
|
|
2
2
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
3
3
|
import { AuditLogSource, OrganizationTag, TagHelper as SharedTagHelper } from '@stamhoofd/structures';
|
|
4
|
-
import { AuditLogService } from '../services/AuditLogService';
|
|
4
|
+
import { AuditLogService } from '../services/AuditLogService.js';
|
|
5
5
|
|
|
6
6
|
export class TagHelper extends SharedTagHelper {
|
|
7
7
|
static async updateOrganizations() {
|
|
@@ -33,6 +33,15 @@ export class ViesHelperStatic {
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
if (company.name.length < 3 || company.name.toLowerCase() === 'vzw') {
|
|
37
|
+
throw new SimpleError({
|
|
38
|
+
code: 'invalid_company_name',
|
|
39
|
+
message: 'Company name is too short',
|
|
40
|
+
human: $t('31bd2a76-8b01-4658-a18d-b63795f4be63'),
|
|
41
|
+
field: 'companyName',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
if (company.VATNumber !== null) {
|
|
37
46
|
// Changed VAT number
|
|
38
47
|
patch.VATNumber = await ViesHelper.checkVATNumber(company.address.country, company.VATNumber);
|
|
@@ -101,44 +101,3 @@ export function createOrderDataHTMLTable(order: Order, webshop: Webshop): string
|
|
|
101
101
|
|
|
102
102
|
return str + '</tbody></table>';
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
export function createPaymentDataHTMLTable(payment: PaymentGeneral): string {
|
|
106
|
-
let str = `<table width="100%" cellspacing="0" cellpadding="0" class="email-data-table"><tbody>`;
|
|
107
|
-
|
|
108
|
-
const customer = payment.customer;
|
|
109
|
-
|
|
110
|
-
const replacements: { title: string; value: string }[] = [];
|
|
111
|
-
|
|
112
|
-
if (customer) {
|
|
113
|
-
replacements.push({
|
|
114
|
-
title: $t(`17edcdd6-4fb2-4882-adec-d3a4f43a1926`),
|
|
115
|
-
value: customer.dynamicName,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
if (customer.phone) {
|
|
119
|
-
replacements.push({
|
|
120
|
-
title: $t(`feea3664-9353-4bd4-b17d-aff005d3e265`),
|
|
121
|
-
value: customer.phone,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
replacements.push({
|
|
127
|
-
title: $t(`07e7025c-0bfb-41be-87bc-1023d297a1a2`),
|
|
128
|
-
value: Formatter.capitalizeFirstLetter(PaymentMethodHelper.getName(payment.method ?? PaymentMethod.Unknown)),
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
replacements.push({
|
|
132
|
-
title: $t(`Totaal`),
|
|
133
|
-
value: Formatter.price(payment.price),
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
for (const replacement of replacements) {
|
|
137
|
-
if (replacement.value.length === 0) {
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
str += `<tr><td><h4>${Formatter.escapeHtml(replacement.title)}</h4></td><td>${Formatter.escapeHtml(replacement.value)}</td></tr>`;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return str + '</tbody></table>';
|
|
144
|
-
}
|
|
@@ -12,7 +12,9 @@ export const memberCachedBalanceForOrganizationJoin = SQL.leftJoin(
|
|
|
12
12
|
)
|
|
13
13
|
.from(CachedBalance.table)
|
|
14
14
|
.where(SQL.column(CachedBalance.table, 'objectType'), 'member')
|
|
15
|
-
.groupBy(SQL.column(CachedBalance.table, 'objectId'), SQL.column(CachedBalance.table, 'organizationId'))
|
|
15
|
+
.groupBy(SQL.column(CachedBalance.table, 'objectId'), SQL.column(CachedBalance.table, 'organizationId'))
|
|
16
|
+
.as('memberCachedBalance') as SQLNamedExpression,
|
|
17
|
+
'memberCachedBalance',
|
|
16
18
|
)
|
|
17
19
|
.where(SQL.column('objectId'), SQL.column(Registration.table, 'memberId'))
|
|
18
20
|
.andWhere(SQL.column('organizationId'), SQL.column(Registration.table, 'organizationId'));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request, RequestMiddleware } from '@simonbackx/simple-endpoints';
|
|
2
2
|
|
|
3
|
-
import { ContextInstance } from '../helpers/Context';
|
|
3
|
+
import { ContextInstance } from '../helpers/Context.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This attaches a context to each request for authentication and authorization
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Migration } from '@simonbackx/simple-database';
|
|
2
2
|
import { Registration } from '@stamhoofd/models';
|
|
3
|
-
import { RegistrationService } from '../services/RegistrationService';
|
|
3
|
+
import { RegistrationService } from '../services/RegistrationService.js';
|
|
4
4
|
|
|
5
5
|
export default new Migration(async () => {
|
|
6
6
|
if (STAMHOOFD.environment == 'test') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Migration } from '@simonbackx/simple-database';
|
|
2
|
-
import { SetupStepUpdater } from '../helpers/SetupStepUpdater';
|
|
2
|
+
import { SetupStepUpdater } from '../helpers/SetupStepUpdater.js';
|
|
3
3
|
|
|
4
4
|
export default new Migration(async () => {
|
|
5
5
|
if (STAMHOOFD.environment == 'test') {
|