@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.
Files changed (49) hide show
  1. package/lib/constants.d.ts +1 -0
  2. package/lib/constants.d.ts.map +1 -1
  3. package/lib/constants.js +1 -0
  4. package/lib/constants.js.map +1 -1
  5. package/lib/types/activities.d.ts +3 -2
  6. package/lib/types/activities.d.ts.map +1 -1
  7. package/lib/types/activities.js.map +1 -1
  8. package/lib/types/leasing-debtors.d.ts +2 -0
  9. package/lib/types/leasing-debtors.d.ts.map +1 -1
  10. package/lib/types/leasing-debtors.js.map +1 -1
  11. package/lib/types/opportunities.d.ts +6 -1
  12. package/lib/types/opportunities.d.ts.map +1 -1
  13. package/lib/types/opportunities.js +1 -0
  14. package/lib/types/opportunities.js.map +1 -1
  15. package/lib/types/reports-leasing.d.ts +98 -0
  16. package/lib/types/reports-leasing.d.ts.map +1 -0
  17. package/lib/types/reports-leasing.js +11 -0
  18. package/lib/types/reports-leasing.js.map +1 -0
  19. package/lib/types/reports-sales.d.ts +6 -0
  20. package/lib/types/reports-sales.d.ts.map +1 -1
  21. package/lib/types/reports-sales.js.map +1 -1
  22. package/lib/types/tenants.d.ts +1 -0
  23. package/lib/types/tenants.d.ts.map +1 -1
  24. package/lib/types/tenants.js.map +1 -1
  25. package/lib/types/users.d.ts +17 -20
  26. package/lib/types/users.d.ts.map +1 -1
  27. package/lib/types/users.js.map +1 -1
  28. package/lib/types/vehicles.d.ts +1 -0
  29. package/lib/types/vehicles.d.ts.map +1 -1
  30. package/lib/types/vehicles.js.map +1 -1
  31. package/lib/utils/accounting.d.ts +1 -0
  32. package/lib/utils/accounting.d.ts.map +1 -1
  33. package/lib/utils/accounting.js +6 -0
  34. package/lib/utils/accounting.js.map +1 -1
  35. package/lib/utils/accounting.test.js +19 -1
  36. package/lib/utils/accounting.test.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/constants.ts +6 -0
  39. package/src/types/activities.ts +4 -3
  40. package/src/types/leasing-debtors.ts +3 -0
  41. package/src/types/opportunities.ts +12 -0
  42. package/src/types/reports-leasing.ts +195 -0
  43. package/src/types/reports-sales.ts +13 -3
  44. package/src/types/tenants.ts +2 -0
  45. package/src/types/users.ts +18 -21
  46. package/src/types/vehicles.ts +1 -0
  47. package/src/utils/accounting.test.ts +27 -1
  48. package/src/utils/accounting.ts +16 -0
  49. package/tsconfig.tsbuildinfo +1 -1
@@ -6,49 +6,46 @@ import {
6
6
  } from '@bisondesk/commons-sdk/types';
7
7
  import { OpportunityType } from '../constants.js';
8
8
 
9
- export type NewUserRequest = {
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 ValidNewUserRequest = Omit<NewUserRequest, 'phone' | 'landline'> & {
25
- phone: PhoneNumberValue;
26
- landline?: PhoneNumberValue;
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 UpdateUserRequest = Omit<User, 'phone' | 'landline'> & {
30
- phone: PhoneNumberRawValue | PhoneNumberValue;
31
- landline?: PhoneNumberRawValue | PhoneNumberValue;
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
- jobTitle?: string;
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
- preferredBranchIds?: string[];
51
- preferredOpportunityTypes?: OpportunityType[];
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
@@ -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 { branchHasAccounting, branchProvider, tenantHasAccounting } from './accounting.js';
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
+ });
@@ -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
+ };