@stamhoofd/backend 2.116.0 → 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.
Files changed (263) hide show
  1. package/migrations.ts +1 -1
  2. package/package.json +10 -10
  3. package/src/audit-logs/DocumentTemplateLogger.ts +1 -1
  4. package/src/audit-logs/EmailAddressLogger.ts +1 -1
  5. package/src/audit-logs/EmailLogger.ts +1 -1
  6. package/src/audit-logs/EmailTemplateLogger.ts +1 -1
  7. package/src/audit-logs/EventLogger.ts +1 -1
  8. package/src/audit-logs/GroupLogger.ts +1 -1
  9. package/src/audit-logs/MemberLogger.ts +1 -1
  10. package/src/audit-logs/MemberPlatformMembershipLogger.ts +1 -1
  11. package/src/audit-logs/MemberResponsibilityRecordLogger.ts +1 -1
  12. package/src/audit-logs/ModelLogger.ts +25 -16
  13. package/src/audit-logs/OrderLogger.ts +1 -1
  14. package/src/audit-logs/OrganizationLogger.ts +23 -3
  15. package/src/audit-logs/OrganizationRegistrationPeriodLogger.ts +1 -1
  16. package/src/audit-logs/PaymentLogger.ts +1 -1
  17. package/src/audit-logs/PlatformLogger.ts +1 -1
  18. package/src/audit-logs/RegistrationLogger.ts +1 -1
  19. package/src/audit-logs/RegistrationPeriodLogger.ts +1 -1
  20. package/src/audit-logs/StripeAccountLogger.ts +1 -1
  21. package/src/audit-logs/UserLogger.ts +1 -1
  22. package/src/audit-logs/WebshopLogger.ts +1 -1
  23. package/src/audit-logs/init.ts +40 -0
  24. package/src/boot.ts +3 -0
  25. package/src/crons/amazon-ses.ts +1 -1
  26. package/src/crons/balance-emails.ts +1 -1
  27. package/src/crons/clearExcelCache.test.ts +1 -1
  28. package/src/crons/endFunctionsOfUsersWithoutRegistration.ts +1 -1
  29. package/src/crons.ts +3 -3
  30. package/src/email-recipient-loaders/members.ts +1 -1
  31. package/src/email-recipient-loaders/orders.ts +3 -3
  32. package/src/email-recipient-loaders/payments.ts +117 -352
  33. package/src/email-replacements/getEmailReplacementsForPayment.ts +321 -0
  34. package/src/endpoints/admin/members/ChargeMembersEndpoint.ts +9 -7
  35. package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +2 -2
  36. package/src/endpoints/admin/memberships/GetChargeMembershipsSummaryEndpoint.ts +1 -1
  37. package/src/endpoints/admin/organizations/ChargeOrganizationsEndpoint.ts +16 -50
  38. package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +2 -2
  39. package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +4 -4
  40. package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +21 -6
  41. package/src/endpoints/admin/registrations/ChargeRegistrationsEndpoint.ts +9 -7
  42. package/src/endpoints/auth/CreateAdminEndpoint.ts +2 -2
  43. package/src/endpoints/auth/CreateTokenEndpoint.test.ts +2 -2
  44. package/src/endpoints/auth/CreateTokenEndpoint.ts +1 -1
  45. package/src/endpoints/auth/DeleteTokenEndpoint.ts +1 -1
  46. package/src/endpoints/auth/DeleteUserEndpoint.ts +1 -1
  47. package/src/endpoints/auth/ForgotPasswordEndpoint.ts +1 -1
  48. package/src/endpoints/auth/GetOtherUserEndpoint.ts +2 -2
  49. package/src/endpoints/auth/GetUserEndpoint.test.ts +2 -2
  50. package/src/endpoints/auth/GetUserEndpoint.ts +2 -2
  51. package/src/endpoints/auth/OpenIDConnectAuthTokenEndpoint.ts +2 -2
  52. package/src/endpoints/auth/OpenIDConnectCallbackEndpoint.ts +2 -2
  53. package/src/endpoints/auth/OpenIDConnectStartEndpoint.ts +2 -2
  54. package/src/endpoints/auth/PollEmailVerificationEndpoint.ts +1 -1
  55. package/src/endpoints/auth/RetryEmailVerificationEndpoint.ts +1 -1
  56. package/src/endpoints/auth/SignupEndpoint.ts +1 -1
  57. package/src/endpoints/auth/VerifyEmailEndpoint.ts +1 -1
  58. package/src/endpoints/global/addresses/ValidateAddressEndpoint.ts +1 -1
  59. package/src/endpoints/global/audit-logs/GetAuditLogsEndpoint.ts +4 -4
  60. package/src/endpoints/global/billing/ActivatePackagesEndpoint.ts +191 -7
  61. package/src/endpoints/global/billing/DeactivatePackageEndpoint.ts +64 -0
  62. package/src/endpoints/global/email/GetAdminEmailsEndpoint.test.ts +2 -2
  63. package/src/endpoints/global/email/GetAdminEmailsEndpoint.ts +3 -3
  64. package/src/endpoints/global/email/GetEmailAddressEndpoint.ts +1 -1
  65. package/src/endpoints/global/email/GetEmailEndpoint.ts +1 -1
  66. package/src/endpoints/global/email/GetUserEmailsEndpoint.test.ts +2 -2
  67. package/src/endpoints/global/email/GetUserEmailsEndpoint.ts +3 -3
  68. package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +62 -16
  69. package/src/endpoints/global/email/PatchEmailEndpoint.test.ts +6 -6
  70. package/src/endpoints/global/email-recipients/GetEmailRecipientsCountEndpoint.ts +2 -2
  71. package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.test.ts +2 -2
  72. package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.ts +4 -4
  73. package/src/endpoints/global/email-recipients/RetryEmailRecipientEndpoint.ts +1 -1
  74. package/src/endpoints/global/email-recipients/helpers/validateEmailRecipientFilter.ts +1 -1
  75. package/src/endpoints/global/events/GetEventNotificationsCountEndpoint.ts +2 -2
  76. package/src/endpoints/global/events/GetEventNotificationsEndpoint.ts +4 -4
  77. package/src/endpoints/global/events/GetEventsEndpoint.ts +4 -4
  78. package/src/endpoints/global/events/PatchEventNotificationsEndpoint.test.ts +2 -2
  79. package/src/endpoints/global/events/PatchEventNotificationsEndpoint.ts +3 -3
  80. package/src/endpoints/global/events/PatchEventsEndpoint.test.ts +2 -2
  81. package/src/endpoints/global/events/PatchEventsEndpoint.ts +5 -5
  82. package/src/endpoints/global/files/ExportToExcelEndpoint.ts +4 -4
  83. package/src/endpoints/global/files/GetFileCache.ts +2 -2
  84. package/src/endpoints/global/files/UploadFile.ts +2 -2
  85. package/src/endpoints/global/files/UploadImage.ts +1 -1
  86. package/src/endpoints/global/groups/GetGroupsEndpoint.test.ts +3 -3
  87. package/src/endpoints/global/groups/GetGroupsEndpoint.ts +4 -4
  88. package/src/endpoints/global/members/GetMembersEndpoint.test.ts +3 -3
  89. package/src/endpoints/global/members/helpers/validateGroupFilter.ts +1 -1
  90. package/src/endpoints/global/organizations/CreateOrganizationEndpoint.test.ts +2 -2
  91. package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +23 -12
  92. package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.test.ts +2 -2
  93. package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.ts +1 -1
  94. package/src/endpoints/global/organizations/GetOrganizationFromUriEndpoint.ts +1 -1
  95. package/src/endpoints/global/organizations/SearchOrganizationEndpoint.test.ts +2 -2
  96. package/src/endpoints/global/organizations/SearchOrganizationEndpoint.ts +1 -1
  97. package/src/endpoints/global/payments/StripeWebhookEndpoint.ts +3 -3
  98. package/src/endpoints/global/platform/GetPlatformAdminsEndpoint.ts +1 -1
  99. package/src/endpoints/global/platform/GetPlatformEndpoint.test.ts +2 -2
  100. package/src/endpoints/global/platform/GetPlatformEndpoint.ts +1 -1
  101. package/src/endpoints/global/platform/PatchPlatformEnpoint.test.ts +2 -2
  102. package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +7 -7
  103. package/src/endpoints/global/registration/GetRegistrationsEndpoint.test.ts +2 -2
  104. package/src/endpoints/global/registration/GetRegistrationsEndpoint.ts +1 -2
  105. package/src/endpoints/global/registration/GetUserMembersEndpoint.ts +2 -2
  106. package/src/endpoints/global/registration/GetUserPayableBalanceEndpoint.ts +2 -2
  107. package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +14 -384
  108. package/src/endpoints/global/registration-periods/GetRegistrationPeriodsEndpoint.ts +3 -3
  109. package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +2 -2
  110. package/src/endpoints/global/sso/GetSSOEndpoint.ts +2 -2
  111. package/src/endpoints/global/sso/SetSSOEndpoint.ts +3 -3
  112. package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemEndpoint.ts +55 -0
  113. package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsCountEndpoint.ts +43 -0
  114. package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsEndpoint.ts +160 -0
  115. package/src/endpoints/organization/dashboard/billing/GetOrganizationDetailedPayableBalanceEndpoint.ts +2 -2
  116. package/src/endpoints/organization/dashboard/billing/GetOrganizationPayableBalanceEndpoint.ts +2 -2
  117. package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.test.ts +3 -3
  118. package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.ts +3 -3
  119. package/src/endpoints/organization/dashboard/documents/GetDocumentTemplateXML.ts +1 -1
  120. package/src/endpoints/organization/dashboard/documents/GetDocumentsCountEndpoint.ts +2 -2
  121. package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +30 -2
  122. package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.test.ts +2 -2
  123. package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.ts +3 -3
  124. package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.test.ts +2 -2
  125. package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +1 -1
  126. package/src/endpoints/organization/dashboard/invoices/PatchInvoicesEndpoint.ts +53 -0
  127. package/src/endpoints/organization/dashboard/mollie/CheckMollieEndpoint.ts +2 -2
  128. package/src/endpoints/organization/dashboard/mollie/ConnectMollieEndpoint.ts +3 -3
  129. package/src/endpoints/organization/dashboard/mollie/DisconnectMollieEndpoint.ts +2 -2
  130. package/src/endpoints/organization/dashboard/mollie/GetMollieDashboardEndpoint.ts +1 -1
  131. package/src/endpoints/organization/dashboard/nolt/CreateNoltTokenEndpoint.ts +1 -1
  132. package/src/endpoints/organization/dashboard/organization/GetOrganizationArchivedGroups.ts +2 -2
  133. package/src/endpoints/organization/dashboard/organization/GetOrganizationDeletedGroups.ts +2 -2
  134. package/src/endpoints/organization/dashboard/organization/GetUitpasClientIdEndpoint.ts +2 -2
  135. package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.test.ts +2 -2
  136. package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +12 -1
  137. package/src/endpoints/organization/dashboard/organization/SearchUitpasOrganizersEndpoint.ts +2 -2
  138. package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +2 -2
  139. package/src/endpoints/organization/dashboard/organization/SetUitpasClientCredentialsEndpoint.ts +2 -2
  140. package/src/endpoints/organization/dashboard/payments/GetPaymentsCountEndpoint.ts +2 -2
  141. package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +4 -4
  142. package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesCountEndpoint.ts +2 -2
  143. package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.ts +4 -4
  144. package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.test.ts +2 -2
  145. package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.ts +4 -4
  146. package/src/endpoints/organization/dashboard/registration-periods/MoveRegistrationPeriods.test.ts +2 -2
  147. package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.test.ts +2 -2
  148. package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +3 -3
  149. package/src/endpoints/organization/dashboard/registration-periods/SetupStepReviewEndpoint.ts +2 -2
  150. package/src/endpoints/organization/dashboard/stripe/ConnectStripeEndpoint.ts +3 -3
  151. package/src/endpoints/organization/dashboard/stripe/DeleteStripeAccountEndpoint.ts +3 -3
  152. package/src/endpoints/organization/dashboard/stripe/GetStripeAccountLinkEndpoint.ts +2 -2
  153. package/src/endpoints/organization/dashboard/stripe/GetStripeAccountsEndpoint.ts +1 -1
  154. package/src/endpoints/organization/dashboard/stripe/GetStripeLoginLinkEndpoint.ts +2 -2
  155. package/src/endpoints/organization/dashboard/stripe/UpdateStripeAccountEndpoint.ts +3 -3
  156. package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.test.ts +3 -3
  157. package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.ts +1 -1
  158. package/src/endpoints/organization/dashboard/users/DeleteUserEndpoint.ts +1 -1
  159. package/src/endpoints/organization/dashboard/users/GetApiUsersEndpoint.ts +1 -1
  160. package/src/endpoints/organization/dashboard/users/GetOrganizationAdminsEndpoint.ts +1 -1
  161. package/src/endpoints/organization/dashboard/users/PatchApiUserEndpoint.test.ts +3 -3
  162. package/src/endpoints/organization/dashboard/users/PatchApiUserEndpoint.ts +1 -1
  163. package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +1 -1
  164. package/src/endpoints/organization/dashboard/webshops/DeleteWebshopEndpoint.ts +2 -2
  165. package/src/endpoints/organization/dashboard/webshops/GetDiscountCodesEndpoint.ts +1 -1
  166. package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersCountEndpoint.ts +2 -2
  167. package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +5 -5
  168. package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +5 -5
  169. package/src/endpoints/organization/dashboard/webshops/GetWebshopUriAvailabilityEndpoint.ts +1 -1
  170. package/src/endpoints/organization/dashboard/webshops/PatchDiscountCodesEndpoint.ts +1 -1
  171. package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +1 -1
  172. package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +1 -1
  173. package/src/endpoints/organization/dashboard/webshops/PatchWebshopTicketsEndpoint.ts +1 -1
  174. package/src/endpoints/organization/dashboard/webshops/SearchUitpasEventsEndpoint.ts +2 -2
  175. package/src/endpoints/organization/dashboard/webshops/VerifyWebshopDomainEndpoint.ts +1 -1
  176. package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +3 -3
  177. package/src/endpoints/organization/shared/GetDocumentHtml.ts +1 -1
  178. package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +2 -2
  179. package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.test.ts +2 -2
  180. package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.ts +2 -2
  181. package/src/endpoints/organization/webshops/CheckWebshopDiscountCodesEndpoint.ts +1 -1
  182. package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +1 -1
  183. package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +1 -1
  184. package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +1 -1
  185. package/src/endpoints/organization/webshops/GetWebshopEndpoint.test.ts +2 -2
  186. package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +2 -2
  187. package/src/endpoints/organization/webshops/PlaceOrderEndpoint.test.ts +4 -4
  188. package/src/excel-loaders/balance-items.ts +268 -0
  189. package/src/excel-loaders/event-notifications.ts +3 -3
  190. package/src/excel-loaders/index.ts +6 -5
  191. package/src/excel-loaders/organizations.ts +4 -4
  192. package/src/excel-loaders/payments.ts +11 -3
  193. package/src/excel-loaders/receivable-balances.ts +2 -2
  194. package/src/helpers/AddressValidator.test.ts +1 -1
  195. package/src/helpers/AddressValidator.ts +1 -1
  196. package/src/helpers/AdminPermissionChecker.ts +1 -1
  197. package/src/helpers/AuthenticatedStructures.ts +17 -2
  198. package/src/helpers/EmailResumer.ts +1 -1
  199. package/src/helpers/FlagMomentCleanup.ts +1 -1
  200. package/src/helpers/ForwardHandler.test.ts +1 -1
  201. package/src/helpers/ForwardHandler.ts +1 -1
  202. package/src/helpers/GlobalHelper.ts +4 -4
  203. package/src/helpers/GroupBuilder.ts +417 -0
  204. package/src/helpers/GroupedThrottledQueue.test.ts +1 -1
  205. package/src/helpers/GroupedThrottledQueue.ts +1 -1
  206. package/src/helpers/MemberUserSyncer.test.ts +1 -1
  207. package/src/helpers/MemberUserSyncer.ts +1 -1
  208. package/src/helpers/ServiceFeeHelper.ts +5 -1
  209. package/src/helpers/TagHelper.ts +1 -1
  210. package/src/helpers/ThrottledQueue.test.ts +1 -1
  211. package/src/helpers/ViesHelper.ts +9 -0
  212. package/src/helpers/email-html-helpers.ts +0 -41
  213. package/src/middleware/ContextMiddleware.ts +1 -1
  214. package/src/seeds/1726572303-schedule-stock-updates.ts +1 -1
  215. package/src/seeds/1726847064-setup-steps.ts +1 -1
  216. package/src/seeds/1728928974-update-cached-outstanding-balance-from-items.ts +1 -1
  217. package/src/seeds/1740046783-update-membership.ts +1 -1
  218. package/src/seeds/1754560914-groups-prices.test.ts +1 -1
  219. package/src/seeds/1755876819-remove-duplicate-members.ts +1 -1
  220. package/src/seeds/1760702454-update-cached-outstanding-balance-from-items.ts +1 -1
  221. package/src/seeds/1761665607-sync-member-users.ts +1 -1
  222. package/src/seeds/data/default-email-templates.sql +1 -1
  223. package/src/seeds-temporary/1732117645-move-rrn.ts +1 -1
  224. package/src/services/AuditLogService.ts +1 -41
  225. package/src/services/BalanceItemPaymentService.ts +1 -1
  226. package/src/services/BalanceItemService.ts +12 -5
  227. package/src/services/EventNotificationService.ts +3 -3
  228. package/src/services/InvoiceService.ts +131 -17
  229. package/src/services/MemberRecordStore.ts +1 -1
  230. package/src/services/PaymentReallocationService.test.ts +9 -10
  231. package/src/services/PaymentReallocationService.ts +1 -1
  232. package/src/services/PaymentService.ts +548 -18
  233. package/src/services/RegistrationService.ts +3 -3
  234. package/src/services/SSOService.ts +2 -2
  235. package/src/services/STPackageService.ts +241 -0
  236. package/src/services/uitpas/UitpasService.test.ts +1 -1
  237. package/src/sql-filters/balance-items.ts +56 -0
  238. package/src/sql-filters/emails.ts +1 -1
  239. package/src/sql-filters/event-notifications.ts +2 -2
  240. package/src/sql-filters/events.ts +51 -0
  241. package/src/sql-filters/members.ts +37 -1
  242. package/src/sql-filters/receivable-balances.ts +3 -3
  243. package/src/sql-filters/users.ts +10 -0
  244. package/src/sql-sorters/balance-items.ts +36 -0
  245. package/src/sql-sorters/document-templates.ts +2 -2
  246. package/src/sql-sorters/documents.ts +2 -2
  247. package/src/sql-sorters/event-notifications.ts +1 -1
  248. package/src/sql-sorters/orders.ts +2 -2
  249. package/src/sql-sorters/tickets.ts +2 -2
  250. package/tests/actions/patchOrganizationMember.ts +3 -3
  251. package/tests/actions/patchPaymentStatus.ts +3 -3
  252. package/tests/actions/patchUserMember.ts +2 -2
  253. package/tests/assertions/assertBalances.ts +1 -1
  254. package/tests/e2e/api-rate-limits.test.ts +3 -3
  255. package/tests/e2e/charge-members.test.ts +14 -14
  256. package/tests/e2e/documents.test.ts +8 -8
  257. package/tests/e2e/private-files.test.ts +4 -4
  258. package/tests/e2e/stock.test.ts +4 -4
  259. package/tests/e2e/tickets.test.ts +4 -4
  260. package/tests/helpers/TestServer.ts +2 -2
  261. package/tests/init/index.ts +7 -7
  262. package/tests/init/initAdmin.ts +1 -1
  263. /package/src/endpoints/organization/dashboard/{payments → balance-items}/PatchBalanceItemsEndpoint.ts +0 -0
