@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.
- package/index.ts +1 -0
- package/package.json +10 -10
- package/src/audit-logs/OrganizationLogger.ts +1 -1
- package/src/audit-logs/PlatformLogger.ts +1 -0
- package/src/email-recipient-loaders/orders.ts +1 -1
- package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +1 -1
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +7 -7
- package/src/endpoints/auth/CreateTokenEndpoint.ts +11 -1
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +26 -2
- package/src/endpoints/auth/PatchUserEndpoint.ts +24 -2
- package/src/endpoints/auth/SignupEndpoint.ts +1 -1
- package/src/endpoints/global/addresses/SearchRegionsEndpoint.ts +23 -3
- package/src/endpoints/global/audit-logs/GetAuditLogsEndpoint.ts +3 -3
- package/src/endpoints/global/events/GetEventsEndpoint.ts +6 -6
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +36 -4
- package/src/endpoints/global/members/GetMembersEndpoint.ts +9 -7
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +24 -14
- package/src/endpoints/global/members/shouldCheckIfMemberIsDuplicate.ts +34 -0
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +11 -1
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +20 -12
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +11 -3
- package/src/endpoints/global/sso/GetSSOEndpoint.ts +8 -1
- package/src/endpoints/global/sso/SetSSOEndpoint.ts +4 -0
- package/src/endpoints/organization/dashboard/documents/GetDocumentsCountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/documents/GetDocumentsEndpoint.ts +6 -6
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +5 -5
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.ts +51 -9
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersCountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +6 -6
- package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +6 -6
- package/src/excel-loaders/members.ts +8 -0
- package/src/excel-loaders/receivable-balances.ts +294 -0
- package/src/helpers/AdminPermissionChecker.ts +4 -3
- package/src/helpers/AuthenticatedStructures.ts +32 -6
- package/src/helpers/SetupStepUpdater.ts +10 -4
- package/src/helpers/xlsxAddressTransformerColumnFactory.ts +8 -0
- package/src/services/PaymentReallocationService.ts +3 -2
- package/src/services/PaymentService.ts +17 -1
- package/src/services/SSOService.ts +68 -4
- package/src/sql-filters/members.ts +20 -1
- package/src/sql-filters/organizations.ts +1 -0
- package/src/sql-filters/receivable-balances.ts +53 -1
- package/src/sql-sorters/organizations.ts +11 -0
|
@@ -8,9 +8,9 @@ import { QueueHandler } from '@stamhoofd/queues';
|
|
|
8
8
|
import { Context } from '../../../helpers/Context';
|
|
9
9
|
import { MembershipCharger } from '../../../helpers/MembershipCharger';
|
|
10
10
|
import { PeriodHelper } from '../../../helpers/PeriodHelper';
|
|
11
|
+
import { SetupStepUpdater } from '../../../helpers/SetupStepUpdater';
|
|
11
12
|
import { TagHelper } from '../../../helpers/TagHelper';
|
|
12
13
|
import { PlatformMembershipService } from '../../../services/PlatformMembershipService';
|
|
13
|
-
import { SetupStepUpdater } from '../../../helpers/SetupStepUpdater';
|
|
14
14
|
|
|
15
15
|
type Params = Record<string, never>;
|
|
16
16
|
type Query = undefined;
|
|
@@ -265,6 +265,16 @@ export class PatchPlatformEndpoint extends Endpoint<
|
|
|
265
265
|
newPremiseTypes: PlatformPremiseType[],
|
|
266
266
|
oldPremiseTypes: PlatformPremiseType[],
|
|
267
267
|
) {
|
|
268
|
+
// should be updated because the step will be removed
|
|
269
|
+
if (newPremiseTypes.length === 0 && oldPremiseTypes.length !== 0) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// should be updated because the step will be added
|
|
274
|
+
if (newPremiseTypes.length !== 0 && oldPremiseTypes.length === 0) {
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
|
|
268
278
|
for (const premiseType of newPremiseTypes) {
|
|
269
279
|
const id = premiseType.id;
|
|
270
280
|
const oldVersion = oldPremiseTypes.find(x => x.id === id);
|
|
@@ -2,13 +2,13 @@ import { AutoEncoderPatchType, Decoder, PatchableArrayAutoEncoder, PatchableArra
|
|
|
2
2
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
3
3
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
4
|
import { Document, Member, RateLimiter } from '@stamhoofd/models';
|
|
5
|
-
import {
|
|
5
|
+
import { MemberDetails, MembersBlob, MemberWithRegistrationsBlob } from '@stamhoofd/structures';
|
|
6
6
|
|
|
7
7
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures';
|
|
8
8
|
import { Context } from '../../../helpers/Context';
|
|
9
9
|
import { MemberUserSyncer } from '../../../helpers/MemberUserSyncer';
|
|
10
10
|
import { PatchOrganizationMembersEndpoint } from '../../global/members/PatchOrganizationMembersEndpoint';
|
|
11
|
-
import {
|
|
11
|
+
import { shouldCheckIfMemberIsDuplicateForPatch, shouldCheckIfMemberIsDuplicateForPut } from '../members/shouldCheckIfMemberIsDuplicate';
|
|
12
12
|
type Params = Record<string, never>;
|
|
13
13
|
type Query = undefined;
|
|
14
14
|
type Body = PatchableArrayAutoEncoder<MemberWithRegistrationsBlob>;
|
|
@@ -61,10 +61,12 @@ export class PatchUserMembersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
61
61
|
|
|
62
62
|
this.throwIfInvalidDetails(member.details);
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
if (shouldCheckIfMemberIsDuplicateForPut(struct)) {
|
|
65
|
+
const duplicate = await PatchOrganizationMembersEndpoint.checkDuplicate(member, struct.details.securityCode);
|
|
66
|
+
if (duplicate) {
|
|
67
|
+
addedMembers.push(duplicate);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
await member.save();
|
|
@@ -86,6 +88,8 @@ export class PatchUserMembersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
86
88
|
const securityCode = struct.details?.securityCode; // will get cleared after the filter
|
|
87
89
|
struct = await Context.auth.filterMemberPatch(member, struct);
|
|
88
90
|
|
|
91
|
+
let shouldCheckDuplicate = false;
|
|
92
|
+
|
|
89
93
|
if (struct.details) {
|
|
90
94
|
if (struct.details.isPut()) {
|
|
91
95
|
throw new SimpleError({
|
|
@@ -96,6 +100,8 @@ export class PatchUserMembersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
96
100
|
});
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
shouldCheckDuplicate = shouldCheckIfMemberIsDuplicateForPatch(struct, member.details);
|
|
104
|
+
|
|
99
105
|
member.details.patchOrPut(struct.details);
|
|
100
106
|
member.details.cleanData();
|
|
101
107
|
this.throwIfInvalidDetails(member.details);
|
|
@@ -110,14 +116,16 @@ export class PatchUserMembersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
110
116
|
});
|
|
111
117
|
}
|
|
112
118
|
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
if (shouldCheckDuplicate) {
|
|
120
|
+
const duplicate = await PatchOrganizationMembersEndpoint.checkDuplicate(member, securityCode);
|
|
121
|
+
if (duplicate) {
|
|
115
122
|
// Remove the member from the list
|
|
116
|
-
|
|
123
|
+
members.splice(members.findIndex(m => m.id === member.id), 1);
|
|
117
124
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
// Add new
|
|
126
|
+
addedMembers.push(duplicate);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
await member.save();
|
|
@@ -359,10 +359,14 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
359
359
|
|
|
360
360
|
const createdBalanceItems: BalanceItem[] = [];
|
|
361
361
|
const unrelatedCreatedBalanceItems: BalanceItem[] = [];
|
|
362
|
+
const deletedBalanceItems: BalanceItem[] = [];
|
|
362
363
|
const shouldMarkValid = whoWillPayNow === 'nobody' || checkout.paymentMethod === PaymentMethod.Transfer || checkout.paymentMethod === PaymentMethod.PointOfSale || checkout.paymentMethod === PaymentMethod.Unknown;
|
|
363
364
|
|
|
364
365
|
// Create negative balance items
|
|
365
|
-
for (const
|
|
366
|
+
for (const { registration: registrationStruct, deleted } of [
|
|
367
|
+
...checkout.cart.deleteRegistrations.map(r => ({ registration: r, deleted: true })),
|
|
368
|
+
...checkout.cart.items.flatMap(i => i.replaceRegistrations).map(r => ({ registration: r, deleted: false })),
|
|
369
|
+
]) {
|
|
366
370
|
if (whoWillPayNow !== 'nobody') {
|
|
367
371
|
// this also fixes the issue that we cannot delete the registration right away if we would need to wait for a payment
|
|
368
372
|
throw new SimpleError({
|
|
@@ -398,7 +402,11 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
398
402
|
|
|
399
403
|
// We can alter right away since whoWillPayNow is nobody, and shouldMarkValid will always be true
|
|
400
404
|
// Find all balance items of this registration and set them to zero
|
|
401
|
-
await BalanceItem.deleteForDeletedRegistration(existingRegistration.id
|
|
405
|
+
deletedBalanceItems.push(...(await BalanceItem.deleteForDeletedRegistration(existingRegistration.id, {
|
|
406
|
+
cancellationFeePercentage: deleted ? checkout.cancellationFeePercentage : 0,
|
|
407
|
+
})));
|
|
408
|
+
|
|
409
|
+
// todo: add cancelation fee
|
|
402
410
|
|
|
403
411
|
// Clear the registration
|
|
404
412
|
let group = groups.find(g => g.id === existingRegistration.groupId);
|
|
@@ -695,7 +703,7 @@ export class RegisterMembersEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
695
703
|
}
|
|
696
704
|
|
|
697
705
|
// Reallocate
|
|
698
|
-
await BalanceItemService.reallocate([...createdBalanceItems, ...unrelatedCreatedBalanceItems], organization.id);
|
|
706
|
+
await BalanceItemService.reallocate([...createdBalanceItems, ...unrelatedCreatedBalanceItems, ...deletedBalanceItems], organization.id);
|
|
699
707
|
|
|
700
708
|
// Update occupancy
|
|
701
709
|
for (const group of groups) {
|
|
@@ -44,6 +44,13 @@ export class GetOrganizationSSOEndpoint extends Endpoint<Params, Query, Body, Re
|
|
|
44
44
|
throw Context.auth.error();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const configuration = service.configuration.clone();
|
|
48
|
+
|
|
49
|
+
// Remove secret by placeholder asterisks
|
|
50
|
+
if (configuration.clientSecret.length > 0) {
|
|
51
|
+
configuration.clientSecret = OpenIDClientConfiguration.placeholderClientSecret;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return new Response(configuration);
|
|
48
55
|
}
|
|
49
56
|
}
|
|
@@ -41,6 +41,10 @@ export class SetOrganizationSSOEndpoint extends Endpoint<Params, Query, Body, Re
|
|
|
41
41
|
throw Context.auth.error();
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
if (request.body.clientSecret === OpenIDClientConfiguration.placeholderClientSecret) {
|
|
45
|
+
delete request.body.clientSecret;
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
const newConfig: OpenIDClientConfiguration = service.configuration.patch(request.body);
|
|
45
49
|
await service.setConfiguration(newConfig);
|
|
46
50
|
|
|
@@ -35,7 +35,7 @@ export class GetDocumentsCountEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
35
35
|
throw Context.auth.error();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const query = GetDocumentsEndpoint.buildQuery(request.query);
|
|
38
|
+
const query = await GetDocumentsEndpoint.buildQuery(request.query);
|
|
39
39
|
|
|
40
40
|
const count = await query
|
|
41
41
|
.count();
|
|
@@ -38,7 +38,7 @@ export class GetDocumentsEndpoint extends Endpoint<Params, Query, Body, Response
|
|
|
38
38
|
return [false];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
static buildQuery(q: CountFilteredRequest | LimitedFilteredRequest) {
|
|
41
|
+
static async buildQuery(q: CountFilteredRequest | LimitedFilteredRequest) {
|
|
42
42
|
const organization = Context.organization!;
|
|
43
43
|
|
|
44
44
|
const documentTable: string = Document.table;
|
|
@@ -46,25 +46,25 @@ export class GetDocumentsEndpoint extends Endpoint<Params, Query, Body, Response
|
|
|
46
46
|
const query = SQL
|
|
47
47
|
.select(SQL.wildcard(documentTable))
|
|
48
48
|
.from(SQL.table(documentTable))
|
|
49
|
-
.where(compileToSQLFilter({
|
|
49
|
+
.where(await compileToSQLFilter({
|
|
50
50
|
organizationId: organization.id,
|
|
51
51
|
}, filterCompilers));
|
|
52
52
|
|
|
53
53
|
if (q.filter) {
|
|
54
|
-
query.where(compileToSQLFilter(q.filter, filterCompilers));
|
|
54
|
+
query.where(await compileToSQLFilter(q.filter, filterCompilers));
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
if (q.search) {
|
|
58
58
|
const searchFilter: StamhoofdFilter | null = getDocumentSearchFilter(q.search);
|
|
59
59
|
|
|
60
60
|
if (searchFilter) {
|
|
61
|
-
query.where(compileToSQLFilter(searchFilter, filterCompilers));
|
|
61
|
+
query.where(await compileToSQLFilter(searchFilter, filterCompilers));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (q instanceof LimitedFilteredRequest) {
|
|
66
66
|
if (q.pageFilter) {
|
|
67
|
-
query.where(compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
67
|
+
query.where(await compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
q.sort = assertSort(q.sort, [{ key: 'id' }]);
|
|
@@ -76,7 +76,7 @@ export class GetDocumentsEndpoint extends Endpoint<Params, Query, Body, Response
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
static async buildData(requestQuery: LimitedFilteredRequest) {
|
|
79
|
-
const query = this.buildQuery(requestQuery);
|
|
79
|
+
const query = await this.buildQuery(requestQuery);
|
|
80
80
|
const data = await query.fetch();
|
|
81
81
|
|
|
82
82
|
const documents: Document[] = Document.fromRows(data, Document.table);
|
|
@@ -8,9 +8,9 @@ import { Formatter } from '@stamhoofd/utility';
|
|
|
8
8
|
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures';
|
|
9
9
|
import { BuckarooHelper } from '../../../../helpers/BuckarooHelper';
|
|
10
10
|
import { Context } from '../../../../helpers/Context';
|
|
11
|
+
import { SetupStepUpdater } from '../../../../helpers/SetupStepUpdater';
|
|
11
12
|
import { TagHelper } from '../../../../helpers/TagHelper';
|
|
12
13
|
import { ViesHelper } from '../../../../helpers/ViesHelper';
|
|
13
|
-
import { SetupStepUpdater } from '../../../../helpers/SetupStepUpdater';
|
|
14
14
|
|
|
15
15
|
type Params = Record<string, never>;
|
|
16
16
|
type Query = undefined;
|
|
@@ -126,6 +126,7 @@ export class PatchOrganizationEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
126
126
|
organization.privateMeta.privateKey = request.body.privateMeta.privateKey ?? organization.privateMeta.privateKey;
|
|
127
127
|
organization.privateMeta.featureFlags = patchObject(organization.privateMeta.featureFlags, request.body.privateMeta.featureFlags);
|
|
128
128
|
organization.privateMeta.balanceNotificationSettings = patchObject(organization.privateMeta.balanceNotificationSettings, request.body.privateMeta.balanceNotificationSettings);
|
|
129
|
+
organization.privateMeta.recordAnswers = request.body.privateMeta.recordAnswers.applyTo(organization.privateMeta.recordAnswers);
|
|
129
130
|
|
|
130
131
|
if (request.body.privateMeta.mollieProfile !== undefined) {
|
|
131
132
|
organization.privateMeta.mollieProfile = patchObject(organization.privateMeta.mollieProfile, request.body.privateMeta.mollieProfile);
|
|
@@ -5,11 +5,11 @@ import { Payment } from '@stamhoofd/models';
|
|
|
5
5
|
import { SQL, compileToSQLFilter, compileToSQLSorter } from '@stamhoofd/sql';
|
|
6
6
|
import { CountFilteredRequest, LimitedFilteredRequest, PaginatedResponse, PaymentGeneral, StamhoofdFilter, TransferSettings, assertSort, getSortFilter } from '@stamhoofd/structures';
|
|
7
7
|
|
|
8
|
+
import { SQLResultNamespacedRow } from '@simonbackx/simple-database';
|
|
8
9
|
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures';
|
|
9
10
|
import { Context } from '../../../../helpers/Context';
|
|
10
11
|
import { paymentFilterCompilers } from '../../../../sql-filters/payments';
|
|
11
12
|
import { paymentSorters } from '../../../../sql-sorters/payments';
|
|
12
|
-
import { SQLResultNamespacedRow } from '@simonbackx/simple-database';
|
|
13
13
|
|
|
14
14
|
type Params = Record<string, never>;
|
|
15
15
|
type Query = LimitedFilteredRequest;
|
|
@@ -59,11 +59,11 @@ export class GetPaymentsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
if (scopeFilter) {
|
|
62
|
-
query.where(compileToSQLFilter(scopeFilter, filterCompilers));
|
|
62
|
+
query.where(await compileToSQLFilter(scopeFilter, filterCompilers));
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (q.filter) {
|
|
66
|
-
query.where(compileToSQLFilter(q.filter, filterCompilers));
|
|
66
|
+
query.where(await compileToSQLFilter(q.filter, filterCompilers));
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
if (q.search) {
|
|
@@ -142,13 +142,13 @@ export class GetPaymentsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
if (searchFilter) {
|
|
145
|
-
query.where(compileToSQLFilter(searchFilter, filterCompilers));
|
|
145
|
+
query.where(await compileToSQLFilter(searchFilter, filterCompilers));
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
if (q instanceof LimitedFilteredRequest) {
|
|
150
150
|
if (q.pageFilter) {
|
|
151
|
-
query.where(compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
151
|
+
query.where(await compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
q.sort = assertSort(q.sort, [{ key: 'id' }]);
|
package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-
|
|
|
3
3
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
4
|
import { CachedBalance } from '@stamhoofd/models';
|
|
5
5
|
import { compileToSQLFilter, compileToSQLSorter } from '@stamhoofd/sql';
|
|
6
|
-
import {
|
|
6
|
+
import { assertSort, CountFilteredRequest, DetailedReceivableBalance, getSortFilter, LimitedFilteredRequest, PaginatedResponse, ReceivableBalance as ReceivableBalanceStruct, StamhoofdFilter } from '@stamhoofd/structures';
|
|
7
7
|
|
|
8
8
|
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures';
|
|
9
9
|
import { Context } from '../../../../helpers/Context';
|
|
@@ -54,23 +54,49 @@ export class GetReceivableBalancesEndpoint extends Endpoint<Params, Query, Body,
|
|
|
54
54
|
.select();
|
|
55
55
|
|
|
56
56
|
if (scopeFilter) {
|
|
57
|
-
query.where(compileToSQLFilter(scopeFilter, filterCompilers));
|
|
57
|
+
query.where(await compileToSQLFilter(scopeFilter, filterCompilers));
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (q.filter) {
|
|
61
|
-
query.where(compileToSQLFilter(q.filter, filterCompilers));
|
|
61
|
+
query.where(await compileToSQLFilter(q.filter, filterCompilers));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (q.search) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
let searchFilter: StamhoofdFilter | null = null;
|
|
66
|
+
|
|
67
|
+
searchFilter = {
|
|
68
|
+
$or: [
|
|
69
|
+
{
|
|
70
|
+
organizations: {
|
|
71
|
+
$elemMatch: {
|
|
72
|
+
$or: [
|
|
73
|
+
{ name: { $contains: q.search } },
|
|
74
|
+
{ uri: q.search },
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
members: {
|
|
81
|
+
$elemMatch: { name: { $contains: q.search } },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
users: {
|
|
86
|
+
$elemMatch: { name: { $contains: q.search } },
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
if (searchFilter) {
|
|
93
|
+
query.where(await compileToSQLFilter(searchFilter, filterCompilers));
|
|
94
|
+
}
|
|
69
95
|
}
|
|
70
96
|
|
|
71
97
|
if (q instanceof LimitedFilteredRequest) {
|
|
72
98
|
if (q.pageFilter) {
|
|
73
|
-
query.where(compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
99
|
+
query.where(await compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
74
100
|
}
|
|
75
101
|
|
|
76
102
|
q.sort = assertSort(q.sort, [{ key: 'id' }]);
|
|
@@ -81,7 +107,7 @@ export class GetReceivableBalancesEndpoint extends Endpoint<Params, Query, Body,
|
|
|
81
107
|
return query;
|
|
82
108
|
}
|
|
83
109
|
|
|
84
|
-
static async
|
|
110
|
+
static async buildDataHelper(requestQuery: LimitedFilteredRequest) {
|
|
85
111
|
const query = await GetReceivableBalancesEndpoint.buildQuery(requestQuery);
|
|
86
112
|
const data = await query.fetch();
|
|
87
113
|
|
|
@@ -107,12 +133,28 @@ export class GetReceivableBalancesEndpoint extends Endpoint<Params, Query, Body,
|
|
|
107
133
|
}
|
|
108
134
|
}
|
|
109
135
|
|
|
136
|
+
return { data, next };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static async buildData(requestQuery: LimitedFilteredRequest) {
|
|
140
|
+
const { data, next } = await GetReceivableBalancesEndpoint.buildDataHelper(requestQuery);
|
|
141
|
+
|
|
110
142
|
return new PaginatedResponse<ReceivableBalanceStruct[], LimitedFilteredRequest>({
|
|
111
143
|
results: await AuthenticatedStructures.receivableBalances(data),
|
|
112
144
|
next,
|
|
113
145
|
});
|
|
114
146
|
}
|
|
115
147
|
|
|
148
|
+
static async buildDetailedData(requestQuery: LimitedFilteredRequest) {
|
|
149
|
+
const organization = Context.organization ?? await Context.setOrganizationScope();
|
|
150
|
+
const { data, next } = await GetReceivableBalancesEndpoint.buildDataHelper(requestQuery);
|
|
151
|
+
|
|
152
|
+
return new PaginatedResponse<DetailedReceivableBalance[], LimitedFilteredRequest>({
|
|
153
|
+
results: await AuthenticatedStructures.detailedReceivableBalances(organization.id, data),
|
|
154
|
+
next,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
116
158
|
async handle(request: DecodedRequest<Params, Query, Body>) {
|
|
117
159
|
await Context.setOrganizationScope();
|
|
118
160
|
await Context.authenticate();
|
|
@@ -35,7 +35,7 @@ export class GetWebshopOrdersCountEndpoint extends Endpoint<Params, Query, Body,
|
|
|
35
35
|
throw Context.auth.error();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const query = GetWebshopOrdersEndpoint.buildQuery(request.query);
|
|
38
|
+
const query = await GetWebshopOrdersEndpoint.buildQuery(request.query);
|
|
39
39
|
|
|
40
40
|
const count = await query
|
|
41
41
|
.count();
|
|
@@ -35,7 +35,7 @@ export class GetWebshopOrdersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
35
35
|
return [false];
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
static buildQuery(q: CountFilteredRequest | LimitedFilteredRequest) {
|
|
38
|
+
static async buildQuery(q: CountFilteredRequest | LimitedFilteredRequest) {
|
|
39
39
|
// todo: filter userId???
|
|
40
40
|
const organization = Context.organization!;
|
|
41
41
|
|
|
@@ -44,7 +44,7 @@ export class GetWebshopOrdersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
44
44
|
const query = SQL
|
|
45
45
|
.select(SQL.wildcard(ordersTable))
|
|
46
46
|
.from(SQL.table(ordersTable))
|
|
47
|
-
.where(compileToSQLFilter({
|
|
47
|
+
.where(await compileToSQLFilter({
|
|
48
48
|
organizationId: organization.id,
|
|
49
49
|
number: {
|
|
50
50
|
$neq: null,
|
|
@@ -52,20 +52,20 @@ export class GetWebshopOrdersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
52
52
|
}, filterCompilers));
|
|
53
53
|
|
|
54
54
|
if (q.filter) {
|
|
55
|
-
query.where(compileToSQLFilter(q.filter, filterCompilers));
|
|
55
|
+
query.where(await compileToSQLFilter(q.filter, filterCompilers));
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
if (q.search) {
|
|
59
59
|
const searchFilter: StamhoofdFilter | null = getOrderSearchFilter(q.search, parsePhoneNumber);
|
|
60
60
|
|
|
61
61
|
if (searchFilter) {
|
|
62
|
-
query.where(compileToSQLFilter(searchFilter, filterCompilers));
|
|
62
|
+
query.where(await compileToSQLFilter(searchFilter, filterCompilers));
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
if (q instanceof LimitedFilteredRequest) {
|
|
67
67
|
if (q.pageFilter) {
|
|
68
|
-
query.where(compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
68
|
+
query.where(await compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
q.sort = assertSort(q.sort, [{ key: 'id' }]);
|
|
@@ -77,7 +77,7 @@ export class GetWebshopOrdersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
static async buildData(requestQuery: LimitedFilteredRequest) {
|
|
80
|
-
const query = this.buildQuery(requestQuery);
|
|
80
|
+
const query = await this.buildQuery(requestQuery);
|
|
81
81
|
const data = await query.fetch();
|
|
82
82
|
|
|
83
83
|
const orders: Order[] = Order.fromRows(data, Order.table);
|
|
@@ -34,7 +34,7 @@ export class GetWebshopTicketsEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
34
34
|
return [false];
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
static buildQuery(q: CountFilteredRequest | LimitedFilteredRequest) {
|
|
37
|
+
static async buildQuery(q: CountFilteredRequest | LimitedFilteredRequest) {
|
|
38
38
|
const organization = Context.organization!;
|
|
39
39
|
|
|
40
40
|
const ticketsTable: string = Ticket.table;
|
|
@@ -42,12 +42,12 @@ export class GetWebshopTicketsEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
42
42
|
const query = SQL
|
|
43
43
|
.select(SQL.wildcard(ticketsTable))
|
|
44
44
|
.from(SQL.table(ticketsTable))
|
|
45
|
-
.where(compileToSQLFilter({
|
|
45
|
+
.where(await Promise.resolve(compileToSQLFilter({
|
|
46
46
|
organizationId: organization.id,
|
|
47
|
-
}, filterCompilers));
|
|
47
|
+
}, filterCompilers)));
|
|
48
48
|
|
|
49
49
|
if (q.filter) {
|
|
50
|
-
query.where(compileToSQLFilter(q.filter, filterCompilers));
|
|
50
|
+
query.where(await Promise.resolve(compileToSQLFilter(q.filter, filterCompilers)));
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// currently no search supported, probably not needed?
|
|
@@ -56,7 +56,7 @@ export class GetWebshopTicketsEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
56
56
|
|
|
57
57
|
if (q instanceof LimitedFilteredRequest) {
|
|
58
58
|
if (q.pageFilter) {
|
|
59
|
-
query.where(compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
59
|
+
query.where(await Promise.resolve(compileToSQLFilter(q.pageFilter, filterCompilers)));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
q.sort = assertSort(q.sort, [{ key: 'id' }]);
|
|
@@ -68,7 +68,7 @@ export class GetWebshopTicketsEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
static async buildData(requestQuery: LimitedFilteredRequest) {
|
|
71
|
-
const query = this.buildQuery(requestQuery);
|
|
71
|
+
const query = await this.buildQuery(requestQuery);
|
|
72
72
|
const data = await query.fetch();
|
|
73
73
|
|
|
74
74
|
const tickets: Ticket[] = Ticket.fromRows(data, Ticket.table);
|
|
@@ -204,6 +204,14 @@ const sheet: XlsxTransformerSheet<PlatformMember, PlatformMember> = {
|
|
|
204
204
|
};
|
|
205
205
|
},
|
|
206
206
|
},
|
|
207
|
+
{
|
|
208
|
+
id: 'nationalRegisterNumber',
|
|
209
|
+
name: 'Rijksregisternummer',
|
|
210
|
+
width: 30,
|
|
211
|
+
getValue: ({ patchedMember: object }: PlatformMember) => ({
|
|
212
|
+
value: object.details.nationalRegisterNumber?.toString() ?? '',
|
|
213
|
+
}),
|
|
214
|
+
},
|
|
207
215
|
|
|
208
216
|
...XlsxTransformerColumnHelper.creatColumnsForParents(),
|
|
209
217
|
|