@bisondesk/core-sdk 1.0.496 → 1.0.497

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 (47) hide show
  1. package/lib/constants.d.ts +2 -0
  2. package/lib/constants.d.ts.map +1 -1
  3. package/lib/constants.js +2 -0
  4. package/lib/constants.js.map +1 -1
  5. package/lib/types/activities.d.ts +17 -5
  6. package/lib/types/activities.d.ts.map +1 -1
  7. package/lib/types/activities.js +1 -0
  8. package/lib/types/activities.js.map +1 -1
  9. package/lib/types/internal-events.d.ts +2 -1
  10. package/lib/types/internal-events.d.ts.map +1 -1
  11. package/lib/types/internal-events.js +1 -0
  12. package/lib/types/internal-events.js.map +1 -1
  13. package/lib/types/journeys.d.ts +7 -0
  14. package/lib/types/journeys.d.ts.map +1 -1
  15. package/lib/types/journeys.js.map +1 -1
  16. package/lib/types/leasing-debtors.d.ts +206 -0
  17. package/lib/types/leasing-debtors.d.ts.map +1 -1
  18. package/lib/types/leasing-debtors.js +58 -1
  19. package/lib/types/leasing-debtors.js.map +1 -1
  20. package/lib/types/leasing.d.ts +1 -22
  21. package/lib/types/leasing.d.ts.map +1 -1
  22. package/lib/types/leasing.js.map +1 -1
  23. package/lib/types/opportunities.d.ts +0 -1
  24. package/lib/types/opportunities.d.ts.map +1 -1
  25. package/lib/types/opportunities.js.map +1 -1
  26. package/lib/types/vehicles.d.ts +4 -0
  27. package/lib/types/vehicles.d.ts.map +1 -1
  28. package/lib/types/vehicles.js.map +1 -1
  29. package/lib/utils/debtors-dossiers.d.ts +15 -0
  30. package/lib/utils/debtors-dossiers.d.ts.map +1 -0
  31. package/lib/utils/debtors-dossiers.js +51 -0
  32. package/lib/utils/debtors-dossiers.js.map +1 -0
  33. package/lib/utils/search.d.ts +3 -2
  34. package/lib/utils/search.d.ts.map +1 -1
  35. package/lib/utils/search.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/constants.ts +2 -0
  38. package/src/types/activities.ts +50 -4
  39. package/src/types/internal-events.ts +1 -0
  40. package/src/types/journeys.ts +8 -0
  41. package/src/types/leasing-debtors.ts +313 -0
  42. package/src/types/leasing.ts +0 -20
  43. package/src/types/opportunities.ts +0 -1
  44. package/src/types/vehicles.ts +4 -0
  45. package/src/utils/debtors-dossiers.ts +73 -0
  46. package/src/utils/search.ts +9 -2
  47. package/tsconfig.tsbuildinfo +1 -1
@@ -1,4 +1,9 @@
1
+ import { EmailMessage } from '@bisondesk/commons-sdk/messages';
2
+ import { NextList, PaginatedList } from '@bisondesk/commons-sdk/types';
1
3
  import { Contact, Organization } from './crm.js';
4
+ import { LeasingContract } from './leasing.js';
5
+ import { BaseSearchRequest, SortFilter } from './search.js';
6
+ import { DataRecord, ReferenceData } from './utils.js';
2
7
 
3
8
  export type MonthData = {
4
9
  activeContractIds: string[];
@@ -33,3 +38,311 @@ export type SearchDebtorInfo = {
33
38
  hasActiveContracts: boolean;
34
39
  };
35
40
  };
