@stamhoofd/backend 2.120.6 → 2.122.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/output-2.txt +1 -0
- package/output.txt +1 -0
- package/package.json +70 -53
- package/src/audit-logs/EventNotificationLogger.ts +40 -0
- package/src/audit-logs/ModelLogger.ts +19 -15
- package/src/audit-logs/OrganizationLogger.ts +1 -1
- package/src/audit-logs/RegistrationInvitationLogger.ts +46 -0
- package/src/audit-logs/init.ts +9 -1
- package/src/boot.ts +19 -18
- package/src/crons/amazon-ses.ts +13 -26
- package/src/crons/balance-emails.ts +3 -5
- package/src/crons/clearExcelCache.test.ts +1 -1
- package/src/crons/clearExcelCache.ts +1 -2
- package/src/crons/drip-emails.ts +42 -0
- package/src/crons/endFunctionsOfUsersWithoutRegistration.ts +4 -0
- package/src/crons/helpers/isOutside.ts +11 -0
- package/src/crons/helpers/useSavedIterator.ts +32 -0
- package/src/crons/index.ts +7 -0
- package/src/crons/invoices.ts +160 -0
- package/src/crons/members-fees.ts +50 -0
- package/src/crons/mollie-chargebacks.ts +86 -0
- package/src/crons/service-fees.ts +152 -0
- package/src/crons/stripe-invoices.ts +48 -0
- package/src/crons/transfer-fees.ts +176 -0
- package/src/crons/update-cached-balances.ts +4 -4
- package/src/crons.ts +54 -74
- package/src/debug.ts +4 -2
- package/src/email-recipient-loaders/documents.ts +1 -1
- package/src/email-recipient-loaders/members.ts +1 -1
- package/src/email-recipient-loaders/payments.ts +87 -46
- package/src/email-recipient-loaders/registrations.ts +1 -1
- package/src/email-replacements/getEmailReplacementsForPayment.ts +5 -9
- package/src/endpoints/admin/members/ChargeMembersEndpoint.ts +1 -1
- package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +1 -1
- package/src/endpoints/admin/memberships/GetChargeMembershipsSummaryEndpoint.ts +3 -5
- package/src/endpoints/admin/organizations/ChargeOrganizationsEndpoint.ts +1 -1
- package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +1 -1
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +13 -7
- package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +4 -6
- package/src/endpoints/admin/organizations/PatchPackagesEndpoint.test.ts +10 -6
- package/src/endpoints/admin/organizations/PatchPackagesEndpoint.ts +39 -21
- package/src/endpoints/admin/registrations/ChargeRegistrationsEndpoint.ts +1 -1
- package/src/endpoints/auth/CreateAdminEndpoint.ts +23 -5
- package/src/endpoints/auth/CreateTokenEndpoint.ts +2 -2
- package/src/endpoints/auth/DeleteTokenEndpoint.ts +1 -1
- package/src/endpoints/auth/DeleteUserEndpoint.ts +3 -3
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +1 -1
- package/src/endpoints/auth/GetOtherUserEndpoint.ts +1 -1
- package/src/endpoints/auth/GetUserEndpoint.ts +1 -1
- package/src/endpoints/auth/OpenIDConnectAuthTokenEndpoint.ts +1 -1
- package/src/endpoints/auth/OpenIDConnectStartEndpoint.ts +1 -1
- package/src/endpoints/auth/PatchUserEndpoint.ts +5 -8
- package/src/endpoints/auth/PollEmailVerificationEndpoint.ts +1 -1
- package/src/endpoints/auth/RetryEmailVerificationEndpoint.ts +1 -1
- package/src/endpoints/auth/SignupEndpoint.ts +2 -3
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +20 -3
- package/src/endpoints/frontend/FrontendEnvironmentEndpoint.ts +2 -1
- package/src/endpoints/global/addresses/SearchRegionsEndpoint.ts +2 -4
- package/src/endpoints/global/addresses/ValidateAddressEndpoint.ts +1 -1
- package/src/endpoints/global/audit-logs/GetAuditLogsEndpoint.ts +5 -7
- package/src/endpoints/global/caddy/CheckDomainCertEndpoint.ts +2 -2
- package/src/endpoints/global/email/CreateEmailEndpoint.ts +3 -4
- package/src/endpoints/global/email/GetAdminEmailsEndpoint.test.ts +1 -1
- package/src/endpoints/global/email/GetAdminEmailsEndpoint.ts +1 -2
- package/src/endpoints/global/email/GetEmailAddressEndpoint.ts +4 -6
- package/src/endpoints/global/email/GetEmailEndpoint.ts +1 -1
- package/src/endpoints/global/email/GetUserEmailsEndpoint.test.ts +1 -1
- package/src/endpoints/global/email/GetUserEmailsEndpoint.ts +1 -1
- package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +6 -10
- package/src/endpoints/global/email/PatchEmailEndpoint.test.ts +4 -7
- package/src/endpoints/global/email/PatchEmailEndpoint.ts +6 -9
- package/src/endpoints/global/email-recipients/GetEmailRecipientsCountEndpoint.ts +1 -1
- package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.test.ts +1 -1
- package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.ts +1 -1
- package/src/endpoints/global/email-recipients/RetryEmailRecipientEndpoint.ts +2 -2
- package/src/endpoints/global/events/GetEventNotificationsCountEndpoint.ts +1 -1
- package/src/endpoints/global/events/GetEventNotificationsEndpoint.ts +3 -3
- package/src/endpoints/global/events/GetEventsEndpoint.ts +3 -3
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.test.ts +49 -4
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.ts +5 -8
- package/src/endpoints/global/events/PatchEventsEndpoint.test.ts +12 -44
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +128 -127
- package/src/endpoints/global/files/ExportToExcelEndpoint.ts +9 -9
- package/src/endpoints/global/files/GetFileCache.ts +3 -4
- package/src/endpoints/global/files/UploadFile.ts +3 -4
- package/src/endpoints/global/files/UploadImage.ts +3 -4
- package/src/endpoints/global/groups/GetGroupsCountEndpoint.ts +51 -0
- package/src/endpoints/global/groups/GetGroupsEndpoint.test.ts +1 -1
- package/src/endpoints/global/groups/GetGroupsEndpoint.ts +4 -2
- package/src/endpoints/global/members/GetMemberFamilyEndpoint.ts +2 -3
- package/src/endpoints/global/members/GetMembersCountEndpoint.ts +1 -1
- package/src/endpoints/global/members/GetMembersEndpoint.test.ts +2 -2
- package/src/endpoints/global/members/GetMembersEndpoint.ts +10 -12
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.test.ts +195 -12
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +16 -22
- package/src/endpoints/global/members/helpers/validateGroupFilter.ts +6 -30
- package/src/endpoints/global/members/shouldCheckIfMemberIsDuplicate.ts +1 -1
- package/src/endpoints/global/organizations/CheckRegisterCodeEndpoint.ts +1 -1
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +40 -8
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.ts +2 -2
- package/src/endpoints/global/organizations/GetOrganizationFromUriEndpoint.ts +2 -2
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.test.ts +4 -1
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.ts +4 -5
- package/src/endpoints/global/payments/StripeWebhookEndpoint.ts +9 -16
- package/src/endpoints/global/platform/GetPlatformAdminsEndpoint.ts +1 -1
- package/src/endpoints/global/platform/GetPlatformEndpoint.ts +1 -1
- package/src/endpoints/global/platform/PatchPlatformEnpoint.test.ts +1 -1
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +32 -13
- package/src/endpoints/global/platform-memberships/GetPlatformMembershipsCountEndpoint.ts +31 -31
- package/src/endpoints/global/platform-memberships/GetPlatformMembershipsEndpoint.ts +18 -20
- package/src/endpoints/global/registration/GetRegistrationsCountEndpoint.ts +1 -1
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.test.ts +1 -1
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.ts +6 -10
- package/src/endpoints/global/registration/GetUserDetailedPayableBalanceEndpoint.ts +35 -6
- package/src/endpoints/global/registration/GetUserDocumentsEndpoint.ts +2 -2
- package/src/endpoints/global/registration/GetUserMembersEndpoint.ts +1 -1
- package/src/endpoints/global/registration/GetUserPayableBalanceEndpoint.ts +1 -1
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.test.ts +2 -2
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +3 -3
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +90 -6
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +38 -33
- package/src/endpoints/global/registration-invitations/GetRegistrationInvitationsCountEndpoint.ts +45 -0
- package/src/endpoints/global/registration-invitations/GetRegistrationInvitationsEndpoint.test.ts +494 -0
- package/src/endpoints/global/registration-invitations/GetRegistrationInvitationsEndpoint.ts +213 -0
- package/src/endpoints/global/registration-invitations/PatchRegistrationInvitationsEndpoint.test.ts +404 -0
- package/src/endpoints/global/registration-invitations/PatchRegistrationInvitationsEndpoint.ts +167 -0
- package/src/endpoints/global/registration-periods/GetRegistrationPeriodsCountEndpoint.ts +43 -0
- package/src/endpoints/global/registration-periods/GetRegistrationPeriodsEndpoint.ts +1 -1
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +13 -5
- package/src/endpoints/global/sso/GetSSOEndpoint.ts +2 -3
- package/src/endpoints/global/sso/SetSSOEndpoint.ts +1 -1
- package/src/endpoints/global/webshops/GetWebshopFromDomainEndpoint.ts +2 -2
- package/src/endpoints/global/webshops/GetWebshopsEndpoint.test.ts +1 -2
- package/src/endpoints/global/webshops/GetWebshopsEndpoint.ts +2 -4
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsCountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsEndpoint.ts +3 -4
- package/src/endpoints/organization/dashboard/balance-items/PatchBalanceItemsEndpoint.ts +19 -6
- package/src/endpoints/organization/dashboard/billing/ApplyRegisterCodeEndpoint.test.ts +73 -0
- package/src/endpoints/organization/dashboard/billing/ApplyRegisterCodeEndpoint.ts +89 -0
- package/src/endpoints/{global → organization/dashboard}/billing/DeactivatePackageEndpoint.ts +4 -9
- package/src/endpoints/organization/dashboard/billing/DeleteOrganizationMandateEndpoint.ts +62 -0
- package/src/endpoints/organization/dashboard/billing/GetOrganizationDetailedPayableBalanceCollectionEndpoint.ts +56 -0
- package/src/endpoints/organization/dashboard/billing/GetOrganizationDetailedPayableBalanceEndpoint.ts +41 -18
- package/src/endpoints/organization/dashboard/billing/GetOrganizationMandatesEndpoint.ts +64 -0
- package/src/endpoints/organization/dashboard/billing/GetOrganizationPayableBalanceEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/billing/GetOrganizationPayableInvoicesEndpoint.ts +68 -0
- package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.ts +12 -4
- package/src/endpoints/organization/dashboard/billing/GetRegisterCodeEndpoint.ts +66 -0
- package/src/endpoints/organization/dashboard/billing/OrganizationCheckoutEndpoint.test.ts +949 -0
- package/src/endpoints/organization/dashboard/billing/OrganizationCheckoutEndpoint.ts +311 -0
- package/src/endpoints/organization/dashboard/billing/PatchOrganizationMandatesEndpoint.ts +94 -0
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplateXML.ts +1 -1
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplatesCountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplatesEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/documents/GetDocumentsCountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/documents/GetDocumentsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/documents/PatchDocumentEndpoint.ts +10 -2
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplatesEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplatesEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.test.ts +1 -1
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.ts +10 -8
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.test.ts +1 -1
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +5 -6
- package/src/endpoints/organization/dashboard/invoices/GetInvoicesCountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/invoices/GetInvoicesEndpoint.ts +15 -4
- package/src/endpoints/organization/dashboard/invoices/PatchInvoicesEndpoint.ts +11 -2
- package/src/endpoints/organization/dashboard/mollie/CheckMollieEndpoint.ts +8 -8
- package/src/endpoints/organization/dashboard/mollie/ConnectMollieEndpoint.ts +10 -5
- package/src/endpoints/organization/dashboard/mollie/DisconnectMollieEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/mollie/GetMollieDashboardEndpoint.ts +7 -7
- 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 +1 -1
- package/src/endpoints/organization/dashboard/organization/GetUitpasClientIdEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +67 -20
- package/src/endpoints/organization/dashboard/organization/SearchUitpasOrganizersEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +5 -10
- package/src/endpoints/organization/dashboard/organization/SetUitpasClientCredentialsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/payments/GetPaymentsCountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +3 -4
- package/src/endpoints/organization/dashboard/payments/PatchPaymentsEndpoint.ts +24 -17
- package/src/endpoints/organization/dashboard/receivable-balances/ChargeReceivableBalancesEndpoint.ts +134 -0
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalanceEndpoint.ts +2 -3
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesCountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.test.ts +1 -1
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.ts +2 -3
- package/src/endpoints/organization/dashboard/registration-periods/MoveRegistrationPeriods.test.ts +1 -1
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.test.ts +1 -1
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +32 -22
- package/src/endpoints/organization/dashboard/registration-periods/SetupStepReviewEndpoint.ts +4 -5
- package/src/endpoints/organization/dashboard/stripe/ConnectStripeEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/stripe/DeleteStripeAccountEndpoint.ts +2 -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 +1 -1
- 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.ts +4 -6
- package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +10 -15
- package/src/endpoints/organization/dashboard/webshops/DeleteWebshopEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/GetDiscountCodesEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersCountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/GetWebshopUriAvailabilityEndpoint.ts +11 -2
- package/src/endpoints/organization/dashboard/webshops/PatchDiscountCodesEndpoint.ts +4 -6
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +29 -8
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +21 -28
- 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 +2 -3
- package/src/endpoints/organization/dashboard/webshops/WebshopReservedPathSegments.test.ts +95 -0
- package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +15 -13
- package/src/endpoints/organization/shared/GetDocumentHtml.ts +1 -1
- package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +1 -1
- package/src/endpoints/organization/shared/GetUitpasNumberDetailsEndpoint.ts +3 -5
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/CheckWebshopDiscountCodesEndpoint.ts +4 -1
- package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +14 -3
- package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +14 -2
- package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +37 -16
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.test.ts +34 -2
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +4 -2
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.test.ts +74 -3
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.ts +28 -50
- package/src/endpoints/organization/webshops/RetrieveUitpasSocialTariffPriceEndpoint.ts +3 -5
- package/src/endpoints/organization/webshops/WebshopAuthHelper.ts +36 -0
- package/src/endpoints/system/HealthEndpoint.ts +1 -1
- package/src/excel-loaders/balance-items.ts +1 -1
- package/src/excel-loaders/event-notifications.ts +1 -1
- package/src/excel-loaders/members.ts +1 -1
- package/src/excel-loaders/organizations.ts +3 -3
- package/src/excel-loaders/payments.ts +31 -1
- package/src/excel-loaders/platform-memberships.ts +13 -14
- package/src/excel-loaders/receivable-balances.ts +2 -2
- package/src/excel-loaders/registrations.ts +2 -3
- package/src/helpers/AddressValidator.ts +7 -14
- package/src/helpers/AdminPermissionChecker.ts +60 -65
- package/src/helpers/AuthenticatedStructures.ts +153 -51
- package/src/helpers/BalanceItemRelationsBackfiller.test.ts +174 -0
- package/src/helpers/BalanceItemRelationsBackfiller.ts +163 -0
- package/src/helpers/BuckarooHelper.ts +2 -4
- package/src/helpers/CheckSettlements.ts +12 -24
- package/src/helpers/Context.ts +15 -10
- package/src/helpers/CookieHelper.ts +1 -2
- package/src/helpers/EmailResumer.ts +1 -2
- package/src/helpers/FileCache.ts +2 -3
- package/src/helpers/FinancialSupportHelper.ts +21 -0
- package/src/helpers/FlagMomentCleanup.ts +1 -2
- package/src/helpers/ForwardHandler.ts +5 -10
- package/src/helpers/GlobalHelper.ts +3 -3
- package/src/helpers/LegacyBillingConverter.ts +787 -0
- package/src/helpers/MemberMerger.test.ts +782 -0
- package/src/helpers/MemberMerger.ts +600 -0
- package/src/helpers/MemberUserSyncer.ts +6 -12
- package/src/helpers/MembershipCharger.ts +2 -4
- package/src/helpers/PaymentCustomerResolver.test.ts +203 -0
- package/src/helpers/PaymentCustomerResolver.ts +144 -0
- package/src/helpers/PeriodHelper.ts +2 -3
- package/src/helpers/RecordAnswerHelper.test.ts +741 -0
- package/src/helpers/RecordAnswerHelper.ts +116 -0
- package/src/helpers/SeedTools.ts +106 -0
- package/src/helpers/ServiceFeeHelper.ts +125 -15
- package/src/helpers/SetupStepUpdater.ts +38 -32
- package/src/helpers/StamhoofdFilterAccessHelper.ts +52 -0
- package/src/helpers/StripeHelper.ts +15 -38
- package/src/helpers/StripeInvoicer.ts +419 -0
- package/src/helpers/StripePayoutChecker.ts +5 -10
- package/src/helpers/TagHelper.ts +7 -8
- package/src/helpers/TemporaryMemberAccess.ts +1 -2
- package/src/helpers/ThrottledQueue.ts +1 -2
- package/src/helpers/UitpasTokenRepository.ts +1 -2
- package/src/helpers/ViesHelper.ts +11 -11
- package/src/helpers/XlsxTransformerColumnHelper.ts +1 -1
- package/src/helpers/outstandingBalanceJoin.ts +2 -2
- package/src/helpers/updateMemberDetailsUitpasNumber.ts +3 -5
- package/src/migrate.ts +12 -5
- package/src/{seeds → migrations}/0000000004-single-organization.ts +10 -1
- package/src/migrations/0000000006-default-organization.ts +139 -0
- package/src/{seeds → migrations}/1715028563-user-permissions.ts +17 -27
- package/src/{seeds/1765896674-document-update-year.test.ts → migrations/1750090029-document-update-year.test.ts} +27 -26
- package/src/migrations/1750090029-document-update-year.ts +103 -0
- package/src/migrations/1750090030-records-configuration.ts +92 -0
- package/src/migrations/1750090031-records-configuration-webshops.ts +36 -0
- package/src/migrations/1752848540-national-numbers.ts +585 -0
- package/src/migrations/1752848550-records-configuration-group-filter.ts +1064 -0
- package/src/{seeds → migrations}/1752848561-groups-registration-periods.ts +95 -27
- package/src/{seeds → migrations}/1754560914-groups-prices.test.ts +1 -1
- package/src/{seeds → migrations}/1754560914-groups-prices.ts +9 -15
- package/src/{seeds → migrations}/1756293699-fill-previous-next-period-id.ts +1 -2
- package/src/migrations/1761665607-sync-member-users.ts +40 -0
- package/src/migrations/1779121239-default-invoice-email-template.sql +3 -0
- package/src/migrations/1779121240-invoice-email-template.sql +6 -0
- package/src/migrations/1779986893-default-payment-failed-email-templates.sql +4 -0
- package/src/migrations/1780578166-convert-legacy-billing.ts +13 -0
- package/src/{seeds/1755876819-remove-duplicate-members.ts → migrations/1780665426-remove-duplicate-members.ts} +23 -4
- package/src/migrations/1780933598-document-groups.ts +88 -0
- package/src/migrations/1781692342-balance-item-relations.ts +13 -0
- package/src/migrations/1781857866-platform-admins.ts +103 -0
- package/src/migrations/1781857867-rm-old-platform-admins.ts +25 -0
- package/src/seeds/0000000001-throw.ts +5 -0
- package/src/seeds/1760702452-update-balance-price-paid.ts +19 -0
- package/src/seeds/1760702453-update-balance-invoiced.ts +19 -0
- package/src/seeds/1760702454-update-cached-outstanding-balance-from-items.ts +51 -14
- package/src/seeds/1773754928-force-save-members.ts +41 -8
- package/src/seeds/1780665427-schedule-stock-updates.ts +45 -0
- package/src/seeds/1780665428-group-update-occupancy.ts +31 -0
- package/src/seeds/1780915001-fill-payment-customer.ts +70 -0
- package/src/seeds/1780915002-update-orders.ts +39 -0
- package/src/seeds/1782047708-organization-company-address.ts +44 -0
- package/src/seeds-temporary/1769088653-uitpas-status.ts +1 -2
- package/src/seeds-temporary/1780416000-migrate-audit-log-legacy-enums.test.ts +69 -0
- package/src/seeds-temporary/1780416000-migrate-audit-log-legacy-enums.ts +85 -0
- package/src/services/AuditLogService.test.ts +51 -0
- package/src/services/AuditLogService.ts +45 -0
- package/src/services/BalanceItemService.ts +148 -55
- package/src/services/CpuService.ts +3 -6
- package/src/services/DatabaseCollationService.test.ts +1 -2
- package/src/services/DocumentService.ts +1 -2
- package/src/services/EventNotificationService.ts +1 -1
- package/src/services/FileSignService.ts +2 -4
- package/src/services/InvoicePdfService.ts +286 -0
- package/src/services/InvoiceService.ts +330 -77
- package/src/services/InvoiceXMLService.ts +424 -0
- package/src/services/MemberNumberService.ts +6 -11
- package/src/services/MemberRecordStore.ts +8 -10
- package/src/services/MollieService.ts +530 -0
- package/src/services/PaymentMandateService.ts +214 -0
- package/src/services/PaymentReallocationService.test.ts +1 -1
- package/src/services/PaymentReallocationService.ts +7 -9
- package/src/services/PaymentService.ts +820 -328
- package/src/services/PlatformMembershipService.ts +5 -9
- package/src/services/ReferralService.ts +223 -0
- package/src/services/RegistrationService.ts +125 -54
- package/src/services/SSOService.test.ts +119 -0
- package/src/services/SSOService.ts +56 -49
- package/src/services/STPackageService.ts +97 -68
- package/src/services/UniqueMemberNumberService.ts +69 -0
- package/src/services/UniqueUserService.ts +3 -6
- package/src/services/VATService.ts +85 -0
- package/src/services/data/invoice.hbs.html +686 -0
- package/src/services/uitpas/PassholderEndpoints.ts +3 -6
- package/src/services/uitpas/UitpasService.ts +6 -10
- package/src/services/uitpas/checkUitpasNumbers.ts +2 -4
- package/src/services/uitpas/getSocialTariffForUitpasNumbers.ts +3 -6
- package/src/services/uitpas/searchUitpasEvents.ts +1 -2
- package/src/sql-filters/audit-logs.ts +1 -1
- package/src/sql-filters/balance-item-payments.ts +1 -1
- package/src/sql-filters/balance-items.ts +1 -1
- package/src/sql-filters/base-registration-filter-compilers.ts +5 -33
- package/src/sql-filters/document-templates.ts +1 -1
- package/src/sql-filters/documents.ts +1 -1
- package/src/sql-filters/email-recipients.ts +1 -1
- package/src/sql-filters/emails.ts +1 -1
- package/src/sql-filters/event-notifications.ts +1 -1
- package/src/sql-filters/events.ts +6 -1
- package/src/sql-filters/groups.ts +16 -1
- package/src/sql-filters/invoiced-balance-items.ts +1 -1
- package/src/sql-filters/invoices.ts +1 -1
- package/src/sql-filters/member-responsibility-records.ts +1 -1
- package/src/sql-filters/members.ts +1 -1
- package/src/sql-filters/orders.ts +4 -4
- package/src/sql-filters/organization-registration-periods.ts +1 -1
- package/src/sql-filters/organizations.ts +1 -1
- package/src/sql-filters/payments.ts +5 -0
- package/src/sql-filters/platform-memberships.ts +3 -3
- package/src/sql-filters/receivable-balances.ts +1 -1
- package/src/sql-filters/registration-invitations.ts +90 -0
- package/src/sql-filters/registration-periods.ts +1 -1
- package/src/sql-filters/registrations.ts +1 -1
- package/src/sql-filters/tickets.ts +1 -1
- package/src/sql-filters/users.ts +1 -1
- package/src/sql-sorters/groups.ts +23 -0
- package/src/sql-sorters/platform-memberships.ts +16 -16
- package/src/sql-sorters/registration-invitations.ts +36 -0
- package/tests/actions/patchOrganizationMember.ts +1 -1
- package/tests/actions/patchUserMember.ts +1 -1
- package/tests/assertions/assertBalances.ts +6 -12
- package/tests/e2e/api-rate-limits.test.ts +12 -24
- package/tests/e2e/bundle-discounts.test.ts +4 -1
- package/tests/e2e/charge-members.test.ts +13 -11
- package/tests/e2e/documents.test.ts +4 -1
- package/tests/e2e/register.test.ts +7 -9
- package/tests/e2e/stock.test.ts +4 -3
- package/tests/e2e/tickets.test.ts +1 -1
- package/tests/helpers/MollieMocker.ts +462 -0
- package/tests/helpers/PayconiqMocker.ts +138 -45
- package/tests/helpers/StripeMocker.ts +9 -6
- package/tests/helpers/index.ts +4 -0
- package/tests/init/initAdmin.ts +2 -2
- package/tests/init/initBundleDiscount.ts +1 -1
- package/tests/init/initMembershipOrganization.ts +13 -0
- package/tests/init/initPermissionRole.ts +3 -4
- package/tests/vitest.global.setup.ts +1 -1
- package/vitest.config.js +7 -0
- package/.nvmrc +0 -1
- package/src/endpoints/global/billing/ActivatePackagesEndpoint.ts +0 -216
- package/src/helpers/GroupBuilder.ts +0 -418
- package/src/seeds/0000000000-example.ts +0 -11
- package/src/seeds/1722256498-group-update-occupancy.ts +0 -52
- package/src/seeds/1726572303-schedule-stock-updates.ts +0 -52
- package/src/seeds/1726847064-setup-steps.ts +0 -16
- package/src/seeds/1728928974-update-cached-outstanding-balance-from-items.ts +0 -31
- package/src/seeds/1729253172-update-orders.ts +0 -21
- package/src/seeds/1733319079-fill-paying-organization-ids.ts +0 -68
- package/src/seeds/1733748412-update-deleted-order-numbers.ts +0 -109
- package/src/seeds/1733994455-balance-item-status-open.ts +0 -30
- package/src/seeds/1740046783-update-membership.ts +0 -17
- package/src/seeds/1741008870-fix-auditlog-description.ts +0 -50
- package/src/seeds/1741011468-fix-auditlog-description-uft16.ts +0 -88
- package/src/seeds/1741268179-fix-group-dates-of-events.ts +0 -32
- package/src/seeds/1750090030-records-configuration.ts +0 -26
- package/src/seeds/1751445358-upload-email-attachments.ts +0 -106
- package/src/seeds/1755532883-update-email-sender-ids.ts +0 -47
- package/src/seeds/1755790070-fill-email-recipient-errors.ts +0 -96
- package/src/seeds/1756115432-remove-old-drafts.ts +0 -16
- package/src/seeds/1756115433-fill-email-recipient-organization-id.ts +0 -30
- package/src/seeds/1756303697-update-email-counts.ts +0 -76
- package/src/seeds/1761665607-sync-member-users.ts +0 -59
- package/src/seeds/1765896674-document-update-year.ts +0 -66
- /package/src/{seeds → migrations}/0000000001-development-user.ts +0 -0
- /package/src/{seeds → migrations}/0000000002-clear-stamhoofd-email-templates.ts +0 -0
- /package/src/{seeds → migrations}/0000000003-default-email-templates.ts +0 -0
- /package/src/{seeds → migrations}/1752848561-groups-registration-periods.test.ts +0 -0
- /package/src/{seeds → migrations}/1766150402-document-published-at.test.ts +0 -0
- /package/src/{seeds → migrations}/1766150402-document-published-at.ts +0 -0
- /package/src/{seeds → migrations}/data/default-email-templates.sql +0 -0
|
@@ -55,8 +55,7 @@ export class ViesHelperStatic {
|
|
|
55
55
|
if (company.companyNumber) {
|
|
56
56
|
if (company.VATNumber !== null && company.address.country === Country.Belgium) {
|
|
57
57
|
// Already validated
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
58
|
+
} else {
|
|
60
59
|
// Need to validate
|
|
61
60
|
const result = await ViesHelper.checkCompanyNumber(company.address.country, company.companyNumber);
|
|
62
61
|
patch.companyNumber = result.companyNumber;
|
|
@@ -103,12 +102,10 @@ export class ViesHelperStatic {
|
|
|
103
102
|
companyNumber: corrected.substring(2),
|
|
104
103
|
VATNumber: corrected,
|
|
105
104
|
};
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
105
|
+
} catch (e) {
|
|
108
106
|
if (isSimpleError(e) || isSimpleErrors(e)) {
|
|
109
107
|
// Ignore: normal that it is not a valid VAT number
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
108
|
+
} else {
|
|
112
109
|
// Other errors should be thrown
|
|
113
110
|
throw e;
|
|
114
111
|
}
|
|
@@ -128,13 +125,17 @@ export class ViesHelperStatic {
|
|
|
128
125
|
if (!result.isValid) {
|
|
129
126
|
throw new SimpleError({
|
|
130
127
|
code: 'invalid_field',
|
|
131
|
-
message: '
|
|
128
|
+
message: $t('%1To', { number: vatNumber }),
|
|
132
129
|
field: 'VATNumber',
|
|
133
130
|
});
|
|
134
131
|
}
|
|
135
132
|
|
|
136
133
|
const formatted = result.value ?? vatNumber;
|
|
137
134
|
|
|
135
|
+
if (STAMHOOFD.environment === 'development' && formatted === 'NL301828519B01') {
|
|
136
|
+
return formatted;
|
|
137
|
+
}
|
|
138
|
+
|
|
138
139
|
try {
|
|
139
140
|
const cleaned = formatted.substring(2).replace(/(?:\.-\s)+/g, '');
|
|
140
141
|
const response = await this.request('POST', 'https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-number', {
|
|
@@ -150,12 +151,11 @@ export class ViesHelperStatic {
|
|
|
150
151
|
if (!response.valid) {
|
|
151
152
|
throw new SimpleError({
|
|
152
153
|
code: 'invalid_field',
|
|
153
|
-
message: '
|
|
154
|
+
message: $t('%1TG', { 'vat-number': formatted }),
|
|
154
155
|
field: 'VATNumber',
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
|
-
}
|
|
158
|
-
catch (e) {
|
|
158
|
+
} catch (e) {
|
|
159
159
|
if (isSimpleError(e) || isSimpleErrors(e)) {
|
|
160
160
|
throw e;
|
|
161
161
|
}
|
|
@@ -164,7 +164,7 @@ export class ViesHelperStatic {
|
|
|
164
164
|
|
|
165
165
|
throw new SimpleError({
|
|
166
166
|
code: 'service_unavailable',
|
|
167
|
-
message: '
|
|
167
|
+
message: $t('%1Sf'),
|
|
168
168
|
field: 'VATNumber',
|
|
169
169
|
});
|
|
170
170
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { XlsxTransformerColumn, XlsxTransformerConcreteColumn } from '@stamhoofd/excel-writer';
|
|
2
2
|
import { isXlsxTransformerConcreteColumn } from '@stamhoofd/excel-writer';
|
|
3
|
-
import type { Address, Parent, PlatformMember, RecordAnswer, RecordSettings} from '@stamhoofd/structures';
|
|
3
|
+
import type { Address, Parent, PlatformMember, RecordAnswer, RecordSettings } from '@stamhoofd/structures';
|
|
4
4
|
import { CountryHelper, ParentTypeHelper, RecordCategory, RecordType } from '@stamhoofd/structures';
|
|
5
5
|
|
|
6
6
|
export class XlsxTransformerColumnHelper {
|
|
@@ -25,7 +25,7 @@ export const registrationCachedBalanceJoin = SQL.leftJoin(
|
|
|
25
25
|
new SQLSelectAs(
|
|
26
26
|
new SQLSum(
|
|
27
27
|
SQL.calculation(SQL.column('amountOpen'))
|
|
28
|
-
.add(SQL.column('amountPending'))
|
|
28
|
+
.add(SQL.column('amountPending')),
|
|
29
29
|
),
|
|
30
30
|
new SQLAlias('toPay'),
|
|
31
31
|
),
|
|
@@ -33,7 +33,7 @@ export const registrationCachedBalanceJoin = SQL.leftJoin(
|
|
|
33
33
|
new SQLSum(
|
|
34
34
|
SQL.calculation(SQL.column('amountOpen'))
|
|
35
35
|
.add(SQL.column('amountPaid'))
|
|
36
|
-
.add(SQL.column('amountPending'))
|
|
36
|
+
.add(SQL.column('amountPending')),
|
|
37
37
|
),
|
|
38
38
|
new SQLAlias('price'),
|
|
39
39
|
),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AutoEncoderPatchType } from '@simonbackx/simple-encoding';
|
|
2
2
|
import { isSimpleError, SimpleError } from '@simonbackx/simple-errors';
|
|
3
3
|
import { Member } from '@stamhoofd/models';
|
|
4
|
-
import type { MemberDetails, ReviewTimes} from '@stamhoofd/structures';
|
|
4
|
+
import type { MemberDetails, ReviewTimes } from '@stamhoofd/structures';
|
|
5
5
|
import { UitpasSocialTariff, UitpasSocialTariffStatus } from '@stamhoofd/structures';
|
|
6
6
|
import type { GetPassResponse } from '../services/uitpas/PassholderEndpoints.js';
|
|
7
7
|
import { UitpasService } from '../services/uitpas/UitpasService.js';
|
|
@@ -42,8 +42,7 @@ export async function updateMemberDetailsUitpasNumberForPatch(memberId: string,
|
|
|
42
42
|
|
|
43
43
|
try {
|
|
44
44
|
isUpdated = await updateMemberDetailsUitpasNumber(details);
|
|
45
|
-
}
|
|
46
|
-
catch (error: any) {
|
|
45
|
+
} catch (error: any) {
|
|
47
46
|
const isUitpasEqual = previousUitpasNumber !== null && previousUitpasNumber === details.uitpasNumberDetails.uitpasNumber;
|
|
48
47
|
|
|
49
48
|
if (isSimpleError(error)) {
|
|
@@ -94,8 +93,7 @@ export function uitpasApiResponseToSocialTariff(response: GetPassResponse): Uitp
|
|
|
94
93
|
if (response.socialTariff.endDate) {
|
|
95
94
|
try {
|
|
96
95
|
endDate = new Date(response.socialTariff.endDate);
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
96
|
+
} catch (e) {
|
|
99
97
|
console.error(e);
|
|
100
98
|
console.error('endDate: ', response.socialTariff.endDate);
|
|
101
99
|
|
package/src/migrate.ts
CHANGED
|
@@ -9,6 +9,9 @@ process.env.TZ = 'UTC';
|
|
|
9
9
|
|
|
10
10
|
// Polyfill require.resolve, since import.meta.resolve is not supported by vitest
|
|
11
11
|
import { createRequire } from 'node:module';
|
|
12
|
+
import { GlobalHelper } from './helpers/GlobalHelper.js';
|
|
13
|
+
import { I18n } from '@stamhoofd/backend-i18n/I18n';
|
|
14
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
12
15
|
const require = createRequire(import.meta.url);
|
|
13
16
|
|
|
14
17
|
const emailPath = require.resolve('@stamhoofd/email');
|
|
@@ -26,13 +29,14 @@ const start = async () => {
|
|
|
26
29
|
|
|
27
30
|
// Reload database so we are sure we are running on the correct database in the
|
|
28
31
|
// environment
|
|
29
|
-
await Database.reload({})
|
|
32
|
+
await Database.reload({});
|
|
30
33
|
|
|
31
34
|
let killSignalReceived = false;
|
|
32
35
|
const handler = () => {
|
|
33
36
|
// Ignore
|
|
34
37
|
console.error('Ignoring SIGTERM signal during migration');
|
|
35
38
|
killSignalReceived = true;
|
|
39
|
+
QueryableModel.shutdownMigrations = true;
|
|
36
40
|
};
|
|
37
41
|
|
|
38
42
|
process.on('SIGTERM', handler);
|
|
@@ -50,15 +54,18 @@ const start = async () => {
|
|
|
50
54
|
|
|
51
55
|
// External migrations
|
|
52
56
|
if (!await Migration.runAll(path.dirname(modelsPath) + '/migrations')) {
|
|
53
|
-
throw new Error('Migrations failed')
|
|
57
|
+
throw new Error('Migrations failed');
|
|
54
58
|
}
|
|
55
59
|
if (!await Migration.runAll(path.dirname(emailPath) + '/../migrations')) {
|
|
56
|
-
throw new Error('Email migrations failed')
|
|
60
|
+
throw new Error('Email migrations failed');
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
// Internal
|
|
64
|
+
await I18n.load();
|
|
65
|
+
GlobalHelper.loadGlobalTranslateFunction();
|
|
66
|
+
|
|
60
67
|
if (!await Migration.runAll(import.meta.dirname + '/migrations')) {
|
|
61
|
-
throw new Error('Internal migrations failed')
|
|
68
|
+
throw new Error('Internal migrations failed');
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
if (killSignalReceived) {
|
|
@@ -67,7 +74,7 @@ const start = async () => {
|
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
// Reload database to prevent connection state leakage
|
|
70
|
-
await Database.reload({})
|
|
77
|
+
await Database.reload({});
|
|
71
78
|
|
|
72
79
|
process.off('SIGTERM', handler);
|
|
73
80
|
process.off('SIGINT', handler);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Migration } from '@simonbackx/simple-database';
|
|
2
|
-
import { Organization, RegistrationPeriod } from '@stamhoofd/models';
|
|
2
|
+
import { Organization, Platform, RegistrationPeriod } from '@stamhoofd/models';
|
|
3
3
|
import { Address } from '@stamhoofd/structures';
|
|
4
4
|
import { Country } from '@stamhoofd/types/Country';
|
|
5
5
|
import { Formatter } from '@stamhoofd/utility';
|
|
@@ -9,6 +9,10 @@ export default new Migration(async () => {
|
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
if (STAMHOOFD.userMode !== 'platform') {
|
|
13
|
+
throw new Error('singleOrganization should never be combined with userMode organization');
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
let organization = await Organization.getByID(STAMHOOFD.singleOrganization);
|
|
13
17
|
if (organization) {
|
|
14
18
|
console.log('Single organization already created.');
|
|
@@ -56,6 +60,11 @@ export default new Migration(async () => {
|
|
|
56
60
|
|
|
57
61
|
await organization.save();
|
|
58
62
|
|
|
63
|
+
// Set as platform organization
|
|
64
|
+
const platform = await Platform.getForEditing();
|
|
65
|
+
platform.membershipOrganizationId = organization.id;
|
|
66
|
+
await platform.save();
|
|
67
|
+
|
|
59
68
|
// Do something here
|
|
60
69
|
return Promise.resolve();
|
|
61
70
|
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Migration } from '@simonbackx/simple-database';
|
|
2
|
+
import { Organization, Platform, RegistrationPeriod } from '@stamhoofd/models';
|
|
3
|
+
import { Address, Company, File, Image, PaymentMethod, Resolution } from '@stamhoofd/structures';
|
|
4
|
+
import { Country } from '@stamhoofd/types/Country';
|
|
5
|
+
import { Formatter } from '@stamhoofd/utility';
|
|
6
|
+
import { STPackageService } from '../services/STPackageService.js';
|
|
7
|
+
|
|
8
|
+
export default new Migration(async () => {
|
|
9
|
+
const platform = await Platform.getForEditing();
|
|
10
|
+
if (platform.membershipOrganizationId) {
|
|
11
|
+
console.log('Membership organization already created.');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const registrationPeriod = STAMHOOFD.userMode === 'platform' ? ((await RegistrationPeriod.select().first(false)) ?? new RegistrationPeriod()) : new RegistrationPeriod();
|
|
16
|
+
if (!registrationPeriod.id) {
|
|
17
|
+
const s = Formatter.luxon();
|
|
18
|
+
const startDate = s.set({
|
|
19
|
+
day: 1,
|
|
20
|
+
month: 9,
|
|
21
|
+
hour: 0,
|
|
22
|
+
minute: 0,
|
|
23
|
+
second: 0,
|
|
24
|
+
millisecond: 0,
|
|
25
|
+
});
|
|
26
|
+
const endDate = s.set({
|
|
27
|
+
year: startDate.year + 1,
|
|
28
|
+
day: 31,
|
|
29
|
+
month: 8,
|
|
30
|
+
hour: 23,
|
|
31
|
+
minute: 59,
|
|
32
|
+
second: 59,
|
|
33
|
+
millisecond: 999,
|
|
34
|
+
});
|
|
35
|
+
registrationPeriod.startDate = startDate.toJSDate();
|
|
36
|
+
registrationPeriod.endDate = endDate.toJSDate();
|
|
37
|
+
}
|
|
38
|
+
await registrationPeriod.save();
|
|
39
|
+
|
|
40
|
+
console.log('Creating membership organization...');
|
|
41
|
+
const organization = new Organization();
|
|
42
|
+
organization.name = STAMHOOFD.platformName;
|
|
43
|
+
organization.uri = Formatter.slug(STAMHOOFD.platformName);
|
|
44
|
+
organization.periodId = registrationPeriod.id;
|
|
45
|
+
organization.address = Address.create({
|
|
46
|
+
street: '',
|
|
47
|
+
number: '',
|
|
48
|
+
postalCode: '',
|
|
49
|
+
city: 'Gent',
|
|
50
|
+
country: STAMHOOFD.fixedCountry ?? Country.Belgium,
|
|
51
|
+
});
|
|
52
|
+
organization.privateMeta.featureFlags = ['organization-receivable-balances'];
|
|
53
|
+
|
|
54
|
+
// Setup Codawood credentials if running Stamhoofd
|
|
55
|
+
if (STAMHOOFD.platformName === 'stamhoofd' && STAMHOOFD.userMode === 'organization') {
|
|
56
|
+
organization.id = '57aa0001-0000-4000-8000-000000000001';
|
|
57
|
+
organization.name = 'Stamhoofd';
|
|
58
|
+
organization.meta.companies = [
|
|
59
|
+
Company.create({
|
|
60
|
+
name: 'Codawood BV',
|
|
61
|
+
VATNumber: 'BE0747832683',
|
|
62
|
+
companyNumber: '0747832683',
|
|
63
|
+
address: Address.create({
|
|
64
|
+
street: 'Collegiebaan',
|
|
65
|
+
number: '54',
|
|
66
|
+
postalCode: '9230',
|
|
67
|
+
city: 'Wetteren',
|
|
68
|
+
country: Country.Belgium,
|
|
69
|
+
}),
|
|
70
|
+
administrationEmail: 'hallo@stamhoofd.be',
|
|
71
|
+
}),
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
organization.address = organization.meta.companies[0].address!;
|
|
75
|
+
organization.meta.registrationPaymentConfiguration.enableMandates = true;
|
|
76
|
+
organization.meta.invoicesEnabled = true;
|
|
77
|
+
organization.meta.registrationPaymentConfiguration.paymentMethods = [
|
|
78
|
+
PaymentMethod.Bancontact,
|
|
79
|
+
PaymentMethod.iDEAL,
|
|
80
|
+
PaymentMethod.CreditCard,
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
// Logo for invoices + normal icon
|
|
84
|
+
const horizontalLogo = new File({
|
|
85
|
+
id: 'logo',
|
|
86
|
+
size: 0,
|
|
87
|
+
server: 'https://files.stamhoofd.be',
|
|
88
|
+
path: 'fixtures/logo.svg',
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
organization.meta.horizontalLogo = Image.create({
|
|
92
|
+
source: horizontalLogo,
|
|
93
|
+
resolutions: [
|
|
94
|
+
new Resolution({
|
|
95
|
+
file: horizontalLogo,
|
|
96
|
+
width: 1650,
|
|
97
|
+
height: 340,
|
|
98
|
+
}),
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const squareLogo = new File({
|
|
103
|
+
id: 'square',
|
|
104
|
+
size: 0,
|
|
105
|
+
server: 'https://files.stamhoofd.be',
|
|
106
|
+
path: 'fixtures/logo-small.svg',
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
organization.meta.squareLogo = Image.create({
|
|
110
|
+
source: squareLogo,
|
|
111
|
+
resolutions: [
|
|
112
|
+
new Resolution({
|
|
113
|
+
file: squareLogo,
|
|
114
|
+
width: 1000,
|
|
115
|
+
height: 1000,
|
|
116
|
+
}),
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Link a mollie token
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
await organization.save();
|
|
124
|
+
|
|
125
|
+
if (STAMHOOFD.userMode === 'organization') {
|
|
126
|
+
registrationPeriod.organizationId = organization.id;
|
|
127
|
+
await registrationPeriod.save();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Set as platform organization
|
|
131
|
+
platform.membershipOrganizationId = organization.id;
|
|
132
|
+
await platform.save();
|
|
133
|
+
|
|
134
|
+
// Make sure default packages are active for this organization
|
|
135
|
+
await STPackageService.updateOrganizationPackages(organization.id);
|
|
136
|
+
|
|
137
|
+
// Do something here
|
|
138
|
+
return Promise.resolve();
|
|
139
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Migration } from '@simonbackx/simple-database';
|
|
2
2
|
import { User } from '@stamhoofd/models';
|
|
3
3
|
import { UserPermissions } from '@stamhoofd/structures';
|
|
4
|
+
import { SeedTools } from '../helpers/SeedTools.js';
|
|
4
5
|
|
|
5
6
|
export default new Migration(async () => {
|
|
6
7
|
if (STAMHOOFD.environment == 'test') {
|
|
@@ -8,42 +9,31 @@ export default new Migration(async () => {
|
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
11
|
process.stdout.write('\n');
|
|
11
|
-
let c = 0;
|
|
12
|
-
while (true) {
|
|
13
|
-
const admins = await User.where({
|
|
14
|
-
organizationPermissions: {
|
|
15
|
-
value: null,
|
|
16
|
-
sign: '!=',
|
|
17
|
-
},
|
|
18
|
-
organizationId: {
|
|
19
|
-
value: null,
|
|
20
|
-
sign: '!=',
|
|
21
|
-
},
|
|
22
|
-
}, { limit: 100 });
|
|
23
12
|
|
|
24
|
-
|
|
13
|
+
let realUpdate = 0;
|
|
14
|
+
|
|
15
|
+
const result = await SeedTools.loop({
|
|
16
|
+
batchSize: 1000,
|
|
17
|
+
query: User.select().whereNot('organizationPermissions', null).whereNot('organizationId', null),
|
|
18
|
+
useTransactionPerBatch: true,
|
|
19
|
+
action: async (admin: User) => {
|
|
25
20
|
if (!admin.organizationPermissions || !admin.organizationId) {
|
|
26
|
-
|
|
21
|
+
return;
|
|
27
22
|
}
|
|
28
23
|
const p = UserPermissions.create({});
|
|
29
24
|
p.organizationPermissions.set(admin.organizationId, admin.organizationPermissions);
|
|
30
25
|
admin.permissions = UserPermissions.limitedAdd(admin.permissions, p, admin.organizationId);
|
|
31
26
|
admin.organizationPermissions = null;
|
|
32
|
-
await admin.save(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
if (await admin.save({
|
|
28
|
+
skipMarkSaved: true,
|
|
29
|
+
skipSendEvents: true,
|
|
30
|
+
})) {
|
|
31
|
+
realUpdate++;
|
|
37
32
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
33
|
+
},
|
|
34
|
+
});
|
|
42
35
|
|
|
43
|
-
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
36
|
+
console.log('Updated permissions of ' + realUpdate + ' users, looped ' + result.total + ' users');
|
|
47
37
|
|
|
48
38
|
// Do something here
|
|
49
39
|
return Promise.resolve();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { RegistrationPeriod} from '@stamhoofd/models';
|
|
1
|
+
import type { RegistrationPeriod } from '@stamhoofd/models';
|
|
2
2
|
import { DocumentTemplate, DocumentTemplateFactory, GroupFactory, OrganizationFactory, RegistrationPeriodFactory } from '@stamhoofd/models';
|
|
3
|
-
import { migrateDocumentYears } from './
|
|
3
|
+
import { migrateDocumentYears } from './1750090029-document-update-year.js';
|
|
4
|
+
import { Formatter } from '@stamhoofd/utility';
|
|
4
5
|
|
|
5
6
|
describe('migration.document-update-year', () => {
|
|
6
7
|
describe('should use most frequent year of groups', () => {
|
|
@@ -9,8 +10,8 @@ describe('migration.document-update-year', () => {
|
|
|
9
10
|
}).create();
|
|
10
11
|
|
|
11
12
|
const period1 = await new RegistrationPeriodFactory({
|
|
12
|
-
startDate:
|
|
13
|
-
endDate:
|
|
13
|
+
startDate: Formatter.luxon().set({ day: 1, month: 1, year: 2021 }).toJSDate(),
|
|
14
|
+
endDate: Formatter.luxon().set({ day: 31, month: 12, year: 2021 }).toJSDate(),
|
|
14
15
|
organization,
|
|
15
16
|
}).create();
|
|
16
17
|
|
|
@@ -18,8 +19,8 @@ describe('migration.document-update-year', () => {
|
|
|
18
19
|
await organization.save();
|
|
19
20
|
|
|
20
21
|
const period2 = await new RegistrationPeriodFactory({
|
|
21
|
-
startDate:
|
|
22
|
-
endDate:
|
|
22
|
+
startDate: Formatter.luxon().set({ day: 1, month: 1, year: 2019 }).toJSDate(),
|
|
23
|
+
endDate: Formatter.luxon().set({ day: 31, month: 12, year: 2019 }).toJSDate(),
|
|
23
24
|
organization,
|
|
24
25
|
}).create();
|
|
25
26
|
|
|
@@ -32,9 +33,9 @@ describe('migration.document-update-year', () => {
|
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
// groups
|
|
35
|
-
const group1 = await createGroup(
|
|
36
|
-
const group2 = await createGroup(
|
|
37
|
-
const group3 = await createGroup(
|
|
36
|
+
const group1 = await createGroup(Formatter.luxon().set({ day: 1, month: 1, year: 2021 }).toJSDate(), Formatter.luxon().set({ day: 31, month: 12, year: 2021 }).toJSDate(), period1);
|
|
37
|
+
const group2 = await createGroup(Formatter.luxon().set({ day: 1, month: 1, year: 2021 }).toJSDate(), Formatter.luxon().set({ day: 31, month: 12, year: 2021 }).toJSDate(), period1);
|
|
38
|
+
const group3 = await createGroup(Formatter.luxon().set({ day: 1, month: 1, year: 2019 }).toJSDate(), Formatter.luxon().set({ day: 31, month: 12, year: 2019 }).toJSDate(), period2);
|
|
38
39
|
|
|
39
40
|
// document created in 2021
|
|
40
41
|
const document1 = await new DocumentTemplateFactory({
|
|
@@ -42,7 +43,7 @@ describe('migration.document-update-year', () => {
|
|
|
42
43
|
year: 0,
|
|
43
44
|
}).create();
|
|
44
45
|
|
|
45
|
-
document1.createdAt =
|
|
46
|
+
document1.createdAt = Formatter.luxon().set({ day: 1, month: 1, year: 2022 }).toJSDate();
|
|
46
47
|
await document1.save();
|
|
47
48
|
|
|
48
49
|
// document created in 2020
|
|
@@ -51,7 +52,7 @@ describe('migration.document-update-year', () => {
|
|
|
51
52
|
year: 0,
|
|
52
53
|
}).create();
|
|
53
54
|
|
|
54
|
-
document2.createdAt =
|
|
55
|
+
document2.createdAt = Formatter.luxon().set({ day: 1, month: 1, year: 2021 }).toJSDate();
|
|
55
56
|
await document2.save();
|
|
56
57
|
|
|
57
58
|
// document created in 2019
|
|
@@ -60,7 +61,7 @@ describe('migration.document-update-year', () => {
|
|
|
60
61
|
year: 0,
|
|
61
62
|
}).create();
|
|
62
63
|
|
|
63
|
-
document3.createdAt =
|
|
64
|
+
document3.createdAt = Formatter.luxon().set({ day: 1, month: 1, year: 2020 }).toJSDate();
|
|
64
65
|
await document3.save();
|
|
65
66
|
|
|
66
67
|
// act
|
|
@@ -74,7 +75,7 @@ describe('migration.document-update-year', () => {
|
|
|
74
75
|
// take most frequent year and prefer date of document creation
|
|
75
76
|
expect(updatedDocument1?.year).toBe(2021);
|
|
76
77
|
expect(updatedDocument2?.year).toBe(2021);
|
|
77
|
-
expect(updatedDocument3?.year).toBe(
|
|
78
|
+
expect(updatedDocument3?.year).toBe(2020); // maxed at creation year
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
test('groups overlapping period', async () => {
|
|
@@ -82,8 +83,8 @@ describe('migration.document-update-year', () => {
|
|
|
82
83
|
}).create();
|
|
83
84
|
|
|
84
85
|
const period1 = await new RegistrationPeriodFactory({
|
|
85
|
-
startDate:
|
|
86
|
-
endDate:
|
|
86
|
+
startDate: Formatter.luxon().set({ day: 1, month: 1, year: 2021 }).toJSDate(),
|
|
87
|
+
endDate: Formatter.luxon().set({ day: 31, month: 12, year: 2021 }).toJSDate(),
|
|
87
88
|
organization,
|
|
88
89
|
}).create();
|
|
89
90
|
|
|
@@ -91,14 +92,14 @@ describe('migration.document-update-year', () => {
|
|
|
91
92
|
await organization.save();
|
|
92
93
|
|
|
93
94
|
const period2 = await new RegistrationPeriodFactory({
|
|
94
|
-
startDate:
|
|
95
|
-
endDate:
|
|
95
|
+
startDate: Formatter.luxon().set({ day: 1, month: 1, year: 2020 }).toJSDate(),
|
|
96
|
+
endDate: Formatter.luxon().set({ day: 31, month: 12, year: 2020 }).toJSDate(),
|
|
96
97
|
organization,
|
|
97
98
|
}).create();
|
|
98
99
|
|
|
99
100
|
const period3 = await new RegistrationPeriodFactory({
|
|
100
|
-
startDate:
|
|
101
|
-
endDate:
|
|
101
|
+
startDate: Formatter.luxon().set({ day: 1, month: 1, year: 2019 }).toJSDate(),
|
|
102
|
+
endDate: Formatter.luxon().set({ day: 31, month: 12, year: 2019 }).toJSDate(),
|
|
102
103
|
organization,
|
|
103
104
|
}).create();
|
|
104
105
|
|
|
@@ -111,9 +112,9 @@ describe('migration.document-update-year', () => {
|
|
|
111
112
|
};
|
|
112
113
|
|
|
113
114
|
// groups
|
|
114
|
-
const group1 = await createGroup(
|
|
115
|
-
const group2 = await createGroup(
|
|
116
|
-
const group3 = await createGroup(
|
|
115
|
+
const group1 = await createGroup(Formatter.luxon().set({ day: 1, month: 7, year: 2020 }).toJSDate(), Formatter.luxon().set({ day: 30, month: 6, year: 2021 }).toJSDate(), period1);
|
|
116
|
+
const group2 = await createGroup(Formatter.luxon().set({ day: 5, month: 8, year: 2020 }).toJSDate(), Formatter.luxon().set({ day: 3, month: 5, year: 2021 }).toJSDate(), period1);
|
|
117
|
+
const group3 = await createGroup(Formatter.luxon().set({ day: 1, month: 6, year: 2018 }).toJSDate(), Formatter.luxon().set({ day: 14, month: 11, year: 2019 }).toJSDate(), period3);
|
|
117
118
|
|
|
118
119
|
// document created in 2021
|
|
119
120
|
const document1 = await new DocumentTemplateFactory({
|
|
@@ -121,7 +122,7 @@ describe('migration.document-update-year', () => {
|
|
|
121
122
|
year: 0,
|
|
122
123
|
}).create();
|
|
123
124
|
|
|
124
|
-
document1.createdAt =
|
|
125
|
+
document1.createdAt = Formatter.luxon().set({ day: 1, month: 1, year: 2022 }).toJSDate();
|
|
125
126
|
await document1.save();
|
|
126
127
|
|
|
127
128
|
// document created in 2020
|
|
@@ -130,7 +131,7 @@ describe('migration.document-update-year', () => {
|
|
|
130
131
|
year: 0,
|
|
131
132
|
}).create();
|
|
132
133
|
|
|
133
|
-
document2.createdAt =
|
|
134
|
+
document2.createdAt = Formatter.luxon().set({ day: 1, month: 1, year: 2021 }).toJSDate();
|
|
134
135
|
await document2.save();
|
|
135
136
|
|
|
136
137
|
// document created in 2019
|
|
@@ -139,7 +140,7 @@ describe('migration.document-update-year', () => {
|
|
|
139
140
|
year: 0,
|
|
140
141
|
}).create();
|
|
141
142
|
|
|
142
|
-
document3.createdAt =
|
|
143
|
+
document3.createdAt = Formatter.luxon().set({ day: 1, month: 1, year: 2020 }).toJSDate();
|
|
143
144
|
await document3.save();
|
|
144
145
|
|
|
145
146
|
// act
|
|
@@ -165,7 +166,7 @@ describe('migration.document-update-year', () => {
|
|
|
165
166
|
year: 0,
|
|
166
167
|
}).create();
|
|
167
168
|
|
|
168
|
-
document.createdAt =
|
|
169
|
+
document.createdAt = Formatter.luxon().set({ day: 1, month: 1, year: 2025 }).toJSDate();
|
|
169
170
|
await document.save();
|
|
170
171
|
|
|
171
172
|
// act
|