@bisondesk/core-sdk 1.0.677 → 1.0.679
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/exchange-rates.d.ts +0 -3
- package/lib/apis/exchange-rates.d.ts.map +1 -1
- package/lib/apis/exchange-rates.js +0 -29
- package/lib/apis/exchange-rates.js.map +1 -1
- package/lib/apis/organization-bank-accounts.d.ts +11 -0
- package/lib/apis/organization-bank-accounts.d.ts.map +1 -0
- package/lib/apis/organization-bank-accounts.js +47 -0
- package/lib/apis/organization-bank-accounts.js.map +1 -0
- package/lib/types/intercompany-payments.d.ts.map +1 -1
- package/lib/types/intercompany-payments.js.map +1 -1
- package/lib/types/offers.d.ts +1 -2
- package/lib/types/offers.d.ts.map +1 -1
- package/lib/types/offers.js.map +1 -1
- package/lib/types/opportunities.d.ts +1 -8
- package/lib/types/opportunities.d.ts.map +1 -1
- package/lib/types/opportunities.js.map +1 -1
- package/lib/types/opportunity-payments.d.ts +0 -9
- package/lib/types/opportunity-payments.d.ts.map +1 -1
- package/lib/types/opportunity-payments.js.map +1 -1
- package/lib/types/organization-bank-accounts.d.ts +35 -0
- package/lib/types/organization-bank-accounts.d.ts.map +1 -0
- package/lib/types/organization-bank-accounts.js +9 -0
- package/lib/types/organization-bank-accounts.js.map +1 -0
- package/lib/types/payment-exports.d.ts +23 -0
- package/lib/types/payment-exports.d.ts.map +1 -0
- package/lib/types/payment-exports.js +2 -0
- package/lib/types/payment-exports.js.map +1 -0
- package/lib/types/tenants.d.ts +1 -1
- package/lib/types/tenants.d.ts.map +1 -1
- package/lib/types/tenants.js +1 -0
- package/lib/types/tenants.js.map +1 -1
- package/lib/types/transports.d.ts +1 -1
- package/lib/types/transports.d.ts.map +1 -1
- package/lib/types/transports.js +1 -1
- package/lib/types/transports.js.map +1 -1
- package/lib/types/vehicle-purchase-payments.d.ts +52 -8
- package/lib/types/vehicle-purchase-payments.d.ts.map +1 -1
- package/lib/types/vehicle-purchase-payments.js +6 -0
- package/lib/types/vehicle-purchase-payments.js.map +1 -1
- package/lib/types/vehicles.d.ts +1 -7
- package/lib/types/vehicles.d.ts.map +1 -1
- package/lib/types/vehicles.js.map +1 -1
- package/lib/utils/organization-bank-accounts.d.ts +3 -0
- package/lib/utils/organization-bank-accounts.d.ts.map +1 -0
- package/lib/utils/organization-bank-accounts.js +9 -0
- package/lib/utils/organization-bank-accounts.js.map +1 -0
- package/lib/utils/tenants.d.ts +0 -3
- package/lib/utils/tenants.d.ts.map +1 -1
- package/lib/utils/tenants.js +0 -3
- package/lib/utils/tenants.js.map +1 -1
- package/lib/utils/tenants.test.js +1 -27
- package/lib/utils/tenants.test.js.map +1 -1
- package/lib/utils/transports.d.ts +8 -4
- package/lib/utils/transports.d.ts.map +1 -1
- package/lib/utils/transports.js +13 -7
- package/lib/utils/transports.js.map +1 -1
- package/lib/utils/transports.test.d.ts +2 -0
- package/lib/utils/transports.test.d.ts.map +1 -0
- package/lib/utils/transports.test.js +40 -0
- package/lib/utils/transports.test.js.map +1 -0
- package/package.json +1 -1
- package/src/apis/exchange-rates.ts +0 -49
- package/src/apis/organization-bank-accounts.ts +123 -0
- package/src/types/intercompany-payments.ts +3 -4
- package/src/types/offers.ts +0 -2
- package/src/types/opportunities.ts +1 -15
- package/src/types/opportunity-payments.ts +0 -23
- package/src/types/organization-bank-accounts.ts +56 -0
- package/src/types/payment-exports.ts +40 -0
- package/src/types/tenants.ts +7 -6
- package/src/types/transports.ts +1 -1
- package/src/types/vehicle-purchase-payments.ts +114 -13
- package/src/types/vehicles.ts +4 -15
- package/src/utils/organization-bank-accounts.ts +19 -0
- package/src/utils/tenants.test.ts +1 -39
- package/src/utils/tenants.ts +0 -17
- package/src/utils/transports.test.ts +50 -0
- package/src/utils/transports.ts +39 -22
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/opportunity-payments.d.ts +0 -3
- package/lib/utils/opportunity-payments.d.ts.map +0 -1
- package/lib/utils/opportunity-payments.js +0 -5
- package/lib/utils/opportunity-payments.js.map +0 -1
- package/lib/utils/opportunity-payments.test.d.ts +0 -2
- package/lib/utils/opportunity-payments.test.d.ts.map +0 -1
- package/lib/utils/opportunity-payments.test.js +0 -23
- package/lib/utils/opportunity-payments.test.js.map +0 -1
- package/src/types/activities.js +0 -13
- package/src/types/activities.js.map +0 -1
- package/src/types/comparables.js +0 -2
- package/src/types/comparables.js.map +0 -1
- package/src/types/crm.js +0 -58
- package/src/types/crm.js.map +0 -1
- package/src/types/dashboard.js +0 -2
- package/src/types/dashboard.js.map +0 -1
- package/src/types/definitions.js +0 -2
- package/src/types/definitions.js.map +0 -1
- package/src/types/fields.js +0 -2
- package/src/types/fields.js.map +0 -1
- package/src/types/insights.js +0 -2
- package/src/types/insights.js.map +0 -1
- package/src/types/interests.js +0 -6
- package/src/types/interests.js.map +0 -1
- package/src/types/internal-events.js +0 -18
- package/src/types/internal-events.js.map +0 -1
- package/src/types/internet-opportunities.js +0 -2
- package/src/types/internet-opportunities.js.map +0 -1
- package/src/types/internet-vehicles.js +0 -2
- package/src/types/internet-vehicles.js.map +0 -1
- package/src/types/leasing-administration.js +0 -2
- package/src/types/leasing-administration.js.map +0 -1
- package/src/types/leasing-debtors.js +0 -2
- package/src/types/leasing-debtors.js.map +0 -1
- package/src/types/leasing-search.js +0 -2
- package/src/types/leasing-search.js.map +0 -1
- package/src/types/leasing-settings.js +0 -7
- package/src/types/leasing-settings.js.map +0 -1
- package/src/types/leasing.js +0 -38
- package/src/types/leasing.js.map +0 -1
- package/src/types/marketing.js +0 -35
- package/src/types/marketing.js.map +0 -1
- package/src/types/offers.js +0 -56
- package/src/types/opportunities.js +0 -107
- package/src/types/opportunities.js.map +0 -1
- package/src/types/payments.js +0 -7
- package/src/types/picklists.js +0 -2
- package/src/types/picklists.js.map +0 -1
- package/src/types/quotes.js +0 -42
- package/src/types/recently-viewed.js +0 -2
- package/src/types/recently-viewed.js.map +0 -1
- package/src/types/reservations.js +0 -5
- package/src/types/reservations.js.map +0 -1
- package/src/types/roi-ratings.js +0 -5
- package/src/types/roi-ratings.js.map +0 -1
- package/src/types/saved-filters.js +0 -9
- package/src/types/saved-filters.js.map +0 -1
- package/src/types/search.js +0 -2
- package/src/types/search.js.map +0 -1
- package/src/types/settings.js +0 -2
- package/src/types/settings.js.map +0 -1
- package/src/types/templates.js +0 -2
- package/src/types/templates.js.map +0 -1
- package/src/types/tenants.js +0 -21
- package/src/types/tenants.js.map +0 -1
- package/src/types/user-performance.js +0 -7
- package/src/types/user-performance.js.map +0 -1
- package/src/types/utils.js +0 -2
- package/src/types/validation.js +0 -2
- package/src/types/validation.js.map +0 -1
- package/src/types/vehicle-sales.js +0 -6
- package/src/types/vehicle-sales.js.map +0 -1
- package/src/types/vehicles.js +0 -98
- package/src/types/vehicles.js.map +0 -1
- package/src/utils/leasing.js +0 -6
- package/src/utils/leasing.js.map +0 -1
- package/src/utils/opportunities.js +0 -48
- package/src/utils/opportunities.js.map +0 -1
- package/src/utils/opportunity-payments.test.ts +0 -31
- package/src/utils/opportunity-payments.ts +0 -15
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { Branch, Tenant } from '../types/tenants.js';
|
|
2
|
-
import {
|
|
3
|
-
areBranchesQuoteCompatible,
|
|
4
|
-
getBranchAskingVies,
|
|
5
|
-
getBranchPaymentCurrencies,
|
|
6
|
-
hasForeignPaymentCurrency,
|
|
7
|
-
isForeignPaymentCurrency,
|
|
8
|
-
} from './tenants.js';
|
|
2
|
+
import { areBranchesQuoteCompatible, getBranchAskingVies } from './tenants.js';
|
|
9
3
|
|
|
10
4
|
const createBranch = (override?: Partial<Branch>): Branch => ({
|
|
11
5
|
id: 'TTC',
|
|
@@ -71,35 +65,3 @@ describe('getBranchAskingVies', () => {
|
|
|
71
65
|
expect(getBranchAskingVies(tenantOf([bolivia]), 'BO')).toBeUndefined();
|
|
72
66
|
});
|
|
73
67
|
});
|
|
74
|
-
|
|
75
|
-
describe('payment currencies of a branch', () => {
|
|
76
|
-
const southAmerica = createBranch({
|
|
77
|
-
id: 'HPA South America',
|
|
78
|
-
paymentCurrencies: ['EUR', 'USD'],
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('a branch without a list is paid in its own currency only', () => {
|
|
82
|
-
expect(getBranchPaymentCurrencies(createBranch())).toEqual(['EUR']);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('a branch with a list is paid in the currencies it lists', () => {
|
|
86
|
-
expect(getBranchPaymentCurrencies(southAmerica)).toEqual(['EUR', 'USD']);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test.each([
|
|
90
|
-
['a listed currency other than its own', 'USD', true],
|
|
91
|
-
['its own currency', 'EUR', false],
|
|
92
|
-
['a currency it does not list', 'BOB', false],
|
|
93
|
-
])('%s is a foreign payment currency: %s', (_label, currencyCode, expected) => {
|
|
94
|
-
expect(isForeignPaymentCurrency(southAmerica, currencyCode)).toBe(expected);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test('a branch without a list has no foreign payment currency', () => {
|
|
98
|
-
expect(isForeignPaymentCurrency(createBranch(), 'USD')).toBe(false);
|
|
99
|
-
expect(hasForeignPaymentCurrency(createBranch())).toBe(false);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test('a branch listing another currency has a foreign payment currency', () => {
|
|
103
|
-
expect(hasForeignPaymentCurrency(southAmerica)).toBe(true);
|
|
104
|
-
});
|
|
105
|
-
});
|
package/src/utils/tenants.ts
CHANGED
|
@@ -24,23 +24,6 @@ export const getBranchAskingVies = (tenant: Tenant, branchId?: string): Branch |
|
|
|
24
24
|
return europeanBranches.find((branch) => branch.id === branchId) ?? europeanBranches.at(0);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
/** The currencies money moves in at the branch, its own currency included. */
|
|
28
|
-
export const getBranchPaymentCurrencies = (branch: Branch): string[] =>
|
|
29
|
-
branch.paymentCurrencies ?? [branch.currency];
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Whether the branch can be paid, price a purchase or receive a supplier invoice in a currency
|
|
33
|
-
* other than its own. Its own currency is never a foreign one.
|
|
34
|
-
*/
|
|
35
|
-
export const isForeignPaymentCurrency = (branch: Branch, currencyCode: string): boolean =>
|
|
36
|
-
currencyCode !== branch.currency && getBranchPaymentCurrencies(branch).includes(currencyCode);
|
|
37
|
-
|
|
38
|
-
/** Whether the branch lists any payment currency other than its own. */
|
|
39
|
-
export const hasForeignPaymentCurrency = (branch: Branch): boolean =>
|
|
40
|
-
getBranchPaymentCurrencies(branch).some((currencyCode) =>
|
|
41
|
-
isForeignPaymentCurrency(branch, currencyCode),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
27
|
/** The source invoices the end customer directly; this branch collects payment and earns
|
|
45
28
|
* commission (see {@link Branch.dropshipping}). */
|
|
46
29
|
export const isDropshippingBranch = (branch: Branch): boolean => branch.dropshipping === true;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BusinessEntityIds } from '../constants.js';
|
|
2
|
+
import { TransportStatus, TransportType } from '../types/transports.js';
|
|
3
|
+
import { VehiclePurchaseLogisticsStatus } from '../types/vehicles.js';
|
|
4
|
+
import { getTransportDocumentOwner, isTransportCompleted } from './transports.js';
|
|
5
|
+
|
|
6
|
+
describe('getTransportDocumentOwner', () => {
|
|
7
|
+
test.each([
|
|
8
|
+
{
|
|
9
|
+
description: 'a sale transport files on its deal',
|
|
10
|
+
transport: { type: TransportType.Sale, vehicleId: 'V1', opportunityId: 'OPP1' },
|
|
11
|
+
expected: { businessEntityId: BusinessEntityIds.Opportunities, recordId: 'OPP1' },
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
description: 'a purchase transport files on its vehicle',
|
|
15
|
+
transport: { type: TransportType.Purchase, vehicleId: 'V1' },
|
|
16
|
+
expected: { businessEntityId: BusinessEntityIds.Vehicles, recordId: 'V1' },
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
description: 'a sale transport without a deal has no owner',
|
|
20
|
+
transport: { type: TransportType.Sale, vehicleId: 'V1' },
|
|
21
|
+
expected: undefined,
|
|
22
|
+
},
|
|
23
|
+
])('$description', ({ transport, expected }) => {
|
|
24
|
+
expect(getTransportDocumentOwner(transport)).toEqual(expected);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('isTransportCompleted', () => {
|
|
29
|
+
test.each([
|
|
30
|
+
{ status: TransportStatus.Done, expected: true },
|
|
31
|
+
{ status: TransportStatus.OngoingInternal, expected: false },
|
|
32
|
+
])('a sale transport at $status is completed: $expected', ({ status, expected }) => {
|
|
33
|
+
expect(isTransportCompleted({ type: TransportType.Sale, status }, {})).toBe(expected);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test.each([
|
|
37
|
+
{ logistics: VehiclePurchaseLogisticsStatus.Arrived, expected: true },
|
|
38
|
+
{ logistics: VehiclePurchaseLogisticsStatus.AtOrigin, expected: false },
|
|
39
|
+
])('a purchase transport whose vehicle is $logistics is completed: $expected', ({
|
|
40
|
+
logistics,
|
|
41
|
+
expected,
|
|
42
|
+
}) => {
|
|
43
|
+
expect(
|
|
44
|
+
isTransportCompleted(
|
|
45
|
+
{ type: TransportType.Purchase, status: TransportStatus.OngoingInternal },
|
|
46
|
+
{ purchase: { logistics: { status: logistics } } },
|
|
47
|
+
),
|
|
48
|
+
).toBe(expected);
|
|
49
|
+
});
|
|
50
|
+
});
|
package/src/utils/transports.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BusinessEntityIds } from '../constants.js';
|
|
1
2
|
import { PurchaseDeliveryTypes } from '../types/deliveries.js';
|
|
2
|
-
import { Opportunity } from '../types/opportunities.js';
|
|
3
3
|
import { PickFieldIds } from '../types/search.js';
|
|
4
|
-
import { SearchTransport, Transport, TransportType } from '../types/transports.js';
|
|
4
|
+
import { SearchTransport, Transport, TransportStatus, TransportType } from '../types/transports.js';
|
|
5
5
|
import { VehiclePurchase } from '../types/vehicles.js';
|
|
6
6
|
import { hasPurchaseArrived } from './vehicles.js';
|
|
7
7
|
|
|
@@ -14,39 +14,56 @@ export const isPurchaseDropOffTransport = (
|
|
|
14
14
|
isPurchaseTransport(transport) && transport.delivery.type === PurchaseDeliveryTypes.DROP_OFF;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* A transport is finished when the journey it describes
|
|
18
|
-
*
|
|
19
|
-
* the record is history and the server refuses edits to it.
|
|
17
|
+
* A transport is finished when the journey it describes is over. From then on the record is
|
|
18
|
+
* history and the server refuses edits to it.
|
|
20
19
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* A sale delivery is over when the transport itself is at Done: the transport drives the deal's
|
|
21
|
+
* delivery, not the other way around, so a deal delivered some other way (a CMR or the Deliver
|
|
22
|
+
* action, before that rule) does not lock a transport that never got there. Moving it out of Done
|
|
23
|
+
* unlocks it again.
|
|
24
|
+
*
|
|
25
|
+
* A purchase is over when the vehicle is on our park. The park declares the arrival on the purchase,
|
|
26
|
+
* without the transport ever being moved, and putting the purchase back to At origin is what
|
|
27
|
+
* unlocks the transport again.
|
|
25
28
|
*
|
|
26
29
|
* Shared so the board, the drawer and the server all answer the question the same way.
|
|
27
30
|
*/
|
|
28
31
|
export const isTransportCompleted = (
|
|
29
|
-
transport: Pick<Transport, 'type'>,
|
|
30
|
-
context: {
|
|
31
|
-
opportunity?: Pick<Opportunity, 'deliveredAt'>;
|
|
32
|
-
purchase?: { logistics: Pick<VehiclePurchase['logistics'], 'status'> };
|
|
33
|
-
},
|
|
32
|
+
transport: Pick<Transport, 'type' | 'status'>,
|
|
33
|
+
context: { purchase?: { logistics: Pick<VehiclePurchase['logistics'], 'status'> } } = {},
|
|
34
34
|
): boolean => {
|
|
35
35
|
if (transport.type === TransportType.Sale) {
|
|
36
|
-
return
|
|
36
|
+
return transport.status === TransportStatus.Done;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return context.purchase != null && hasPurchaseArrived(context.purchase);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
/** The same question asked of a search document, which already carries
|
|
42
|
+
/** The same question asked of a search document, which already carries the purchase. */
|
|
43
43
|
export const isSearchTransportCompleted = (
|
|
44
44
|
record: PickFieldIds<
|
|
45
45
|
SearchTransport,
|
|
46
|
-
'transport.type' | '
|
|
46
|
+
'transport.type' | 'transport.status' | 'purchase.logistics.status'
|
|
47
47
|
>,
|
|
48
|
-
): boolean =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
): boolean => isTransportCompleted(record.transport, { purchase: record.purchase });
|
|
49
|
+
|
|
50
|
+
export type TransportDocumentOwner = {
|
|
51
|
+
businessEntityId: BusinessEntityIds.Opportunities | BusinessEntityIds.Vehicles;
|
|
52
|
+
recordId: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Where a transport's documents are filed. A transport owns none: a sale's belong to the deal and a
|
|
57
|
+
* purchase's to the vehicle, whose purchase tab lists them. Undefined for a sale without a deal.
|
|
58
|
+
*/
|
|
59
|
+
export const getTransportDocumentOwner = (
|
|
60
|
+
transport: Pick<Transport, 'type' | 'vehicleId' | 'opportunityId'>,
|
|
61
|
+
): TransportDocumentOwner | undefined => {
|
|
62
|
+
if (isPurchaseTransport(transport)) {
|
|
63
|
+
return { businessEntityId: BusinessEntityIds.Vehicles, recordId: transport.vehicleId };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return transport.opportunityId == null
|
|
67
|
+
? undefined
|
|
68
|
+
: { businessEntityId: BusinessEntityIds.Opportunities, recordId: transport.opportunityId };
|
|
69
|
+
};
|