@bisondesk/core-sdk 1.0.367 → 1.0.369

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/src/types/crm.ts CHANGED
@@ -7,6 +7,14 @@ import {
7
7
  import { PublicSearchDefinition } from './definitions.js';
8
8
  import { ReferenceData } from './utils.js';
9
9
 
10
+ export enum OrganizatioRiskTags {
11
+ BAD_FINANCIAL_INFO = 'BAD_FINANCIAL_INFO',
12
+ VAT_NUMBER_INVALID = 'VAT_NUMBER_INVALID',
13
+ INSTINCT = 'INSTINCT',
14
+ NEW_CUSTOMER = 'NEW_CUSTOMER',
15
+ BANK_ACCOUNT_BLOCKED = 'BANK_ACCOUNT_BLOCKED',
16
+ }
17
+
10
18
  export type CrmEvent = CrmOrganizationEvent | CrmContactEvent;
11
19
 
12
20
  export type CrmContactEvent = {
@@ -8,6 +8,7 @@ export type SimilarVehiclesRequest = {
8
8
 
9
9
  export type InsightsSimilarRequest = {
10
10
  comparable: InsightsComparableSpecs;
11
+ excludeVehicleIds?: string[];
11
12
  limit: number;
12
13
  nextToken?: string;
13
14
  };
@@ -23,9 +24,7 @@ export type InsightsVehicleComparableResponse = {
23
24
  };
24
25
 
25
26
  // here we are considering only specs that we can use to filter Market vehicles
26
- export interface InsightsComparableSpecs extends ComparableSpecs {
27
- vehicleId: string;
28
- }
27
+ export interface InsightsComparableSpecs extends ComparableSpecs {}
29
28
 
30
29
  export type InsightsOptions = {
31
30
  months?: number;
@@ -0,0 +1,274 @@
1
+ import { DistributiveOmit, Document, NextList } from '@bisondesk/commons-sdk/types';
2
+ import { BusinessEntityIds, WarningHints } from '../constants.js';
3
+ import { Contact, Organization } from './crm.js';
4
+ import { Insights, InsightsComparableSpecs } from './insights.js';
5
+ import { ContactMetdata } from './opportunities.js';
6
+ import { BaseSearchRequest } from './search.js';
7
+ import { DataRecord, ReferenceData } from './utils.js';
8
+ import { VehicleExternalInfo } from './vehicles.js';
9
+
10
+ export enum OfferActions {
11
+ CREATE_BID = 'create_bid',
12
+ SET_FINAL_VALUATION = 'set_final_valuation',
13
+ LOSE = 'lose',
14
+ REOPEN = 'reopen',
15
+ SET_DOCUMENTS = 'set_documents',
16
+ SET_METADATA = 'set_metadata',
17
+ SEE_SUPPLIER = 'see_supplier',
18
+ SEE_INSIGHTS = 'see_insights',
19
+ VIEW_BIDS = 'view_bids',
20
+ SEE_ASKING_PRICE = 'see_asking_price',
21
+ ACCEPT_NEGOTIATION = 'accept_negotiation',
22
+ UNDO_ACCEPT_NEGOTIATION = 'undo_accept_negotiation',
23
+ SET_SUPPLIER_VEHICLE = 'set_supplier_vehicle',
24
+ }
25
+
26
+ export enum OfferBidActions {
27
+ EDIT_BID = 'create_bid',
28
+ DELETE_BID = 'delete_bid',
29
+ }
30
+
31
+ export enum OfferStatus {
32
+ PROSPECTION = 'prospection', // initial status
33
+ VALUATION = 'valuation', // has at least one internal or external bid with bid amount > 0
34
+ NEGOTIATION = 'negotiation', // there is a final valuation, purchaser is talking to the supplier
35
+ }
36
+
37
+ export enum OfferLostReasonValues {
38
+ Expensive = 'expensive',
39
+ NoMarket = 'no_market',
40
+ BadExperience = 'bad_experience',
41
+ NoAnswer = 'supplier_mia',
42
+ Automatic = 'automatic',
43
+ }
44
+
45
+ export enum OfferBidType {
46
+ INTERNAL = 'internal',
47
+ EXTERNAL = 'external',
48
+ }
49
+
50
+ export enum OfferWarningsCode {
51
+ NO_SUPPLIER = 'no_supplier',
52
+ }
53
+
54
+ export const OfferStatusOrder: OfferStatus[] = [
55
+ OfferStatus.PROSPECTION,
56
+ OfferStatus.VALUATION,
57
+ OfferStatus.NEGOTIATION,
58
+ ];
59
+
60
+ export const OfferWonColumnId = 'closed_won';
61
+
62
+ export const OfferKanbanColumns = [...OfferStatusOrder, OfferWonColumnId];
63
+
64
+ export const OfferKanbanEndColumns: string[] = [OfferWonColumnId];
65
+
66
+ type BaseOffer = {
67
+ branchId: string;
68
+ availableWeek?: string; // ISOWEEK, e.g. 2016-W02
69
+ askingPrice?: string;
70
+ currency?: string;
71
+ quantity: number;
72
+ specs: VehicleExternalInfo;
73
+ documents: Document[];
74
+ source?: string; // e.g., website, email, visit
75
+ contactId: string;
76
+ organizationId?: string;
77
+
78
+ supplierNotes?: string; // Optional notes from the supplier
79
+ };
80
+
81
+ export type NewOffer = BaseOffer & {
82
+ id?: undefined;
83
+ createdAt?: undefined;
84
+ createdBy?: undefined;
85
+ modifiedAt?: undefined;
86
+ modifiedBy?: undefined;
87
+ };
88
+
89
+ export type Offer = BaseOffer & {
90
+ id: string;
91
+ accountManager?: string; // optional since some offers might come directly from the internet
92
+ createdAt: string;
93
+ createdBy: string;
94
+ modifiedAt: string;
95
+ modifiedBy: string;
96
+ firstBidAt?: string;
97
+
98
+ lostReason?: OfferLostReasonValues;
99
+ status: OfferStatus;
100
+ quantity: number;
101
+
102
+ appPrice?: string;
103
+ appAvailability: boolean;
104
+
105
+ wonAt?: string;
106
+ wonBy?: string;
107
+ lostAt?: string;
108
+ lostBy?: string;
109
+
110
+ valuation?: { amount: string; valuationAt: string; valuationBy: string };
111
+
112
+ agreedAt?: string;
113
+ agreedBy?: string;
114
+ };
115
+
116
+ export type OfferUpdate = {
117
+ accountManager?: string | null;
118
+ branchId?: string | null;
119
+ supplierNotes?: string | null;
120
+ contactId?: string | null;
121
+ organizationId?: string | null;
122
+ lost?: boolean;
123
+ lostReason?: OfferLostReasonValues;
124
+ source?: string;
125
+ askingPrice?: string;
126
+ currency?: string;
127
+ quantity?: number;
128
+ specs?: VehicleExternalInfo;
129
+ addNewBid?: boolean;
130
+ documents?: Document[];
131
+ appAvailability?: boolean;
132
+
133
+ finalValuation?: string;
134
+ agreed?: boolean;
135
+ };
136
+
137
+ type OfferWarningActionLink = {
138
+ businessEntityId: BusinessEntityIds;
139
+ recordId: string;
140
+ };
141
+
142
+ type OfferWarningActionData = { [key: string]: string | number };
143
+
144
+ export type OfferWarning = {
145
+ code: OfferWarningsCode;
146
+ level: WarningHints;
147
+ link?: OfferWarningActionLink;
148
+ data?: OfferWarningActionData;
149
+ showAction?: boolean;
150
+ };
151
+
152
+ export type OfferMetadata = {
153
+ insights: {
154
+ online: Pick<Insights['online'], 'count' | 'percentilesDays' | 'percentilesPrices'>;
155
+ sold: Pick<Insights['sold'], 'count' | 'percentilesPrices' | 'percentilesDays'>;
156
+ };
157
+ stock: {
158
+ available: number;
159
+ leads: number;
160
+ };
161
+ comparable: InsightsComparableSpecs;
162
+ warnings: OfferWarning[];
163
+ };
164
+
165
+ export type OfferBff = {
166
+ offer: DataRecord<Offer, OfferMetadata>;
167
+ bids: DataRecord<OfferBid>[];
168
+ customer?: {
169
+ contact: DataRecord<Contact>;
170
+ org?: DataRecord<Organization>;
171
+ };
172
+ };
173
+
174
+ /************
175
+ *
176
+ * Bids
177
+ */
178
+
179
+ type BaseOfferBid = {
180
+ id: string;
181
+ createdAt: string;
182
+ createdBy: string;
183
+ modifiedAt: string;
184
+ modifiedBy: string;
185
+ offerId: string;
186
+ amount: string;
187
+ currency: string;
188
+ description?: string;
189
+ deleted: boolean;
190
+ };
191
+
192
+ export type InternalOfferBid = BaseOfferBid & {
193
+ userId: string;
194
+ final?: boolean; // Optional flag to indicate if this is the final valuation
195
+ type: OfferBidType.INTERNAL;
196
+ };
197
+
198
+ export type ExternalOfferBid = BaseOfferBid & {
199
+ contactId: string;
200
+ organizationId: string;
201
+ notes?: string;
202
+ type: OfferBidType.EXTERNAL;
203
+ };
204
+
205
+ export type OfferBid = InternalOfferBid | ExternalOfferBid;
206
+
207
+ export type NewOfferBid = DistributiveOmit<
208
+ OfferBid,
209
+ 'id' | 'createdAt' | 'createdBy' | 'modifiedAt' | 'modifiedBy' | 'deleted'
210
+ >;
211
+
212
+ export type InternalOfferBidUpdate = {
213
+ amount?: string | null;
214
+ currency?: string | null;
215
+ description?: string | null;
216
+ };
217
+
218
+ /************
219
+ *
220
+ * Search
221
+ */
222
+
223
+ export type SearchOffer = {
224
+ contact?: Contact;
225
+ offer: Offer;
226
+ org?: Organization;
227
+ custom: {
228
+ lost: boolean;
229
+ status: OfferStatus | 'won';
230
+ totalBids: number;
231
+ };
232
+ };
233
+
234
+ export type AppOffer = {
235
+ id: string;
236
+ branchId: string;
237
+ createdAt: string;
238
+ unavailableAt?: string;
239
+
240
+ availableWeek?: string;
241
+ appPrice?: string;
242
+ currency?: string;
243
+ quantity: number;
244
+
245
+ specs: VehicleExternalInfo;
246
+ };
247
+
248
+ /************
249
+ *
250
+ * Kanban
251
+ */
252
+
253
+ export type OffersKanbanColumn = {
254
+ status: string;
255
+ results: SearchOffer[];
256
+ totalCount: number;
257
+ totalValue: string;
258
+ };
259
+
260
+ export type MSearchOffersKanbanColumn = {
261
+ column: OffersKanbanColumn;
262
+ nextToken?: string;
263
+ };
264
+
265
+ export type KanbanOffersSearchRequest = BaseSearchRequest & {
266
+ nextTokens?: Record<string, string | undefined>;
267
+ };
268
+
269
+ export type KanbanOffersNextList = Omit<
270
+ NextList<OffersKanbanColumn, ReferenceData>,
271
+ 'nextToken'
272
+ > & {
273
+ nextTokens?: Record<string, string | undefined>;
274
+ };
@@ -68,8 +68,13 @@ export type HdmsCrmSync = {
68
68
  active: boolean;
69
69
  };
70
70
 
71
+ export type HdmsDocumentSync = {
72
+ active: boolean;
73
+ };
74
+
71
75
  export type TenantSyncSettings = {
72
76
  tenantId: string;
73
77
  hdmsVehicles: HdmsVehiclesSync | undefined;
74
78
  hdmsCrm: HdmsCrmSync | undefined;
79
+ hdmsDocuments: HdmsDocumentSync | undefined;
75
80
  };
@@ -5,6 +5,7 @@ import {
5
5
  MultiLangValue,
6
6
  SearchPermissions,
7
7
  ShareEmailRequest,
8
+ ShareWhatsappRequest,
8
9
  } from '@bisondesk/commons-sdk/types';
9
10
  import { OpportunityReservation } from './reservations.js';
10
11
 
@@ -673,3 +674,8 @@ export type VehicleReservationEvent =
673
674
  | VehicleReservationCreateEvent
674
675
  | VehicleReservationUpdateEvent
675
676
  | VehicleReservationDeleteEvent;
677
+
678
+ export type ShareVehicleViaWahtsappRequest = {
679
+ data: ShareWhatsappRequest;
680
+ vehicleId: string;
681
+ };
@@ -0,0 +1,42 @@
1
+ import { OfferStatus, OfferStatusOrder } from '../types/offers.js';
2
+
3
+ type CompareInput = {
4
+ currentStatus: OfferStatus;
5
+ referenceStatus: OfferStatus;
6
+ };
7
+
8
+ const compareOfferStatus = (input: CompareInput) => {
9
+ const { currentStatus, referenceStatus } = input;
10
+
11
+ const currentStatusIdx = OfferStatusOrder.indexOf(currentStatus);
12
+ const referenceStatusIdx = OfferStatusOrder.indexOf(referenceStatus);
13
+
14
+ return {
15
+ currentStatusIdx,
16
+ referenceStatusIdx,
17
+ };
18
+ };
19
+
20
+ export const isSameOrAfterReferenceOfferStatus = (input: CompareInput): boolean => {
21
+ const { currentStatusIdx, referenceStatusIdx } = compareOfferStatus(input);
22
+
23
+ return currentStatusIdx >= referenceStatusIdx;
24
+ };
25
+
26
+ export const isAfterReferenceOfferStatus = (input: CompareInput): boolean => {
27
+ const { currentStatusIdx, referenceStatusIdx } = compareOfferStatus(input);
28
+
29
+ return currentStatusIdx > referenceStatusIdx;
30
+ };
31
+
32
+ export const isSameOrBeforeReferenceOfferStatus = (input: CompareInput): boolean => {
33
+ const { currentStatusIdx, referenceStatusIdx } = compareOfferStatus(input);
34
+
35
+ return currentStatusIdx <= referenceStatusIdx;
36
+ };
37
+
38
+ export const isBeforeReferenceOfferStatus = (input: CompareInput): boolean => {
39
+ const { currentStatusIdx, referenceStatusIdx } = compareOfferStatus(input);
40
+
41
+ return currentStatusIdx < referenceStatusIdx;
42
+ };