@stamhoofd/backend 2.71.0 → 2.73.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 (44) hide show
  1. package/index.ts +1 -0
  2. package/package.json +10 -10
  3. package/src/audit-logs/OrganizationLogger.ts +1 -1
  4. package/src/audit-logs/PlatformLogger.ts +1 -0
  5. package/src/email-recipient-loaders/orders.ts +1 -1
  6. package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +1 -1
  7. package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +7 -7
  8. package/src/endpoints/auth/CreateTokenEndpoint.ts +11 -1
  9. package/src/endpoints/auth/ForgotPasswordEndpoint.ts +26 -2
  10. package/src/endpoints/auth/PatchUserEndpoint.ts +24 -2
  11. package/src/endpoints/auth/SignupEndpoint.ts +1 -1
  12. package/src/endpoints/global/addresses/SearchRegionsEndpoint.ts +23 -3
  13. package/src/endpoints/global/audit-logs/GetAuditLogsEndpoint.ts +3 -3
  14. package/src/endpoints/global/events/GetEventsEndpoint.ts +6 -6
  15. package/src/endpoints/global/events/PatchEventsEndpoint.ts +36 -4
  16. package/src/endpoints/global/members/GetMembersEndpoint.ts +9 -7
  17. package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +24 -14
  18. package/src/endpoints/global/members/shouldCheckIfMemberIsDuplicate.ts +34 -0
  19. package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +11 -1
  20. package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +20 -12
  21. package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +11 -3
  22. package/src/endpoints/global/sso/GetSSOEndpoint.ts +8 -1
  23. package/src/endpoints/global/sso/SetSSOEndpoint.ts +4 -0
  24. package/src/endpoints/organization/dashboard/documents/GetDocumentsCountEndpoint.ts +1 -1
  25. package/src/endpoints/organization/dashboard/documents/GetDocumentsEndpoint.ts +6 -6
  26. package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +2 -1
  27. package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +5 -5
  28. package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.ts +51 -9
  29. package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersCountEndpoint.ts +1 -1
  30. package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +6 -6
  31. package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +6 -6
  32. package/src/excel-loaders/members.ts +8 -0
  33. package/src/excel-loaders/receivable-balances.ts +294 -0
  34. package/src/helpers/AdminPermissionChecker.ts +4 -3
  35. package/src/helpers/AuthenticatedStructures.ts +32 -6
  36. package/src/helpers/SetupStepUpdater.ts +10 -4
  37. package/src/helpers/xlsxAddressTransformerColumnFactory.ts +8 -0
  38. package/src/services/PaymentReallocationService.ts +3 -2
  39. package/src/services/PaymentService.ts +17 -1
  40. package/src/services/SSOService.ts +68 -4
  41. package/src/sql-filters/members.ts +20 -1
  42. package/src/sql-filters/organizations.ts +1 -0
  43. package/src/sql-filters/receivable-balances.ts +53 -1
  44. package/src/sql-sorters/organizations.ts +11 -0
@@ -1,4 +1,6 @@
1
- import { SQL, SQLFilterDefinitions, baseSQLFilterCompilers, createSQLColumnFilterCompiler, createSQLExpressionFilterCompiler } from '@stamhoofd/sql';
1
+ import { SQL, SQLConcat, SQLFilterDefinitions, SQLScalar, baseSQLFilterCompilers, createSQLColumnFilterCompiler, createSQLExpressionFilterCompiler, createSQLRelationFilterCompiler } from '@stamhoofd/sql';
2
+ import { memberFilterCompilers } from './members';
3
+ import { organizationFilterCompilers } from './organizations';
2
4
  import { EmailRelationFilterCompilers } from './shared/EmailRelationFilterCompilers';
3
5
 
4
6
  /**
@@ -22,6 +24,56 @@ export const receivableBalanceFilterCompilers: SQLFilterDefinitions = {
22
24
  ).then(1).else(0),
23
25
  { isJSONValue: false, isJSONObject: false },
24
26
  ),
27
+ organizations: createSQLRelationFilterCompiler(
28
+ SQL.select()
29
+ .from(SQL.table('organizations'))
30
+ .where(
31
+ SQL.column(
32
+ 'organizations',
33
+ 'id',
34
+ ),
35
+ SQL.column('cached_outstanding_balances', 'objectId'),
36
+ ).where(
37
+ SQL.column('cached_outstanding_balances', 'objectType'),
38
+ 'organization'),
39
+ organizationFilterCompilers,
40
+ ),
41
+ members: createSQLRelationFilterCompiler(
42
+ SQL.select()
43
+ .from(SQL.table('members'))
44
+ .where(
45
+ SQL.column(
46
+ 'members',
47
+ 'id',
48
+ ),
49
+ SQL.column('cached_outstanding_balances', 'objectId'),
50
+ ).where(
51
+ SQL.column('cached_outstanding_balances', 'objectType'),
52
+ 'member'),
53
+ memberFilterCompilers,
54
+ ),
55
+ users: createSQLRelationFilterCompiler(
56
+ SQL.select()
57
+ .from(SQL.table('users'))
58
+ .where(
59
+ SQL.column(
60
+ 'users',
61
+ 'id',
62
+ ),
63
+ SQL.column('cached_outstanding_balances', 'objectId'),
64
+ ).where(
65
+ SQL.column('cached_outstanding_balances', 'objectType'),
66
+ 'user'),
67
+ {
68
+ name: createSQLExpressionFilterCompiler(
69
+ new SQLConcat(
70
+ SQL.column('firstName'),
71
+ new SQLScalar(' '),
72
+ SQL.column('lastName'),
73
+ ),
74
+ ),
75
+ },
76
+ ),
25
77
 
26
78
  // Allowed to filter by recent emails
27
79
  ...EmailRelationFilterCompilers,
@@ -43,6 +43,17 @@ export const organizationSorters: SQLSortDefinitions<Organization> = {
43
43
  });
44
44
  },
45
45
  },
46
+ uriPadded: {
47
+ getValue(a) {
48
+ return a.uri.padStart(100, '0');
49
+ },
50
+ toSQL: (direction: SQLOrderByDirection): SQLOrderBy => {
51
+ return new SQLOrderBy({
52
+ column: SQL.lpad(SQL.column('uri'), 100, '0'),
53
+ direction,
54
+ });
55
+ },
56
+ },
46
57
  type: {
47
58
  getValue(a) {
48
59
  return a.meta.type;