@bisondesk/core-sdk 1.0.162 → 1.0.164

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/lib/apis/leasing-administration.d.ts +4 -1
  2. package/lib/apis/leasing-administration.d.ts.map +1 -1
  3. package/lib/apis/leasing-administration.js +20 -1
  4. package/lib/apis/leasing-administration.js.map +1 -1
  5. package/lib/constants.d.ts +4 -2
  6. package/lib/constants.d.ts.map +1 -1
  7. package/lib/constants.js +5 -0
  8. package/lib/constants.js.map +1 -1
  9. package/lib/types/crm.d.ts +5 -0
  10. package/lib/types/crm.d.ts.map +1 -1
  11. package/lib/types/crm.js.map +1 -1
  12. package/lib/types/leads.d.ts +1 -0
  13. package/lib/types/leads.d.ts.map +1 -1
  14. package/lib/types/leasing-administration.d.ts +13 -0
  15. package/lib/types/leasing-administration.d.ts.map +1 -1
  16. package/lib/types/messages.d.ts +2 -0
  17. package/lib/types/messages.d.ts.map +1 -1
  18. package/lib/types/opportunities.d.ts +121 -30
  19. package/lib/types/opportunities.d.ts.map +1 -1
  20. package/lib/types/opportunities.js +27 -10
  21. package/lib/types/opportunities.js.map +1 -1
  22. package/lib/types/tenants.d.ts +1 -0
  23. package/lib/types/tenants.d.ts.map +1 -1
  24. package/lib/types/utils.d.ts +3 -2
  25. package/lib/types/utils.d.ts.map +1 -1
  26. package/lib/types/vehicles.d.ts +1 -0
  27. package/lib/types/vehicles.d.ts.map +1 -1
  28. package/package.json +3 -3
  29. package/src/apis/leasing-administration.ts +33 -1
  30. package/src/constants.ts +5 -0
  31. package/src/types/crm.ts +5 -0
  32. package/src/types/leads.ts +1 -0
  33. package/src/types/leasing-administration.ts +15 -0
  34. package/src/types/messages.ts +2 -0
  35. package/src/types/opportunities.ts +134 -30
  36. package/src/types/tenants.ts +1 -0
  37. package/src/types/utils.ts +3 -2
  38. package/src/types/vehicles.ts +1 -0
  39. package/tsconfig.tsbuildinfo +1 -1
  40. package/lib/types/notifications.d.ts +0 -19
  41. package/lib/types/notifications.d.ts.map +0 -1
  42. package/lib/types/notifications.js +0 -9
  43. package/lib/types/notifications.js.map +0 -1
  44. package/src/types/notifications.ts +0 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bisondesk/core-sdk",
3
- "version": "1.0.162",
3
+ "version": "1.0.164",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "clean": "rm -rf build dist lib *.tsbuildinfo",
@@ -11,13 +11,13 @@
11
11
  },
12
12
  "author": "TheTruckCompany",
13
13
  "dependencies": {
14
- "@bisondesk/commons-sdk": "1.0.162",
14
+ "@bisondesk/commons-sdk": "1.0.164",
15
15
  "joi": "17.4.0",
16
16
  "lru-cache": "6.0.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/lru-cache": "5.1.0",
20
20
  "@types/node": "16.11.7",
21
- "typescript": "4.5.2"
21
+ "typescript": "4.6.3"
22
22
  }
23
23
  }
@@ -4,9 +4,41 @@ import {
4
4
  } from '@bisondesk/commons-sdk/lib/constants';
5
5
  import { XError } from '@bisondesk/commons/lib/errors';
6
6
  import fetch, { Response } from 'node-fetch';
7
- import { LeasingAdminUpload, LeasingAdminUploadStatus } from '../types/leasing-administration';
7
+ import {
8
+ LeasingAdminUpload,
9
+ LeasingAdminUploadStatus,
10
+ NewLeasingAdminUploadRequest,
11
+ } from '../types/leasing-administration';
8
12
  import { cleanHeaders, getAdminAuth } from './utils';
9
13
 