@@ -0,0 +1,268 @@
1
+ import { XlsxBuiltInNumberFormat, XlsxTransformerColumn } from '@stamhoofd/excel-writer';
2
+ import { BalanceItem } from '@stamhoofd/models';
3
+ import { BalanceItemRelationType, BalanceItemWithPayments, ExcelExportType, getBalanceItemRelationTypeName, getBalanceItemTypeName, PaginatedResponse, PaymentStatus } from '@stamhoofd/structures';
4
+ import { Formatter } from '@stamhoofd/utility';
5
+ import { ExportToExcelEndpoint } from '../endpoints/global/files/ExportToExcelEndpoint.js';
6
+ import { GetBalanceItemsEndpoint } from '../endpoints/organization/dashboard/balance-items/GetBalanceItemsEndpoint.js';
7
+
8
+ ExportToExcelEndpoint.loaders.set(ExcelExportType.BalanceItems, {
9
+ fetch: async (requestQuery) => {
10
+ const data = await GetBalanceItemsEndpoint.buildData(requestQuery);
11
+
12
+ return new PaginatedResponse({
13
+ ...data,
14
+ results: await BalanceItem.getStructureWithPayments(data.results),
15
+ });
16
+ },
17
+ sheets: [
18
+ {
19
+ id: 'balanceItems',
20
+ name: $t(`fbe6e4c4-8d98-41b5-b839-11d469031002`),
21
+ columns: [
22
+ ...getBalanceItemColumns(),
23
+ ],
24
+ },
25
+ ],
26
+ });
27
+
28
+ function getBalanceItemColumns(): XlsxTransformerColumn<BalanceItemWithPayments>[] {
29
+ return [
30
+ {
31
+ id: 'id',
32
+ name: $t(`29360811-3663-496c-8d8f-c9fdf9467a74`),
33
+ width: 40,
34
+ getValue: (object: BalanceItemWithPayments) => ({
35
+ value: object.id,
36
+ style: {
37
+ font: {
38
+ bold: true,
39
+ },
40
+ },
41
+ }),
42
+ },
43
+ {
44
+ id: 'type',
45
+ name: $t(`f97ad8c1-31d2-4b61-9e09-3be86eaeba08`),
46
+ width: 30,
47
+ getValue: (object: BalanceItemWithPayments) => ({
48
+ value: getBalanceItemTypeName(object.type),
49
+ }),
50
+ },
51
+ {
52
+ id: 'category',
53
+ name: $t(`c5d24ab8-a87a-481d-a470-23e9386199f3`),
54
+ width: 30,
55
+ getValue: (object: BalanceItemWithPayments) => {
56
+ return {
57
+ value: Formatter.capitalizeFirstLetter(object.category),
58
+ };
59
+ },
60
+ },
61
+ {
62
+ id: 'description',
63
+ name: $t(`9c4977db-1ce9-424b-92cf-4bbe7f6606fd`),
64
+ width: 40,
65
+ getValue: (object: BalanceItemWithPayments) => ({
66
+ value: object.description,
67
+ }),
68
+ },
69
+ {
70
+ id: 'createdAt',
71
+ name: $t(`10a1cf76-0757-4c92-9923-a19cd77fe24c`),
72
+ width: 16,
73
+ getValue: (object: BalanceItemWithPayments) => ({
74
+ value: object.createdAt,
75
+ style: {
76
+ numberFormat: {
77
+ id: XlsxBuiltInNumberFormat.DateTimeSlash,
78
+ },
79
+ },
80
+ }),
81
+ },
82
+ {
83
+ id: 'dueAt',
84
+ name: $t(`3d586760-01f3-42c3-82be-44cea7ad0820`),
85
+ width: 16,
86
+ getValue: (object: BalanceItemWithPayments) => ({
87
+ value: object.dueAt,
88
+ style: {
89
+ numberFormat: {
90
+ id: XlsxBuiltInNumberFormat.DateTimeSlash,
91
+ },
92
+ },
93
+ }),
94
+ },
95
+ {
96
+ match: (id) => {
97
+ if (id.startsWith('relations.')) {
98
+ const type = id.split('.')[1] as BalanceItemRelationType;
99
+ if (Object.values(BalanceItemRelationType).includes(type)) {
100
+ return [
101
+ {
102
+ id: `relations.${type}`,
103
+ name: getBalanceItemRelationTypeName(type),
104
+ width: 35,
105
+ getValue: (object: BalanceItemWithPayments) => ({
106
+ value: object.relations.get(type)?.name?.toString() || '',
107
+ }),
108
+ },
109
+ ];
110
+ }
111
+ }
112
+ },
113
+ },
114
+ {
115
+ id: 'quantity',
116
+ name: $t(`f085f874-242d-47cb-a404-96eab69662ec`),
117
+ width: 20,
118
+ getValue: (object: BalanceItemWithPayments) => ({
119
+ value: object.quantity,
120
+ style: {
121
+ numberFormat: {
122
+ id: XlsxBuiltInNumberFormat.Number,
123
+ },
124
+ },
125
+ }),
126
+ },
127
+ {
128
+ id: 'unitPrice',
129
+ name: $t(`7f7fdce2-1fcd-44c9-8c98-856aea11ffc3`),
130
+ width: 20,
131
+ getValue: (object: BalanceItemWithPayments) => ({
132
+ value: object.unitPrice / 1_0000,
133
+ style: {
134
+ numberFormat: {
135
+ id: XlsxBuiltInNumberFormat.Currency2DecimalWithRed,
136
+ },
137
+ },
138
+ }),
139
+ },
140
+ {
141
+ id: 'payablePriceWithVAT',
142
+ name: $t(`6f3104d4-9b8f-4946-8434-77202efae9f0`),
143
+ width: 20,
144
+ getValue: (object: BalanceItemWithPayments) => ({
145
+ value: object.payablePriceWithVAT / 1_0000,
146
+ style: {
147
+ numberFormat: {
148
+ id: XlsxBuiltInNumberFormat.Currency2DecimalWithRed,
149
+ },
150
+ },
151
+ }),
152
+ },
153
+
154
+ {
155
+ id: 'priceOpen',
156
+ name: $t(`cae1af9b-b2b1-440e-893c-e7c1010f0d4b`),
157
+ width: 40,
158
+ getValue: (object: BalanceItemWithPayments) => ({
159
+ value: object.priceOpen / 1_0000,
160
+ style: {
161
+ numberFormat: {
162
+ id: XlsxBuiltInNumberFormat.Currency2DecimalWithRed,
163
+ },
164
+ },
165
+ }),
166
+ },
167
+
168
+ {
169
+ id: 'pricePaid',
170
+ name: $t(`b9716962-aa02-4bd5-a8b3-d7d8def6ac28`),
171
+ width: 40,
172
+ getValue: (object: BalanceItemWithPayments) => ({
173
+ value: object.pricePaid / 1_0000,
174
+ style: {
175
+ numberFormat: {
176
+ id: XlsxBuiltInNumberFormat.Currency2DecimalWithRed,
177
+ },
178
+ },
179
+ }),
180
+ },
181
+
182
+ {
183
+ id: 'pricePending',
184
+ name: $t(`73637226-b5a9-4a64-b006-27122c0516d4`),
185
+ width: 40,
186
+ getValue: (object: BalanceItemWithPayments) => ({
187
+ value: object.pricePending / 1_0000,
188
+ style: {
189
+ numberFormat: {
190
+ id: XlsxBuiltInNumberFormat.Currency2DecimalWithRed,
191
+ },
192
+ },
193
+ }),
194
+ },
195
+
196
+ {
197
+ match: (id) => {
198
+ if (id.startsWith('paidIn[')) {
199
+ // paidIn[year]
200
+ const yearStr = id.substring('paidIn['.length, id.length - 1);
201
+ const year = parseInt(yearStr);
202
+ if (year && year > 2000 && year < 2100) {
203
+ return [
204
+ {
205
+ id: `paidIn[${year}]`,
206
+ name: $t('7df15807-0b2d-487f-8c97-deb8ce79d07b', { year: year.toFixed(0) }),
207
+ width: 35,
208
+ getValue: (object: BalanceItemWithPayments) => {
209
+ let value = 0;
210
+ for (const p of object.payments) {
211
+ if (p.payment.status === PaymentStatus.Succeeded && p.payment.paidAt) {
212
+ if (Formatter.year(p.payment.paidAt) === year) {
213
+ value += p.price;
214
+ }
215
+ }
216
+ }
217
+
218
+ return {
219
+ value: value / 1_0000,
220
+ style: {
221
+ numberFormat: {
222
+ id: XlsxBuiltInNumberFormat.Currency2DecimalWithRed,
223
+ },
224
+ },
225
+ };
226
+ },
227
+ },
228
+ ];
229
+ }
230
+ }
231
+ },
232
+ },
233
+
234
+ {
235
+ match: (id) => {
236
+ if (id.startsWith('chargedIn[')) {
237
+ // paidIn[year]
238
+ const yearStr = id.substring('chargedIn['.length, id.length - 1);
239
+ const year = parseInt(yearStr);
240
+ if (year && year > 2000 && year < 2100) {
241
+ return [
242
+ {
243
+ id: `chargedIn[${year}]`,
244
+ name: $t('91748032-ca3b-49c2-b065-ddfcb9fd460e', { year: year.toFixed(0) }),
245
+ width: 35,
246
+ getValue: (object: BalanceItemWithPayments) => {
247
+ let value = 0;
248
+ if (Formatter.year(object.createdAt) === year) {
249
+ value = object.payablePriceWithVAT;
250
+ }
251
+
252
+ return {
253
+ value: value / 1_0000,
254
+ style: {
255
+ numberFormat: {
256
+ id: XlsxBuiltInNumberFormat.Currency2DecimalWithRed,
257
+ },
258
+ },
259
+ };
260
+ },
261
+ },
262
+ ];
263
+ }
264
+ }
265
+ },
266
+ },
267
+ ];
268
+ }
@@ -1,9 +1,9 @@
1
1
  import { XlsxBuiltInNumberFormat, XlsxTransformerSheet } from '@stamhoofd/excel-writer';
