@bisondesk/core-sdk 1.0.654 → 1.0.656

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 (105) hide show
  1. package/lib/types/deliveries.d.ts +74 -0
  2. package/lib/types/deliveries.d.ts.map +1 -0
  3. package/lib/types/deliveries.js +24 -0
  4. package/lib/types/deliveries.js.map +1 -0
  5. package/lib/types/quotes.d.ts +5 -65
  6. package/lib/types/quotes.d.ts.map +1 -1
  7. package/lib/types/quotes.js +1 -18
  8. package/lib/types/quotes.js.map +1 -1
  9. package/lib/types/transports.d.ts +10 -15
  10. package/lib/types/transports.d.ts.map +1 -1
  11. package/lib/types/transports.js +5 -5
  12. package/lib/types/transports.js.map +1 -1
  13. package/lib/types/vehicle-sales.d.ts +3 -2
  14. package/lib/types/vehicle-sales.d.ts.map +1 -1
  15. package/lib/types/vehicle-sales.js.map +1 -1
  16. package/lib/utils/deliveries.d.ts +3 -0
  17. package/lib/utils/deliveries.d.ts.map +1 -0
  18. package/lib/utils/deliveries.js +3 -0
  19. package/lib/utils/deliveries.js.map +1 -0
  20. package/lib/utils/deliveries.test.d.ts +2 -0
  21. package/lib/utils/deliveries.test.d.ts.map +1 -0
  22. package/lib/utils/deliveries.test.js +34 -0
  23. package/lib/utils/deliveries.test.js.map +1 -0
  24. package/lib/utils/transports.d.ts +1 -1
  25. package/lib/utils/transports.d.ts.map +1 -1
  26. package/lib/utils/transports.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/types/activities.js +13 -0
  29. package/src/types/activities.js.map +1 -0
  30. package/src/types/comparables.js +2 -0
  31. package/src/types/comparables.js.map +1 -0
  32. package/src/types/crm.js +58 -0
  33. package/src/types/crm.js.map +1 -0
  34. package/src/types/dashboard.js +2 -0
  35. package/src/types/dashboard.js.map +1 -0
  36. package/src/types/definitions.js +2 -0
  37. package/src/types/definitions.js.map +1 -0
  38. package/src/types/deliveries.ts +92 -0
  39. package/src/types/fields.js +2 -0
  40. package/src/types/fields.js.map +1 -0
  41. package/src/types/insights.js +2 -0
  42. package/src/types/insights.js.map +1 -0
  43. package/src/types/interests.js +6 -0
  44. package/src/types/interests.js.map +1 -0
  45. package/src/types/internal-events.js +18 -0
  46. package/src/types/internal-events.js.map +1 -0
  47. package/src/types/internet-opportunities.js +2 -0
  48. package/src/types/internet-opportunities.js.map +1 -0
  49. package/src/types/internet-vehicles.js +2 -0
  50. package/src/types/internet-vehicles.js.map +1 -0
  51. package/src/types/leasing-administration.js +2 -0
  52. package/src/types/leasing-administration.js.map +1 -0
  53. package/src/types/leasing-debtors.js +2 -0
  54. package/src/types/leasing-debtors.js.map +1 -0
  55. package/src/types/leasing-search.js +2 -0
  56. package/src/types/leasing-search.js.map +1 -0
  57. package/src/types/leasing-settings.js +7 -0
  58. package/src/types/leasing-settings.js.map +1 -0
  59. package/src/types/leasing.js +38 -0
  60. package/src/types/leasing.js.map +1 -0
  61. package/src/types/marketing.js +35 -0
  62. package/src/types/marketing.js.map +1 -0
  63. package/src/types/offers.js +56 -0
  64. package/src/types/opportunities.js +107 -0
  65. package/src/types/opportunities.js.map +1 -0
  66. package/src/types/payments.js +7 -0
  67. package/src/types/picklists.js +2 -0
  68. package/src/types/picklists.js.map +1 -0
  69. package/src/types/quotes.js +42 -0
  70. package/src/types/quotes.ts +17 -73
  71. package/src/types/recently-viewed.js +2 -0
  72. package/src/types/recently-viewed.js.map +1 -0
  73. package/src/types/reservations.js +5 -0
  74. package/src/types/reservations.js.map +1 -0
  75. package/src/types/roi-ratings.js +5 -0
  76. package/src/types/roi-ratings.js.map +1 -0
  77. package/src/types/saved-filters.js +9 -0
  78. package/src/types/saved-filters.js.map +1 -0
  79. package/src/types/search.js +2 -0
  80. package/src/types/search.js.map +1 -0
  81. package/src/types/settings.js +2 -0
  82. package/src/types/settings.js.map +1 -0
  83. package/src/types/templates.js +2 -0
  84. package/src/types/templates.js.map +1 -0
  85. package/src/types/tenants.js +21 -0
  86. package/src/types/tenants.js.map +1 -0
  87. package/src/types/transports.ts +24 -24
  88. package/src/types/user-performance.js +7 -0
  89. package/src/types/user-performance.js.map +1 -0
  90. package/src/types/utils.js +2 -0
  91. package/src/types/validation.js +2 -0
  92. package/src/types/validation.js.map +1 -0
  93. package/src/types/vehicle-sales.js +6 -0
  94. package/src/types/vehicle-sales.js.map +1 -0
  95. package/src/types/vehicle-sales.ts +3 -2
  96. package/src/types/vehicles.js +98 -0
  97. package/src/types/vehicles.js.map +1 -0
  98. package/src/utils/deliveries.test.ts +50 -0
  99. package/src/utils/deliveries.ts +13 -0
  100. package/src/utils/leasing.js +6 -0
  101. package/src/utils/leasing.js.map +1 -0
  102. package/src/utils/opportunities.js +48 -0
  103. package/src/utils/opportunities.js.map +1 -0
  104. package/src/utils/transports.ts +3 -5
  105. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,50 @@
