@bisondesk/core-sdk 1.0.553 → 1.0.555

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.
@@ -11,7 +11,7 @@ import {
11
11
  import { BaseEvent } from './internal-events.js';
12
12
  import { VehicleSaleLogisticsStatus } from './opportunities.js';
13
13
  import { OpportunityReservation } from './reservations.js';
14
- import { DataRecord } from './utils.js';
14
+ import { DataRecord, ReferenceData } from './utils.js';
15
15
  import { VehicleBusinessOverviewXL } from './vehicle-performance.js';
16
16
  import { VehicleSaleInfo } from './vehicle-sales.js';
17
17
 
@@ -165,7 +165,7 @@ export type NewVehicleRequest = {
165
165
  bonus?: string;
166
166
  };
167
167
  logistics: {
168
- availableDate: string;
168
+ availableDate?: string;
169
169
  vehicleRole: VehicleRoles;
170
170
  };
171
171
  };
@@ -278,6 +278,12 @@ export type InputSearchVehicle = SearchVehicle & {
278
278
  permissions?: SearchPermissions;
279
279
  };
280
280
 
281
+ export type VehicleSearchMeta = ReferenceData & {
282
+ matchingOffers?: {
283
+ count: number;
284
+ };
285
+ };
286
+
281
287
  export type PriceChangeEvent = BaseEvent & {
282
288
  tenantId: string;
283
289
  userId: string;
@@ -1,6 +1,11 @@
1
1
  import { UTCDate } from '@date-fns/utc';
2
2
  import { format } from 'date-fns';
3
+ import { Decimal } from 'decimal.js';
3
4
  import { last, map, sortBy, uniqBy } from 'lodash-es';
5
+ import {
6
+ CustomLeasingQuoteExtraInput,
7
+ LeasingItemsPaymentSplit,
8
+ } from '../types/leasing-settings.js';
4
9
  import {
5
10
  ConditionsRef,
6
11
  LeasingContract,
@@ -24,3 +29,31 @@ export const getDealRef = ({
24
29
  opportunities,
25
30
  }: Pick<LeasingContract, 'conditions' | 'opportunities'>): ConditionsRef | OpportunityRef =>
26
31
  last(conditions) ?? last(opportunities)!;
32
+
33
+ export const getItemClientPercentage = (value: LeasingItemsPaymentSplit): Decimal => {
34
+ switch (value) {
35
+ case LeasingItemsPaymentSplit.Company:
36
+ return new Decimal(0);
37
+ case LeasingItemsPaymentSplit.Split:
38
+ return new Decimal(50);
39
+ case LeasingItemsPaymentSplit.Customer:
40
+ default:
41
+ return new Decimal(100);
42
+ }
43
+ };
44
+
45
+ export const getLeasingExtrasTotal = (extras: CustomLeasingQuoteExtraInput[]) => {
46
+ let total = new Decimal(0);
47
+ for (const extra of extras) {
48
+ if (new Decimal(extra!.leasingPercentage).lt(100)) {
49
+ const leasingRatio = new Decimal(1).sub(new Decimal(extra!.leasingPercentage).div(100));
50
+ const paymentSplitRatio = getItemClientPercentage(extra!.paymentSplit).div(100);
51
+ const extraAgreedPrice = new Decimal(extra!.agreedPrice)
52
+ .mul(extra!.quantity)
53
+ .mul(paymentSplitRatio)
54
+ .mul(leasingRatio);
55
+ total = total.add(extraAgreedPrice);
56
+ }
57
+ }
58
+ return total;
59
+ };