2
2
  import { EventNotification, EventNotificationStatus, EventNotificationStatusHelper, ExcelExportType, LimitedFilteredRequest, Platform as PlatformStruct } from '@stamhoofd/structures';
3
3
  import { Formatter } from '@stamhoofd/utility';
4
- import { GetEventNotificationsEndpoint } from '../endpoints/global/events/GetEventNotificationsEndpoint';
5
- import { ExportToExcelEndpoint } from '../endpoints/global/files/ExportToExcelEndpoint';
6
- import { XlsxTransformerColumnHelper } from '../helpers/XlsxTransformerColumnHelper';
4
+ import { GetEventNotificationsEndpoint } from '../endpoints/global/events/GetEventNotificationsEndpoint.js';
5
+ import { ExportToExcelEndpoint } from '../endpoints/global/files/ExportToExcelEndpoint.js';
6
+ import { XlsxTransformerColumnHelper } from '../helpers/XlsxTransformerColumnHelper.js';
7
7
 
8
8
  // Assign to a typed variable to assure we have correct type checking in place
9
9
  const sheet: XlsxTransformerSheet<EventNotification, EventNotification> = {
@@ -1,5 +1,6 @@
1
- import './members';
2
- import './payments';
3
- import './organizations';
4
- import './receivable-balances';
5
- import './event-notifications';
1
+ import './members.js';
2
+ import './payments.js';
3
+ import './organizations.js';
4
+ import './receivable-balances.js';
5
+ import './event-notifications.js';
6
+ import './balance-items.js';
@@ -3,10 +3,10 @@ import { XlsxTransformerSheet } from '@stamhoofd/excel-writer';
3
3
  import { Group, Member, MemberResponsibilityRecord } from '@stamhoofd/models';
4
4
  import { ExcelExportType, LimitedFilteredRequest, MemberResponsibilityRecord as MemberResponsibilityRecordStruct, MemberWithRegistrationsBlob, Organization as OrganizationStruct, PaginatedResponse, Platform as PlatformStruct, Premise } from '@stamhoofd/structures';
5
5
  import { Formatter, Sorter } from '@stamhoofd/utility';
6
- import { GetOrganizationsEndpoint } from '../endpoints/admin/organizations/GetOrganizationsEndpoint';
7
- import { ExportToExcelEndpoint } from '../endpoints/global/files/ExportToExcelEndpoint';
8
- import { AuthenticatedStructures } from '../helpers/AuthenticatedStructures';
9
- import { XlsxTransformerColumnHelper } from '../helpers/XlsxTransformerColumnHelper';
6
+ import { GetOrganizationsEndpoint } from '../endpoints/admin/organizations/GetOrganizationsEndpoint.js';
7
+ import { ExportToExcelEndpoint } from '../endpoints/global/files/ExportToExcelEndpoint.js';
8
+ import { AuthenticatedStructures } from '../helpers/AuthenticatedStructures.js';
9
+ import { XlsxTransformerColumnHelper } from '../helpers/XlsxTransformerColumnHelper.js';
10
10
 
11
11
  class MemberResponsibilityRecordWithMember extends MemberResponsibilityRecordStruct {
12
12
  @field({ decoder: MemberWithRegistrationsBlob })
@@ -3,9 +3,9 @@ import { XlsxBuiltInNumberFormat, XlsxTransformerColumn, XlsxTransformerConcrete
3
3
  import { StripeAccount } from '@stamhoofd/models';
4
4
  import { BalanceItemPaymentDetailed, BalanceItemRelationType, ExcelExportType, getBalanceItemRelationTypeName, getBalanceItemTypeName, PaginatedResponse, PaymentGeneral, PaymentMethodHelper, PaymentStatusHelper, StripeAccount as StripeAccountStruct } from '@stamhoofd/structures';
5
5
  import { Formatter } from '@stamhoofd/utility';
6
- import { ExportToExcelEndpoint } from '../endpoints/global/files/ExportToExcelEndpoint';
7
- import { GetPaymentsEndpoint } from '../endpoints/organization/dashboard/payments/GetPaymentsEndpoint';
8
- import { XlsxTransformerColumnHelper } from '../helpers/XlsxTransformerColumnHelper';
6
+ import { ExportToExcelEndpoint } from '../endpoints/global/files/ExportToExcelEndpoint.js';
7
+ import { GetPaymentsEndpoint } from '../endpoints/organization/dashboard/payments/GetPaymentsEndpoint.js';
8
+ import { XlsxTransformerColumnHelper } from '../helpers/XlsxTransformerColumnHelper.js';
9
9
 
10
10
  type PaymentWithItem = {
11
11
  payment: PaymentGeneral;
@@ -113,6 +113,14 @@ function getBalanceItemColumns(): XlsxTransformerColumn<PaymentWithItem>[] {
113
113
  },
114
114
  }),
115
115
  },
116
+ {
117
+ id: 'balanceItem.id',
118
+ name: $t(`89594841-9a44-473f-8250-0ccafb570b6f`),
119
+ width: 40,
120
+ getValue: (object: PaymentWithItem) => ({
121
+ value: object.balanceItemPayment.balanceItem.id,
122
+ }),
123
+ },
116
124
  {
117
125
  id: 'paymentId',
118
126
  name: $t(`0601033f-1678-4781-96cd-1653448d689a`),
@@ -1,8 +1,8 @@
1
1
  import { XlsxBuiltInNumberFormat, XlsxTransformerColumn, XlsxTransformerConcreteColumn } from '@stamhoofd/excel-writer';
2
2
  import { BalanceItemRelationType, BalanceItemWithPayments, DetailedReceivableBalance, ExcelExportType, getBalanceItemRelationTypeName, getBalanceItemStatusName, getBalanceItemTypeName, getReceivableBalanceTypeName, PaginatedResponse, ReceivableBalance } from '@stamhoofd/structures';
3
3
  import { Formatter } from '@stamhoofd/utility';
4
- import { ExportToExcelEndpoint } from '../endpoints/global/files/ExportToExcelEndpoint';
5
- import { GetReceivableBalancesEndpoint } from '../endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint';
4
+ import { ExportToExcelEndpoint } from '../endpoints/global/files/ExportToExcelEndpoint.js';
5
+ import { GetReceivableBalancesEndpoint } from '../endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.js';
6
6
 
7
7
  type ReceivableBalanceWithItem = {
8
8
  receivableBalance: DetailedReceivableBalance;
@@ -1,7 +1,7 @@
1
1
  import { City, PostalCode, Province } from '@stamhoofd/models';
2
2
  import { Address, Country } from '@stamhoofd/structures';
3
3
 
4
- import { AddressValidator } from './AddressValidator';
4
+ import { AddressValidator } from './AddressValidator.js';
5
5
 
6
6
  describe('AddressValidator', () => {
7
7
  it('Can validate a city', async () => {
@@ -137,7 +137,7 @@ export class AddressValidatorStatic {
137
137
  throw new SimpleError({
138
138
  code: 'invalid_field',
139
139
  message: 'Invalid street, do you mean ' + bestStreet.name + '?',
140
- human: $t("f35e3d3a-880e-4703-a018-a24eed53bf64", { street: bestStreet.name }),
140
+ human: $t('f35e3d3a-880e-4703-a018-a24eed53bf64', { street: bestStreet.name }),
141
141
  field: 'street',
142
142
  });
143
143
  }
@@ -932,7 +932,7 @@ export class AdminPermissionChecker {
932
932
  if (organizationId) {
933
933
  return this.hasSomeAccess(organizationId);
934
934
  }
935
- return this.hasPlatformFullAccess();
935
+ return this.hasSomePlatformAccess();
936
936
  }
937
937
 
938
938
  async canSendEmails(organizationId: Organization | string | null) {
@@ -1,11 +1,10 @@
1
1
  import { SimpleError } from '@simonbackx/simple-errors';
2
2
  import { AuditLog, BalanceItem, CachedBalance, Document, Event, EventNotification, Group, Invoice, Member, MemberPlatformMembership, MemberResponsibilityRecord, MemberWithUsersRegistrationsAndGroups, Order, Organization, OrganizationRegistrationPeriod, Payment, Registration, RegistrationPeriod, Ticket, User, Webshop } from '@stamhoofd/models';
3
- import { AuditLogReplacement, AuditLogReplacementType, AuditLog as AuditLogStruct, Company, DetailedReceivableBalance, Document as DocumentStruct, EventNotification as EventNotificationStruct, Event as EventStruct, GenericBalance, Group as GroupStruct, GroupType, InvoicedBalanceItem, InvoiceStruct, MemberPlatformMembership as MemberPlatformMembershipStruct, MembersBlob, MemberWithRegistrationsBlob, NamedObject, OrganizationRegistrationPeriod as OrganizationRegistrationPeriodStruct, Organization as OrganizationStruct, PaymentCustomer, PaymentGeneral, PermissionLevel, Platform, PrivateOrder, PrivateWebshop, ReceivableBalanceObject, ReceivableBalanceObjectContact, ReceivableBalance as ReceivableBalanceStruct, ReceivableBalanceType, RegistrationsBlob, RegistrationWithMemberBlob, TicketPrivate, UserWithMembers, WebshopPreview, Webshop as WebshopStruct } from '@stamhoofd/structures';
3
+ import { AuditLogReplacement, AuditLogReplacementType, AuditLog as AuditLogStruct, DetailedReceivableBalance, Document as DocumentStruct, EventNotification as EventNotificationStruct, Event as EventStruct, GenericBalance, Group as GroupStruct, GroupType, InvoicedBalanceItem, InvoiceStruct, MemberPlatformMembership as MemberPlatformMembershipStruct, MembersBlob, MemberWithRegistrationsBlob, NamedObject, OrganizationRegistrationPeriod as OrganizationRegistrationPeriodStruct, Organization as OrganizationStruct, PaymentCustomer, PaymentGeneral, PermissionLevel, Platform, PrivateOrder, PrivateWebshop, ReceivableBalanceObject, ReceivableBalanceObjectContact, ReceivableBalance as ReceivableBalanceStruct, ReceivableBalanceType, RegistrationsBlob, RegistrationWithMemberBlob, TicketPrivate, UserWithMembers, WebshopPreview, Webshop as WebshopStruct, BalanceItem as BalanceItemStruct } from '@stamhoofd/structures';
4
4
  import { Sorter } from '@stamhoofd/utility';
5
5
 
6
6
  import { SQL } from '@stamhoofd/sql';
7
7
  import { Formatter } from '@stamhoofd/utility';
8
- import { BalanceItemService } from '../services/BalanceItemService.js';
9
8
  import { Context } from './Context.js';
10
9
 
11
10
  /**
@@ -61,6 +60,9 @@ export class AuthenticatedStructures {
61
60
 
62
61
  const { invoicedBalanceItems } = await Invoice.loadBalanceItems(invoices);
63
62
 
63
+ const paymentModels = await Payment.select().where('invoiceId', invoices.map(i => i.id)).fetch();
64
+ const payments = await this.paymentsGeneral(paymentModels, false);
65
+
64
66
  return invoices.map((invoice) => {
65
67
  const items = invoicedBalanceItems.filter(i => i.invoiceId === invoice.id);
66
68
  return InvoiceStruct.create({
@@ -68,6 +70,7 @@ export class AuthenticatedStructures {
68
70
  items: items.map((item) => {
69
71
  return InvoicedBalanceItem.create(item);
70
72
  }),
73
+ payments: payments.filter(p => p.invoiceId === invoice.id),
71
74
  });
72
75
  });
73
76
  }
@@ -1203,4 +1206,16 @@ export class AuthenticatedStructures {
1203
1206
 
1204
1207
  return structs;
1205
1208
  }
1209
+
1210
+ static async balanceItems(balanceItems: BalanceItem[]) {
1211
+ return balanceItems.map((balanceItem) => {
1212
+ return BalanceItemStruct.create({
1213
+ ...balanceItem,
1214
+ });
1215
+ });
1216
+ }
1217
+
1218
+ static async balanceItemsWithPayments(balanceItems: BalanceItem[]) {
1219
+ return await BalanceItem.getStructureWithPayments(balanceItems);
1220
+ }
1206
1221
  }
@@ -1,7 +1,7 @@
1
1
  import { Email, Organization, User } from '@stamhoofd/models';
2
2
  import { SQL } from '@stamhoofd/sql';
3
3
  import { EmailStatus } from '@stamhoofd/structures';
4
- import { ContextInstance } from './Context';
4
+ import { ContextInstance } from './Context.js';
5
5
 
6
6
  export async function resumeEmails() {
7
7
  const query = SQL.select()
@@ -1,7 +1,7 @@
1
1
  import { Group, Member, MemberResponsibilityRecord, Organization, Platform, Registration } from '@stamhoofd/models';
2
2
  import { SQL, SQLWhereExists } from '@stamhoofd/sql';
3
3
  import { GroupType } from '@stamhoofd/structures';
4
- import { MemberUserSyncer } from './MemberUserSyncer';
4
+ import { MemberUserSyncer } from './MemberUserSyncer.js';
5
5
 
6
6
  export class FlagMomentCleanup {
7
7
  /**
@@ -2,7 +2,7 @@ import { EmailAddress } from '@stamhoofd/email';
2
2
  import { OrganizationFactory, UserFactory } from '@stamhoofd/models';
3
3
  import { OrganizationEmail, PermissionLevel, Permissions } from '@stamhoofd/structures';
4
4
 
5
- import { ForwardHandler } from './ForwardHandler';
5
+ import { ForwardHandler } from './ForwardHandler.js';
6
6
 
7
7
  describe('ForwardHandler', () => {
8
8
  it('should send to default e-mail', async () => {
@@ -111,7 +111,7 @@ export class ForwardHandler {
111
111
  return doBounce();
112
112
  }
113
113
 
114
- console.log('Forward to ' + defaultEmail);
114
+ console.log('Forward to', defaultEmail);
115
115
 
116
116
  let html: string | undefined = undefined;
117
117
 
@@ -1,8 +1,8 @@
1
1
  import { I18n } from '@stamhoofd/backend-i18n';
2
- import { BalanceItemService } from '../services/BalanceItemService';
3
- import { FileSignService } from '../services/FileSignService';
4
- import { MemberRecordStore } from '../services/MemberRecordStore';
5
- import { ContextInstance } from './Context';
2
+ import { BalanceItemService } from '../services/BalanceItemService.js';
3
+ import { FileSignService } from '../services/FileSignService.js';
4
+ import { MemberRecordStore } from '../services/MemberRecordStore.js';
5
+ import { ContextInstance } from './Context.js';
6
6
 
7
7
  export class GlobalHelper {
8
8
  static async load() {