41
+
42
+ export enum DebtorsDossierStatus {
43
+ AUTO_REMINDER = 'auto_reminder',
44
+ OVERDUE = 'overdue',
45
+ CONTACT_ATTEMPTED = 'contact_attempted',
46
+ DIALOGUE = 'dialogue',
47
+ PROMISE_TO_PAY = 'promise_to_pay',
48
+ FAILURE = 'failure',
49
+ RESOLVED = 'resolved',
50
+ }
51
+
52
+ export const debtorsDossierStatusToDateFieldMap: Record<
53
+ DebtorsDossierStatus,
54
+ { date: keyof DossierStatusLogFields; author: keyof DossierStatusLogFields } | null
55
+ > = {
56
+ [DebtorsDossierStatus.AUTO_REMINDER]: null,
57
+ [DebtorsDossierStatus.OVERDUE]: { date: 'overdueAt', author: 'overdueBy' },
58
+ [DebtorsDossierStatus.CONTACT_ATTEMPTED]: { date: 'contactedAt', author: 'contactedBy' },
59
+ [DebtorsDossierStatus.DIALOGUE]: { date: 'dialogueAt', author: 'dialogueBy' },
60
+ [DebtorsDossierStatus.PROMISE_TO_PAY]: { date: 'promiseToPayAt', author: 'promiseToPayBy' },
61
+ [DebtorsDossierStatus.RESOLVED]: { date: 'resolvedAt', author: 'resolvedBy' },
62
+ [DebtorsDossierStatus.FAILURE]: { date: 'failedAt', author: 'failedBy' },
63
+ };
64
+
65
+ /******
66
+ * Auto Follow-Up Types
67
+ ******/
68
+
69
+ export type DebtorAutoFollowUp = {
70
+ id: string;
71
+ organizationId: string;
72
+ organizationName: string;
73
+ status: 'ONGOING' | 'ERROR' | 'SUCCESS' | 'EXPIRED' | 'DISCARDED';
74
+ emails: EmailMessage[];
75
+ createdAt: string;
76
+ modifiedAt: string;
77
+ completedAt?: string;
78
+ nextActionAt: string;
79
+ riskLevel: number;
80
+ };
81
+
82
+ export type ListOverdueRemindersResponse = PaginatedList<DebtorAutoFollowUp, ReferenceData>;
83
+ export type ListOverdueRemindersRequest = {
84
+ offset: number;
85
+ limit: number;
86
+ sortBy: SortFilter;
87
+ };
88
+
89
+ /******
90
+ * Debtor Dossier Types
91
+ ******/
92
+
93
+ export enum DebtorsDossierActions {
94
+ SET_METADATA = 'set_metadata',
95
+ ADD_ACTIVITY = 'add_activity',
96
+ FINISH = 'finish',
97
+ SET_DOCUMENTS = 'set_documents',
98
+ SET_PAYMENT_PLAN = 'set_payment_plan',
99
+ SET_LEGAL_DOSSIER = 'set_legal_dossier',
100
+ }
101
+
102
+ export type DossierStatusLogFields = {
103
+ failedAt?: string;
104
+ failedBy?: string;
105
+ resolvedAt?: string;
106
+ contactedAt?: string;
107
+ contactedBy?: string;
108
+ overdueAt?: string;
109
+ overdueBy?: string;
110
+ resolvedBy?: string;
111
+ dialogueAt?: string;
112
+ dialogueBy?: string;
113
+ promiseToPayAt?: string;
114
+ promiseToPayBy?: string;
115
+ };
116
+
117
+ export type BaseDebtorsDossier = {
118
+ organizationId: string;
119
+ contactId?: string;
120
+ tags: string[];
121
+ origin: 'manual' | 'auto';
122
+ autoFollowUpId?: string;
123
+ administrativeUserId?: string;
124
+ branchId: string;
125
+ tenantId: string;
126
+ };
127
+ export type DebtorsDossierStatusAudit = {
128
+ from: DebtorsDossierStatus;
129
+ to: DebtorsDossierStatus;
130
+ changedAt: string;
131
+ changedBy: string;
132
+ };
133
+
134
+ export type DebtorsDossier = BaseDebtorsDossier &
135
+ DossierStatusLogFields & {
136
+ id: string;
137
+ createdAt: string;
138
+ createdBy: string;
139
+ updatedAt: string;
140
+ updatedBy: string;
141
+ status: DebtorsDossierStatus;
142
+ statusAudit: DebtorsDossierStatusAudit[];
143
+ };
144
+
145
+ export type NewDebtorsDossier = BaseDebtorsDossier & {
146
+ id?: undefined;
147
+ createdBy?: undefined;
148
+ createdAt?: undefined;
149
+ updatedBy?: undefined;
150
+ updatedAt?: undefined;
151
+ };
152
+
153
+ export type DebtorsDossierBff = {
154
+ dossier: DataRecord<DebtorsDossier>;
155
+ organization?: Organization;
156
+ contact?: Contact;
157
+ leasingContracts: LeasingContract[];
158
+ debt?: DebtorInfo;
159
+ paymentPlan?: DebtorsPaymentPlan;
160
+ legalDossier?: LegalDossier;
161
+ trackAndTraceDevices: {
162
+ /* odometer: TrackAndTraceOdometerData;
163
+ device: TrackAndTraceDevice; */
164
+ }[];
165
+ };
166
+
167
+ export type UpdateDebtorsDossier = Partial<
168
+ Pick<
169
+ DebtorsDossier,
170
+ 'status' | 'tags' | 'contactId' | 'administrativeUserId' | 'branchId' | 'organizationId'
171
+ >
172
+ > & {
173
+ overdue?: boolean;
174
+ resolve?: boolean;
175
+ };
176
+
177
+ /******
178
+ * Payment Plan Types
179
+ ******/
180
+
181
+ export type DebtorsPaymentPlan = {
182
+ id: string;
183
+ debtorDossierId: string;
184
+
185
+ notes?: string;
186
+
187
+ reminders?: {
188
+ frequency: {
189
+ every: number;
190
+ period: 'days' | 'weeks' | 'months';
191
+ };
192
+ endCondition:
193
+ | {
194
+ endDate: string; // ISO date string
195
+ }
196
+ | {
197
+ occurrences: number; // Number of reminders to send
198
+ };
199
+ };
200
+
201
+ createdAt: string;
202
+ createdBy: string;
203
+ updatedAt: string;
204
+ updatedBy: string;
205
+ };
206
+
207
+ export type NewPaymentPlan = Omit<
208
+ DebtorsPaymentPlan,
209
+ 'id' | 'createdAt' | 'updatedAt' | 'createdBy' | 'updatedBy'
210
+ >;
211
+
212
+ export type UpdatePaymentPlan = Partial<Pick<DebtorsPaymentPlan, 'notes' | 'reminders'>>;
213
+
214
+ /******
215
+ * Legal Dossier Types
216
+ ******/
217
+
218
+ export enum LegalDossierStatus {
219
+ ASSESSMENT = 'assessment',
220
+ PRE_LEGAL_NOTICE = 'pre_legal_notice',
221
+ SENT_TO_LAWYER = 'sent_to_lawyer',
222
+ FILED = 'filed',
223
+ IN_COURT = 'in_court',
224
+ JUDGMENT = 'judgment',
225
+ ENFORCEMENT = 'enforcement',
226
+ SETTLEMENT = 'settlement',
227
+ CLOSED_RECOVERED = 'closed_recovered',
228
+ CLOSED_UNRECOVERABLE = 'closed_unrecoverable',
229
+ ON_HOLD = 'on_hold',
230
+ }
231
+
232
+ export type LegalDossier = {
233
+ id: string;
234
+ debtorDossierId: string;
235
+ caseNumber?: string;
236
+ notes?: string;
237
+ createdAt: string;
238
+ createdBy: string;
239
+ updatedAt: string;
240
+ updatedBy: string;
241
+ status: LegalDossierStatus;
242
+ };
243
+
244
+ export type NewLegalDossier = Omit<
245
+ LegalDossier,
246
+ 'id' | 'createdAt' | 'updatedAt' | 'createdBy' | 'updatedBy'
247
+ >;
248
+
249
+ export type UpdateLegalDossier = Partial<Pick<LegalDossier, 'caseNumber' | 'status' | 'notes'>>;
250
+
251
+ /******
252
+ * Debtor Dossier Events
253
+ ******/
254
+
255
+ export type DebtorsDossierCreateEvent = {
256
+ action: 'created';
257
+ data: DebtorsDossier;
258
+ previousData?: undefined;
259
+ tenantId: string;
260
+ userId: string;
261
+ };
262
+
263
+ export type DebtorsDossierUpdateEvent = {
264
+ action: 'updated';
265
+ data: DebtorsDossier;
266
+ previousData: DebtorsDossier;
267
+ tenantId: string;
268
+ userId: string;
269
+ };
270
+
271
+ export type DebtorsDossierDeleteEvent = {
272
+ action: 'deleted';
273
+ data?: undefined;
274
+ previousData: DebtorsDossier;
275
+ tenantId: string;
276
+ userId: string;
277
+ };
278
+
279
+ export type DebtorsDossierEvent =
280
+ | DebtorsDossierCreateEvent
281
+ | DebtorsDossierUpdateEvent
282
+ | DebtorsDossierDeleteEvent;
283
+
284
+ /************
285
+ *
286
+ * Search
287
+ */
288
+
289
+ export type SearchDebtorsDossier = {
290
+ contact?: Contact;
291
+ debtorsDossier: DebtorsDossier;
292
+ org?: Organization;
293
+ legalDossier?: LegalDossier;
294
+ paymentPlan?: DebtorsPaymentPlan;
295
+ tasks: {
296
+ totalTasks: number;
297
+ openTasks: number;
298
+ lastDueAt?: string;
299
+ };
300
+ };
301
+
302
+ /************
303
+ *
304
+ * Kanban
305
+ */
306
+
307
+ export type DebtorsDossierKanbanColumn = {
308
+ status: string;
309
+ results: SearchDebtorsDossier[];
310
+ totalCount: number;
311
+ totalValue: string;
312
+ };
313
+
314
+ export type MSearchDebtorsDossierKanbanColumn = {
315
+ column: DebtorsDossierKanbanColumn;
316
+ nextToken?: string;
317
+ };
318
+
319
+ export type KanbanDebtorsDossierSearchRequest = BaseSearchRequest & {
320
+ nextTokens?: Record<string, string | undefined>;
321
+ };
322
+
323
+ export type KanbanDebtorsDossierNextList = Omit<
324
+ NextList<DebtorsDossierKanbanColumn, ReferenceData>,
325
+ 'nextToken'
326
+ > & {
327
+ nextTokens?: Record<string, string | undefined>;
328
+ };
329
+
330
+ export const DebtorsDossierStatusOrder: DebtorsDossierStatus[] = [
331
+ DebtorsDossierStatus.AUTO_REMINDER,
332
+ DebtorsDossierStatus.OVERDUE,
333
+ DebtorsDossierStatus.CONTACT_ATTEMPTED,
334
+ DebtorsDossierStatus.DIALOGUE,
335
+ DebtorsDossierStatus.PROMISE_TO_PAY,
336
+ ];
337
+
338
+ export const DebtorsDossierWonColumnId = DebtorsDossierStatus.RESOLVED;
339
+
340
+ export const DebtorsDossierKanbanEndColumns: string[] = [
341
+ DebtorsDossierStatus.RESOLVED,
342
+ DebtorsDossierStatus.FAILURE,
343
+ ];
344
+
345
+ export const DebtorsDossierKanbanColumns = [
346
+ ...DebtorsDossierStatusOrder,
347
+ ...DebtorsDossierKanbanEndColumns,
348
+ ];
@@ -42,19 +42,6 @@ export type LeasingConditionEvent = {
42
42
  tenantId: string;
43
43
  };
