@bisondesk/core-sdk 1.0.370 → 1.0.372

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 (40) hide show
  1. package/lib/apis/crm.d.ts.map +1 -1
  2. package/lib/apis/debtors.d.ts.map +1 -1
  3. package/lib/apis/internet-vehicles.d.ts.map +1 -1
  4. package/lib/apis/leasing-administration.d.ts.map +1 -1
  5. package/lib/apis/leasing.d.ts.map +1 -1
  6. package/lib/apis/opportunities.d.ts.map +1 -1
  7. package/lib/apis/tenants.d.ts.map +1 -1
  8. package/lib/apis/users.d.ts.map +1 -1
  9. package/lib/apis/vehicle-sales.d.ts +5 -0
  10. package/lib/apis/vehicle-sales.d.ts.map +1 -0
  11. package/lib/apis/vehicle-sales.js +32 -0
  12. package/lib/apis/vehicle-sales.js.map +1 -0
  13. package/lib/apis/vehicles.d.ts.map +1 -1
  14. package/lib/constants.d.ts +2 -2
  15. package/lib/constants.d.ts.map +1 -1
  16. package/lib/constants.js +2 -2
  17. package/lib/constants.js.map +1 -1
  18. package/lib/types/interests.d.ts.map +1 -1
  19. package/lib/types/offers.d.ts.map +1 -1
  20. package/lib/types/offers.js.map +1 -1
  21. package/lib/types/opportunities.d.ts +11 -11
  22. package/lib/types/opportunities.d.ts.map +1 -1
  23. package/lib/types/opportunities.js +11 -11
  24. package/lib/types/opportunities.js.map +1 -1
  25. package/lib/types/vehicle-sales.d.ts +76 -0
  26. package/lib/types/vehicle-sales.d.ts.map +1 -0
  27. package/lib/types/vehicle-sales.js +6 -0
  28. package/lib/types/vehicle-sales.js.map +1 -0
  29. package/lib/types/vehicles.d.ts +13 -15
  30. package/lib/types/vehicles.d.ts.map +1 -1
  31. package/lib/types/vehicles.js +6 -12
  32. package/lib/types/vehicles.js.map +1 -1
  33. package/package.json +2 -2
  34. package/src/apis/vehicle-sales.ts +48 -0
  35. package/src/constants.ts +2 -2
  36. package/src/types/offers.ts +0 -1
  37. package/src/types/opportunities.ts +13 -13
  38. package/src/types/vehicle-sales.ts +80 -0
  39. package/src/types/vehicles.ts +14 -17
  40. package/tsconfig.tsbuildinfo +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bisondesk/core-sdk",
