@stamhoofd/backend 2.52.0 → 2.53.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/package.json +10 -10
- package/src/endpoints/global/organizations/GetOrganizationFromUriEndpoint.ts +0 -1
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.ts +2 -5
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +4 -0
- package/src/excel-loaders/payments.ts +53 -1
- package/src/helpers/AuthenticatedStructures.ts +23 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.53.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"@simonbackx/simple-encoding": "2.16.6",
|
|
37
37
|
"@simonbackx/simple-endpoints": "1.14.0",
|
|
38
38
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
39
|
-
"@stamhoofd/backend-i18n": "2.
|
|
40
|
-
"@stamhoofd/backend-middleware": "2.
|
|
41
|
-
"@stamhoofd/email": "2.
|
|
42
|
-
"@stamhoofd/models": "2.
|
|
43
|
-
"@stamhoofd/queues": "2.
|
|
44
|
-
"@stamhoofd/sql": "2.
|
|
45
|
-
"@stamhoofd/structures": "2.
|
|
46
|
-
"@stamhoofd/utility": "2.
|
|
39
|
+
"@stamhoofd/backend-i18n": "2.53.0",
|
|
40
|
+
"@stamhoofd/backend-middleware": "2.53.0",
|
|
41
|
+
"@stamhoofd/email": "2.53.0",
|
|
42
|
+
"@stamhoofd/models": "2.53.0",
|
|
43
|
+
"@stamhoofd/queues": "2.53.0",
|
|
44
|
+
"@stamhoofd/sql": "2.53.0",
|
|
45
|
+
"@stamhoofd/structures": "2.53.0",
|
|
46
|
+
"@stamhoofd/utility": "2.53.0",
|
|
47
47
|
"archiver": "^7.0.1",
|
|
48
48
|
"aws-sdk": "^2.885.0",
|
|
49
49
|
"axios": "1.6.8",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "d202fb8d4a234f7369c3da54ba15f2b10b82e74e"
|
|
67
67
|
}
|
|
@@ -3,7 +3,6 @@ import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-
|
|
|
3
3
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
4
|
import { Organization } from '@stamhoofd/models';
|
|
5
5
|
import { Organization as OrganizationStruct } from '@stamhoofd/structures';
|
|
6
|
-
import { GoogleTranslateHelper } from '@stamhoofd/utility';
|
|
7
6
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures';
|
|
8
7
|
type Params = Record<string, never>;
|
|
9
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AutoEncoder, Decoder, field, StringDecoder } from '@simonbackx/simple-encoding';
|
|
2
2
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
3
3
|
import { Organization } from '@stamhoofd/models';
|
|
4
|
-
import { Organization as OrganizationStruct
|
|
4
|
+
import { Organization as OrganizationStruct } from '@stamhoofd/structures';
|
|
5
5
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures';
|
|
6
6
|
|
|
7
7
|
type Params = Record<string, never>;
|
|
@@ -12,7 +12,7 @@ class Query extends AutoEncoder {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
type Body = undefined;
|
|
15
|
-
type ResponseBody =
|
|
15
|
+
type ResponseBody = OrganizationStruct[];
|
|
16
16
|
|
|
17
17
|
export class SearchOrganizationEndpoint extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
18
18
|
protected queryDecoder = Query as Decoder<Query>;
|
|
@@ -55,9 +55,6 @@ export class SearchOrganizationEndpoint extends Endpoint<Params, Query, Body, Re
|
|
|
55
55
|
],
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
if (request.request.getVersion() < 169) {
|
|
59
|
-
return new Response(organizations.map(o => OrganizationSimple.create(o)));
|
|
60
|
-
}
|
|
61
58
|
return new Response(await Promise.all(organizations.map(o => AuthenticatedStructures.organization(o))));
|
|
62
59
|
}
|
|
63
60
|
}
|
|
@@ -321,6 +321,8 @@ export class PatchOrganizationRegistrationPeriodsEndpoint extends Endpoint<Param
|
|
|
321
321
|
if (period) {
|
|
322
322
|
model.periodId = period.id;
|
|
323
323
|
model.settings.period = period.getBaseStructure();
|
|
324
|
+
model.settings.startDate = period.startDate;
|
|
325
|
+
model.settings.endDate = period.endDate;
|
|
324
326
|
}
|
|
325
327
|
|
|
326
328
|
const patch = struct;
|
|
@@ -424,6 +426,8 @@ export class PatchOrganizationRegistrationPeriodsEndpoint extends Endpoint<Param
|
|
|
424
426
|
model.status = struct.status;
|
|
425
427
|
model.type = struct.type;
|
|
426
428
|
model.settings.period = period.getBaseStructure();
|
|
429
|
+
model.settings.startDate = period.startDate;
|
|
430
|
+
model.settings.endDate = period.endDate;
|
|
427
431
|
|
|
428
432
|
if (!await Context.auth.canAccessGroup(model, PermissionLevel.Full)) {
|
|
429
433
|
// Create a temporary permission role for this user
|
|
@@ -45,6 +45,7 @@ ExportToExcelEndpoint.loaders.set(ExcelExportType.Payments, {
|
|
|
45
45
|
columns: [
|
|
46
46
|
...getGeneralColumns(),
|
|
47
47
|
...getInvoiceColumns(),
|
|
48
|
+
...getPayingOrganizationColumns(),
|
|
48
49
|
...getSettlementColumns(),
|
|
49
50
|
...getStripeColumns(),
|
|
50
51
|
...getTransferColumns(),
|
|
@@ -64,6 +65,7 @@ ExportToExcelEndpoint.loaders.set(ExcelExportType.Payments, {
|
|
|
64
65
|
...[
|
|
65
66
|
...getGeneralColumns(),
|
|
66
67
|
...getInvoiceColumns(),
|
|
68
|
+
...getPayingOrganizationColumns(),
|
|
67
69
|
].map((c) => {
|
|
68
70
|
if ('match' in c) {
|
|
69
71
|
return {
|
|
@@ -127,6 +129,16 @@ function getBalanceItemColumns(): XlsxTransformerColumn<PaymentWithItem>[] {
|
|
|
127
129
|
value: getBalanceItemTypeName(object.balanceItemPayment.balanceItem.type),
|
|
128
130
|
}),
|
|
129
131
|
},
|
|
132
|
+
{
|
|
133
|
+
id: 'balanceItem.category',
|
|
134
|
+
name: 'Categorie',
|
|
135
|
+
width: 30,
|
|
136
|
+
getValue: (object: PaymentWithItem) => {
|
|
137
|
+
return {
|
|
138
|
+
value: Formatter.capitalizeFirstLetter(object.balanceItemPayment.balanceItem.category),
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
},
|
|
130
142
|
{
|
|
131
143
|
id: 'balanceItem.description',
|
|
132
144
|
name: 'Beschrijving',
|
|
@@ -245,7 +257,7 @@ function getGeneralColumns(): XlsxTransformerConcreteColumn<PaymentGeneral>[] {
|
|
|
245
257
|
name: 'Betaalprovider',
|
|
246
258
|
width: 16,
|
|
247
259
|
getValue: (object: PaymentGeneralWithStripeAccount) => ({
|
|
248
|
-
value: object.provider,
|
|
260
|
+
value: object.provider ?? PaymentMethodHelper.getNameCapitalized(object.method),
|
|
249
261
|
}),
|
|
250
262
|
},
|
|
251
263
|
{
|
|
@@ -432,6 +444,46 @@ function getTransferColumns(): XlsxTransformerColumn<PaymentGeneral>[] {
|
|
|
432
444
|
];
|
|
433
445
|
}
|
|
434
446
|
|
|
447
|
+
function getPayingOrganizationColumns(): XlsxTransformerColumn<PaymentGeneral>[] {
|
|
448
|
+
return [
|
|
449
|
+
{
|
|
450
|
+
id: 'payingOrganization.id',
|
|
451
|
+
name: 'ID betalende groep',
|
|
452
|
+
width: 30,
|
|
453
|
+
getValue: (object: PaymentGeneralWithStripeAccount) => {
|
|
454
|
+
return {
|
|
455
|
+
value: object.payingOrganization?.id || '',
|
|
456
|
+
};
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
id: 'payingOrganization.name',
|
|
461
|
+
name: 'Naam betalende groep',
|
|
462
|
+
width: 30,
|
|
463
|
+
getValue: (object: PaymentGeneralWithStripeAccount) => {
|
|
464
|
+
return {
|
|
465
|
+
value: object.payingOrganization?.name || '',
|
|
466
|
+
};
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
id: 'payingOrganization.uri',
|
|
471
|
+
name: 'Groepsnummer betalende groep',
|
|
472
|
+
width: 30,
|
|
473
|
+
getValue: (object: PaymentGeneralWithStripeAccount) => {
|
|
474
|
+
return {
|
|
475
|
+
value: object.payingOrganization?.uri || '',
|
|
476
|
+
};
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
XlsxTransformerColumnHelper.createAddressColumns<PaymentGeneralWithStripeAccount>({
|
|
480
|
+
matchId: 'payingOrganization.address',
|
|
481
|
+
getAddress: object => object.payingOrganization?.address,
|
|
482
|
+
identifier: 'Adres betalende groep',
|
|
483
|
+
}),
|
|
484
|
+
];
|
|
485
|
+
}
|
|
486
|
+
|
|
435
487
|
function getInvoiceColumns(): XlsxTransformerColumn<PaymentGeneral>[] {
|
|
436
488
|
return [
|
|
437
489
|
{
|
|
@@ -42,10 +42,13 @@ export class AuthenticatedStructures {
|
|
|
42
42
|
|
|
43
43
|
console.log('includeSettlements', includeSettlements);
|
|
44
44
|
|
|
45
|
+
const { payingOrganizations } = await Payment.loadPayingOrganizations(payments);
|
|
46
|
+
|
|
45
47
|
return Payment.getGeneralStructureFromRelations({
|
|
46
48
|
payments,
|
|
47
49
|
balanceItemPayments,
|
|
48
50
|
balanceItems,
|
|
51
|
+
payingOrganizations,
|
|
49
52
|
}, includeSettlements);
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -323,8 +326,26 @@ export class AuthenticatedStructures {
|
|
|
323
326
|
if (includeContextOrganization || organizationId !== Context.auth.organization?.id) {
|
|
324
327
|
const found = organizations.get(organizationId);
|
|
325
328
|
if (!found) {
|
|
326
|
-
|
|
327
|
-
|
|
329
|
+
try {
|
|
330
|
+
const organization = await Context.auth.getOrganization(organizationId);
|
|
331
|
+
organizations.set(organization.id, organization);
|
|
332
|
+
}
|
|
333
|
+
catch (e) {
|
|
334
|
+
if (e.message.includes('Unexpected missing organization')) {
|
|
335
|
+
// This user has permissions for an organization that is deleted
|
|
336
|
+
console.error(e);
|
|
337
|
+
console.error('User has permissions for an organization that is not found:', organizationId, 'userid', includeUser.id);
|
|
338
|
+
|
|
339
|
+
// Remove permissions for this organization
|
|
340
|
+
if (includeUser.permissions) {
|
|
341
|
+
includeUser.permissions.organizationPermissions.delete(organizationId);
|
|
342
|
+
await includeUser.save();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
throw e;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
328
349
|
}
|
|
329
350
|
}
|
|
330
351
|
}
|