44
44
 
45
- export type OverdueDossier = {
46
- id: string;
47
- organizationId: string;
48
- organizationName: string;
49
- status: 'ONGOING' | 'ERROR' | 'SUCCESS' | 'EXPIRED' | 'DISCARDED';
50
- emails: EmailMessage[];
51
- createdAt: string;
52
- modifiedAt: string;
53
- completedAt?: string;
54
- nextActionAt: string;
55
- riskLevel: number;
56
- };
57
-
58
45
  export type LeasingContractClient = {
59
46
  organizationId: string;
60
47
  contactIds: string[];
@@ -193,13 +180,6 @@ export type OpportunityRef = BaseRef & {
193
180
  //Since VAT is client specific and contracts can be transferred between clients, we always handle values without VAT
194
181
  };
195
182
 
196
- export type ListOverdueRemindersResponse = PaginatedList<OverdueDossier, ReferenceData>;
197
- export type ListOverdueRemindersRequest = {
198
- offset: number;
199
- limit: number;
200
- sortBy: SortFilter;
201
- };
202
-
203
183
  export type NewLeasingConditions = {
204
184
  parameters: {
205
185
  yearlyRoadTax: string;
@@ -803,7 +803,6 @@ export type HpWorkOrderProcessRequest = {
803
803
  locationVehicle2?: string; //entityId
804
804
  customer: string; //entityId
805
805
  vehicle: string; //entityId
806
- vehiclePurchaseLogisticsStatus?: string; //entityId
807
806
  trailerHasBeenCheckedIn: boolean;
808
807
  deliveryDetails?: string | null;
809
808
  technicalInspectionNeeded: boolean | null;
@@ -439,6 +439,10 @@ export type VehicleExternalInfo = {
439
439
  };
440
440
  identification: {
441
441
  licensePlate?: string;
442
+ licensePlateHistory?: {
443
+ licensePlate: string;
444
+ changedAt: string;
445
+ }[];
442
446
  stockNumber?: string;
443
447
  vin?: string;
444
448
  buildStockNumber?: string;
@@ -0,0 +1,73 @@
1
+ import { DebtorsDossier, DebtorsDossierStatus } from '@bisondesk/core-sdk/types/leasing-debtors';
2
+
3
+ export const DebtorsDossierStatusOrder: DebtorsDossierStatus[] = [
4
+ DebtorsDossierStatus.AUTO_REMINDER,
5
+ DebtorsDossierStatus.OVERDUE,
6
+ DebtorsDossierStatus.CONTACT_ATTEMPTED,
7
+ DebtorsDossierStatus.DIALOGUE,
8
+ DebtorsDossierStatus.PROMISE_TO_PAY,
9
+ DebtorsDossierStatus.FAILURE,
10
+ DebtorsDossierStatus.RESOLVED,
11
+ ];
12
+
13
+ type CompareInput = {
14
+ currentStatus: DebtorsDossierStatus;
15
+ referenceStatus: DebtorsDossierStatus;
16
+ };
17
+
18
+ const compareDebtorsDossierStatus = (input: CompareInput) => {
19
+ const { currentStatus, referenceStatus } = input;
20
+
21
+ const currentStatusIdx = DebtorsDossierStatusOrder.indexOf(currentStatus);
22
+ const referenceStatusIdx = DebtorsDossierStatusOrder.indexOf(referenceStatus);
23
+
24
+ return {
25
+ currentStatusIdx,
26
+ referenceStatusIdx,
27
+ };
28
+ };
29
+
30
+ export const getPreviousStatus = (
31
+ currentStatus: DebtorsDossierStatus
32
+ ): DebtorsDossierStatus | undefined => {
33
+ const currentIndex = DebtorsDossierStatusOrder.indexOf(currentStatus);
34
+ if (currentIndex <= 0) {
35
+ return;
36
+ }
37
+ return DebtorsDossierStatusOrder[currentIndex - 1];
38
+ };
39
+
40
+ export const getNextStatus = (status: DebtorsDossierStatus): DebtorsDossierStatus | undefined => {
41
+ const statusIndex = DebtorsDossierStatusOrder.indexOf(status);
42
+ if (statusIndex >= DebtorsDossierStatusOrder.length - 1) {
43
+ return;
44
+ }
45
+ return DebtorsDossierStatusOrder[statusIndex + 1];
46
+ };
47
+
48
+ export const isSameOrAfterReferenceDebtorsDossierStatus = (input: CompareInput): boolean => {
49
+ const { currentStatusIdx, referenceStatusIdx } = compareDebtorsDossierStatus(input);
50
+
51
+ return currentStatusIdx >= referenceStatusIdx;
52
+ };
53
+
54
+ export const isAfterReferenceDebtorsDossierStatus = (input: CompareInput): boolean => {
55
+ const { currentStatusIdx, referenceStatusIdx } = compareDebtorsDossierStatus(input);
56
+
57
+ return currentStatusIdx > referenceStatusIdx;
58
+ };
59
+
60
+ export const isSameOrBeforeReferenceDebtorsDossierStatus = (input: CompareInput): boolean => {
61
+ const { currentStatusIdx, referenceStatusIdx } = compareDebtorsDossierStatus(input);
62
+
63
+ return currentStatusIdx <= referenceStatusIdx;
64
+ };
65
+
66
+ export const isBeforeReferenceDebtorsDossierStatus = (input: CompareInput): boolean => {
67
+ const { currentStatusIdx, referenceStatusIdx } = compareDebtorsDossierStatus(input);
68
+
69
+ return currentStatusIdx < referenceStatusIdx;
70
+ };
71
+
72
+ export const isDossierFinished = (dossier: DebtorsDossier): boolean =>
73
+ dossier.resolvedAt != null || dossier.failedAt != null;
@@ -1,17 +1,24 @@
1
1
  import { joinWithSeparator } from '@bisondesk/commons-sdk/formatting';
2
2
  import { BusinessEntityIds } from '../constants.js';
3
3
  import { Contact, Organization, SearchOrganization } from '../types/crm.js';
4
+ import { DebtorsDossier, SearchDebtorsDossier } from '../types/leasing-debtors.js';
4
5
  import { SearchLeasingContract } from '../types/leasing-search.js';
5
6
  import { LeasingContract } from '../types/leasing.js';
6
7
  import { Opportunity, SearchOpportunity } from '../types/opportunities.js';
7
8
  import { SearchVehicle, Vehicle } from '../types/vehicles.js';
8
9
 
9
- export type GlobalBusinessEntity = Opportunity | Vehicle | Organization | LeasingContract;
10
+ export type GlobalBusinessEntity =
11
+ | Opportunity
12
+ | Vehicle
13
+ | Organization
14
+ | LeasingContract
15
+ | DebtorsDossier;
10
16
  export type GlobalSearchEntity =
11
17
  | SearchOpportunity
12
18
  | SearchVehicle
13
19
  | SearchOrganization
14
- | SearchLeasingContract;
20
+ | SearchLeasingContract
21
+ | SearchDebtorsDossier;
15
22
 
16
23
  export const getCustomerInformation = (org?: Organization, contact?: Contact) => {
17
24
  if (org != null) {