1
+ import { DeliveryTypes } from '@bisondesk/core-sdk/types/quotes';
2
+ import { expectTypeOf } from 'vitest';
3
+ import {
4
+ AddressDeliveryType,
5
+ DropOffDeliveryType,
6
+ PickUpDeliveryType,
7
+ PurchaseDeliveryType,
8
+ PurchaseDeliveryTypes,
9
+ SalesDeliveryType,
10
+ SalesDeliveryTypes,
11
+ } from '../types/deliveries.js';
12
+ import { isAddressDelivery } from './deliveries.js';
13
+
14
+ test('purchase and sales contracts keep supplier drop-off and customer pick-up separate', () => {
15
+ expectTypeOf<DropOffDeliveryType>().not.toMatchTypeOf<SalesDeliveryType>();
16
+ expectTypeOf<PickUpDeliveryType>().not.toMatchTypeOf<PurchaseDeliveryType>();
17
+ expectTypeOf<AddressDeliveryType>().toMatchTypeOf<PurchaseDeliveryType>();
18
+ expectTypeOf<
19
+ AddressDeliveryType<PurchaseDeliveryTypes.ADDRESS>
20
+ >().toMatchTypeOf<PurchaseDeliveryType>();
21
+ });
22
+
23
+ test('the previous quote export keeps its four sales methods', () => {
24
+ expect(DeliveryTypes).toEqual(SalesDeliveryTypes);
25
+ expect(Object.values(DeliveryTypes)).toEqual(['park', 'address', 'port', 'portAndShip']);
26
+ });
27
+
28
+ test.each([
29
+ SalesDeliveryTypes.ADDRESS,
30
+ PurchaseDeliveryTypes.ADDRESS,
31
+ ] as const)('reads the address fields for %s', (type) => {
32
+ const delivery: AddressDeliveryType<SalesDeliveryTypes.ADDRESS | PurchaseDeliveryTypes.ADDRESS> =
33
+ {
34
+ type,
35
+ address: { country: 'be', city: 'Gent' },
36
+ distanceKm: '100',
37
+ agreedPrice: '0',
38
+ technicalControlNeeded: false,
39
+ };
40
+ expect(isAddressDelivery(delivery)).toBe(true);
41
+ });
42
+
43
+ test('a supplier drop-off has no collection address', () => {
44
+ expect(
45
+ isAddressDelivery({
46
+ type: PurchaseDeliveryTypes.DROP_OFF,
47
+ agreedPrice: '0',
48
+ }),
49
+ ).toBe(false);
50
+ });
@@ -0,0 +1,13 @@
1
+ import {
2
+ AddressDeliveryType,
3
+ PurchaseDeliveryType,
4
+ PurchaseDeliveryTypes,
5
+ SalesDeliveryType,
6
+ SalesDeliveryTypes,
7
+ } from '../types/deliveries.js';
8
+
9
+ /** Purchase collection and sales delivery share the same stored address fields. */
10
+ export const isAddressDelivery = (
11
+ delivery?: PurchaseDeliveryType | SalesDeliveryType,
12
+ ): delivery is AddressDeliveryType<PurchaseDeliveryTypes.ADDRESS | SalesDeliveryTypes.ADDRESS> =>
13
+ delivery?.type === PurchaseDeliveryTypes.ADDRESS || delivery?.type === SalesDeliveryTypes.ADDRESS;
@@ -0,0 +1,6 @@
1
+ import { UTCDate } from '@date-fns/utc';
2
+ import { format } from 'date-fns';
3
+ import { last, map, sortBy, uniqBy } from 'lodash-es';
4
+ export const sortContractClients = (clients) => sortBy(map(uniqBy(clients, (c) => c.takeoverId), (c) => ({ ...c, since: format(new UTCDate(c.since), 'yyyy-MM-dd') })), (cli) => cli.since, (cli) => (cli.takeoverId ? parseInt(cli.takeoverId.replace(/[^0-9]/g, '')) : 0));
5
+ export const getDealRef = ({ conditions, opportunities, }) => last(conditions) ?? last(opportunities);
6
+ //# sourceMappingURL=leasing.js.map
@@ -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"}
@@ -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,sBA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kBAAkB,EAAE,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAEjF,OAAO,gBAAgB,GAAG,kBAAkB,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wCAAwC,GAAG,CAAC,KAAmB,EAAW,EAAE;IACvF,MAAM,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAEjF,OAAO,gBAAgB,IAAI,kBAAkB,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,KAAmB,EAAW,EAAE;IACjF,MAAM,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAEjF,OAAO,gBAAgB,GAAG,kBAAkB,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAkB,EAAW,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC;AAEvF,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAwB,EAAE,CAAC;IACrE,iBAAiB,CAAC,MAAM;IACxB,iBAAiB,CAAC,WAAW;IAC7B,iBAAiB,CAAC,QAAQ;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAkB,EAAW,EAAE,CACnE,4BAA4B,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC"}
@@ -4,12 +4,10 @@ import { VehiclePurchase } from '../types/vehicles.js';
4
4
  import { hasPurchaseArrived } from './vehicles.js';
5
5
 
6
6
  /**
7
- * Which side of the trade the transport serves. Both purchase types answer yes: a pick-up we drive
8
- * and a drop-off the supplier drives differ only in who is behind the wheel, and every rule that
9
- * asks this question — what it costs, whose money moved, which papers it needs — is the same for
10
- * both.
7
+ * Both purchase types bring a vehicle to our park: we collect a pickup, and the supplier brings
8
+ * a drop-off. They share the purchase payment and arrival rules.
11
9
  */
12
- export const isPurchaseTransport = (transport: Transport): boolean =>
10
+ export const isPurchaseTransport = (transport: Pick<Transport, 'type'>): boolean =>
13
11
  transport.type !== TransportType.SaleDelivery;
14
12
 
15
13
  /**