@bisondesk/core-sdk 1.0.498 → 1.0.499
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 +2 -0
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +2 -0
- package/lib/constants.js.map +1 -1
- package/lib/types/activities.d.ts +17 -5
- package/lib/types/activities.d.ts.map +1 -1
- package/lib/types/activities.js +1 -0
- package/lib/types/activities.js.map +1 -1
- package/lib/types/internal-events.d.ts +2 -1
- package/lib/types/internal-events.d.ts.map +1 -1
- package/lib/types/internal-events.js +1 -0
- package/lib/types/internal-events.js.map +1 -1
- package/lib/types/journeys.d.ts +7 -0
- package/lib/types/journeys.d.ts.map +1 -1
- package/lib/types/journeys.js.map +1 -1
- package/lib/types/leasing-debtors.d.ts +228 -0
- package/lib/types/leasing-debtors.d.ts.map +1 -1
- package/lib/types/leasing-debtors.js +58 -1
- package/lib/types/leasing-debtors.js.map +1 -1
- package/lib/types/leasing.d.ts +1 -22
- package/lib/types/leasing.d.ts.map +1 -1
- package/lib/types/leasing.js.map +1 -1
- package/lib/utils/debtors-dossiers.d.ts +15 -0
- package/lib/utils/debtors-dossiers.d.ts.map +1 -0
- package/lib/utils/debtors-dossiers.js +51 -0
- package/lib/utils/debtors-dossiers.js.map +1 -0
- package/lib/utils/search.d.ts +3 -2
- package/lib/utils/search.d.ts.map +1 -1
- package/lib/utils/search.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +2 -0
- package/src/types/activities.ts +50 -4
- package/src/types/internal-events.ts +1 -0
- package/src/types/journeys.ts +8 -0
- package/src/types/leasing-debtors.ts +330 -0
- package/src/types/leasing.ts +0 -20
- package/src/utils/debtors-dossiers.ts +73 -0
- package/src/utils/search.ts +9 -2
- package/tsconfig.tsbuildinfo +1 -1
package/lib/utils/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"/","sources":["utils/search.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C,MAAM,CAAC;QACrD,+BAA+B,CAC7B,gBAAgB,EAChB,6BAA6B,CAAC,gBAAgB,EAAE,MAAM,CAAC,CACxD,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,gBAAmC,EACnC,MAA0B,EAC1B,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,gBAAmC,EACnC,MAA4B,EAC5B,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,gBAAmC,EACnC,YAAgC,EAChC,EAAE,CACF,yBAAyB,CACvB,gBAAgB,EAChB,6BAA6B,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAC9D,CAAC;AAEJ,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,gBAAmC,EACnC,MAA4B,EAC5B,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,gBAAmC,EACnC,YAAgC,EAChC,EAAE,CACF,wBAAwB,CACtB,gBAAgB,EAChB,6BAA6B,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAC9D,CAAC","sourcesContent":["import { joinWithSeparator } from '@bisondesk/commons-sdk/formatting';\nimport { BusinessEntityIds } from '../constants.js';\nimport { Contact, Organization, SearchOrganization } from '../types/crm.js';\nimport { SearchLeasingContract } from '../types/leasing-search.js';\nimport { LeasingContract } from '../types/leasing.js';\nimport { Opportunity, SearchOpportunity } from '../types/opportunities.js';\nimport { SearchVehicle, Vehicle } from '../types/vehicles.js';\n\nexport type GlobalBusinessEntity = Opportunity | Vehicle | Organization | LeasingContract;\nexport type GlobalSearchEntity =\n | SearchOpportunity\n | SearchVehicle\n | SearchOrganization\n | SearchLeasingContract;\n\nexport const getCustomerInformation = (org?: Organization, contact?: Contact) => {\n if (org != null) {\n return {\n countryCode: org.countryCode,\n title: org.name,\n code: org.externalId,\n };\n }\n\n if (contact != null) {\n return {\n countryCode: contact.countryCode,\n title: [contact?.firstName, contact?.lastName].filter(Boolean).join(' '),\n };\n }\n};\n\nexport const mappings: {\n [key in BusinessEntityIds]?: {\n getMainEntity: (entity: any) => GlobalBusinessEntity;\n getTitle: (entity: any) => string;\n getTags: (entity: any) => string[];\n getTagsForSearchEntity?: (entity: any) => string[];\n getDescription?: (entity: any) => string;\n getMeta?: (entity: any) => Record<string, any>;\n };\n} = {\n [BusinessEntityIds.Opportunities]: {\n getMainEntity: (entity: SearchOpportunity) => entity.opportunity,\n getTitle: (opp: Opportunity) => opp.id,\n getDescription: (opp: SearchOpportunity) => {\n const customer = getCustomerInformation(opp.org, opp.contact);\n return joinWithSeparator(\n [customer?.code, customer?.title, opp.vehicle?.external.identification.stockNumber].filter(\n Boolean\n )\n );\n },\n getTags: (opp: Opportunity) => [opp.id],\n getTagsForSearchEntity: (opp: SearchOpportunity) => {\n const vehicleTags =\n opp.vehicle != null\n ? getTagsForBusinessEntity(BusinessEntityIds.Vehicles, opp.vehicle)\n : [];\n return [...vehicleTags, opp.opportunity.id];\n },\n getMeta: (opp: Opportunity) => ({\n status: opp.status,\n wonAt: opp.wonAt,\n lostAt: opp.lostAt,\n }),\n },\n [BusinessEntityIds.Vehicles]: {\n getMainEntity: (entity: SearchVehicle) => entity.vehicle,\n getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,\n getTags: (vehicle: Vehicle) =>\n [\n // the order of the tags here is relevant for exact integration\n // see: packages/exact/src/service/purchase.ts\n vehicle.external.identification?.stockNumber,\n vehicle.internal.identification?.administrativeNumber,\n vehicle.external.identification?.vin,\n ].filter(Boolean) as string[],\n },\n [BusinessEntityIds.ExternalVehicleSale]: {\n getMainEntity: (entity: SearchVehicle) => entity.vehicle,\n getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,\n getTags: (vehicle: Vehicle) =>\n [\n // the order of the tags here is relevant for exact integration\n // see: packages/exact/src/service/purchase.ts\n vehicle.external.identification?.stockNumber,\n vehicle.internal.identification?.administrativeNumber,\n vehicle.external.identification?.vin,\n ].filter(Boolean) as string[],\n },\n [BusinessEntityIds.Organizations]: {\n getMainEntity: (entity: SearchOrganization) => entity.org,\n getTitle: (org: Organization) => org.name,\n getTags: (org: Organization) =>\n [`${org.externalId}`, org.vatNumber].filter(Boolean) as string[],\n },\n [BusinessEntityIds.LeasingContracts]: {\n getMainEntity: (entity: SearchLeasingContract) => entity.contract,\n getTitle: (contract: LeasingContract) => contract.contractNumber ?? contract.id,\n getTags: (contract: LeasingContract) =>\n [contract.id, contract.contractNumber].filter(Boolean) as string[],\n },\n [BusinessEntityIds.FinanceDocuments]: {\n getMainEntity: (entity: any) => entity,\n getTitle: (entity: any) => entity.id,\n getTags: (entity: any) => [entity.id],\n },\n [BusinessEntityIds.AdministrativeDocuments]: {\n getMainEntity: (entity: any) => entity,\n getTitle: (entity: any) => entity.id,\n getTags: (entity: any) => [entity.id],\n },\n};\n\nconst getMapping = (businessEntityId: BusinessEntityIds) => {\n const mapping = mappings[businessEntityId];\n if (!mapping) {\n throw new Error(`Invalid business entity id ${businessEntityId}`);\n }\n return mapping;\n};\n\nexport const getTagsForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n): string[] => getMapping(businessEntityId).getTags(entity);\n\nexport const getTagsForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => {\n const tags = getMapping(businessEntityId).getTagsForSearchEntity?.(entity);\n\n if (tags) {\n return tags;\n }\n\n return getTagsForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, entity)\n );\n};\n\nexport const getDescriptionForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => joinWithSeparator(getTagsForBusinessEntity(businessEntityId, entity));\n\nexport const getDescriptionForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => {\n return (\n getMapping(businessEntityId).getDescription?.(entity) ??\n getDescriptionForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, entity)\n )\n );\n};\n\nexport const getMainEntityFromSearchEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => getMapping(businessEntityId).getMainEntity(entity);\n\nexport const getTitleForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => getMapping(businessEntityId).getTitle(entity);\n\nexport const getTitleForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n searchEntity: GlobalSearchEntity\n) =>\n getTitleForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, searchEntity)\n );\n\nexport const getMetaForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => getMapping(businessEntityId).getMeta?.(entity);\n\nexport const getMetaForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n searchEntity: GlobalSearchEntity\n) =>\n getMetaForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, searchEntity)\n );\n"]}
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"/","sources":["utils/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAqBpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAiB,EAAE,EAAE;IAC9E,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO;YACL,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,KAAK,EAAE,GAAG,CAAC,IAAI;YAC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C,MAA4B,EAC5B,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,gBAAmC,EACnC,YAAgC,EAChC,EAAE,CACF,yBAAyB,CACvB,gBAAgB,EAChB,6BAA6B,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAC9D,CAAC;AAEJ,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,gBAAmC,EACnC,MAA4B,EAC5B,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,gBAAmC,EACnC,YAAgC,EAChC,EAAE,CACF,wBAAwB,CACtB,gBAAgB,EAChB,6BAA6B,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAC9D,CAAC","sourcesContent":["import { joinWithSeparator } from '@bisondesk/commons-sdk/formatting';\nimport { BusinessEntityIds } from '../constants.js';\nimport { Contact, Organization, SearchOrganization } from '../types/crm.js';\nimport { DebtorsDossier, SearchDebtorsDossier } from '../types/leasing-debtors.js';\nimport { SearchLeasingContract } from '../types/leasing-search.js';\nimport { LeasingContract } from '../types/leasing.js';\nimport { Opportunity, SearchOpportunity } from '../types/opportunities.js';\nimport { SearchVehicle, Vehicle } from '../types/vehicles.js';\n\nexport type GlobalBusinessEntity =\n | Opportunity\n | Vehicle\n | Organization\n | LeasingContract\n | DebtorsDossier;\nexport type GlobalSearchEntity =\n | SearchOpportunity\n | SearchVehicle\n | SearchOrganization\n | SearchLeasingContract\n | SearchDebtorsDossier;\n\nexport const getCustomerInformation = (org?: Organization, contact?: Contact) => {\n if (org != null) {\n return {\n countryCode: org.countryCode,\n title: org.name,\n code: org.externalId,\n };\n }\n\n if (contact != null) {\n return {\n countryCode: contact.countryCode,\n title: [contact?.firstName, contact?.lastName].filter(Boolean).join(' '),\n };\n }\n};\n\nexport const mappings: {\n [key in BusinessEntityIds]?: {\n getMainEntity: (entity: any) => GlobalBusinessEntity;\n getTitle: (entity: any) => string;\n getTags: (entity: any) => string[];\n getTagsForSearchEntity?: (entity: any) => string[];\n getDescription?: (entity: any) => string;\n getMeta?: (entity: any) => Record<string, any>;\n };\n} = {\n [BusinessEntityIds.Opportunities]: {\n getMainEntity: (entity: SearchOpportunity) => entity.opportunity,\n getTitle: (opp: Opportunity) => opp.id,\n getDescription: (opp: SearchOpportunity) => {\n const customer = getCustomerInformation(opp.org, opp.contact);\n return joinWithSeparator(\n [customer?.code, customer?.title, opp.vehicle?.external.identification.stockNumber].filter(\n Boolean\n )\n );\n },\n getTags: (opp: Opportunity) => [opp.id],\n getTagsForSearchEntity: (opp: SearchOpportunity) => {\n const vehicleTags =\n opp.vehicle != null\n ? getTagsForBusinessEntity(BusinessEntityIds.Vehicles, opp.vehicle)\n : [];\n return [...vehicleTags, opp.opportunity.id];\n },\n getMeta: (opp: Opportunity) => ({\n status: opp.status,\n wonAt: opp.wonAt,\n lostAt: opp.lostAt,\n }),\n },\n [BusinessEntityIds.Vehicles]: {\n getMainEntity: (entity: SearchVehicle) => entity.vehicle,\n getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,\n getTags: (vehicle: Vehicle) =>\n [\n // the order of the tags here is relevant for exact integration\n // see: packages/exact/src/service/purchase.ts\n vehicle.external.identification?.stockNumber,\n vehicle.internal.identification?.administrativeNumber,\n vehicle.external.identification?.vin,\n ].filter(Boolean) as string[],\n },\n [BusinessEntityIds.ExternalVehicleSale]: {\n getMainEntity: (entity: SearchVehicle) => entity.vehicle,\n getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,\n getTags: (vehicle: Vehicle) =>\n [\n // the order of the tags here is relevant for exact integration\n // see: packages/exact/src/service/purchase.ts\n vehicle.external.identification?.stockNumber,\n vehicle.internal.identification?.administrativeNumber,\n vehicle.external.identification?.vin,\n ].filter(Boolean) as string[],\n },\n [BusinessEntityIds.Organizations]: {\n getMainEntity: (entity: SearchOrganization) => entity.org,\n getTitle: (org: Organization) => org.name,\n getTags: (org: Organization) =>\n [`${org.externalId}`, org.vatNumber].filter(Boolean) as string[],\n },\n [BusinessEntityIds.LeasingContracts]: {\n getMainEntity: (entity: SearchLeasingContract) => entity.contract,\n getTitle: (contract: LeasingContract) => contract.contractNumber ?? contract.id,\n getTags: (contract: LeasingContract) =>\n [contract.id, contract.contractNumber].filter(Boolean) as string[],\n },\n [BusinessEntityIds.FinanceDocuments]: {\n getMainEntity: (entity: any) => entity,\n getTitle: (entity: any) => entity.id,\n getTags: (entity: any) => [entity.id],\n },\n [BusinessEntityIds.AdministrativeDocuments]: {\n getMainEntity: (entity: any) => entity,\n getTitle: (entity: any) => entity.id,\n getTags: (entity: any) => [entity.id],\n },\n};\n\nconst getMapping = (businessEntityId: BusinessEntityIds) => {\n const mapping = mappings[businessEntityId];\n if (!mapping) {\n throw new Error(`Invalid business entity id ${businessEntityId}`);\n }\n return mapping;\n};\n\nexport const getTagsForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n): string[] => getMapping(businessEntityId).getTags(entity);\n\nexport const getTagsForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => {\n const tags = getMapping(businessEntityId).getTagsForSearchEntity?.(entity);\n\n if (tags) {\n return tags;\n }\n\n return getTagsForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, entity)\n );\n};\n\nexport const getDescriptionForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => joinWithSeparator(getTagsForBusinessEntity(businessEntityId, entity));\n\nexport const getDescriptionForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => {\n return (\n getMapping(businessEntityId).getDescription?.(entity) ??\n getDescriptionForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, entity)\n )\n );\n};\n\nexport const getMainEntityFromSearchEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => getMapping(businessEntityId).getMainEntity(entity);\n\nexport const getTitleForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => getMapping(businessEntityId).getTitle(entity);\n\nexport const getTitleForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n searchEntity: GlobalSearchEntity\n) =>\n getTitleForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, searchEntity)\n );\n\nexport const getMetaForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => getMapping(businessEntityId).getMeta?.(entity);\n\nexport const getMetaForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n searchEntity: GlobalSearchEntity\n) =>\n getMetaForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, searchEntity)\n );\n"]}
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -11,6 +11,8 @@ export const CRM_CONTACT_TAGS_PICKLIST_ID = 'crmContactTags';
|
|
|
11
11
|
export const CRM_ORG_TAGS_PICKLIST_ID = 'crmOrganizationTags';
|
|
12
12
|
export const TIMEZONES_PICKLIST_ID = 'timezones';
|
|
13
13
|
export const COUNTRIES_PICKLIST_ID = 'countries';
|
|
14
|
+
export const DEBTORS_DOSSIER_STATUS_PICKLIST_ID = 'debtorsDossierStatus';
|
|
15
|
+
export const LEGAL_DOSSIER_STATUS_PICKLIST_ID = 'legalDossierStatus';
|
|
14
16
|
export const VEHICLE_MAIN_FEATURES_PICKLIST_ID = 'vehicleMainFeatures';
|
|
15
17
|
export const VEHICLE_STATE_FILTERS_PICKLIST_ID = 'vehicleStateFilters';
|
|
16
18
|
export const VEHICLE_SEARCH_SALE_DEAL_STATUS_PICKLIST_ID = 'vehicleSearchSaleDealStatus';
|
package/src/types/activities.ts
CHANGED
|
@@ -6,6 +6,7 @@ export enum ActivityType {
|
|
|
6
6
|
MEETING = 'meeting',
|
|
7
7
|
EMAIL = 'email',
|
|
8
8
|
CHAT = 'chat',
|
|
9
|
+
SMS = 'sms',
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export enum ActivityActions {
|
|
@@ -13,15 +14,16 @@ export enum ActivityActions {
|
|
|
13
14
|
EDIT = 'edit',
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
export interface BaseActivity<Meta = ActivityV2Meta> {
|
|
17
18
|
type: ActivityType;
|
|
18
19
|
businessEntityId: BusinessEntityIds;
|
|
19
20
|
recordId: string;
|
|
20
21
|
description?: string;
|
|
21
22
|
readonly?: boolean;
|
|
22
|
-
|
|
23
|
+
meta?: Meta;
|
|
24
|
+
}
|
|
23
25
|
|
|
24
|
-
export type NewActivity = BaseActivity & {
|
|
26
|
+
export type NewActivity<Meta = ActivityV2Meta> = BaseActivity<Meta> & {
|
|
25
27
|
id?: undefined;
|
|
26
28
|
createdAt?: undefined;
|
|
27
29
|
createdBy?: undefined;
|
|
@@ -30,7 +32,7 @@ export type NewActivity = BaseActivity & {
|
|
|
30
32
|
activityAt?: string;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
|
-
export type Activity = BaseActivity & {
|
|
35
|
+
export type Activity<Meta = ActivityV2Meta> = BaseActivity<Meta> & {
|
|
34
36
|
id: string;
|
|
35
37
|
createdAt: string;
|
|
36
38
|
createdBy: string;
|
|
@@ -73,3 +75,47 @@ export type ActivityDeleteEvent = BaseActivityEvent & {
|
|
|
73
75
|
data: undefined;
|
|
74
76
|
previousData: Activity;
|
|
75
77
|
};
|
|
78
|
+
|
|
79
|
+
/************
|
|
80
|
+
* ActivityV2Meta Types
|
|
81
|
+
* These types are used to define the structure of the metadata for different activity types.
|
|
82
|
+
************/
|
|
83
|
+
|
|
84
|
+
export type ActivityV2Meta =
|
|
85
|
+
| EmailDebtorsDossierActivityPayload
|
|
86
|
+
| CallDebtorsDossierActivityPayload
|
|
87
|
+
| MeetingDebtorsDossierActivityPayload
|
|
88
|
+
| ChatDebtorsDossierActivityPayload;
|
|
89
|
+
|
|
90
|
+
export type EmailDebtorsDossierActivityPayload = {
|
|
91
|
+
/* from: { email: string; name?: string; external?: boolean };
|
|
92
|
+
to: { email: string; name?: string }[];
|
|
93
|
+
cc?: { email: string; name?: string }[];
|
|
94
|
+
bcc?: { email: string; name?: string }[];
|
|
95
|
+
subject?: string;
|
|
96
|
+
attachments?: AttachmentValue[]; */
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type CallDebtorsDossierActivityPayload = {
|
|
100
|
+
didNotAnswer: boolean;
|
|
101
|
+
/* from: { phone: string; name?: string; external?: boolean };
|
|
102
|
+
to: string;
|
|
103
|
+
duration?: number;
|
|
104
|
+
recordingUrl?: string;
|
|
105
|
+
transcription?: string; */
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export type MeetingDebtorsDossierActivityPayload = {
|
|
109
|
+
/* organizer: string;
|
|
110
|
+
participants: string[];
|
|
111
|
+
location?: string;
|
|
112
|
+
startTime: string;
|
|
113
|
+
endTime: string; */
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export type ChatDebtorsDossierActivityPayload = {
|
|
117
|
+
/* from: { phone: string; name?: string; external?: boolean };
|
|
118
|
+
to: string[]; */
|
|
119
|
+
message: string;
|
|
120
|
+
platform: 'whatsapp' | 'sms';
|
|
121
|
+
};
|
package/src/types/journeys.ts
CHANGED
|
@@ -12,10 +12,12 @@ export type JourneyTaskConfig<T> = {
|
|
|
12
12
|
priority?: TaskPriority;
|
|
13
13
|
tag?: string;
|
|
14
14
|
description?: MultiLangValue;
|
|
15
|
+
dueDateOn?: string;
|
|
15
16
|
completionCriteria: RulesLogic<AdditionalOperation>;
|
|
16
17
|
prerequisiteTaskIds: string[];
|
|
17
18
|
requiredAtStatus?: T; //Required at a given status or higher
|
|
18
19
|
disabled: boolean;
|
|
20
|
+
autoAssignToRequester?: boolean;
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
export type JourneyConfig<T> = {
|
|
@@ -26,3 +28,9 @@ export type JourneyConfig<T> = {
|
|
|
26
28
|
createdBy: string;
|
|
27
29
|
disabled: boolean;
|
|
28
30
|
};
|
|
31
|
+
|
|
32
|
+
export type JourneyConfigCustomTasks<T> = Pick<JourneyConfig<T>, 'businessEntityId' | 'tasks'> & {
|
|
33
|
+
recordId: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
createdBy: string;
|
|
36
|
+
};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { EmailMessage } from '@bisondesk/commons-sdk/messages';
|
|
2
|
+
import { NextList, PaginatedList } from '@bisondesk/commons-sdk/types';
|
|
1
3
|
import { Contact, Organization } from './crm.js';
|
|
4
|
+
import { LeasingContract } from './leasing.js';
|
|
5
|
+
import { BaseSearchRequest, SortFilter, SortOrder } from './search.js';
|
|
6
|
+
import { DataRecord, ReferenceData } from './utils.js';
|
|
2
7
|
|
|
3
8
|
export type MonthData = {
|
|
4
9
|
activeContractIds: string[];
|
|
@@ -28,8 +33,333 @@ export type SearchDebtorInfo = {
|
|
|
28
33
|
org: Organization;
|
|
29
34
|
contact?: Contact;
|
|
30
35
|
debtor: DebtorInfo;
|
|
36
|
+
activeDebtorDossier?: {
|
|
37
|
+
dossier: DebtorsDossier;
|
|
38
|
+
hasDossier: boolean;
|
|
39
|
+
lastActivityAt?: string;
|
|
40
|
+
lastActivityBy?: string;
|
|
41
|
+
};
|
|
31
42
|
custom: {
|
|
32
43
|
riskLevelLabel: string;
|
|
33
44
|
hasActiveContracts: boolean;
|
|
34
45
|
};
|
|
35
46
|
};
|
|
47
|
+
|
|
48
|
+
export enum DebtorsDossierStatus {
|
|
49
|
+
AUTO_REMINDER = 'auto_reminder',
|
|
50
|
+
OVERDUE = 'overdue',
|
|
51
|
+
CONTACT_ATTEMPTED = 'contact_attempted',
|
|
52
|
+
DIALOGUE = 'dialogue',
|
|
53
|
+
PROMISE_TO_PAY = 'promise_to_pay',
|
|
54
|
+
FAILURE = 'failure',
|
|
55
|
+
RESOLVED = 'resolved',
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const debtorsDossierStatusToDateFieldMap: Record<
|
|
59
|
+
DebtorsDossierStatus,
|
|
60
|
+
{ date: keyof DossierStatusLogFields; author: keyof DossierStatusLogFields } | null
|
|
61
|
+
> = {
|
|
62
|
+
[DebtorsDossierStatus.AUTO_REMINDER]: null,
|
|
63
|
+
[DebtorsDossierStatus.OVERDUE]: { date: 'overdueAt', author: 'overdueBy' },
|
|
64
|
+
[DebtorsDossierStatus.CONTACT_ATTEMPTED]: { date: 'contactedAt', author: 'contactedBy' },
|
|
65
|
+
[DebtorsDossierStatus.DIALOGUE]: { date: 'dialogueAt', author: 'dialogueBy' },
|
|
66
|
+
[DebtorsDossierStatus.PROMISE_TO_PAY]: { date: 'promiseToPayAt', author: 'promiseToPayBy' },
|
|
67
|
+
[DebtorsDossierStatus.RESOLVED]: { date: 'resolvedAt', author: 'resolvedBy' },
|
|
68
|
+
[DebtorsDossierStatus.FAILURE]: { date: 'failedAt', author: 'failedBy' },
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/******
|
|
72
|
+
* Auto Follow-Up Types
|
|
73
|
+
******/
|
|
74
|
+
|
|
75
|
+
export type DebtorAutoFollowUp = {
|
|
76
|
+
id: string;
|
|
77
|
+
organizationId: string;
|
|
78
|
+
organizationName: string;
|
|
79
|
+
status: 'ONGOING' | 'ERROR' | 'SUCCESS' | 'EXPIRED' | 'DISCARDED';
|
|
80
|
+
emails: EmailMessage[];
|
|
81
|
+
createdAt: string;
|
|
82
|
+
modifiedAt: string;
|
|
83
|
+
completedAt?: string;
|
|
84
|
+
nextActionAt: string;
|
|
85
|
+
riskLevel: number;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type ListOverdueRemindersResponse = PaginatedList<DebtorAutoFollowUp, ReferenceData>;
|
|
89
|
+
export type ListOverdueRemindersRequest = {
|
|
90
|
+
offset: number;
|
|
91
|
+
limit: number;
|
|
92
|
+
sortBy: SortFilter;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/******
|
|
96
|
+
* Debtor Dossier Types
|
|
97
|
+
******/
|
|
98
|
+
|
|
99
|
+
export enum DebtorsDossierActions {
|
|
100
|
+
SET_METADATA = 'set_metadata',
|
|
101
|
+
ADD_ACTIVITY = 'add_activity',
|
|
102
|
+
FINISH = 'finish',
|
|
103
|
+
SET_DOCUMENTS = 'set_documents',
|
|
104
|
+
SET_PAYMENT_PLAN = 'set_payment_plan',
|
|
105
|
+
SET_LEGAL_DOSSIER = 'set_legal_dossier',
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type DossierStatusLogFields = {
|
|
109
|
+
failedAt?: string;
|
|
110
|
+
failedBy?: string;
|
|
111
|
+
resolvedAt?: string;
|
|
112
|
+
contactedAt?: string;
|
|
113
|
+
contactedBy?: string;
|
|
114
|
+
overdueAt?: string;
|
|
115
|
+
overdueBy?: string;
|
|
116
|
+
resolvedBy?: string;
|
|
117
|
+
dialogueAt?: string;
|
|
118
|
+
dialogueBy?: string;
|
|
119
|
+
promiseToPayAt?: string;
|
|
120
|
+
promiseToPayBy?: string;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export type BaseDebtorsDossier = {
|
|
124
|
+
organizationId: string;
|
|
125
|
+
contactId?: string;
|
|
126
|
+
tags: string[];
|
|
127
|
+
origin: 'manual' | 'auto';
|
|
128
|
+
autoFollowUpId?: string;
|
|
129
|
+
administrativeUserId?: string;
|
|
130
|
+
branchId: string;
|
|
131
|
+
tenantId: string;
|
|
132
|
+
};
|
|
133
|
+
export type DebtorsDossierStatusAudit = {
|
|
134
|
+
from: DebtorsDossierStatus;
|
|
135
|
+
to: DebtorsDossierStatus;
|
|
136
|
+
changedAt: string;
|
|
137
|
+
changedBy: string;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export type DebtorsDossier = BaseDebtorsDossier &
|
|
141
|
+
DossierStatusLogFields & {
|
|
142
|
+
id: string;
|
|
143
|
+
createdAt: string;
|
|
144
|
+
createdBy: string;
|
|
145
|
+
updatedAt: string;
|
|
146
|
+
updatedBy: string;
|
|
147
|
+
status: DebtorsDossierStatus;
|
|
148
|
+
statusAudit: DebtorsDossierStatusAudit[];
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export type NewDebtorsDossier = BaseDebtorsDossier & {
|
|
152
|
+
id?: undefined;
|
|
153
|
+
createdBy?: undefined;
|
|
154
|
+
createdAt?: undefined;
|
|
155
|
+
updatedBy?: undefined;
|
|
156
|
+
updatedAt?: undefined;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export type DebtorsDossierBff = {
|
|
160
|
+
dossier: DataRecord<DebtorsDossier>;
|
|
161
|
+
organization?: Organization;
|
|
162
|
+
contact?: Contact;
|
|
163
|
+
leasingContracts: LeasingContract[];
|
|
164
|
+
debt?: DebtorInfo;
|
|
165
|
+
paymentPlan?: DebtorsPaymentPlan;
|
|
166
|
+
legalDossier?: LegalDossier;
|
|
167
|
+
trackAndTraceDevices: {
|
|
168
|
+
/* odometer: TrackAndTraceOdometerData;
|
|
169
|
+
device: TrackAndTraceDevice; */
|
|
170
|
+
}[];
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export type UpdateDebtorsDossier = Partial<
|
|
174
|
+
Pick<
|
|
175
|
+
DebtorsDossier,
|
|
176
|
+
'status' | 'tags' | 'contactId' | 'administrativeUserId' | 'branchId' | 'organizationId'
|
|
177
|
+
>
|
|
178
|
+
> & {
|
|
179
|
+
overdue?: boolean;
|
|
180
|
+
resolve?: boolean;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/******
|
|
184
|
+
* Payment Plan Types
|
|
185
|
+
******/
|
|
186
|
+
|
|
187
|
+
export type DebtorsPaymentPlan = {
|
|
188
|
+
id: string;
|
|
189
|
+
debtorDossierId: string;
|
|
190
|
+
|
|
191
|
+
notes: {
|
|
192
|
+
content: string;
|
|
193
|
+
createdAt: string;
|
|
194
|
+
createdBy: string;
|
|
195
|
+
}[];
|
|
196
|
+
|
|
197
|
+
reminders?: {
|
|
198
|
+
startDate: string; // ISO date string
|
|
199
|
+
frequency: {
|
|
200
|
+
every: number;
|
|
201
|
+
period: 'days' | 'weeks' | 'months';
|
|
202
|
+
};
|
|
203
|
+
endCondition:
|
|
204
|
+
| {
|
|
205
|
+
endDate: string; // ISO date string
|
|
206
|
+
}
|
|
207
|
+
| {
|
|
208
|
+
occurrences: number; // Number of reminders to send
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
createdAt: string;
|
|
213
|
+
createdBy: string;
|
|
214
|
+
updatedAt: string;
|
|
215
|
+
updatedBy: string;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export type NewPaymentPlan = Omit<
|
|
219
|
+
DebtorsPaymentPlan,
|
|
220
|
+
'id' | 'createdAt' | 'updatedAt' | 'createdBy' | 'updatedBy' | 'notes'
|
|
221
|
+
> & { notes?: string };
|
|
222
|
+
|
|
223
|
+
export type UpdatePaymentPlan = Partial<Pick<DebtorsPaymentPlan, 'reminders'>> & {
|
|
224
|
+
newNote?: string;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/******
|
|
228
|
+
* Legal Dossier Types
|
|
229
|
+
******/
|
|
230
|
+
|
|
231
|
+
export enum LegalDossierStatus {
|
|
232
|
+
ASSESSMENT = 'assessment',
|
|
233
|
+
PRE_LEGAL_NOTICE = 'pre_legal_notice',
|
|
234
|
+
SENT_TO_LAWYER = 'sent_to_lawyer',
|
|
235
|
+
FILED = 'filed',
|
|
236
|
+
IN_COURT = 'in_court',
|
|
237
|
+
JUDGMENT = 'judgment',
|
|
238
|
+
ENFORCEMENT = 'enforcement',
|
|
239
|
+
SETTLEMENT = 'settlement',
|
|
240
|
+
CLOSED_RECOVERED = 'closed_recovered',
|
|
241
|
+
CLOSED_UNRECOVERABLE = 'closed_unrecoverable',
|
|
242
|
+
ON_HOLD = 'on_hold',
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export type LegalDossier = {
|
|
246
|
+
id: string;
|
|
247
|
+
debtorDossierId: string;
|
|
248
|
+
caseNumber?: string;
|
|
249
|
+
notes?: string;
|
|
250
|
+
createdAt: string;
|
|
251
|
+
createdBy: string;
|
|
252
|
+
updatedAt: string;
|
|
253
|
+
updatedBy: string;
|
|
254
|
+
status: LegalDossierStatus;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
export type NewLegalDossier = Omit<
|
|
258
|
+
LegalDossier,
|
|
259
|
+
'id' | 'createdAt' | 'updatedAt' | 'createdBy' | 'updatedBy'
|
|
260
|
+
>;
|
|
261
|
+
|
|
262
|
+
export type UpdateLegalDossier = Partial<Pick<LegalDossier, 'caseNumber' | 'status' | 'notes'>>;
|
|
263
|
+
|
|
264
|
+
/******
|
|
265
|
+
* Debtor Dossier Events
|
|
266
|
+
******/
|
|
267
|
+
|
|
268
|
+
export type DebtorsDossierCreateEvent = {
|
|
269
|
+
action: 'created';
|
|
270
|
+
data: DebtorsDossier;
|
|
271
|
+
previousData?: undefined;
|
|
272
|
+
tenantId: string;
|
|
273
|
+
userId: string;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export type DebtorsDossierUpdateEvent = {
|
|
277
|
+
action: 'updated';
|
|
278
|
+
data: DebtorsDossier;
|
|
279
|
+
previousData: DebtorsDossier;
|
|
280
|
+
tenantId: string;
|
|
281
|
+
userId: string;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export type DebtorsDossierDeleteEvent = {
|
|
285
|
+
action: 'deleted';
|
|
286
|
+
data?: undefined;
|
|
287
|
+
previousData: DebtorsDossier;
|
|
288
|
+
tenantId: string;
|
|
289
|
+
userId: string;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
export type DebtorsDossierEvent =
|
|
293
|
+
| DebtorsDossierCreateEvent
|
|
294
|
+
| DebtorsDossierUpdateEvent
|
|
295
|
+
| DebtorsDossierDeleteEvent;
|
|
296
|
+
|
|
297
|
+
/************
|
|
298
|
+
*
|
|
299
|
+
* Search
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
export type SearchDebtorsDossier = {
|
|
303
|
+
contact?: Contact;
|
|
304
|
+
debtorsDossier: DebtorsDossier;
|
|
305
|
+
org?: Organization;
|
|
306
|
+
legalDossier?: LegalDossier;
|
|
307
|
+
paymentPlan?: DebtorsPaymentPlan;
|
|
308
|
+
tasks: {
|
|
309
|
+
totalTasks: number;
|
|
310
|
+
openTasks: number;
|
|
311
|
+
nextDueAt?: string;
|
|
312
|
+
};
|
|
313
|
+
overdue: {
|
|
314
|
+
remindersSent: number;
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
/************
|
|
319
|
+
*
|
|
320
|
+
* Kanban
|
|
321
|
+
*/
|
|
322
|
+
|
|
323
|
+
export type DebtorsDossierKanbanColumn = {
|
|
324
|
+
status: DebtorsDossierStatus;
|
|
325
|
+
results: SearchDebtorsDossier[];
|
|
326
|
+
totalCount: number;
|
|
327
|
+
totalValue: string;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
export type MSearchDebtorsDossierKanbanColumn = {
|
|
331
|
+
column: DebtorsDossierKanbanColumn;
|
|
332
|
+
nextToken?: string;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export type KanbanDebtorsDossierSearchRequest = BaseSearchRequest & {
|
|
336
|
+
nextTokens?: Record<string, string | undefined>;
|
|
337
|
+
statusSortBy?: Record<DebtorsDossierStatus, { fieldId: string; order: SortOrder }[]>;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export type KanbanDebtorsDossierNextList = Omit<
|
|
341
|
+
NextList<DebtorsDossierKanbanColumn, ReferenceData>,
|
|
342
|
+
'nextToken'
|
|
343
|
+
> & {
|
|
344
|
+
nextTokens?: Record<string, string | undefined>;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export const DebtorsDossierStatusOrder: DebtorsDossierStatus[] = [
|
|
348
|
+
DebtorsDossierStatus.AUTO_REMINDER,
|
|
349
|
+
DebtorsDossierStatus.OVERDUE,
|
|
350
|
+
DebtorsDossierStatus.CONTACT_ATTEMPTED,
|
|
351
|
+
DebtorsDossierStatus.DIALOGUE,
|
|
352
|
+
DebtorsDossierStatus.PROMISE_TO_PAY,
|
|
353
|
+
];
|
|
354
|
+
|
|
355
|
+
export const DebtorsDossierWonColumnId = DebtorsDossierStatus.RESOLVED;
|
|
356
|
+
|
|
357
|
+
export const DebtorsDossierKanbanEndColumns: DebtorsDossierStatus[] = [
|
|
358
|
+
DebtorsDossierStatus.RESOLVED,
|
|
359
|
+
DebtorsDossierStatus.FAILURE,
|
|
360
|
+
];
|
|
361
|
+
|
|
362
|
+
export const DebtorsDossierKanbanColumns = [
|
|
363
|
+
...DebtorsDossierStatusOrder,
|
|
364
|
+
...DebtorsDossierKanbanEndColumns,
|
|
365
|
+
];
|
package/src/types/leasing.ts
CHANGED
|
@@ -42,19 +42,6 @@ export type LeasingConditionEvent = {
|
|
|
42
42
|
tenantId: string;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
export type OverdueDossier = {
|
|
46
|
-
id: string;
|
|
47
|
-
organizationId: string;
|
|
48
|
-
organizationName: string;
|
|
49
|
-
status: 'ONGOING' | 'ERROR' | 'SUCCESS' | 'EXPIRED' | 'DISCARDED';
|
|
50
|
-
emails: EmailMessage[];
|
|
51
|
-
createdAt: string;
|
|
52
|
-
modifiedAt: string;
|
|
53
|
-
completedAt?: string;
|
|
54
|
-
nextActionAt: string;
|
|
55
|
-
riskLevel: number;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
45
|
export type LeasingContractClient = {
|
|
59
46
|
organizationId: string;
|
|
60
47
|
contactIds: string[];
|
|
@@ -193,13 +180,6 @@ export type OpportunityRef = BaseRef & {
|
|
|
193
180
|
//Since VAT is client specific and contracts can be transferred between clients, we always handle values without VAT
|
|
194
181
|
};
|
|
195
182
|
|
|
196
|
-
export type ListOverdueRemindersResponse = PaginatedList<OverdueDossier, ReferenceData>;
|
|
197
|
-
export type ListOverdueRemindersRequest = {
|
|
198
|
-
offset: number;
|
|
199
|
-
limit: number;
|
|
200
|
-
sortBy: SortFilter;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
183
|
export type NewLeasingConditions = {
|
|
204
184
|
parameters: {
|
|
205
185
|
yearlyRoadTax: string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { DebtorsDossier, DebtorsDossierStatus } from '@bisondesk/core-sdk/types/leasing-debtors';
|
|
2
|
+
|
|
3
|
+
export const DebtorsDossierStatusOrder: DebtorsDossierStatus[] = [
|
|
4
|
+
DebtorsDossierStatus.AUTO_REMINDER,
|
|
5
|
+
DebtorsDossierStatus.OVERDUE,
|
|
6
|
+
DebtorsDossierStatus.CONTACT_ATTEMPTED,
|
|
7
|
+
DebtorsDossierStatus.DIALOGUE,
|
|
8
|
+
DebtorsDossierStatus.PROMISE_TO_PAY,
|
|
9
|
+
DebtorsDossierStatus.FAILURE,
|
|
10
|
+
DebtorsDossierStatus.RESOLVED,
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
type CompareInput = {
|
|
14
|
+
currentStatus: DebtorsDossierStatus;
|
|
15
|
+
referenceStatus: DebtorsDossierStatus;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const compareDebtorsDossierStatus = (input: CompareInput) => {
|
|
19
|
+
const { currentStatus, referenceStatus } = input;
|
|
20
|
+
|
|
21
|
+
const currentStatusIdx = DebtorsDossierStatusOrder.indexOf(currentStatus);
|
|
22
|
+
const referenceStatusIdx = DebtorsDossierStatusOrder.indexOf(referenceStatus);
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
currentStatusIdx,
|
|
26
|
+
referenceStatusIdx,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const getPreviousStatus = (
|
|
31
|
+
currentStatus: DebtorsDossierStatus
|
|
32
|
+
): DebtorsDossierStatus | undefined => {
|
|
33
|
+
const currentIndex = DebtorsDossierStatusOrder.indexOf(currentStatus);
|
|
34
|
+
if (currentIndex <= 0) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
return DebtorsDossierStatusOrder[currentIndex - 1];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const getNextStatus = (status: DebtorsDossierStatus): DebtorsDossierStatus | undefined => {
|
|
41
|
+
const statusIndex = DebtorsDossierStatusOrder.indexOf(status);
|
|
42
|
+
if (statusIndex >= DebtorsDossierStatusOrder.length - 1) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
return DebtorsDossierStatusOrder[statusIndex + 1];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const isSameOrAfterReferenceDebtorsDossierStatus = (input: CompareInput): boolean => {
|
|
49
|
+
const { currentStatusIdx, referenceStatusIdx } = compareDebtorsDossierStatus(input);
|
|
50
|
+
|
|
51
|
+
return currentStatusIdx >= referenceStatusIdx;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const isAfterReferenceDebtorsDossierStatus = (input: CompareInput): boolean => {
|
|
55
|
+
const { currentStatusIdx, referenceStatusIdx } = compareDebtorsDossierStatus(input);
|
|
56
|
+
|
|
57
|
+
return currentStatusIdx > referenceStatusIdx;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const isSameOrBeforeReferenceDebtorsDossierStatus = (input: CompareInput): boolean => {
|
|
61
|
+
const { currentStatusIdx, referenceStatusIdx } = compareDebtorsDossierStatus(input);
|
|
62
|
+
|
|
63
|
+
return currentStatusIdx <= referenceStatusIdx;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const isBeforeReferenceDebtorsDossierStatus = (input: CompareInput): boolean => {
|
|
67
|
+
const { currentStatusIdx, referenceStatusIdx } = compareDebtorsDossierStatus(input);
|
|
68
|
+
|
|
69
|
+
return currentStatusIdx < referenceStatusIdx;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const isDossierFinished = (dossier: DebtorsDossier): boolean =>
|
|
73
|
+
dossier.resolvedAt != null || dossier.failedAt != null;
|
package/src/utils/search.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { joinWithSeparator } from '@bisondesk/commons-sdk/formatting';
|
|
2
2
|
import { BusinessEntityIds } from '../constants.js';
|
|
3
3
|
import { Contact, Organization, SearchOrganization } from '../types/crm.js';
|
|
4
|
+
import { DebtorsDossier, SearchDebtorsDossier } from '../types/leasing-debtors.js';
|
|
4
5
|
import { SearchLeasingContract } from '../types/leasing-search.js';
|
|
5
6
|
import { LeasingContract } from '../types/leasing.js';
|
|
6
7
|
import { Opportunity, SearchOpportunity } from '../types/opportunities.js';
|
|
7
8
|
import { SearchVehicle, Vehicle } from '../types/vehicles.js';
|
|
8
9
|
|
|
9
|
-
export type GlobalBusinessEntity =
|
|
10
|
+
export type GlobalBusinessEntity =
|
|
11
|
+
| Opportunity
|
|
12
|
+
| Vehicle
|
|
13
|
+
| Organization
|
|
14
|
+
| LeasingContract
|
|
15
|
+
| DebtorsDossier;
|
|
10
16
|
export type GlobalSearchEntity =
|
|
11
17
|
| SearchOpportunity
|
|
12
18
|
| SearchVehicle
|
|
13
19
|
| SearchOrganization
|
|
14
|
-
| SearchLeasingContract
|
|
20
|
+
| SearchLeasingContract
|
|
21
|
+
| SearchDebtorsDossier;
|
|
15
22
|
|
|
16
23
|
export const getCustomerInformation = (org?: Organization, contact?: Contact) => {
|
|
17
24
|
if (org != null) {
|