@bisondesk/core-sdk 1.0.140 → 1.0.142
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/lib/apis/leasing.js +2 -2
- package/lib/apis/leasing.js.map +1 -1
- package/lib/apis/vehicles.d.ts +6 -0
- package/lib/apis/vehicles.d.ts.map +1 -1
- package/lib/apis/vehicles.js +37 -1
- package/lib/apis/vehicles.js.map +1 -1
- package/lib/constants.d.ts +12 -6
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +10 -4
- package/lib/constants.js.map +1 -1
- package/lib/types/crm.d.ts +8 -0
- package/lib/types/crm.d.ts.map +1 -1
- package/lib/types/crm.js +11 -0
- package/lib/types/crm.js.map +1 -1
- package/lib/types/leasing-administration.d.ts +44 -39
- package/lib/types/leasing-administration.d.ts.map +1 -1
- package/lib/types/leasing.d.ts +6 -6
- package/lib/types/leasing.d.ts.map +1 -1
- package/lib/types/saved-filters.d.ts +1 -0
- package/lib/types/saved-filters.d.ts.map +1 -1
- package/lib/types/storage.d.ts +2 -2
- package/lib/types/storage.d.ts.map +1 -1
- package/lib/types/storage.js.map +1 -1
- package/lib/types/vehicles.d.ts +36 -0
- package/lib/types/vehicles.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/apis/leasing.ts +9 -9
- package/src/apis/vehicles.ts +56 -2
- package/src/constants.ts +10 -4
- package/src/types/crm.ts +10 -0
- package/src/types/leasing-administration.ts +49 -39
- package/src/types/leasing.ts +7 -7
- package/src/types/saved-filters.ts +1 -0
- package/src/types/storage.ts +5 -2
- package/src/types/vehicles.ts +44 -0
- package/tsconfig.tsbuildinfo +1 -1
package/src/apis/leasing.ts
CHANGED
|
@@ -26,7 +26,7 @@ export const getLeasingConditions = async (
|
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
if (response.ok) {
|
|
29
|
-
return response.status === 200 ?
|
|
29
|
+
return response.status === 200 ? response.json() : undefined;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const body = await response.text();
|
|
@@ -49,11 +49,11 @@ export const createLeasingConditions = async (
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
if (response.status === 200) {
|
|
52
|
-
return response.json()
|
|
52
|
+
return response.json();
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const body = await response.text();
|
|
56
|
-
throw new XError(response.statusText, { tenantId, body });
|
|
56
|
+
throw new XError(response.statusText, { tenantId, conditions, body });
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
export const getLeasingContractByNumber = async (
|
|
@@ -72,7 +72,7 @@ export const getLeasingContractByNumber = async (
|
|
|
72
72
|
);
|
|
73
73
|
|
|
74
74
|
if (response.ok) {
|
|
75
|
-
return response.status === 200 ?
|
|
75
|
+
return response.status === 200 ? response.json() : undefined;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const body = await response.text();
|
|
@@ -95,7 +95,7 @@ export const getLeasingContract = async (
|
|
|
95
95
|
);
|
|
96
96
|
|
|
97
97
|
if (response.ok) {
|
|
98
|
-
return response.status === 200 ?
|
|
98
|
+
return response.status === 200 ? response.json() : undefined;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
const body = await response.text();
|
|
@@ -119,7 +119,7 @@ export const findLeasingContracts = async (
|
|
|
119
119
|
);
|
|
120
120
|
|
|
121
121
|
if (response.status === 200) {
|
|
122
|
-
return response.json()
|
|
122
|
+
return response.json();
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
const body = await response.text();
|
|
@@ -142,11 +142,11 @@ export const upsertLeasingContract = async (
|
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
if (response.status === 200) {
|
|
145
|
-
return response.json()
|
|
145
|
+
return response.json();
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
const body = await response.text();
|
|
149
|
-
throw new XError(response.statusText, { tenantId, body });
|
|
149
|
+
throw new XError(response.statusText, { tenantId, contract, body });
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
export const computeFinanceDocLeasingAmounts = async (
|
|
@@ -197,7 +197,7 @@ export const getLeasingAmortizations = async (
|
|
|
197
197
|
);
|
|
198
198
|
|
|
199
199
|
if (response.status === 200) {
|
|
200
|
-
return response.json()
|
|
200
|
+
return response.json();
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
const body = await response.text();
|
package/src/apis/vehicles.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
SERVICE_ID_ADMIN_HEADER,
|
|
3
|
+
TENANT_ID_ADMIN_HEADER,
|
|
4
|
+
} from '@bisondesk/commons-sdk/lib/constants';
|
|
2
5
|
import { XError } from '@bisondesk/commons/lib/errors';
|
|
3
6
|
import fetch, { Response } from 'node-fetch';
|
|
4
7
|
import { Vehicle } from '../types/vehicles';
|
|
5
|
-
import { getAdminAuth } from './utils';
|
|
8
|
+
import { cleanHeaders, getAdminAuth } from './utils';
|
|
6
9
|
|
|
7
10
|
export const getVehicle = async (
|
|
8
11
|
tenantId: string,
|
|
@@ -49,3 +52,54 @@ export const getVehicleByStockNumber = async (
|
|
|
49
52
|
const body = await response.text();
|
|
50
53
|
throw new XError(response.statusText, { body });
|
|
51
54
|
};
|
|
55
|
+
|
|
56
|
+
export const saveVehicle = async (
|
|
57
|
+
tenantId: string,
|
|
58
|
+
vehicle: Vehicle,
|
|
59
|
+
opts?: { serviceId: string }
|
|
60
|
+
): Promise<Vehicle> => {
|
|
61
|
+
const auth = await getAdminAuth();
|
|
62
|
+
const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/vehicles`, {
|
|
63
|
+
method: 'POST',
|
|
64
|
+
headers: cleanHeaders({
|
|
65
|
+
Authorization: auth,
|
|
66
|
+
'Content-Type': 'application/json',
|
|
67
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
68
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
69
|
+
}),
|
|
70
|
+
body: JSON.stringify(vehicle),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (response.ok) {
|
|
74
|
+
return response.json();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const body = await response.text();
|
|
78
|
+
throw new XError(response.statusText, { body, tenantId, vehicle, opts });
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const deleteVehicle = async (
|
|
82
|
+
tenantId: string,
|
|
83
|
+
vehicleId: string,
|
|
84
|
+
opts?: { serviceId: string }
|
|
85
|
+
): Promise<void> => {
|
|
86
|
+
const auth = await getAdminAuth();
|
|
87
|
+
const response: Response = await fetch(
|
|
88
|
+
`${process.env.CORE_API_ORIGIN}/api/vehicles/${vehicleId}`,
|
|
89
|
+
{
|
|
90
|
+
method: 'DELETE',
|
|
91
|
+
headers: cleanHeaders({
|
|
92
|
+
Authorization: auth,
|
|
93
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
94
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
95
|
+
}),
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
if (response.ok) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const body = await response.text();
|
|
104
|
+
throw new XError(response.statusText, { body, tenantId, vehicleId, opts });
|
|
105
|
+
};
|
package/src/constants.ts
CHANGED
|
@@ -40,6 +40,7 @@ export enum BusinessEntityIds {
|
|
|
40
40
|
Emails = 'emails',
|
|
41
41
|
LeasingUploadAutomation = 'leasing_upload_automation',
|
|
42
42
|
BecrisDeclarations = 'becris_declarations',
|
|
43
|
+
VehiclesPriceLists = 'vehicles_price_lists',
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
//
|
|
@@ -76,7 +77,9 @@ export const PRICE_ROUNDING = 1000;
|
|
|
76
77
|
export const KM_ROUNDING = 100_000;
|
|
77
78
|
|
|
78
79
|
export enum LeasingAdminUploadHandlers {
|
|
79
|
-
|
|
80
|
+
DhondtMonthly = 'dhondt-monthly-invoice',
|
|
81
|
+
DhondtProrata = 'dhondt-prorata-invoice',
|
|
82
|
+
Belfius = 'belfius-monthly-invoice',
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
export enum LeasingAdminEntities {
|
|
@@ -87,10 +90,13 @@ export enum LeasingAdminEntities {
|
|
|
87
90
|
export enum LeasingAdminUploadErrors {
|
|
88
91
|
DuplicatedFile = 'leasing-administration.file-already-exists',
|
|
89
92
|
FetchCurrentFile = 'leasing-administration.diff.fetch-current-file-failed',
|
|
90
|
-
Publish = 'leasing-administration.upload.publish-failed',
|
|
91
|
-
Validation = 'leasing-administration.upload.invalid-request',
|
|
92
|
-
InvalidInvoiceFormat = 'leasing-administration.upload.invalid-invoice',
|
|
93
93
|
InvalidAttachment = 'leasing-administration.invalid-attachment',
|
|
94
|
+
InvalidBelfiusXlsx = 'leasing-administration.belfius.invalid-xlsx',
|
|
94
95
|
InvalidHandlerId = 'leasing-administration.invalid-handler',
|
|
96
|
+
InvalidInvoiceFormat = 'leasing-administration.upload.invalid-invoice',
|
|
97
|
+
NegativeAmount = 'leasing-administration.negative-amount',
|
|
95
98
|
OngoingUpload = 'leasing-administration.ongoing-upload',
|
|
99
|
+
Publish = 'leasing-administration.upload.publish-failed',
|
|
100
|
+
UnknownVehicle = 'leasing-administration.belfius.unknown-vehicle',
|
|
101
|
+
Validation = 'leasing-administration.upload.invalid-request',
|
|
96
102
|
}
|
package/src/types/crm.ts
CHANGED
|
@@ -112,3 +112,13 @@ export type Contact = {
|
|
|
112
112
|
/** will not be filled if organizationId is present */
|
|
113
113
|
orgName?: string;
|
|
114
114
|
};
|
|
115
|
+
|
|
116
|
+
export enum SaveContactResolution {
|
|
117
|
+
IgnoreDuplicates = 'IGNORE_DUPLICATES',
|
|
118
|
+
BlockDuplicates = 'BLOCK_DUPLICATES',
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export enum SaveOrgResolution {
|
|
122
|
+
IgnoreDuplicates = 'IGNORE_DUPLICATES',
|
|
123
|
+
BlockDuplicates = 'BLOCK_DUPLICATES',
|
|
124
|
+
}
|
|
@@ -39,54 +39,64 @@ export type DhondtAttachments = {
|
|
|
39
39
|
json: AttachmentValue;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
export type BelfiusAttachments = {
|
|
43
|
+
xlsx: AttachmentValue;
|
|
44
|
+
json?: AttachmentValue; // json version of the xlsx file
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type BelfiusMetadata = {
|
|
48
|
+
totalLines: number;
|
|
49
|
+
totalIncludingVat: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
42
52
|
export type DhondtMetadata = {
|
|
43
53
|
invoiceNumber: string;
|
|
44
|
-
invoiceDate: string;
|
|
45
54
|
};
|
|
46
55
|
|
|
47
56
|
export type DhondtVehicle = {
|
|
48
|
-
|
|
49
|
-
Plaatnummer: string;
|
|
50
|
-
Bouwjaar: number;
|
|
57
|
+
BrutoPremie: number;
|
|
51
58
|
ChassisNummer: string;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
Datum: string;
|
|
60
|
+
NettoPremie: number;
|
|
61
|
+
Plaatnummer: string;
|
|
62
|
+
Taksen: number;
|
|
56
63
|
VoertuigVlootNummer: string;
|
|
57
|
-
Type: string;
|
|
58
|
-
Merk: string;
|
|
59
|
-
MerkID: number;
|
|
60
|
-
TotaalNettoPremie: number;
|
|
61
|
-
TotaalTaksen: number;
|
|
62
|
-
TotaalBrutoPremie: number;
|
|
63
|
-
TotaalFee: number;
|
|
64
|
-
TotaalBTW: number;
|
|
65
|
-
TotaalPNettoPremie: number;
|
|
66
|
-
TotaalPTaksen: number;
|
|
67
|
-
TotaalPBrutoPremie: number;
|
|
68
|
-
TotaalPFee: number;
|
|
69
|
-
TotaalPBTW: number;
|
|
70
|
-
TotaalProRataNettoPremie: number;
|
|
71
|
-
TotaalProRataTaksen: number;
|
|
72
|
-
TotaalProRataBrutoPremie: number;
|
|
73
|
-
TotaalProRataFee: number;
|
|
74
|
-
TotaalProRataBTW: number;
|
|
75
|
-
TotaalTermijnPremie: number;
|
|
76
|
-
TotaalTermijnFee: number;
|
|
77
|
-
TotaalTermijnBTW: number;
|
|
78
|
-
fonetisch: string;
|
|
79
|
-
TotaalPremie: number;
|
|
80
|
-
TotaalPPremie: number;
|
|
81
|
-
TotaalProRataPremie: number;
|
|
82
|
-
TotaalAcquisitieKosten: number;
|
|
83
|
-
TotaalPAcquisitieKosten: number;
|
|
84
|
-
TotaalProrataAcquisitieKosten: number;
|
|
85
|
-
TotaalAdministratieKosten: number;
|
|
86
|
-
TotaalPAdministratieKosten: number;
|
|
87
|
-
TotaalProRataAdministratieKosten: number;
|
|
88
64
|
};
|
|
89
65
|
|
|
66
|
+
export type BelfiusRawInvoiceLine = {
|
|
67
|
+
'% BTW': number;
|
|
68
|
+
'BTW Nr': string;
|
|
69
|
+
'Client Nr.': string;
|
|
70
|
+
'Contractnr.': number;
|
|
71
|
+
'FACT NR.': number;
|
|
72
|
+
'Huurgeld excl. BTW': number;
|
|
73
|
+
'Omschrijving 1': string;
|
|
74
|
+
'Omschrijving 2': string;
|
|
75
|
+
'Totaal incl. BTW': number;
|
|
76
|
+
Avenant: number;
|
|
77
|
+
BTW: number;
|
|
78
|
+
Datum: number;
|
|
79
|
+
Intresten: number;
|
|
80
|
+
Kapitaal: number;
|
|
81
|
+
Muntcode: string;
|
|
82
|
+
Vervaldag: number;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type BelfiusInvoiceLine = {
|
|
86
|
+
capital: string;
|
|
87
|
+
contractNr: string;
|
|
88
|
+
interest: string;
|
|
89
|
+
invoiceNr: string;
|
|
90
|
+
invoiceDate: string;
|
|
91
|
+
rentExcl: string;
|
|
92
|
+
rentIncl: string;
|
|
93
|
+
vatAmount: string;
|
|
94
|
+
vehicleId: string;
|
|
95
|
+
stockNumber: string;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type DiffableBelfiusInvoiceLine = Omit<BelfiusInvoiceLine, 'invoiceNr' | 'invoiceDate'>;
|
|
99
|
+
|
|
90
100
|
export type LineDiff<T> = {
|
|
91
101
|
[Property in keyof T]: {
|
|
92
102
|
value: T[Property];
|
package/src/types/leasing.ts
CHANGED
|
@@ -46,6 +46,13 @@ export type LeasingContractClient = {
|
|
|
46
46
|
country: string;
|
|
47
47
|
beEntityType?: 'Legal Person' | 'Natural Person';
|
|
48
48
|
beForeignEntity?: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Used to overwrite the startDate in the context of a Becris declaration. This might be necessary
|
|
52
|
+
* when due to some data-quality issue we do not report the contract at the right period and it is no
|
|
53
|
+
* longer possible to resend the declaration for the corresponding month.
|
|
54
|
+
*/
|
|
55
|
+
becrisStartDate?: string;
|
|
49
56
|
};
|
|
50
57
|
|
|
51
58
|
export type LeasingContract = {
|
|
@@ -59,13 +66,6 @@ export type LeasingContract = {
|
|
|
59
66
|
endDate?: string;
|
|
60
67
|
slbPartner?: string;
|
|
61
68
|
|
|
62
|
-
/**
|
|
63
|
-
* Used to overwrite the startDate in the context of a Becris declaration. This might be necessary
|
|
64
|
-
* when due to some data-quality issue we do not report the contract at the right period and it is no
|
|
65
|
-
* longer possible to resend the declaration for the corresponding month.
|
|
66
|
-
*/
|
|
67
|
-
becrisStartDate?: string;
|
|
68
|
-
|
|
69
69
|
links?: LinkValue[];
|
|
70
70
|
|
|
71
71
|
accountManager?: string;
|
package/src/types/storage.ts
CHANGED
|
@@ -54,8 +54,11 @@ export type UploadUrlRequest<
|
|
|
54
54
|
|
|
55
55
|
export type UploadProvider = {
|
|
56
56
|
validationSchema: Joi.ObjectSchema<any>;
|
|
57
|
-
|
|
58
|
-
getUploadInfo(
|
|
57
|
+
getVideoListInfo: (requester: Requester, videoIds: string[]) => Promise<VideoInfo[]>;
|
|
58
|
+
getUploadInfo(
|
|
59
|
+
requester: Requester,
|
|
60
|
+
request: UploadUrlRequest<UploadProviders>
|
|
61
|
+
): Promise<UploadInfo>;
|
|
59
62
|
};
|
|
60
63
|
|
|
61
64
|
export type UploadProvidersDefinition = {
|
package/src/types/vehicles.ts
CHANGED
|
@@ -15,6 +15,14 @@ export type VehicleEvent = {
|
|
|
15
15
|
tenantId: string;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
export type UpdateVehiclesPricesEvent = {
|
|
19
|
+
id: string;
|
|
20
|
+
actionAt: string;
|
|
21
|
+
userId: string;
|
|
22
|
+
tenantId: string;
|
|
23
|
+
priceList: AttachmentValue;
|
|
24
|
+
};
|
|
25
|
+
|
|
18
26
|
export type PublicVehicle = Pick<Vehicle, 'external' | 'id'>;
|
|
19
27
|
|
|
20
28
|
export type PublicSearchVehicle = {
|
|
@@ -305,3 +313,39 @@ export type VehicleStatus = {
|
|
|
305
313
|
logisticsStatus: HdmsVehiclePurchaseLogisticsStatus | undefined;
|
|
306
314
|
};
|
|
307
315
|
};
|
|
316
|
+
|
|
317
|
+
export type VehiclePriceList = {
|
|
318
|
+
uploadedAt: string;
|
|
319
|
+
uploadedBy: string;
|
|
320
|
+
priceList: AttachmentValue;
|
|
321
|
+
id: string;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export type UpdateVehiclesPricesRequest = {
|
|
325
|
+
priceList: AttachmentValue;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export type VehiclePriceListLine = {
|
|
329
|
+
reference: string;
|
|
330
|
+
internet?: string;
|
|
331
|
+
premium?: string;
|
|
332
|
+
minimum?: string;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export type VehiclePriceUpdateError = {
|
|
336
|
+
data: VehiclePriceListLine;
|
|
337
|
+
line: number;
|
|
338
|
+
error: {
|
|
339
|
+
fieldId: keyof VehiclePriceListLine;
|
|
340
|
+
msg: string;
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
export type VehiclePriceUpdateResponse =
|
|
345
|
+
| {
|
|
346
|
+
success: true;
|
|
347
|
+
}
|
|
348
|
+
| {
|
|
349
|
+
success: false;
|
|
350
|
+
errors: VehiclePriceUpdateError[];
|
|
351
|
+
};
|