14
+ export const createLeasingAdminUpload = async (
15
+ tenantId: string,
16
+ data: NewLeasingAdminUploadRequest,
17
+ opts?: { serviceId: string }
18
+ ): Promise<LeasingAdminUpload> => {
19
+ const auth = await getAdminAuth();
20
+ const response: Response = await fetch(
21
+ `${process.env.CORE_API_ORIGIN}/api/leasing/administration/uploads`,
22
+ {
23
+ method: 'POST',
24
+ headers: cleanHeaders({
25
+ Authorization: auth,
26
+ 'Content-Type': 'application/json',
27
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
28
+ [SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
29
+ }),
30
+ body: JSON.stringify(data),
31
+ }
32
+ );
33
+
34
+ if (response.ok) {
35
+ return response.json();
36
+ }
37
+
38
+ const body = await response.text();
39
+ throw new XError(response.statusText, { body, data, opts });
40
+ };
41
+
10
42
  export const updateLeasingAdminUploadStatus = async (
11
43
  tenantId: string,
12
44
  handlerId: string,
package/src/constants.ts CHANGED
@@ -82,15 +82,20 @@ export const MAX_PRICE = 100_000;
82
82
  export const PRICE_ROUNDING = 1000;
83
83
  export const KM_ROUNDING = 100_000;
84
84
 
85
+ //
86
+ // Leasing administration
87
+ //
85
88
  export enum LeasingAdminUploadHandlers {
86
89
  DhondtMonthly = 'dhondt-monthly-invoice',
87
90
  DhondtProrata = 'dhondt-prorata-invoice',
88
91
  Belfius = 'belfius-monthly-invoice',
92
+ ING = 'ing-monthly-invoice',
89
93
  }
90
94
 
91
95
  export enum LeasingAdminEntities {
92
96
  Dhondt = 'dhondt',
93
97
  Becris = 'becris',
98
+ ING = 'ing',
94
99
  }
95
100
 
96
101
  export enum LeasingAdminUploadErrors {
package/src/types/crm.ts CHANGED
@@ -56,6 +56,11 @@ export type Organization = BaseOrganization & {
56
56
  externalId?: number;
57
57
  id: string;
58
58
  debt?: OrganizationDebtInfo;
59
+ blocked?: boolean;
60
+ blockedAt?: string;
61
+ blockedBy?: string;
62
+ blockedReason?: string;
63
+ openOpportunitiesCount: number;
59
64
  };
60
65
 
61
66
  export type OrganizationDebtInfo = {
@@ -120,6 +120,7 @@ export type Interest = {
120
120
  suspensions?: string[];
121
121
  tailgate?: boolean;
122
122
  transmissions?: string[];
123
+ autoGenerated?: boolean;
123
124
 
124
125
  remarks?: string;
125
126
  };
@@ -64,6 +64,21 @@ export type DhondtInvoiceLine = {
64
64
  VoertuigVlootNummer: string;
65
65
  };
66
66
 
67
+ export type INGMetadata = {
68
+ capital: string;
69
+ chassisNumber: string;
70
+ emailId: string;
71
+ interest: string;
72
+ invoiceDate: string;
73
+ invoiceNumber: string;
74
+ pdfUrl: string;
75
+ stockNumber: string;
76
+ };
77
+
78
+ export type INGAttachments = {
79
+ email: AttachmentValue;
80
+ };
81
+
67
82
  export type DiffableDhondtInvoiceLine = DhondtInvoiceLine;
68
83
 
69
84
  export type BelfiusRawInvoiceLine = {
@@ -45,6 +45,8 @@ export type TemplatedEmailRequest = {
45
45
  };
46
46
 
47
47
  export type EmailRequest = {
48
+ references?: string[] | string;
49
+ inReplyTo?: string; // messageId of the email to reply to
48
50
  destinations: EmailDestination[];
49
51
  replyTo?: EmailAddress;
50
52
  source: EmailAddress;
@@ -1,65 +1,119 @@
1
+ import { Contact, Organization } from './crm';
2
+ import { AttachmentValue } from './fields';
1
3
  import { Interest } from './leads';
4
+ import { DataRecord } from './utils';
2
5
  import { Vehicle } from './vehicles';
3
6
 
4
- enum OpportunityDealStatus {
7
+ export enum OpportunityDealStatus {
5
8
  SALES_AGREED = 'sales_agreed',
6
9
  FIRST_PAYMENT = 'first_payment',
7
10
  FULL_PAYMENT = 'full_payment',
8
11
  }
9
12
 
10
- enum OpportunityStatus {
11
- PROSPECTING = 'prospecting',
12
- DISCOVERY = 'discovery',
13
- CUSTOMER_EVALUATING = 'customer_evaluating',
14
- NEGOTIATION_REVIEW = 'negotiation_review',
15
- WON = 'won',
16
- LOST = 'lost',
13
+ export enum OpportunityStatus {
14
+ PROSPECTION = 'prospection',
15
+ VEHICLE_DISCOVERY = 'vehicle_discovery',
16
+ QUOTE_EVALUATION = 'quote_evaluation',
17
+ VEHICLE_LOCKED = 'vehicle_locked',
18
+ QUOTE_ACCEPTED = 'quote_accepted',
19
+ CLOSED_WON = 'closed_won',
20
+ CLOSED_LOST = 'closed_lost',
17
21
  }
18
22
 
19
- enum OpportunityLogisticStatus {
23
+ export enum OpportunityLogisticStatus {
20
24
  AT_ORIGIN = 'at_origin',
21
25
  DELIVERED = 'delivered',
22
26
  }
23
27
 
24
- enum OpportunityType {
28
+ export enum OpportunityType {
25
29
  LEASING = 'leasing',
26
30
  SALES = 'sales',
27
31
  }
28
32
 
29
- export type Bid = {
30
- id: string;
33
+ export enum OpportunityLostReasonValues {
34
+ NOT_INTERESTED = 'not_interested',
35
+ NOT_ENOUGH_INFO = 'not_enough_info',
36
+ NO_RESPONSE = 'no_response',
37
+ QUOTE_REJECTED = 'quote_rejected',
38
+ }
39
+
40
+ export enum QuoteStatusValues {
41
+ CREATED = 'created',
42
+ VALIDATED = 'validated',
43
+ INVALIDATED = 'invalidated',
44
+ ACCEPTED = 'accepted',
45
+ REJECTED = 'rejected',
46
+ }
47
+
48
+ export type BaseBid = {
31
49
  vehicleId: string;
32
- opportunityId: string;
50
+ opportunityId?: string;
33
51
  contactId: string;
34
52
  amount: string;
53
+ };
54
+
55
+ export type NewBid = BaseBid & {};
56
+
57
+ export type Bid = BaseBid & {
58
+ id: string;
35
59
  createdAt: string;
36
60
  createdBy: string;
37
61
  };
38
62
 
39
- export type Quote = {
63
+ export type QuoteStatus = {
64
+ status: QuoteStatusValues;
65
+ date: string;
66
+ author: string;
67
+ };
68
+
69
+ export type QuoteCalculatorValues = {
70
+ pruchasePrice: string;
71
+ };
72
+
73
+ export type BaseQuote = {
40
74
  id: string;
75
+ opportunityId: string;
76
+ vehicleId: string;
77
+ contactId: string;
78
+ createdAt: string;
79
+ createdBy: string;
80
+ updatedAt: string;
81
+ updatedBy: string;
82
+ calculatorValues: QuoteCalculatorValues;
83
+ };
84
+
85
+ export type NewQuote = BaseQuote & {
86
+ id?: undefined;
87
+ createdAt?: undefined;
88
+ createdBy?: undefined;
89
+ modifiedAt?: undefined;
90
+ modifiedBy?: undefined;
91
+ };
92
+
93
+ export type Quote = BaseQuote & {
94
+ version: number;
95
+ status: QuoteStatus;
96
+ monthlyAmount: string;
97
+ residualAmount: string;
98
+ beforeDeliveryAmount: string;
99
+ roi: string;
100
+ cashflow: string;
101
+ profitability: string;
102
+ proformaPdf?: AttachmentValue;
103
+ quotePdf?: AttachmentValue;
104
+ };
105
+
106
+ export type QuoteUpdate = {
107
+ status: QuoteStatus;
41
108
  };
42
109
 
43
110
  type BaseOpportunity = {
44
- accountManager?: string;
45
- countryCode: string;
111
+ accountManager: string;
112
+ type: OpportunityType;
46
113
  organizationId?: string;
47
- /** will not be filled if organizationId is present */
48
- orgName?: string;
49
114
  contactId?: string;
50
- /** will not be filled if contactId is present */
51
- contactName?: string;
52
115
  vehicleId?: string;
53
- vechicle?: Vehicle;
54
- bids?: Bid[];
55
- dealStatus: OpportunityDealStatus;
56
- logisticStatus: OpportunityLogisticStatus;
57
- type: OpportunityType;
58
- contractId?: string;
59
- quotes?: Quote[];
60
- amount: string;
61
- status: OpportunityStatus;
62
- interest: Interest;
116
+ source: string; // e.g. manual, website, autoscout, mobile...
63
117
  };
64
118
 
65
119
  export type NewOpportunity = BaseOpportunity & {
@@ -70,10 +124,60 @@ export type NewOpportunity = BaseOpportunity & {
70
124
  modifiedBy?: undefined;
71
125
  };
72
126
 
127
+ export type OpportunityDocument = {
128
+ type: string; // passport, driving_license, ...
129
+ displayName: string;
130
+ file: AttachmentValue;
131
+ };
132
+
73
133
  export type Opportunity = BaseOpportunity & {
74
134
  id: string;
75
135
  createdAt: string;
76
136
  createdBy: string;
77
137
  modifiedAt: string;
78
138
  modifiedBy: string;
139
+ lostAt?: string;
140
+ lostBy?: string;
141
+ lostReason?: OpportunityLostReasonValues;
142
+ deliveredAt?: string;
143
+ deliveredBy?: string;
144
+ status: OpportunityStatus;
145
+ dealStatus?: OpportunityDealStatus;
146
+ logisticStatus?: OpportunityLogisticStatus;
147
+ activeQuoteId?: string;
148
+ contractId?: string;
149
+ amount?: string;
150
+ interest?: Interest;
151
+ documents?: OpportunityDocument[];
152
+ };
153
+
154
+ export type OpportunityUpdate = {
155
+ vehicleId?: string | null;
156
+ accountManager?: string;
157
+ contactId?: string | null;
158
+ activeQuoteId?: string;
159
+ interest?: Interest | null;
160
+ lost?: boolean;
161
+ lostReason?: OpportunityLostReasonValues;
162
+ delivered?: boolean;
163
+ documents?: OpportunityDocument[];
164
+ };
165
+
166
+ export type OpportunityBFF = {
167
+ opportunity: DataRecord<Opportunity>;
168
+ vehicle?: DataRecord<Vehicle>;
169
+ bids: DataRecord<Bid>[];
170
+ quotes: DataRecord<Quote>[];
171
+ customer?: {
172
+ contact: DataRecord<Contact>;
173
+ org?: DataRecord<Organization>;
174
+ };
175
+ };
176
+
177
+ export type OpportunityEvent = {
178
+ opportunity: Opportunity;
179
+ action: 'create' | 'update' | 'delete';
180
+ actionAt: string;
181
+ userId: string;
182
+ tenantId: string;
79
183
  };
@@ -18,6 +18,7 @@ export type Tenant = PublicTenant & {
18
18
  emailDomain: string;
19
19
  hyperdmsIds?: string[];
20
20
  hyperportalId?: string;
21
+ exactAccounting?: boolean;
21
22
  };
22
23
 
23
24
  export type HdmsVehiclesSync = {
@@ -40,7 +40,8 @@ export type AdHocRecordTitles = {
40
40
  };
41
41
  };
42
42
 
43
- export type MetaRecord<T> = {
43
+ export type DataRecord<T, M = undefined> = {
44
44
  record: T;
45
- meta: ReferenceData;
45
+ meta?: M; // typically ReferenceData
46
+ actions: string[];
46
47
  };
@@ -64,6 +64,7 @@ export type VehicleInternalInfo = {
64
64
  currency?: string;
65
65
  };
66
66
  status: VehicleStatus;
67
+ openOpportunitiesCount: number;
67
68
  updatedAt: string;
68
69
  };
69
70