@bisondesk/core-sdk 1.0.609 → 1.0.611
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/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/activities.d.ts +3 -2
- package/lib/types/activities.d.ts.map +1 -1
- package/lib/types/activities.js.map +1 -1
- package/lib/types/leasing-debtors.d.ts +2 -0
- package/lib/types/leasing-debtors.d.ts.map +1 -1
- package/lib/types/leasing-debtors.js.map +1 -1
- package/lib/types/opportunities.d.ts +6 -1
- package/lib/types/opportunities.d.ts.map +1 -1
- package/lib/types/opportunities.js +1 -0
- package/lib/types/opportunities.js.map +1 -1
- package/lib/types/reports-leasing.d.ts +98 -0
- package/lib/types/reports-leasing.d.ts.map +1 -0
- package/lib/types/reports-leasing.js +11 -0
- package/lib/types/reports-leasing.js.map +1 -0
- package/lib/types/reports-sales.d.ts +6 -0
- package/lib/types/reports-sales.d.ts.map +1 -1
- package/lib/types/reports-sales.js.map +1 -1
- package/lib/types/tenants.d.ts +1 -0
- package/lib/types/tenants.d.ts.map +1 -1
- package/lib/types/tenants.js.map +1 -1
- package/lib/types/users.d.ts +17 -20
- package/lib/types/users.d.ts.map +1 -1
- package/lib/types/users.js.map +1 -1
- package/lib/types/vehicles.d.ts +1 -0
- package/lib/types/vehicles.d.ts.map +1 -1
- package/lib/types/vehicles.js.map +1 -1
- package/lib/utils/accounting.d.ts +1 -0
- package/lib/utils/accounting.d.ts.map +1 -1
- package/lib/utils/accounting.js +6 -0
- package/lib/utils/accounting.js.map +1 -1
- package/lib/utils/accounting.test.js +19 -1
- package/lib/utils/accounting.test.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +6 -0
- package/src/types/activities.ts +4 -3
- package/src/types/leasing-debtors.ts +3 -0
- package/src/types/opportunities.ts +12 -0
- package/src/types/reports-leasing.ts +195 -0
- package/src/types/reports-sales.ts +13 -3
- package/src/types/tenants.ts +2 -0
- package/src/types/users.ts +18 -21
- package/src/types/vehicles.ts +1 -0
- package/src/utils/accounting.test.ts +27 -1
- package/src/utils/accounting.ts +16 -0
- package/tsconfig.tsbuildinfo +1 -1
package/src/types/users.ts
CHANGED
|
@@ -6,49 +6,46 @@ import {
|
|
|
6
6
|
} from '@bisondesk/commons-sdk/types';
|
|
7
7
|
import { OpportunityType } from '../constants.js';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
type BaseUser = {
|
|
10
10
|
email: string;
|
|
11
11
|
firstName: string;
|
|
12
12
|
googleEmail?: string;
|
|
13
13
|
jobTitle?: string;
|
|
14
|
-
landline?: PhoneNumberRawValue; // landline phone number
|
|
15
14
|
language: string;
|
|
16
15
|
lastName: string;
|
|
17
|
-
phone: PhoneNumberRawValue;
|
|
18
16
|
picture?: AttachmentValue;
|
|
19
17
|
roles: AppRoles[];
|
|
20
18
|
preferredBranchIds?: string[];
|
|
21
19
|
preferredOpportunityTypes?: OpportunityType[];
|
|
22
20
|
};
|
|
23
21
|
|
|
24
|
-
export type
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
export type NewUserRequest = BaseUser & {
|
|
23
|
+
landline?: PhoneNumberRawValue;
|
|
24
|
+
phone: PhoneNumberRawValue;
|
|
25
|
+
twilioPhoneNumber?: PhoneNumberRawValue; // Twilio caller ID used when placing calls
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
export type
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
export type ValidNewUserRequest = BaseUser & {
|
|
29
|
+
landline?: PhoneNumberValue;
|
|
30
|
+
phone: PhoneNumberValue;
|
|
31
|
+
twilioPhoneNumber?: PhoneNumberValue;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export type User = {
|
|
34
|
+
export type User = BaseUser & {
|
|
35
35
|
active: boolean;
|
|
36
36
|
createdAt: string;
|
|
37
|
-
email: string;
|
|
38
|
-
firstName: string;
|
|
39
|
-
googleEmail?: string;
|
|
40
37
|
id: string;
|
|
41
|
-
|
|
42
|
-
landline?: PhoneNumberValue; // landline phone number
|
|
43
|
-
language: string;
|
|
44
|
-
lastName: string;
|
|
38
|
+
landline?: PhoneNumberValue;
|
|
45
39
|
phone: PhoneNumberValue;
|
|
46
|
-
picture?: AttachmentValue;
|
|
47
40
|
roleActions?: TopLevelActions[]; // auto-generated based on the roles provided in the request
|
|
48
|
-
roles: AppRoles[];
|
|
49
41
|
updatedAt: string;
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
twilioPhoneNumber?: PhoneNumberValue; // Twilio caller ID used when placing calls
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type UpdateUserRequest = Omit<User, 'phone' | 'landline' | 'twilioPhoneNumber'> & {
|
|
46
|
+
phone: PhoneNumberRawValue | PhoneNumberValue;
|
|
47
|
+
landline?: PhoneNumberRawValue | PhoneNumberValue;
|
|
48
|
+
twilioPhoneNumber?: PhoneNumberRawValue | PhoneNumberValue;
|
|
52
49
|
};
|
|
53
50
|
|
|
54
51
|
// Short version of the User entity, with only the properties
|
package/src/types/vehicles.ts
CHANGED
|
@@ -260,6 +260,7 @@ export type SearchVehicle = {
|
|
|
260
260
|
dealStatus?: VehiclePurchaseDealStatus;
|
|
261
261
|
logisticsStatus?: VehiclePurchaseLogisticsStatus;
|
|
262
262
|
purchasedBy?: string;
|
|
263
|
+
purchaseAgreedAt?: string;
|
|
263
264
|
parkingName?: string;
|
|
264
265
|
organizationId: string;
|
|
265
266
|
organizationExternalId?: number;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Branch, Tenant } from '../types/tenants.js';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
branchHasAccounting,
|
|
4
|
+
branchHasAccountingInTenant,
|
|
5
|
+
branchProvider,
|
|
6
|
+
tenantHasAccounting,
|
|
7
|
+
} from './accounting.js';
|
|
3
8
|
|
|
4
9
|
const makeBranch = (overrides: Partial<Branch> = {}): Branch => ({
|
|
5
10
|
id: 'b1',
|
|
@@ -87,3 +92,24 @@ describe('tenantHasAccounting', () => {
|
|
|
87
92
|
expect(tenantHasAccounting(undefined)).toBe(false);
|
|
88
93
|
});
|
|
89
94
|
});
|
|
95
|
+
|
|
96
|
+
describe('branchHasAccountingInTenant', () => {
|
|
97
|
+
it('resolves per branch in a mixed tenant', () => {
|
|
98
|
+
const tenant = makeTenant([
|
|
99
|
+
makeBranch({ id: 'odoo-branch', accounting: 'odoo' }),
|
|
100
|
+
makeBranch({ id: 'plain-branch' }),
|
|
101
|
+
]);
|
|
102
|
+
expect(branchHasAccountingInTenant(tenant, 'odoo-branch')).toBe(true);
|
|
103
|
+
expect(branchHasAccountingInTenant(tenant, 'plain-branch')).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('ignores the deprecated tenant-wide flag and resolves per branch', () => {
|
|
107
|
+
const tenant = makeTenant([makeBranch({ id: 'plain-branch' })], { exactAccounting: true });
|
|
108
|
+
expect(branchHasAccountingInTenant(tenant, 'plain-branch')).toBe(false);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('is false for an unknown branch or missing tenant', () => {
|
|
112
|
+
expect(branchHasAccountingInTenant(makeTenant([makeBranch()]), 'nope')).toBe(false);
|
|
113
|
+
expect(branchHasAccountingInTenant(undefined, 'b1')).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
});
|
package/src/utils/accounting.ts
CHANGED
|
@@ -22,3 +22,19 @@ export const tenantHasAccounting = (tenant: Tenant | undefined): boolean => {
|
|
|
22
22
|
}
|
|
23
23
|
return tenant.branches.some((b) => branchHasAccounting(b));
|
|
24
24
|
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Whether a specific branch books through an accounting integration. Resolves
|
|
28
|
+
* purely per branch — a tenant can mix accounting and non-accounting branches.
|
|
29
|
+
* Accounting is carried on the branch (`accounting`, or the deprecated
|
|
30
|
+
* `exactAccounting`), so the tenant-wide flag is not consulted.
|
|
31
|
+
*/
|
|
32
|
+
export const branchHasAccountingInTenant = (
|
|
33
|
+
tenant: Tenant | undefined,
|
|
34
|
+
branchId: string,
|
|
35
|
+
): boolean => {
|
|
36
|
+
if (tenant == null) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return branchHasAccounting(tenant.branches.find((b) => b.id === branchId));
|
|
40
|
+
};
|