@bisondesk/core-sdk 1.0.651 → 1.0.653
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/leasing.d.ts +1 -1
- package/lib/apis/leasing.d.ts.map +1 -1
- package/lib/apis/leasing.js +3 -2
- package/lib/apis/leasing.js.map +1 -1
- package/lib/types/deliveries.d.ts +74 -0
- package/lib/types/deliveries.d.ts.map +1 -0
- package/lib/types/deliveries.js +24 -0
- package/lib/types/deliveries.js.map +1 -0
- package/lib/types/quotes.d.ts +5 -64
- package/lib/types/quotes.d.ts.map +1 -1
- package/lib/types/quotes.js +1 -18
- package/lib/types/quotes.js.map +1 -1
- package/lib/types/reports-arrivals.d.ts +67 -0
- package/lib/types/reports-arrivals.d.ts.map +1 -0
- package/lib/types/reports-arrivals.js +4 -0
- package/lib/types/reports-arrivals.js.map +1 -0
- package/lib/types/reports-sales.d.ts +7 -0
- package/lib/types/reports-sales.d.ts.map +1 -1
- package/lib/types/reports-sales.js.map +1 -1
- package/lib/types/templates.d.ts +22 -0
- package/lib/types/templates.d.ts.map +1 -1
- package/lib/types/templates.js.map +1 -1
- package/lib/types/tenants.d.ts +1 -1
- package/lib/types/tenants.d.ts.map +1 -1
- package/lib/types/tenants.js +1 -1
- package/lib/types/tenants.js.map +1 -1
- package/lib/types/transports.d.ts +15 -16
- package/lib/types/transports.d.ts.map +1 -1
- package/lib/types/transports.js +11 -5
- package/lib/types/transports.js.map +1 -1
- package/lib/types/vehicle-sales.d.ts +3 -2
- package/lib/types/vehicle-sales.d.ts.map +1 -1
- package/lib/types/vehicle-sales.js.map +1 -1
- package/lib/utils/deliveries.d.ts +3 -0
- package/lib/utils/deliveries.d.ts.map +1 -0
- package/lib/utils/deliveries.js +3 -0
- package/lib/utils/deliveries.js.map +1 -0
- package/lib/utils/deliveries.test.d.ts +2 -0
- package/lib/utils/deliveries.test.d.ts.map +1 -0
- package/lib/utils/deliveries.test.js +34 -0
- package/lib/utils/deliveries.test.js.map +1 -0
- package/lib/utils/leasing.d.ts +1 -0
- package/lib/utils/leasing.d.ts.map +1 -1
- package/lib/utils/leasing.js +7 -1
- package/lib/utils/leasing.js.map +1 -1
- package/lib/utils/leasing.test.d.ts +2 -0
- package/lib/utils/leasing.test.d.ts.map +1 -0
- package/lib/utils/leasing.test.js +69 -0
- package/lib/utils/leasing.test.js.map +1 -0
- package/lib/utils/reports-arrivals.d.ts +3 -0
- package/lib/utils/reports-arrivals.d.ts.map +1 -0
- package/lib/utils/reports-arrivals.js +15 -0
- package/lib/utils/reports-arrivals.js.map +1 -0
- package/lib/utils/transports.d.ts +1 -0
- package/lib/utils/transports.d.ts.map +1 -1
- package/lib/utils/transports.js +3 -4
- package/lib/utils/transports.js.map +1 -1
- package/lib/utils/vehicles.d.ts +3 -1
- package/lib/utils/vehicles.d.ts.map +1 -1
- package/lib/utils/vehicles.js +6 -1
- package/lib/utils/vehicles.js.map +1 -1
- package/package.json +1 -1
- package/src/apis/leasing.ts +3 -1
- 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/deliveries.ts +92 -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/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/quotes.ts +17 -72
- package/src/types/recently-viewed.js +2 -0
- package/src/types/recently-viewed.js.map +1 -0
- package/src/types/reports-arrivals.ts +95 -0
- package/src/types/reports-sales.ts +13 -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/templates.ts +27 -0
- package/src/types/tenants.js +21 -0
- package/src/types/tenants.js.map +1 -0
- package/src/types/tenants.ts +1 -1
- package/src/types/transports.ts +35 -25
- 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/vehicle-sales.ts +3 -2
- package/src/types/vehicles.js +98 -0
- package/src/types/vehicles.js.map +1 -0
- package/src/utils/deliveries.test.ts +50 -0
- package/src/utils/deliveries.ts +13 -0
- package/src/utils/leasing.js +6 -0
- package/src/utils/leasing.js.map +1 -0
- package/src/utils/leasing.test.ts +79 -0
- package/src/utils/leasing.ts +22 -1
- package/src/utils/opportunities.js +48 -0
- package/src/utils/opportunities.js.map +1 -0
- package/src/utils/reports-arrivals.ts +19 -0
- package/src/utils/transports.ts +11 -7
- package/src/utils/vehicles.ts +10 -0
- package/tsconfig.tsbuildinfo +1 -1
package/lib/utils/leasing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leasing.js","sourceRoot":"/","sources":["utils/leasing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"leasing.js","sourceRoot":"/","sources":["utils/leasing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAO7D,OAAO,EAEL,wBAAwB,GACzB,MAAM,8BAA8B,CAAC;AAGtC,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,C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AwB,CAAC,OAAO;YACnC,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;QACxB,KAAK,wBAAwB,CAAC,KAAK;YACjC,OAAO,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC;QACzB,KAAK,wBAAwB,CAAC,QAAQ,CAAC;QACvC;YACE,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAsC,EAAE,EAAE;IAC9E,IAAI,KAAK,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,IAAI,OAAO,CAAC,KAAM,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;YAClD,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,KAAM,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YACxF,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,KAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAChF,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,KAAM,CAAC,WAAW,CAAC;iBACrD,GAAG,CAAC,KAAM,CAAC,QAAQ,CAAC;iBACpB,GAAG,CAAC,iBAAiB,CAAC;iBACtB,GAAG,CAAC,YAAY,CAAC,CAAC;YACrB,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import { UTCDate } from '@date-fns/utc';\nimport { format } from 'date-fns';\nimport { Decimal } from 'decimal.js';\nimport { first, last, map, sortBy, uniqBy } from 'lodash-es';\nimport {\n ConditionsRef,\n LeasingContract,\n LeasingContractClient,\n OpportunityRef,\n} from '../types/leasing.js';\nimport {\n CustomLeasingQuoteExtraInput,\n LeasingItemsPaymentSplit,\n} from '../types/leasing-settings.js';\n\n/* sort from oldest to most recent client */\nexport const sortContractClients = (clients: LeasingContractClient[]): LeasingContractClient[] =>\n sortBy(\n map(\n uniqBy(clients, (c) => c.takeoverId),\n (c) => ({ ...c, since: format(new UTCDate(c.since), 'yyyy-MM-dd') }), // doing a map to also fix legacy data\n ),\n (cli) => cli.since,\n (cli) => (cli.takeoverId ? parseInt(cli.takeoverId.replace(/[^0-9]/g, '')) : 0),\n );\n\nexport const getDealRef = ({\n conditions,\n opportunities,\n}: Pick<LeasingContract, 'conditions' | 'opportunities'>): ConditionsRef | OpportunityRef =>\n last(conditions) ?? last(opportunities)!;\n\nconst refEffectiveFrom = (ref: ConditionsRef | OpportunityRef): string =>\n 'validSince' in ref ? ref.validSince : ref.createdAt;\n\n/**\n * Picks the conditions snapshot that was in force on a given date, rather than the latest one.\n *\n * A contract keeps its conditions/opportunities snapshots oldest first, each with an effective\n * date. This returns the most recent snapshot effective on or before `asOfDate` — the terms a\n * document issued on that date was billed under. Dates are compared by day, so the mix of\n * date-only `validSince` and datetime `createdAt` strings behaves consistently. When `asOfDate`\n * predates every snapshot, it falls back to the earliest one.\n */\nexport const getDealRefAsOf = (\n { conditions, opportunities }: Pick<LeasingContract, 'conditions' | 'opportunities'>,\n asOfDate: string,\n): ConditionsRef | OpportunityRef => {\n const refs: (ConditionsRef | OpportunityRef)[] = conditions ?? opportunities ?? [];\n const inForce = refs.filter((ref) => refEffectiveFrom(ref).slice(0, 10) <= asOfDate.slice(0, 10));\n return last(inForce) ?? first(refs) ?? last(refs)!;\n};\n\nexport const getItemClientPercentage = (value: LeasingItemsPaymentSplit): Decimal => {\n switch (value) {\n case LeasingItemsPaymentSplit.Company:\n return new Decimal(0);\n case LeasingItemsPaymentSplit.Split:\n return new Decimal(50);\n case LeasingItemsPaymentSplit.Customer:\n default:\n return new Decimal(100);\n }\n};\n\nexport const getLeasingExtrasTotal = (extras: CustomLeasingQuoteExtraInput[]) => {\n let total = new Decimal(0);\n for (const extra of extras) {\n if (new Decimal(extra!.leasingPercentage).lt(100)) {\n const leasingRatio = new Decimal(1).sub(new Decimal(extra!.leasingPercentage).div(100));\n const paymentSplitRatio = getItemClientPercentage(extra!.paymentSplit).div(100);\n const extraAgreedPrice = new Decimal(extra!.agreedPrice)\n .mul(extra!.quantity)\n .mul(paymentSplitRatio)\n .mul(leasingRatio);\n total = total.add(extraAgreedPrice);\n }\n }\n return total;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leasing.test.d.ts","sourceRoot":"/","sources":["utils/leasing.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { getDealRefAsOf } from './leasing.js';
|
|
2
|
+
const makeOpportunityRef = (overrides = {}) => ({
|
|
3
|
+
id: 'opp',
|
|
4
|
+
createdAt: '2025-01-01',
|
|
5
|
+
quoteId: 'q',
|
|
6
|
+
depositAmount: '0',
|
|
7
|
+
durationInMonths: 24,
|
|
8
|
+
saleAmount: '0',
|
|
9
|
+
interestRate: '0',
|
|
10
|
+
residualAmount: '0',
|
|
11
|
+
leasingMonthlyAmount: '0',
|
|
12
|
+
otherMonthlyAmounts: '0',
|
|
13
|
+
totalMonthlyAmount: '0',
|
|
14
|
+
...overrides,
|
|
15
|
+
});
|
|
16
|
+
const makeConditionsRef = (overrides = {}) => ({
|
|
17
|
+
id: 'cond',
|
|
18
|
+
validSince: '2025-01-01',
|
|
19
|
+
depositAmount: '0',
|
|
20
|
+
durationInMonths: 24,
|
|
21
|
+
saleAmount: '0',
|
|
22
|
+
interestRate: '0',
|
|
23
|
+
residualAmount: '0',
|
|
24
|
+
leasingMonthlyAmount: '0',
|
|
25
|
+
otherMonthlyAmounts: '0',
|
|
26
|
+
totalMonthlyAmount: '0',
|
|
27
|
+
...overrides,
|
|
28
|
+
});
|
|
29
|
+
describe('getDealRefAsOf', () => {
|
|
30
|
+
test('picks the opportunity snapshot in force when the invoice was issued (the failing case)', () => {
|
|
31
|
+
const original = makeOpportunityRef({
|
|
32
|
+
id: 'original',
|
|
33
|
+
createdAt: '2025-06-19T09:20:28.019Z',
|
|
34
|
+
insuranceAmount: '196',
|
|
35
|
+
otherMonthlyAmounts: '213',
|
|
36
|
+
totalMonthlyAmount: '1423',
|
|
37
|
+
});
|
|
38
|
+
const renegotiated = makeOpportunityRef({
|
|
39
|
+
id: 'renegotiated',
|
|
40
|
+
createdAt: '2026-01-01',
|
|
41
|
+
insuranceAmount: '211.65',
|
|
42
|
+
otherMonthlyAmounts: '228.65',
|
|
43
|
+
totalMonthlyAmount: '1438.65',
|
|
44
|
+
});
|
|
45
|
+
const contract = { conditions: undefined, opportunities: [original, renegotiated] };
|
|
46
|
+
expect(getDealRefAsOf(contract, '2025-11-01').id).toBe('original');
|
|
47
|
+
expect(getDealRefAsOf(contract, '2026-02-01').id).toBe('renegotiated');
|
|
48
|
+
});
|
|
49
|
+
test('picks the conditions snapshot in force by validSince', () => {
|
|
50
|
+
const first = makeConditionsRef({ id: 'first', validSince: '2024-01-01' });
|
|
51
|
+
const second = makeConditionsRef({ id: 'second', validSince: '2025-01-01' });
|
|
52
|
+
const contract = { conditions: [first, second], opportunities: undefined };
|
|
53
|
+
expect(getDealRefAsOf(contract, '2024-06-01').id).toBe('first');
|
|
54
|
+
expect(getDealRefAsOf(contract, '2025-06-01').id).toBe('second');
|
|
55
|
+
});
|
|
56
|
+
test('is inclusive of a snapshot effective on the same day as the invoice', () => {
|
|
57
|
+
const before = makeConditionsRef({ id: 'before', validSince: '2024-01-01' });
|
|
58
|
+
const sameDay = makeConditionsRef({ id: 'sameDay', validSince: '2025-05-10' });
|
|
59
|
+
const contract = { conditions: [before, sameDay], opportunities: undefined };
|
|
60
|
+
expect(getDealRefAsOf(contract, '2025-05-10').id).toBe('sameDay');
|
|
61
|
+
});
|
|
62
|
+
test('falls back to the earliest snapshot when the date predates all of them', () => {
|
|
63
|
+
const first = makeConditionsRef({ id: 'first', validSince: '2025-01-01' });
|
|
64
|
+
const second = makeConditionsRef({ id: 'second', validSince: '2026-01-01' });
|
|
65
|
+
const contract = { conditions: [first, second], opportunities: undefined };
|
|
66
|
+
expect(getDealRefAsOf(contract, '2024-01-01').id).toBe('first');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=leasing.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leasing.test.js","sourceRoot":"/","sources":["utils/leasing.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,kBAAkB,GAAG,CAAC,SAAS,GAA4B,EAAE,EAAkB,EAAE,CAAC,CAAC;IACvF,EAAE,EAAE,KAAK;IACT,SAAS,EAAE,YAAY;IACvB,OAAO,EAAE,GAAG;IACZ,aAAa,EAAE,GAAG;IAClB,gBAAgB,EAAE,EAAE;IACpB,UAAU,EAAE,GAAG;IACf,YAAY,EAAE,GAAG;IACjB,cAAc,EAAE,GAAG;IACnB,oBAAoB,EAAE,GAAG;IACzB,mBAAmB,EAAE,GAAG;IACxB,kBAAkB,EAAE,GAAG;IACvB,GAAG,SAAS;CACb,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CAAC,SAAS,GAA2B,EAAE,EAAiB,EAAE,CAAC,CAAC;IACpF,EAAE,EAAE,MAAM;IACV,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,GAAG;IAClB,gBAAgB,EAAE,EAAE;IACpB,UAAU,EAAE,GAAG;IACf,YAAY,EAAE,GAAG;IACjB,cAAc,EAAE,GAAG;IACnB,oBAAoB,EAAE,GAAG;IACzB,mBAAmB,EAAE,GAAG;IACxB,kBAAkB,EAAE,GAAG;IACvB,GAAG,SAAS;CACb,CAAC,CAAC;AAEH,QAAQ,CAAC,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ityRef } from '../types/leasing.js';\nimport { getDealRefAsOf } from './leasing.js';\n\nconst makeOpportunityRef = (overrides: Partial<OpportunityRef> = {}): OpportunityRef => ({\n id: 'opp',\n createdAt: '2025-01-01',\n quoteId: 'q',\n depositAmount: '0',\n durationInMonths: 24,\n saleAmount: '0',\n interestRate: '0',\n residualAmount: '0',\n leasingMonthlyAmount: '0',\n otherMonthlyAmounts: '0',\n totalMonthlyAmount: '0',\n ...overrides,\n});\n\nconst makeConditionsRef = (overrides: Partial<ConditionsRef> = {}): ConditionsRef => ({\n id: 'cond',\n validSince: '2025-01-01',\n depositAmount: '0',\n durationInMonths: 24,\n saleAmount: '0',\n interestRate: '0',\n residualAmount: '0',\n leasingMonthlyAmount: '0',\n otherMonthlyAmounts: '0',\n totalMonthlyAmount: '0',\n ...overrides,\n});\n\ndescribe('getDealRefAsOf', () => {\n test('picks the opportunity snapshot in force when the invoice was issued (the failing case)', () => {\n const original = makeOpportunityRef({\n id: 'original',\n createdAt: '2025-06-19T09:20:28.019Z',\n insuranceAmount: '196',\n otherMonthlyAmounts: '213',\n totalMonthlyAmount: '1423',\n });\n const renegotiated = makeOpportunityRef({\n id: 'renegotiated',\n createdAt: '2026-01-01',\n insuranceAmount: '211.65',\n otherMonthlyAmounts: '228.65',\n totalMonthlyAmount: '1438.65',\n });\n const contract = { conditions: undefined, opportunities: [original, renegotiated] };\n\n expect(getDealRefAsOf(contract, '2025-11-01').id).toBe('original');\n expect(getDealRefAsOf(contract, '2026-02-01').id).toBe('renegotiated');\n });\n\n test('picks the conditions snapshot in force by validSince', () => {\n const first = makeConditionsRef({ id: 'first', validSince: '2024-01-01' });\n const second = makeConditionsRef({ id: 'second', validSince: '2025-01-01' });\n const contract = { conditions: [first, second], opportunities: undefined };\n\n expect(getDealRefAsOf(contract, '2024-06-01').id).toBe('first');\n expect(getDealRefAsOf(contract, '2025-06-01').id).toBe('second');\n });\n\n test('is inclusive of a snapshot effective on the same day as the invoice', () => {\n const before = makeConditionsRef({ id: 'before', validSince: '2024-01-01' });\n const sameDay = makeConditionsRef({ id: 'sameDay', validSince: '2025-05-10' });\n const contract = { conditions: [before, sameDay], opportunities: undefined };\n\n expect(getDealRefAsOf(contract, '2025-05-10').id).toBe('sameDay');\n });\n\n test('falls back to the earliest snapshot when the date predates all of them', () => {\n const first = makeConditionsRef({ id: 'first', validSince: '2025-01-01' });\n const second = makeConditionsRef({ id: 'second', validSince: '2026-01-01' });\n const contract = { conditions: [first, second], opportunities: undefined };\n\n expect(getDealRefAsOf(contract, '2024-01-01').id).toBe('first');\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reports-arrivals.d.ts","sourceRoot":"/","sources":["utils/reports-arrivals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAIlE,eAAO,MAAM,sBAAsB,QAC5B,kBAAkB,KACtB,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAYpC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TransportType } from '../types/transports.js';
|
|
2
|
+
export const getArrivalDeliveryType = (row) => {
|
|
3
|
+
if (row.readyToDeliver) {
|
|
4
|
+
return 'direct';
|
|
5
|
+
}
|
|
6
|
+
switch (row.transport?.type) {
|
|
7
|
+
case TransportType.PurchasePickUp:
|
|
8
|
+
return 'pickUp';
|
|
9
|
+
case TransportType.PurchaseDropOff:
|
|
10
|
+
return 'dropOff';
|
|
11
|
+
default:
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=reports-arrivals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reports-arrivals.js","sourceRoot":"/","sources":["utils/reports-arrivals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,GAAuB,EACsB,EAAE;IAC/C,IAAI,GAAG,CAAC,cAAc,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,QAAQ,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC;QAC5B,KAAK,aAAa,CAAC,cAAc;YAC/B,OAAO,QAAQ,CAAC;QAClB,KAAK,aAAa,CAAC,eAAe;YAChC,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { ExpectedArrivalRow } from '../types/reports-arrivals.js';\nimport { TransportType } from '../types/transports.js';\n\n/** Pick up and drop off come from the transport; direct-to-client deliveries stay separate. */\nexport const getArrivalDeliveryType = (\n row: ExpectedArrivalRow,\n): 'pickUp' | 'dropOff' | 'direct' | undefined => {\n if (row.readyToDeliver) {\n return 'direct';\n }\n switch (row.transport?.type) {\n case TransportType.PurchasePickUp:\n return 'pickUp';\n case TransportType.PurchaseDropOff:\n return 'dropOff';\n default:\n return undefined;\n }\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Opportunity } from '../types/opportunities.js';
|
|
2
2
|
import { SearchTransport, Transport } from '../types/transports.js';
|
|
3
3
|
import { VehiclePurchase } from '../types/vehicles.js';
|
|
4
|
+
export declare const isPurchaseTransport: (transport: Pick<Transport, 'type'>) => boolean;
|
|
4
5
|
export declare const isTransportCompleted: (transport: Transport, context: {
|
|
5
6
|
opportunity?: Opportunity;
|
|
6
7
|
purchase?: VehiclePurchase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports.d.ts","sourceRoot":"/","sources":["utils/transports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAiB,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"transports.d.ts","sourceRoot":"/","sources":["utils/transports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAiB,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAOvD,eAAO,MAAM,mBAAmB,cAAe,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,KAAG,OAC1B,CAAC;AAchD,eAAO,MAAM,oBAAoB,cACpB,SAAS,WACX;IAAE,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,eAAe,CAAA;CAAE,KACjE,OAMF,CAAC;AAGF,eAAO,MAAM,0BAA0B,WAAY,eAAe,KAAG,OAIjE,CAAC"}
|
package/lib/utils/transports.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { TransportType } from '../types/transports.js';
|
|
2
|
-
import {
|
|
2
|
+
import { hasPurchaseArrived } from './vehicles.js';
|
|
3
|
+
export const isPurchaseTransport = (transport) => transport.type !== TransportType.SaleDelivery;
|
|
3
4
|
export const isTransportCompleted = (transport, context) => {
|
|
4
5
|
if (transport.type === TransportType.SaleDelivery) {
|
|
5
6
|
return context.opportunity?.deliveredAt != null;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
-
return (status === VehiclePurchaseLogisticsStatus.Arrived ||
|
|
9
|
-
status === VehiclePurchaseLogisticsStatus.CheckedIn);
|
|
8
|
+
return context.purchase != null && hasPurchaseArrived(context.purchase);
|
|
10
9
|
};
|
|
11
10
|
export const isSearchTransportCompleted = (record) => isTransportCompleted(record.transport, {
|
|
12
11
|
opportunity: record.opportunity,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports.js","sourceRoot":"/","sources":["utils/transports.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"transports.js","sourceRoot":"/","sources":["utils/transports.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAMnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAkC,EAAW,EAAE,CACjF,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,YAAY,CAAC;AAchD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,SAAoB,EACpB,OAAkE,EACzD,EAAE;IACX,IAAI,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,YAAY,EAAE,CAAC;QAClD,OAAO,OAAO,CAAC,WAAW,EAAE,WAAW,IAAI,IAAI,CAAC;IAClD,CAAC;IAED,OAAO,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1E,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,MAAuB,EAAW,EAAE,CAC7E,oBAAoB,CAAC,MAAM,CAAC,SAAS,EAAE;IACrC,WAAW,EAAE,MAAM,CAAC,WAAW;IAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;CAC1B,CAAC,CAAC","sourcesContent":["import { Opportunity } from '../types/opportunities.js';\nimport { SearchTransport, Transport, TransportType } from '../types/transports.js';\nimport { VehiclePurchase } from '../types/vehicles.js';\nimport { hasPurchaseArrived } from './vehicles.js';\n\n/**\n * Both purchase types bring a vehicle to our park: we collect a pickup, and the supplier brings\n * a drop-off. They share the purchase payment and arrival rules.\n */\nexport const isPurchaseTransport = (transport: Pick<Transport, 'type'>): boolean =>\n transport.type !== TransportType.SaleDelivery;\n\n/**\n * A transport is finished when the journey it describes has demonstrably happened: the customer has\n * the vehicle for a sale delivery, the vehicle is on our park for a purchase. From then on\n * the record is history and the server refuses edits to it.\n *\n * Not the same thing as the transport's own `doneAt`. Delivery can be declared on the opportunity\n * (a CMR, a delivery confirmation) and arrival on the purchase, without the transport ever being\n * moved — and reversing either of those is what unlocks the transport again, which a status stamped\n * on the transport itself could not express.\n *\n * Shared so the board, the drawer and the server all answer the question the same way.\n */\nexport const isTransportCompleted = (\n transport: Transport,\n context: { opportunity?: Opportunity; purchase?: VehiclePurchase },\n): boolean => {\n if (transport.type === TransportType.SaleDelivery) {\n return context.opportunity?.deliveredAt != null;\n }\n\n return context.purchase != null && hasPurchaseArrived(context.purchase);\n};\n\n/** The same question asked of a search document, which already carries both sides. */\nexport const isSearchTransportCompleted = (record: SearchTransport): boolean =>\n isTransportCompleted(record.transport, {\n opportunity: record.opportunity,\n purchase: record.purchase,\n });\n"]}
|
package/lib/utils/vehicles.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Vehicle, VehicleExternalInfo, VehiclePurchase } from '../types/vehicles.js';
|
|
1
|
+
import { Vehicle, VehicleExternalInfo, VehiclePurchase, VehiclePurchaseLogisticsStatus } from '../types/vehicles.js';
|
|
2
|
+
export declare const PURCHASE_ARRIVED_STATUSES: readonly VehiclePurchaseLogisticsStatus[];
|
|
3
|
+
export declare const hasPurchaseArrived: (purchase: Pick<VehiclePurchase, 'logistics'>) => boolean;
|
|
2
4
|
export declare const isDealInMarketing: (purchase: VehiclePurchase | undefined) => boolean;
|
|
3
5
|
export declare const isSourceMastered: (vehicle: Pick<Vehicle, 'original'>, purchase: VehiclePurchase | undefined) => boolean;
|
|
4
6
|
export declare const isUnavailableFromSource: (vehicle: Pick<Vehicle, 'original'>, purchase: VehiclePurchase | undefined) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vehicles.d.ts","sourceRoot":"/","sources":["utils/vehicles.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,eAAe,
|
|
1
|
+
{"version":3,"file":"vehicles.d.ts","sourceRoot":"/","sources":["utils/vehicles.ts"],"names":[],"mappings":"AAGA,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AE/D,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,OAAgC,CAAC;AAE1E,eAAO,MAAM,qBAAqB,aACtB,mBAAmB,qDAK1B;IACD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,WAyBF,CAAC"}
|
package/lib/utils/vehicles.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { XError } from '@bisondesk/commons-sdk/errors';
|
|
2
2
|
import { joinWithSeparator } from '@bisondesk/commons-sdk/formatting';
|
|
3
3
|
import { Categories } from '../constants.js';
|
|
4
|
-
import { VehiclePurchaseDealStatus, } from '../types/vehicles.js';
|
|
4
|
+
import { VehiclePurchaseDealStatus, VehiclePurchaseLogisticsStatus, } from '../types/vehicles.js';
|
|
5
|
+
export const PURCHASE_ARRIVED_STATUSES = [
|
|
6
|
+
VehiclePurchaseLogisticsStatus.Arrived,
|
|
7
|
+
VehiclePurchaseLogisticsStatus.CheckedIn,
|
|
8
|
+
];
|
|
9
|
+
export const hasPurchaseArrived = (purchase) => PURCHASE_ARRIVED_STATUSES.includes(purchase.logistics.status);
|
|
5
10
|
export const isDealInMarketing = (purchase) => purchase == null || purchase.deal.status === VehiclePurchaseDealStatus.Marketing;
|
|
6
11
|
export const isSourceMastered = (vehicle, purchase) => vehicle.original != null && isDealInMarketing(purchase);
|
|
7
12
|
export const isUnavailableFromSource = (vehicle, purchase) => isSourceMastered(vehicle, purchase) && (vehicle.original?.salesConditions?.unavailable ?? false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vehicles.js","sourceRoot":"/","sources":["utils/vehicles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAA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E,KAAK;QACjF,UAAU;QACV,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS;KAC9E,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import { XError } from '@bisondesk/commons-sdk/errors';\nimport { joinWithSeparator } from '@bisondesk/commons-sdk/formatting';\nimport { Categories } from '../constants.js';\nimport {\n Vehicle,\n VehicleExternalInfo,\n VehiclePurchase,\n VehiclePurchaseDealStatus,\n} from '../types/vehicles.js';\n\n/**\n * The deal has not been committed: there is no purchase yet, or its deal is still in\n * `Marketing`. Copies are created in this state; it ends when the owner agrees to buy\n * (e.g. an ICO invoice moves the deal to PurchaseAgreed).\n */\nexport const isDealInMarketing = (purchase: VehiclePurchase | undefined): boolean =>\n purchase == null || purchase.deal.status === VehiclePurchaseDealStatus.Marketing;\n\n/**\n * A cross-tenant copy whose source still masters it: it has an `original` link and its deal is\n * still in Marketing ({@link isDealInMarketing}). While this holds, the next sync overwrites\n * `external` (specs, pictures, videos) and `salesConditions` from the source; once the deal\n * progresses, the vehicle is the owner's own stock and the sync hands off. Native vehicles are\n * never source-mastered.\n */\nexport const isSourceMastered = (\n vehicle: Pick<Vehicle, 'original'>,\n purchase: VehiclePurchase | undefined,\n): boolean => vehicle.original != null && isDealInMarketing(purchase);\n\n/**\n * A cross-tenant copy whose source is not sellable, as stamped on the last sync hop. Only\n * meaningful while the source still masters the copy ({@link isSourceMastered}): past Marketing\n * the vehicle is the owner's own stock, and a still-present flag is merely stale — the sync\n * clears it on the next source event — so it must be ignored.\n */\nexport const isUnavailableFromSource = (\n vehicle: Pick<Vehicle, 'original'>,\n purchase: VehiclePurchase | undefined,\n): boolean =>\n isSourceMastered(vehicle, purchase) && (vehicle.original?.salesConditions?.unavailable ?? false);\n\n/**\n * A trailer or semi-trailer that has never been used — what the sales ladder calls a new\n * trailer, and the reason it has opportunity types of its own (`NEW_TRAILER`,\n * `NEW_TRAILER_NEW_PRODUCTION`) instead of going through plain sales.\n */\nexport const isNewTrailer = (vehicle: Pick<Vehicle, 'external'>): boolean =>\n [Categories.Trailer, Categories.SemiTrailer].includes(\n vehicle.external.general.category as Categories,\n ) && !vehicle.external.condition?.used;\n\nexport const extractCustomFeatures = (vehicle: VehicleExternalInfo): string[] => {\n const features: {\n getValue: (vehicle: VehicleExternalInfo) => any;\n picklistValueId: string;\n }[] = [\n {\n getValue: (vehicle) => vehicle.superstructure?.crane?.present,\n picklistValueId: 'crane',\n },\n {\n getValue: (vehicle) => vehicle.superstructure?.tailgate?.present,\n picklistValueId: 'tailgate',\n },\n { getValue: (vehicle) => vehicle.accessories.adr, picklistValueId: 'adr' },\n {\n getValue: (vehicle) => vehicle.accessories.retarderIntarder,\n picklistValueId: 'retarderIntarder',\n },\n {\n getValue: (vehicle) => vehicle.accessories.hydraulicTipperKit,\n picklistValueId: 'hydraulicTipperKit',\n },\n {\n getValue: (vehicle) => vehicle.accessories.lowDeck,\n picklistValueId: 'lowDeck',\n },\n {\n getValue: (vehicle) => vehicle.accessories.coil,\n picklistValueId: 'coil',\n },\n {\n getValue: (vehicle) => vehicle.accessories.doubleStock,\n picklistValueId: 'doubleStock',\n },\n {\n getValue: (vehicle) => vehicle.accessories.mega,\n picklistValueId: 'mega',\n },\n {\n getValue: (vehicle) =>\n vehicle.salesConditions?.manufacturerWarranty?.available ||\n vehicle.salesConditions?.manufacturerWarranty?.included,\n picklistValueId: 'warranty',\n },\n ];\n\n return features\n .filter((feature) => !!feature.getValue(vehicle))\n .map((feature) => feature.picklistValueId);\n};\n\nexport const getInternalTitle = ({\n make,\n category,\n modelName,\n bodywork,\n modelTypeName,\n}: {\n category: string;\n make?: string;\n modelName?: string;\n modelTypeName?: string;\n bodywork?: string;\n}): string => {\n if (category === Categories.Trailer || category === Categories.SemiTrailer) {\n return [make, modelName, modelTypeName, bodywork]\n .filter((v): v is string => !!v)\n .map((v) => v.trim())\n .join(' ')\n .trim();\n }\n\n return [make, modelName, modelTypeName]\n .filter((v): v is string => !!v)\n .map((v) => v.trim())\n .join(' ')\n .trim();\n};\n\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n\n// example: 1 -> A, 2 -> B, 26 -> Z, 27 -> AA, 28 -> AB, 52 -> AZ, 53 -> BA, 54 -> BB, 702 -> ZZ\nexport const convertNumberToLetters = (num: number): string => {\n const lettersLength = ALPHABET.length;\n\n if (num < 1) {\n return '';\n }\n\n let remainder = num % lettersLength;\n let quotient = Math.floor(num / lettersLength);\n\n // If remainder is 0, it means we should map it to 'Z' and reduce the quotient by 1\n if (remainder === 0) {\n remainder = lettersLength;\n quotient -= 1;\n }\n\n return convertNumberToLetters(quotient) + ALPHABET.charAt(remainder - 1);\n};\n\n// example: A -> 1, B -> 2, Z -> 26, AA -> 27, AB -> 28, AZ -> 52, BA -> 53, BB -> 54, ZZ -> 702\nexport const convertLettersToNumber = (letters: string): number => {\n const base = ALPHABET.length;\n\n let result = 0;\n\n for (let i = 0; i < letters.length; i++) {\n const charValue = ALPHABET.indexOf(letters[i]) + 1;\n result = result * base + charValue;\n }\n\n return result;\n};\n\n/**\n * Canonical stock-number shape: a branch prefix of 1 to 3 letters followed by exactly 5 digits\n * and up to 2 trailing counter letters (e.g. B49397AB, TC12345 — see\n * {@link getNextRelatedStockNumber}). Callers supply the prefix pattern (concrete branch\n * prefixes, or a policy like `[A-Z]{2}`) and wrap their own boundary/anchor policy around the\n * returned pattern.\n */\nexport const buildStockNumberPattern = (prefixPattern: string): string =>\n `(?:${prefixPattern})\\\\d{5}[A-Z]{0,2}`;\n\nexport const getNextRelatedStockNumber = (stockNumber: string): string => {\n const counterPattern = /^([A-Z]+\\d{5})([A-Z]{0,2})$/;\n const match = stockNumber.match(counterPattern);\n if (match == null) {\n throw new XError('core-sdk.vehicles.bad-stock-number', { stockNumber });\n }\n\n const baseStockNumber = match[1];\n const counterLetters = match[2];\n const counterNumber = convertLettersToNumber(counterLetters);\n const nextCounterNumber = counterNumber + 1;\n const nextCounterLetters = convertNumberToLetters(nextCounterNumber);\n return `${baseStockNumber}${nextCounterLetters}`;\n};\n\n/**\n * Canonical VIN shape: exactly 17 characters from the VIN alphabet — letters A–Z and\n * digits 0–9, excluding I, O and Q. Unanchored so callers can wrap their own\n * boundary/anchor policy when scanning free text (mirror of {@link buildStockNumberPattern}).\n * Use {@link VIN_PATTERN} / {@link isValidVin} to validate a whole string.\n */\nexport const VIN_BODY_PATTERN = '[A-HJ-NPR-Z0-9]{17}';\n\nexport const VIN_PATTERN = new RegExp(`^${VIN_BODY_PATTERN}$`);\n\nexport const isValidVin = (vin: string): boolean => VIN_PATTERN.test(vin);\n\nexport const getVehicleDescription = (\n external: VehicleExternalInfo,\n {\n showStockNumber = false,\n showAxleConfiguration = false,\n lang,\n }: {\n showStockNumber?: boolean;\n showAxleConfiguration?: boolean;\n lang?: string;\n },\n) => {\n const dimensions = [\n external.superstructure?.dimensions?.extended,\n external.superstructure?.dimensions?.heightened,\n ]\n .filter((value) => !!value)\n .join('');\n const kmFormatter = Intl.NumberFormat(lang, {\n style: 'unit',\n unit: 'kilometer',\n });\n\n const text = joinWithSeparator([\n showStockNumber ? external.identification.stockNumber : undefined,\n external.history?.advertisingYear,\n external.condition?.odometer?.km != null\n ? kmFormatter.format(external.condition.odometer.km)\n : undefined,\n external.powertrain?.emissions?.subclass ?? external.powertrain?.emissions?.class,\n dimensions,\n showAxleConfiguration ? external.powertrain?.axles?.configuration : undefined,\n ]);\n\n return text;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"vehicles.js","sourceRoot":"/","sources":["utils/vehicles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAIL,yBAAyB,EACzB,8B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AAE,IAAI,IAAI;YACtC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YACpD,CAAC,CAAC,SAAS;QACb,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,IAAI,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK;QACjF,UAAU;QACV,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS;KAC9E,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import { XError } from '@bisondesk/commons-sdk/errors';\nimport { joinWithSeparator } from '@bisondesk/commons-sdk/formatting';\nimport { Categories } from '../constants.js';\nimport {\n Vehicle,\n VehicleExternalInfo,\n VehiclePurchase,\n VehiclePurchaseDealStatus,\n VehiclePurchaseLogisticsStatus,\n} from '../types/vehicles.js';\n\n/** The logistics statuses at which the purchased vehicle is on our park. */\nexport const PURCHASE_ARRIVED_STATUSES: readonly VehiclePurchaseLogisticsStatus[] = [\n VehiclePurchaseLogisticsStatus.Arrived,\n VehiclePurchaseLogisticsStatus.CheckedIn,\n];\n\nexport const hasPurchaseArrived = (purchase: Pick<VehiclePurchase, 'logistics'>): boolean =>\n PURCHASE_ARRIVED_STATUSES.includes(purchase.logistics.status);\n\n/**\n * The deal has not been committed: there is no purchase yet, or its deal is still in\n * `Marketing`. Copies are created in this state; it ends when the owner agrees to buy\n * (e.g. an ICO invoice moves the deal to PurchaseAgreed).\n */\nexport const isDealInMarketing = (purchase: VehiclePurchase | undefined): boolean =>\n purchase == null || purchase.deal.status === VehiclePurchaseDealStatus.Marketing;\n\n/**\n * A cross-tenant copy whose source still masters it: it has an `original` link and its deal is\n * still in Marketing ({@link isDealInMarketing}). While this holds, the next sync overwrites\n * `external` (specs, pictures, videos) and `salesConditions` from the source; once the deal\n * progresses, the vehicle is the owner's own stock and the sync hands off. Native vehicles are\n * never source-mastered.\n */\nexport const isSourceMastered = (\n vehicle: Pick<Vehicle, 'original'>,\n purchase: VehiclePurchase | undefined,\n): boolean => vehicle.original != null && isDealInMarketing(purchase);\n\n/**\n * A cross-tenant copy whose source is not sellable, as stamped on the last sync hop. Only\n * meaningful while the source still masters the copy ({@link isSourceMastered}): past Marketing\n * the vehicle is the owner's own stock, and a still-present flag is merely stale — the sync\n * clears it on the next source event — so it must be ignored.\n */\nexport const isUnavailableFromSource = (\n vehicle: Pick<Vehicle, 'original'>,\n purchase: VehiclePurchase | undefined,\n): boolean =>\n isSourceMastered(vehicle, purchase) && (vehicle.original?.salesConditions?.unavailable ?? false);\n\n/**\n * A trailer or semi-trailer that has never been used — what the sales ladder calls a new\n * trailer, and the reason it has opportunity types of its own (`NEW_TRAILER`,\n * `NEW_TRAILER_NEW_PRODUCTION`) instead of going through plain sales.\n */\nexport const isNewTrailer = (vehicle: Pick<Vehicle, 'external'>): boolean =>\n [Categories.Trailer, Categories.SemiTrailer].includes(\n vehicle.external.general.category as Categories,\n ) && !vehicle.external.condition?.used;\n\nexport const extractCustomFeatures = (vehicle: VehicleExternalInfo): string[] => {\n const features: {\n getValue: (vehicle: VehicleExternalInfo) => any;\n picklistValueId: string;\n }[] = [\n {\n getValue: (vehicle) => vehicle.superstructure?.crane?.present,\n picklistValueId: 'crane',\n },\n {\n getValue: (vehicle) => vehicle.superstructure?.tailgate?.present,\n picklistValueId: 'tailgate',\n },\n { getValue: (vehicle) => vehicle.accessories.adr, picklistValueId: 'adr' },\n {\n getValue: (vehicle) => vehicle.accessories.retarderIntarder,\n picklistValueId: 'retarderIntarder',\n },\n {\n getValue: (vehicle) => vehicle.accessories.hydraulicTipperKit,\n picklistValueId: 'hydraulicTipperKit',\n },\n {\n getValue: (vehicle) => vehicle.accessories.lowDeck,\n picklistValueId: 'lowDeck',\n },\n {\n getValue: (vehicle) => vehicle.accessories.coil,\n picklistValueId: 'coil',\n },\n {\n getValue: (vehicle) => vehicle.accessories.doubleStock,\n picklistValueId: 'doubleStock',\n },\n {\n getValue: (vehicle) => vehicle.accessories.mega,\n picklistValueId: 'mega',\n },\n {\n getValue: (vehicle) =>\n vehicle.salesConditions?.manufacturerWarranty?.available ||\n vehicle.salesConditions?.manufacturerWarranty?.included,\n picklistValueId: 'warranty',\n },\n ];\n\n return features\n .filter((feature) => !!feature.getValue(vehicle))\n .map((feature) => feature.picklistValueId);\n};\n\nexport const getInternalTitle = ({\n make,\n category,\n modelName,\n bodywork,\n modelTypeName,\n}: {\n category: string;\n make?: string;\n modelName?: string;\n modelTypeName?: string;\n bodywork?: string;\n}): string => {\n if (category === Categories.Trailer || category === Categories.SemiTrailer) {\n return [make, modelName, modelTypeName, bodywork]\n .filter((v): v is string => !!v)\n .map((v) => v.trim())\n .join(' ')\n .trim();\n }\n\n return [make, modelName, modelTypeName]\n .filter((v): v is string => !!v)\n .map((v) => v.trim())\n .join(' ')\n .trim();\n};\n\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n\n// example: 1 -> A, 2 -> B, 26 -> Z, 27 -> AA, 28 -> AB, 52 -> AZ, 53 -> BA, 54 -> BB, 702 -> ZZ\nexport const convertNumberToLetters = (num: number): string => {\n const lettersLength = ALPHABET.length;\n\n if (num < 1) {\n return '';\n }\n\n let remainder = num % lettersLength;\n let quotient = Math.floor(num / lettersLength);\n\n // If remainder is 0, it means we should map it to 'Z' and reduce the quotient by 1\n if (remainder === 0) {\n remainder = lettersLength;\n quotient -= 1;\n }\n\n return convertNumberToLetters(quotient) + ALPHABET.charAt(remainder - 1);\n};\n\n// example: A -> 1, B -> 2, Z -> 26, AA -> 27, AB -> 28, AZ -> 52, BA -> 53, BB -> 54, ZZ -> 702\nexport const convertLettersToNumber = (letters: string): number => {\n const base = ALPHABET.length;\n\n let result = 0;\n\n for (let i = 0; i < letters.length; i++) {\n const charValue = ALPHABET.indexOf(letters[i]) + 1;\n result = result * base + charValue;\n }\n\n return result;\n};\n\n/**\n * Canonical stock-number shape: a branch prefix of 1 to 3 letters followed by exactly 5 digits\n * and up to 2 trailing counter letters (e.g. B49397AB, TC12345 — see\n * {@link getNextRelatedStockNumber}). Callers supply the prefix pattern (concrete branch\n * prefixes, or a policy like `[A-Z]{2}`) and wrap their own boundary/anchor policy around the\n * returned pattern.\n */\nexport const buildStockNumberPattern = (prefixPattern: string): string =>\n `(?:${prefixPattern})\\\\d{5}[A-Z]{0,2}`;\n\nexport const getNextRelatedStockNumber = (stockNumber: string): string => {\n const counterPattern = /^([A-Z]+\\d{5})([A-Z]{0,2})$/;\n const match = stockNumber.match(counterPattern);\n if (match == null) {\n throw new XError('core-sdk.vehicles.bad-stock-number', { stockNumber });\n }\n\n const baseStockNumber = match[1];\n const counterLetters = match[2];\n const counterNumber = convertLettersToNumber(counterLetters);\n const nextCounterNumber = counterNumber + 1;\n const nextCounterLetters = convertNumberToLetters(nextCounterNumber);\n return `${baseStockNumber}${nextCounterLetters}`;\n};\n\n/**\n * Canonical VIN shape: exactly 17 characters from the VIN alphabet — letters A–Z and\n * digits 0–9, excluding I, O and Q. Unanchored so callers can wrap their own\n * boundary/anchor policy when scanning free text (mirror of {@link buildStockNumberPattern}).\n * Use {@link VIN_PATTERN} / {@link isValidVin} to validate a whole string.\n */\nexport const VIN_BODY_PATTERN = '[A-HJ-NPR-Z0-9]{17}';\n\nexport const VIN_PATTERN = new RegExp(`^${VIN_BODY_PATTERN}$`);\n\nexport const isValidVin = (vin: string): boolean => VIN_PATTERN.test(vin);\n\nexport const getVehicleDescription = (\n external: VehicleExternalInfo,\n {\n showStockNumber = false,\n showAxleConfiguration = false,\n lang,\n }: {\n showStockNumber?: boolean;\n showAxleConfiguration?: boolean;\n lang?: string;\n },\n) => {\n const dimensions = [\n external.superstructure?.dimensions?.extended,\n external.superstructure?.dimensions?.heightened,\n ]\n .filter((value) => !!value)\n .join('');\n const kmFormatter = Intl.NumberFormat(lang, {\n style: 'unit',\n unit: 'kilometer',\n });\n\n const text = joinWithSeparator([\n showStockNumber ? external.identification.stockNumber : undefined,\n external.history?.advertisingYear,\n external.condition?.odometer?.km != null\n ? kmFormatter.format(external.condition.odometer.km)\n : undefined,\n external.powertrain?.emissions?.subclass ?? external.powertrain?.emissions?.class,\n dimensions,\n showAxleConfiguration ? external.powertrain?.axles?.configuration : undefined,\n ]);\n\n return text;\n};\n"]}
|
package/package.json
CHANGED
package/src/apis/leasing.ts
CHANGED
|
@@ -287,9 +287,11 @@ export const upsertLeasingContract = async (
|
|
|
287
287
|
export const getLeasingAmortizations = async (
|
|
288
288
|
tenantId: string,
|
|
289
289
|
contractId: string,
|
|
290
|
+
asOfDate?: string,
|
|
290
291
|
): Promise<AmortizationTable | undefined> => {
|
|
291
292
|
const auth = await getAdminAuth();
|
|
292
|
-
const
|
|
293
|
+
const query = asOfDate != null ? `?asOfDate=${encodeURIComponent(asOfDate)}` : '';
|
|
294
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/${contractId}/amortization${query}`;
|
|
293
295
|
const response: Response = await fetch(url, {
|
|
294
296
|
headers: {
|
|
295
297
|
Authorization: auth,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var ActivityType;
|
|
2
|
+
(function (ActivityType) {
|
|
3
|
+
ActivityType["CALL"] = "call";
|
|
4
|
+
ActivityType["MEETING"] = "meeting";
|
|
5
|
+
ActivityType["EMAIL"] = "email";
|
|
6
|
+
ActivityType["CHAT"] = "chat";
|
|
7
|
+
})(ActivityType || (ActivityType = {}));
|
|
8
|
+
export var ActivityActions;
|
|
9
|
+
(function (ActivityActions) {
|
|
10
|
+
ActivityActions["DELETE"] = "delete";
|
|
11
|
+
ActivityActions["EDIT"] = "edit";
|
|
12
|
+
})(ActivityActions || (ActivityActions = {}));
|
|
13
|
+
//# sourceMappingURL=activities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activities.js","sourceRoot":"","sources":["activities.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,+BAAe,CAAA;IACf,6BAAa,CAAA;AACf,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,gCAAa,CAAA;AACf,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparables.js","sourceRoot":"","sources":["comparables.ts"],"names":[],"mappings":""}
|
package/src/types/crm.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export var OrganizatioRiskTags;
|
|
2
|
+
(function (OrganizatioRiskTags) {
|
|
3
|
+
OrganizatioRiskTags["BAD_FINANCIAL_INFO"] = "BAD_FINANCIAL_INFO";
|
|
4
|
+
OrganizatioRiskTags["VAT_NUMBER_INVALID"] = "VAT_NUMBER_INVALID";
|
|
5
|
+
OrganizatioRiskTags["INSTINCT"] = "INSTINCT";
|
|
6
|
+
OrganizatioRiskTags["NEW_CUSTOMER"] = "NEW_CUSTOMER";
|
|
7
|
+
OrganizatioRiskTags["BANK_ACCOUNT_BLOCKED"] = "BANK_ACCOUNT_BLOCKED";
|
|
8
|
+
OrganizatioRiskTags["NO_GPS"] = "NO_GPS";
|
|
9
|
+
})(OrganizatioRiskTags || (OrganizatioRiskTags = {}));
|
|
10
|
+
export var ContactActions;
|
|
11
|
+
(function (ContactActions) {
|
|
12
|
+
ContactActions["UPSERT"] = "upsert";
|
|
13
|
+
ContactActions["DELETE"] = "delete";
|
|
14
|
+
})(ContactActions || (ContactActions = {}));
|
|
15
|
+
export var OrganizationActions;
|
|
16
|
+
(function (OrganizationActions) {
|
|
17
|
+
OrganizationActions["ADD_ACTIVITY"] = "add_activity";
|
|
18
|
+
OrganizationActions["UPSERT"] = "upsert";
|
|
19
|
+
OrganizationActions["DELETE"] = "delete";
|
|
20
|
+
OrganizationActions["SELL_TO_ORGANIZATION"] = "sell_to_organization";
|
|
21
|
+
})(OrganizationActions || (OrganizationActions = {}));
|
|
22
|
+
export var MarketingChannel;
|
|
23
|
+
(function (MarketingChannel) {
|
|
24
|
+
MarketingChannel["Email"] = "email";
|
|
25
|
+
MarketingChannel["Whatsapp"] = "whatsapp";
|
|
26
|
+
MarketingChannel["Sms"] = "sms";
|
|
27
|
+
MarketingChannel["Phone"] = "phone";
|
|
28
|
+
})(MarketingChannel || (MarketingChannel = {}));
|
|
29
|
+
export var PartnerLevel;
|
|
30
|
+
(function (PartnerLevel) {
|
|
31
|
+
PartnerLevel["Internal"] = "05-internal";
|
|
32
|
+
PartnerLevel["Gold"] = "10-gold";
|
|
33
|
+
PartnerLevel["Silver"] = "20-silver";
|
|
34
|
+
PartnerLevel["Bronze"] = "30-bronze";
|
|
35
|
+
})(PartnerLevel || (PartnerLevel = {}));
|
|
36
|
+
export var SaveContactResolution;
|
|
37
|
+
(function (SaveContactResolution) {
|
|
38
|
+
SaveContactResolution["IgnoreDuplicates"] = "IGNORE_DUPLICATES";
|
|
39
|
+
SaveContactResolution["BlockDuplicates"] = "BLOCK_DUPLICATES";
|
|
40
|
+
})(SaveContactResolution || (SaveContactResolution = {}));
|
|
41
|
+
export var SaveOrgResolution;
|
|
42
|
+
(function (SaveOrgResolution) {
|
|
43
|
+
SaveOrgResolution["IgnoreDuplicates"] = "IGNORE_DUPLICATES";
|
|
44
|
+
SaveOrgResolution["BlockDuplicates"] = "BLOCK_DUPLICATES";
|
|
45
|
+
})(SaveOrgResolution || (SaveOrgResolution = {}));
|
|
46
|
+
export var CrmSearchScope;
|
|
47
|
+
(function (CrmSearchScope) {
|
|
48
|
+
CrmSearchScope["Tenant"] = "tenant";
|
|
49
|
+
CrmSearchScope["Conglomerate"] = "conglomerate";
|
|
50
|
+
})(CrmSearchScope || (CrmSearchScope = {}));
|
|
51
|
+
export var OrgEngagementType;
|
|
52
|
+
(function (OrgEngagementType) {
|
|
53
|
+
OrgEngagementType["offers"] = "offers";
|
|
54
|
+
OrgEngagementType["purchases"] = "purchases";
|
|
55
|
+
OrgEngagementType["opportunities"] = "opportunities";
|
|
56
|
+
OrgEngagementType["sales"] = "sales";
|
|
57
|
+
})(OrgEngagementType || (OrgEngagementType = {}));
|
|
58
|
+
//# sourceMappingURL=crm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crm.js","sourceRoot":"","sources":["crm.ts"],"names":[],"mappings":"AAUA,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,gEAAyC,CAAA;IACzC,gEAAyC,CAAA;IACzC,4CAAqB,CAAA;IACrB,oDAA6B,CAAA;IAC7B,oEAA6C,CAAA;IAC7C,wCAAiB,CAAA;AACnB,CAAC,EAPW,mBAAmB,KAAnB,mBAAmB,QAO9B;AAED,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,oDAA6B,CAAA;IAC7B,wCAAiB,CAAA;IACjB,wCAAiB,CAAA;IACjB,oEAA6C,CAAA;AAC/C,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B;AAgKD,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,yCAAqB,CAAA;IACrB,+BAAW,CAAA;IACX,mCAAe,CAAA;AACjB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAWD,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,wCAAwB,CAAA;IACxB,gCAAgB,CAAA;IAChB,oCAAoB,CAAA;IACpB,oCAAoB,CAAA;AACtB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AA6CD,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,+DAAsC,CAAA;IACtC,6DAAoC,CAAA;AACtC,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC;AAED,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,2DAAsC,CAAA;IACtC,yDAAoC,CAAA;AACtC,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;AAED,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,+CAA6B,CAAA;AAC/B,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,4CAAuB,CAAA;IACvB,oDAA+B,CAAA;IAC/B,oCAAe,CAAA;AACjB,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["dashboard.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["definitions.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { LocationValue } from '@bisondesk/commons-sdk/types';
|
|
2
|
+
|
|
3
|
+
/** Supplier collection keeps the existing address value in stored transports. */
|
|
4
|
+
export enum PurchaseDeliveryTypes {
|
|
5
|
+
ADDRESS = 'address',
|
|
6
|
+
DROP_OFF = 'park',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum SalesDeliveryTypes {
|
|
10
|
+
PICK_UP = 'park',
|
|
11
|
+
ADDRESS = 'address',
|
|
12
|
+
PORT = 'port',
|
|
13
|
+
PORT_AND_SHIP = 'portAndShip',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export enum SpoilerInfo {
|
|
17
|
+
MOUNT = 'mount',
|
|
18
|
+
UNMOUNT = 'unmount',
|
|
19
|
+
NO_ACTION = 'noAction',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export enum TransportationMode {
|
|
23
|
+
BY_ROAD = 'byRoad',
|
|
24
|
+
ON_LOW_BED = 'onLowBed',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type BaseDeliveryType = {
|
|
28
|
+
agreedPrice: string;
|
|
29
|
+
spoiler?: SpoilerInfo;
|
|
30
|
+
stackingVehicleNeeded?: boolean;
|
|
31
|
+
detailsStacking?: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type PickUpDeliveryType = BaseDeliveryType & {
|
|
35
|
+
type: SalesDeliveryTypes.PICK_UP;
|
|
36
|
+
urgent: boolean;
|
|
37
|
+
transportationMode?: TransportationMode;
|
|
38
|
+
detailsBorderCrossing?: string;
|
|
39
|
+
technicalControlNeeded: boolean;
|
|
40
|
+
insuranceNeeded: boolean;
|
|
41
|
+
transitPlateBelgiumNeeded: boolean;
|
|
42
|
+
transitPlateAustriaNeeded: boolean;
|
|
43
|
+
licensePlateNeeded: boolean;
|
|
44
|
+
dateOfPickUpByCustomer?: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** The supplier brings the vehicle to our park without a collection address or distance. */
|
|
48
|
+
export type DropOffDeliveryType = BaseDeliveryType & {
|
|
49
|
+
type: PurchaseDeliveryTypes.DROP_OFF;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type AddressDeliveryType<
|
|
53
|
+
T extends SalesDeliveryTypes.ADDRESS | PurchaseDeliveryTypes.ADDRESS = SalesDeliveryTypes.ADDRESS,
|
|
54
|
+
> = BaseDeliveryType & {
|
|
55
|
+
type: T;
|
|
56
|
+
address: LocationValue;
|
|
57
|
+
distanceKm: string;
|
|
58
|
+
technicalControlNeeded: boolean;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type PortDeliverytype = BaseDeliveryType & {
|
|
62
|
+
type: SalesDeliveryTypes.PORT | SalesDeliveryTypes.PORT_AND_SHIP;
|
|
63
|
+
portOriginId: string;
|
|
64
|
+
portDestination?: string;
|
|
65
|
+
shippingCompany?: string;
|
|
66
|
+
portToPortCostPrice: string;
|
|
67
|
+
parkToPortCostPrice?: string;
|
|
68
|
+
portToPortMargin: string;
|
|
69
|
+
ets?: string;
|
|
70
|
+
eta?: string;
|
|
71
|
+
etd?: string;
|
|
72
|
+
shipClosingDate?: string;
|
|
73
|
+
bookingRef?: string;
|
|
74
|
+
deliveryLocation?: string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type SalesDeliveryType = PickUpDeliveryType | AddressDeliveryType | PortDeliverytype;
|
|
78
|
+
|
|
79
|
+
/** Earlier SDKs also used the sales address enum for purchase collection. Both store address. */
|
|
80
|
+
export type PurchaseDeliveryType =
|
|
81
|
+
| AddressDeliveryType<SalesDeliveryTypes.ADDRESS | PurchaseDeliveryTypes.ADDRESS>
|
|
82
|
+
| DropOffDeliveryType;
|
|
83
|
+
|
|
84
|
+
export type DeliveryLocationValue = Omit<LocationValue, 'addressLine1' | 'city'> & {
|
|
85
|
+
addressLine1: string;
|
|
86
|
+
city: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type DeliveryRoutesRequest = {
|
|
90
|
+
origin: DeliveryLocationValue;
|
|
91
|
+
destination: DeliveryLocationValue;
|
|
92
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["fields.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insights.js","sourceRoot":"","sources":["insights.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var InterestActions;
|
|
2
|
+
(function (InterestActions) {
|
|
3
|
+
InterestActions["SET_INTEREST"] = "set_interest";
|
|
4
|
+
})(InterestActions || (InterestActions = {}));
|
|
5
|
+
export const isOpportunityInterest = (interest) => 'opportunityId' in interest;
|
|
6
|
+
//# sourceMappingURL=interests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interests.js","sourceRoot":"","sources":["interests.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,eAEX;AAFD,WAAY,eAAe;IACzB,gDAA6B,CAAA;AAC/B,CAAC,EAFW,eAAe,KAAf,eAAe,QAE1B;AAwBD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAkB,EAAmC,EAAE,CAC3F,eAAe,IAAI,QAAQ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export var InternalEventTypes;
|
|
2
|
+
(function (InternalEventTypes) {
|
|
3
|
+
InternalEventTypes["VEHICLE_PURCHASE"] = "vehicle-purchases";
|
|
4
|
+
InternalEventTypes["ORGANIZATION"] = "organizations";
|
|
5
|
+
InternalEventTypes["CONTACT"] = "contacts";
|
|
6
|
+
InternalEventTypes["FINANCE_DOCUMENT"] = "finance-documents";
|
|
7
|
+
InternalEventTypes["OPPORTUNITY"] = "opportunities";
|
|
8
|
+
InternalEventTypes["VEHICLE"] = "vehicles";
|
|
9
|
+
InternalEventTypes["SALE_PAYMENT"] = "sale-payments";
|
|
10
|
+
InternalEventTypes["PURCHASE_PAYMENT"] = "vehicle-purchase-payments";
|
|
11
|
+
InternalEventTypes["OFFER"] = "offers";
|
|
12
|
+
})(InternalEventTypes || (InternalEventTypes = {}));
|
|
13
|
+
export var InternalNotificationChannels;
|
|
14
|
+
(function (InternalNotificationChannels) {
|
|
15
|
+
InternalNotificationChannels["APP"] = "app";
|
|
16
|
+
InternalNotificationChannels["EMAIL"] = "email";
|
|
17
|
+
})(InternalNotificationChannels || (InternalNotificationChannels = {}));
|
|
18
|
+
//# sourceMappingURL=internal-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-events.js","sourceRoot":"","sources":["internal-events.ts"],"names":[],"mappings":"AASA,MAAM,CAAN,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC5B,4DAAsC,CAAA;IACtC,oDAA8B,CAAA;IAC9B,0CAAoB,CAAA;IACpB,4DAAsC,CAAA;IACtC,mDAA6B,CAAA;IAC7B,0CAAoB,CAAA;IACpB,oDAA8B,CAAA;IAC9B,oEAA8C,CAAA;IAC9C,sCAAgB,CAAA;AAClB,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,QAU7B;AAED,MAAM,CAAN,IAAY,4BAGX;AAHD,WAAY,4BAA4B;IACtC,2CAAW,CAAA;IACX,+CAAe,CAAA;AACjB,CAAC,EAHW,4BAA4B,KAA5B,4BAA4B,QAGvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internet-opportunities.js","sourceRoot":"","sources":["internet-opportunities.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internet-vehicles.js","sourceRoot":"","sources":["internet-vehicles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leasing-administration.js","sourceRoot":"","sources":["leasing-administration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leasing-debtors.js","sourceRoot":"","sources":["leasing-debtors.ts"],"names":[],"mappings":""}
|