@bisondesk/core-sdk 1.0.552 → 1.0.554
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/lib/apis/insights.d.ts +5 -1
- package/lib/apis/insights.d.ts.map +1 -1
- package/lib/apis/insights.js +18 -0
- package/lib/apis/insights.js.map +1 -1
- package/lib/constants.d.ts +1 -0
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +1 -0
- package/lib/constants.js.map +1 -1
- package/lib/types/offers.d.ts +16 -4
- package/lib/types/offers.d.ts.map +1 -1
- package/lib/types/offers.js +12 -3
- package/lib/types/offers.js.map +1 -1
- package/lib/types/vehicles.d.ts +6 -1
- package/lib/types/vehicles.d.ts.map +1 -1
- package/lib/types/vehicles.js.map +1 -1
- package/lib/utils/leasing.d.ts +4 -0
- package/lib/utils/leasing.d.ts.map +1 -1
- package/lib/utils/leasing.js +28 -0
- package/lib/utils/leasing.js.map +1 -1
- package/package.json +1 -1
- package/src/apis/insights.ts +28 -1
- package/src/constants.ts +1 -0
- package/src/types/activities.js +13 -0
- package/src/types/activities.js.map +1 -0
- package/src/types/comparables.js +2 -0
- package/src/types/comparables.js.map +1 -0
- package/src/types/crm.js +58 -0
- package/src/types/crm.js.map +1 -0
- package/src/types/dashboard.js +2 -0
- package/src/types/dashboard.js.map +1 -0
- package/src/types/definitions.js +2 -0
- package/src/types/definitions.js.map +1 -0
- package/src/types/fields.js +2 -0
- package/src/types/fields.js.map +1 -0
- package/src/types/insights.js +2 -0
- package/src/types/insights.js.map +1 -0
- package/src/types/interests.js +6 -0
- package/src/types/interests.js.map +1 -0
- package/src/types/internal-events.js +18 -0
- package/src/types/internal-events.js.map +1 -0
- package/src/types/internet-opportunities.js +2 -0
- package/src/types/internet-opportunities.js.map +1 -0
- package/src/types/internet-vehicles.js +2 -0
- package/src/types/internet-vehicles.js.map +1 -0
- package/src/types/leasing-administration.js +2 -0
- package/src/types/leasing-administration.js.map +1 -0
- package/src/types/leasing-debtors.js +2 -0
- package/src/types/leasing-debtors.js.map +1 -0
- package/src/types/leasing-search.js +2 -0
- package/src/types/leasing-search.js.map +1 -0
- package/src/types/leasing-settings.js +7 -0
- package/src/types/leasing-settings.js.map +1 -0
- package/src/types/leasing.js +38 -0
- package/src/types/leasing.js.map +1 -0
- package/src/types/marketing.js +35 -0
- package/src/types/marketing.js.map +1 -0
- package/src/types/offers.js +56 -0
- package/src/types/offers.ts +24 -5
- package/src/types/opportunities.js +107 -0
- package/src/types/opportunities.js.map +1 -0
- package/src/types/payments.js +7 -0
- package/src/types/picklists.js +2 -0
- package/src/types/picklists.js.map +1 -0
- package/src/types/quotes.js +42 -0
- package/src/types/recently-viewed.js +2 -0
- package/src/types/recently-viewed.js.map +1 -0
- package/src/types/reservations.js +5 -0
- package/src/types/reservations.js.map +1 -0
- package/src/types/roi-ratings.js +5 -0
- package/src/types/roi-ratings.js.map +1 -0
- package/src/types/saved-filters.js +9 -0
- package/src/types/saved-filters.js.map +1 -0
- package/src/types/search.js +2 -0
- package/src/types/search.js.map +1 -0
- package/src/types/settings.js +2 -0
- package/src/types/settings.js.map +1 -0
- package/src/types/templates.js +2 -0
- package/src/types/templates.js.map +1 -0
- package/src/types/tenants.js +21 -0
- package/src/types/tenants.js.map +1 -0
- package/src/types/user-performance.js +7 -0
- package/src/types/user-performance.js.map +1 -0
- package/src/types/utils.js +2 -0
- package/src/types/validation.js +2 -0
- package/src/types/validation.js.map +1 -0
- package/src/types/vehicle-sales.js +6 -0
- package/src/types/vehicle-sales.js.map +1 -0
- package/src/types/vehicles.js +98 -0
- package/src/types/vehicles.js.map +1 -0
- package/src/types/vehicles.ts +7 -1
- package/src/utils/leasing.js +6 -0
- package/src/utils/leasing.js.map +1 -0
- package/src/utils/leasing.ts +33 -0
- package/src/utils/opportunities.js +48 -0
- package/src/utils/opportunities.js.map +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leasing.js","sourceRoot":"","sources":["leasing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAStD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAgC,EAA2B,EAAE,CAC/F,MAAM,CACJ,GAAG,CACD,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,EACpC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,CACrE,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAClB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAChF,CAAC;AAEJ,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,UAAU,EACV,aAAa,GACyC,EAAkC,EAAE,CAC1F,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,aAAa,CAAE,CAAC"}
|
package/src/utils/leasing.ts
CHANGED
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { OpportunityStatus, OpportunityStatusOrder } from '../types/opportunities.js';
|
|
2
|
+
const compareOpportunityStatus = (input) => {
|
|
3
|
+
const { currentStatus, referenceStatus } = input;
|
|
4
|
+
const currentStatusIdx = OpportunityStatusOrder.indexOf(currentStatus);
|
|
5
|
+
const referenceStatusIdx = OpportunityStatusOrder.indexOf(referenceStatus);
|
|
6
|
+
return {
|
|
7
|
+
currentStatusIdx,
|
|
8
|
+
referenceStatusIdx,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export const getPreviousStatus = (currentStatus) => {
|
|
12
|
+
const currentIndex = OpportunityStatusOrder.indexOf(currentStatus);
|
|
13
|
+
if (currentIndex === 0) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return OpportunityStatusOrder[currentIndex - 1];
|
|
17
|
+
};
|
|
18
|
+
export const getNextStatus = (status) => {
|
|
19
|
+
const statusIndex = OpportunityStatusOrder.indexOf(status);
|
|
20
|
+
if (statusIndex >= OpportunityStatusOrder.length - 1) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return OpportunityStatusOrder[statusIndex + 1];
|
|
24
|
+
};
|
|
25
|
+
export const isSameOrAfterReferenceOpportunityStatus = (input) => {
|
|
26
|
+
const { currentStatusIdx, referenceStatusIdx } = compareOpportunityStatus(input);
|
|
27
|
+
return currentStatusIdx >= referenceStatusIdx;
|
|
28
|
+
};
|
|
29
|
+
export const isAfterReferenceOpportunityStatus = (input) => {
|
|
30
|
+
const { currentStatusIdx, referenceStatusIdx } = compareOpportunityStatus(input);
|
|
31
|
+
return currentStatusIdx > referenceStatusIdx;
|
|
32
|
+
};
|
|
33
|
+
export const isSameOrBeforeReferenceOpportunityStatus = (input) => {
|
|
34
|
+
const { currentStatusIdx, referenceStatusIdx } = compareOpportunityStatus(input);
|
|
35
|
+
return currentStatusIdx <= referenceStatusIdx;
|
|
36
|
+
};
|
|
37
|
+
export const isBeforeReferenceOpportunityStatus = (input) => {
|
|
38
|
+
const { currentStatusIdx, referenceStatusIdx } = compareOpportunityStatus(input);
|
|
39
|
+
return currentStatusIdx < referenceStatusIdx;
|
|
40
|
+
};
|
|
41
|
+
export const isOpportunityLost = (input) => input.lostAt != null;
|
|
42
|
+
export const getOpportunityReservedStatus = () => [
|
|
43
|
+
OpportunityStatus.REVIEW,
|
|
44
|
+
OpportunityStatus.PREPARATION,
|
|
45
|
+
OpportunityStatus.DELIVERY,
|
|
46
|
+
];
|
|
47
|
+
export const isOpportunityReserved = (input) => getOpportunityReservedStatus().includes(input.status);
|
|
48
|
+
//# sourceMappingURL=opportunities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opportunities.js","sourceRoot":"","sources":["opportunities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAOnG,MAAM,wBAAwB,GAAG,CAAC,KAAmB,EAAE,EAAE;IACvD,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;IAEjD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACvE,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAE3E,OAAO;QACL,gBAAgB;QAChB,kBAAkB;KACnB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,aAAgC,EACD,EAAE;IACjC,MAAM,YAAY,GAAG,sBAAsB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACnE,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;IACT,CAAC;IACD,OAAO,sBAAsB,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAyB,EAAiC,EAAE;IACxF,MAAM,WAAW,GAAG,sBAAsB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,WAAW,IAAI,sBAAsB,CAAC,MAAM,GAAG,CAAC,E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