3
- "version": "1.0.370",
3
+ "version": "1.0.372",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -21,7 +21,7 @@
21
21
  "devDependencies": {
22
22
  "@types/lodash-es": "4.17.12",
23
23
  "@types/node": "20.11.24",
24
- "typescript": "5.4.4"
24
+ "typescript": "5.5.2"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@bisondesk/commons-sdk": "*"
@@ -0,0 +1,48 @@
1
+ import {
2
+ ExternalVehicleSale,
3
+ NewExternalVehicleSale,
4
+ VehicleSaleInfo,
5
+ } from '../types/vehicle-sales.js';
6
+ import { TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/constants';
7
+ import { fetchJson, getAdminAuth } from '@bisondesk/commons-sdk/fetch';
8
+
9
+ export const getVehicleSaleInfo = async (
10
+ tenantId: string,
11
+ vehicleId: string
12
+ ): Promise<VehicleSaleInfo | undefined> => {
13
+ const auth = await getAdminAuth();
14
+ return fetchJson(`${process.env.CORE_API_ORIGIN}/api/vehicle-sales/${vehicleId}`, {
15
+ headers: {
16
+ Authorization: auth,
17
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
18
+ },
19
+ });
20
+ };
21
+
22
+ export const getExternalVehicleSale = async (
23
+ tenantId: string,
24
+ saleId: string
25
+ ): Promise<ExternalVehicleSale | undefined> => {
26
+ const auth = await getAdminAuth();
27
+ return fetchJson(`${process.env.CORE_API_ORIGIN}/api/external-sales/${saleId}`, {
28
+ headers: {
29
+ Authorization: auth,
30
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
31
+ },
32
+ });
33
+ };
34
+
35
+ export const saveExternalVehicleSale = async (
36
+ tenantId: string,
37
+ data: NewExternalVehicleSale
38
+ ): Promise<ExternalVehicleSale | undefined> => {
39
+ const auth = await getAdminAuth();
40
+ return fetchJson(`${process.env.CORE_API_ORIGIN}/api/external-sales`, {
41
+ method: 'POST',
42
+ headers: {
43
+ Authorization: auth,
44
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
45
+ },
46
+ body: JSON.stringify(data),
47
+ });
48
+ };
package/src/constants.ts CHANGED
@@ -11,15 +11,15 @@ export const TIMEZONES_PICKLIST_ID = 'timezones';
11
11
  export const COUNTRIES_PICKLIST_ID = 'countries';
12
12
  export const VEHICLE_MAIN_FEATURES_PICKLIST_ID = 'vehicleMainFeatures';
13
13
  export const VEHICLE_STATE_FILTERS_PICKLIST_ID = 'vehicleStateFilters';
14
+ export const VEHICLE_SEARCH_SALE_DEAL_STATUS_PICKLIST_ID = 'vehicleSearchSaleDealStatus';
14
15
  export const VEHICLE_SALE_DEAL_STATUS_PICKLIST_ID = 'vehicleSaleDealStatus';
16
+ export const VEHICLE_SALE_LOGISTICS_STATUS_PICKLIST_ID = 'vehicleSaleLogisticsStatus';
15
17
  export const VEHICLE_ROLES_PICKLIST_ID = 'vehicleRoles';
16
18
  export const MARKETING_PLATFORMS_PICKLIST_ID = 'marketingPlatforms';
17
19
  export const OFFER_STATUS_PICKLIST_ID = 'offerStatus';
18
20
  export const OFFER_SOURCE_PICKLIST_ID = 'offerSource';
19
21
  export const OPPORTUNITY_STATUS_PICKLIST_ID = 'opportunityStatus';
20
- export const OPPORTUNITY_DEAL_STATUS_PICKLIST_ID = 'opportunityDealStatus';
21
22
  export const OPPORTUNITY_PAYMENT_STATUS_PICKLIST_ID = 'opportunityPaymentStatus';
22
- export const OPPORTUNITY_LOGISTIC_STATUS_PICKLIST_ID = 'opportunityLogisticStatus';
23
23
  export const OPPORTUNITY_SOURCE_PICKLIST_ID = 'opportunity_source';
24
24
  export const ORGANIZATION_RISK_TAGS_PICKLIST_ID = 'organizationRiskTags';
25
25
  export const DEPARTMENT_PICKLIST_ID = 'department';
@@ -2,7 +2,6 @@ import { DistributiveOmit, Document, NextList } from '@bisondesk/commons-sdk/typ
2
2
  import { BusinessEntityIds, WarningHints } from '../constants.js';
3
3
  import { Contact, Organization } from './crm.js';
4
4
  import { Insights, InsightsComparableSpecs } from './insights.js';
5
- import { ContactMetdata } from './opportunities.js';
6
5
  import { BaseSearchRequest } from './search.js';
7
6
  import { DataRecord, ReferenceData } from './utils.js';
8
7
  import { VehicleExternalInfo } from './vehicles.js';
@@ -32,12 +32,6 @@ export enum OpportunityActions {
32
32
  ISSUE_INVOICE = 'issue_invoice',
33
33
  }
34
34
 
35
- export enum OpportunityDealStatus {
36
- SALES_AGREED = 'sales_agreed',
37
- FIRST_PAYMENT = 'first_payment',
38
- FULL_PAYMENT = 'full_payment',
39
- }
40
-
41
35
  export enum OpportunityPaymentStatus {
42
36
  PARTIAL_PAYMENT = 'partial_payment',
43
37
  FULL_PAYMENT = 'full_payment',
@@ -62,11 +56,6 @@ export const OpportunityStatusOrder: OpportunityStatus[] = [
62
56
  OpportunityStatus.DELIVERY,
63
57
  ];
64
58
 
65
- export enum OpportunityLogisticStatus {
66
- AT_ORIGIN = 'at_origin',
67
- DELIVERED = 'delivered',
68
- }
69
-
70
59
  export enum OpportunityRequirementsCode {
71
60
  VEHICLE_AT_ORIGIN = 'vehicle_at_origin',
72
61
  LEASING_SL_ACTION = 'sl_action',
@@ -139,6 +128,17 @@ export type NewOpportunity = BaseOpportunity & {
139
128
  modifiedBy?: undefined;
140
129
  };
141
130
 
131
+ export enum VehicleSaleDealStatus {
132
+ SaleAgreed = 'SALE_AGREED',
133
+ FirstPaymentReceived = 'FIRST_PAYMENT_RECEIVED',
134
+ FullPaymentReceived = 'FULL_PAYMENT_RECEIVED',
135
+ }
136
+
137
+ export enum VehicleSaleLogisticsStatus {
138
+ AtOrigin = 'AT_ORIGIN',
139
+ Delivered = 'DELIVERED',
140
+ }
141
+
142
142
  export type Opportunity = BaseOpportunity & {
143
143
  id: string;
144
144
  createdAt: string;
@@ -164,8 +164,8 @@ export type Opportunity = BaseOpportunity & {
164
164
  deliveredAt?: string;
165
165
  deliveredBy?: string;
166
166
  status: OpportunityStatus;
167
- dealStatus?: OpportunityDealStatus;
168
- logisticStatus?: OpportunityLogisticStatus;
167
+ dealStatus?: VehicleSaleDealStatus;
168
+ logisticStatus?: VehicleSaleLogisticsStatus;
169
169
  activeQuoteId?: string;
170
170
  amount?: string;
171
171
  documents?: Document[];
@@ -0,0 +1,80 @@
1
+ import { LocationValue } from '@bisondesk/commons-sdk/locations';
2
+ import { Organization } from './crm.js';
3
+ import { Opportunity, VehicleSaleDealStatus, VehicleSaleLogisticsStatus } from './opportunities.js';
4
+ import { DeliveryTypes, Quote } from './quotes.js';
5
+ import { DataRecord } from './utils.js';
6
+
7
+ export enum VehicleSaleInfoActions {
8
+ VIEW_COSTS = 'canSeeCosts',
9
+ VIEW_CUSTOMER = 'canSeeCustomer',
10
+ }
11
+
12
+ export type VehicleSaleInfo = {
13
+ externalSaleId?: string;
14
+ opportunityId?: string;
15
+ sold: boolean;
16
+ soldAt?: string;
17
+ soldBy?: string;
18
+ dealStatus: VehicleSaleDealStatus;
19
+ logisticStatus: VehicleSaleLogisticsStatus;
20
+ };
21
+
22
+ export type VehicleSaleInfoBff = {
23
+ info: DataRecord<VehicleSaleInfo>;
24
+ opportunitySale?: {
25
+ opportunity: Opportunity;
26
+ activeQuote: Quote;
27
+ };
28
+ externalSale?: ExternalVehicleSale;
29
+ client?: Organization;
30
+ delivery?: {
31
+ address?: LocationValue;
32
+ type: DeliveryTypes;
33
+ };
34
+ };
35
+
36
+ type BaseExternalVehicleSale = {
37
+ log?: {
38
+ deliveredDate?: string;
39
+ deliveredReporter?: string;
40
+ saleAgreedDate?: string;
41
+ saleAgreedReporter?: string;
42
+ firstPaymentReceivedDate?: string;
43
+ firstPaymentReceivedReporter?: string;
44
+ fullPaymentReceivedDate?: string;
45
+ fullPaymentReceivedReporter?: string;
46
+ deletedDate?: string;
47
+ deletedReporter?: string;
48
+ };
49
+ source: 'HDMS' | 'Hexon';
50
+ deleted?: boolean;
51
+ status: VehicleSaleDealStatus;
52
+ vehicleId: string;
53
+ saleAmount?: number;
54
+ totalRevenue?: number;
55
+ vatPercentage?: number;
56
+ logisticsStatus: VehicleSaleLogisticsStatus;
57
+ saleAmountTaxable?: number;
58
+ organizationSummary?: {
59
+ contactId: string;
60
+ organizationId: string;
61
+ };
62
+ deal?: {
63
+ internalTransportCost?: number;
64
+ externalTransportCost?: number;
65
+ internalGarageCost?: number;
66
+ externalGarageCost?: number;
67
+ carwashCost?: number;
68
+ spoilerMountingCost?: number;
69
+ loadStackCost?: number;
70
+ otherCosts?: number;
71
+ };
72
+ };
73
+
74
+ export type ExternalVehicleSale = BaseExternalVehicleSale & {
75
+ id: string;
76
+ createdAt: string;
77
+ createdBy: string;
78
+ };
79
+
80
+ export type NewExternalVehicleSale = BaseExternalVehicleSale;
@@ -183,9 +183,16 @@ export type PublicSearchVehicle = {
183
183
  vehicle: PublicVehicle;
184
184
  };
185
185
 
186
+ export enum SearchVehicleSaleDealStatus {
187
+ NotSold = 'NOT_SOLD',
188
+ Reserved = 'RESERVED',
189
+ Sold = 'SOLD',
190
+ }
191
+
186
192
  export type SearchVehicle = {
187
193
  custom: {
188
194
  features: string[];
195
+ sold: boolean;
189
196
  isReserved: boolean;
190
197
  hasPayments: boolean;
191
198
  };
@@ -194,6 +201,13 @@ export type SearchVehicle = {
194
201
  };
195
202
  reservation?: Pick<OpportunityReservation, 'expiresAt' | 'opportunityId' | 'createdBy'>;
196
203
  vehicle: Vehicle;
204
+ sale: {
205
+ opportunityId?: string;
206
+ externalSaleId?: string;
207
+ soldAt?: string;
208
+ soldBy?: string;
209
+ dealStatus: SearchVehicleSaleDealStatus;
210
+ };
197
211
  };
198
212
 
199
213
  export type InputSearchVehicle = SearchVehicle & {
@@ -486,13 +500,6 @@ export type VehicleMarketing = {
486
500
  };
487
501
  };
488
502
 
489
- export enum VehicleSaleDealStatus {
490
- SaleAgreed = 'SALE_AGREED',
491
- FirstPaymentReceived = 'FIRST_PAYMENT_RECEIVED',
492
- FullPaymentReceived = 'FULL_PAYMENT_RECEIVED',
493
- NotSold = 'NOT_SOLD',
494
- }
495
-
496
503
  export enum VehiclePurchaseDealStatus {
497
504
  PurchaseEvaluation = 'PURCHASE_EVALUATION', // used for vehicle consignation
498
505
  PurchaseAgreed = 'PURCHASE_AGREED',
@@ -502,11 +509,6 @@ export enum VehiclePurchaseDealStatus {
502
509
  FullPaymentSent = 'FULL_PAYMENT_SENT',
503
510
  }
504
511
 
505
- export enum VehicleSaleLogisticsStatus {
506
- AtOrigin = 'AT_ORIGIN',
507
- Delivered = 'DELIVERED',
508
- }
509
-
510
512
  export enum VehiclePurchaseLogisticsStatus {
511
513
  AtOrigin = 'AT_ORIGIN',
512
514
  Arrived = 'ARRIVED',
@@ -520,11 +522,6 @@ export enum VehiclePurchaseDeliveryType {
520
522
 
521
523
  export type VehicleStatus = {
522
524
  deleted?: boolean;
523
- sale: {
524
- id?: string;
525
- dealStatus: VehicleSaleDealStatus;
526
- logisticsStatus?: VehicleSaleLogisticsStatus;
527
- };
528
525
  purchase: {
529
526
  purchasedBy?: string;
530
527
  dealStatus: VehiclePurchaseDealStatus;