@bisondesk/documents-sdk 1.0.588 → 1.0.589

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.
@@ -19,7 +19,7 @@ import { StorecoveEvidenceStatus } from '../types/storecove.js';
19
19
  export const getDocumentCategory = async <T extends DocumentCategory>(
20
20
  tenantId: string,
21
21
  branchId: string,
22
- docCategoryId: string
22
+ docCategoryId: string,
23
23
  ): Promise<T | undefined> => {
24
24
  const auth = await getAdminAuth();
25
25
  const response: Response = await fetch(
@@ -29,7 +29,7 @@ export const getDocumentCategory = async <T extends DocumentCategory>(
29
29
  Authorization: auth,
30
30
  [TENANT_ID_ADMIN_HEADER]: tenantId,
31
31
  },
32
- }
32
+ },
33
33
  );
34
34
 
35
35
  if (response.status === 200) {
@@ -52,7 +52,7 @@ export const listDocumentCategories = async <T extends DocumentCategory>(
52
52
  filter: {
53
53
  type: DocumentCategoryType;
54
54
  transactionType?: TransactionType;
55
- }
55
+ },
56
56
  ): Promise<T[]> => {
57
57
  const auth = await getAdminAuth();
58
58
  const response: Response = await fetch(
@@ -66,7 +66,7 @@ export const listDocumentCategories = async <T extends DocumentCategory>(
66
66
  Authorization: auth,
67
67
  [TENANT_ID_ADMIN_HEADER]: tenantId,
68
68
  },
69
- }
69
+ },
70
70
  );
71
71
 
72
72
  if (response.status === 200) {
@@ -85,7 +85,7 @@ export const listDocumentCategories = async <T extends DocumentCategory>(
85
85
  export const listFinanceLineCategories = async (
86
86
  tenantId: string,
87
87
  branchId: string,
88
- docCategoryId: string
88
+ docCategoryId: string,
89
89
  ): Promise<FinanceDocumentLineCategory[]> => {
90
90
  const auth = await getAdminAuth();
91
91
  const response: Response = await fetch(
@@ -95,7 +95,7 @@ export const listFinanceLineCategories = async (
95
95
  Authorization: auth,
96
96
  [TENANT_ID_ADMIN_HEADER]: tenantId,
97
97
  },
98
- }
98
+ },
99
99
  );
100
100
 
101
101
  if (response.status === 200) {
@@ -114,7 +114,7 @@ export const listFinanceLineCategories = async (
114
114
 
115
115
  export const listVehicleFinanceLineCategories = async (
116
116
  tenantId: string,
117
- branchId: string
117
+ branchId: string,
118
118
  ): Promise<FinanceDocumentLineCategory[]> => {
119
119
  const auth = await getAdminAuth();
120
120
  const response: Response = await fetch(
@@ -124,7 +124,7 @@ export const listVehicleFinanceLineCategories = async (
124
124
  Authorization: auth,
125
125
  [TENANT_ID_ADMIN_HEADER]: tenantId,
126
126
  },
127
- }
127
+ },
128
128
  );
129
129
 
130
130
  if (response.status === 200) {
@@ -142,7 +142,7 @@ export const listVehicleFinanceLineCategories = async (
142
142
 
143
143
  export const listCostCenters = async (
144
144
  tenantId: string,
145
- branchId: string
145
+ branchId: string,
146
146
  ): Promise<CostCenter[]> => {
147
147
  const auth = await getAdminAuth();
148
148
  const response: Response = await fetch(
@@ -152,7 +152,7 @@ export const listCostCenters = async (
152
152
  Authorization: auth,
153
153
  [TENANT_ID_ADMIN_HEADER]: tenantId,
154
154
  },
155
- }
155
+ },
156
156
  );
157
157
 
158
158
  if (response.status === 200) {
@@ -170,7 +170,7 @@ export const listCostCenters = async (
170
170
 
171
171
  export const getLastValidationRulesResults = async (
172
172
  tenantId: string,
173
- documentId: string
173
+ documentId: string,
174
174
  ): Promise<DocumentValidationRulesResults> => {
175
175
  const auth = await getAdminAuth();
176
176
  const response: Response = await fetch(
@@ -180,7 +180,7 @@ export const getLastValidationRulesResults = async (
180
180
  Authorization: auth,
181
181
  [TENANT_ID_ADMIN_HEADER]: tenantId,
182
182
  },
183
- }
183
+ },
184
184
  );
185
185
 
186
186
  if (response.status === 200) {
@@ -198,7 +198,7 @@ export const getLastValidationRulesResults = async (
198
198
 
199
199
  export const disableAnyActiveRecurringInvoices = async (
200
200
  tenantId: string,
201
- contractId: string
201
+ contractId: string,
202
202
  ): Promise<void> => {
203
203
  const auth = await getAdminAuth();
204
204
  const response: Response = await fetch(
@@ -209,7 +209,7 @@ export const disableAnyActiveRecurringInvoices = async (
209
209
  Authorization: auth,
210
210
  [TENANT_ID_ADMIN_HEADER]: tenantId,
211
211
  }),
212
- }
212
+ },
213
213
  );
214
214
 
215
215
  if (response.status === 204) {
@@ -227,7 +227,7 @@ export const disableAnyActiveRecurringInvoices = async (
227
227
 
228
228
  export const createDocumentDraft = async (
229
229
  tenantId: string,
230
- draft: NewDocumentDraft
230
+ draft: NewDocumentDraft,
231
231
  ): Promise<DocumentDraft> => {
232
232
  const auth = await getAdminAuth();
233
233
  const response: Response = await fetch(
@@ -240,7 +240,7 @@ export const createDocumentDraft = async (
240
240
  'Content-Type': 'application/json',
241
241
  }),
242
242
  body: JSON.stringify(draft),
243
- }
243
+ },
244
244
  );
245
245
 
246
246
  if (response.status === 200) {
@@ -265,7 +265,7 @@ export const sartProcessing = async (tenantId: string, draftId: string): Promise
265
265
  Authorization: auth,
266
266
  [TENANT_ID_ADMIN_HEADER]: tenantId,
267
267
  }),
268
- }
268
+ },
269
269
  );
270
270
 
271
271
  if (response.status === 204) {
@@ -293,7 +293,7 @@ export const ocrDocument = async (tenantId: string, fileKey: string): Promise<Do
293
293
  'Content-Type': 'application/json',
294
294
  }),
295
295
  body: JSON.stringify({ fileKey }),
296
- }
296
+ },
297
297
  );
298
298
 
299
299
  if (response.status === 200) {
@@ -312,7 +312,7 @@ export const ocrDocument = async (tenantId: string, fileKey: string): Promise<Do
312
312
  export const getStorecoveEvidenceStatus = async (
313
313
  tenantId: string,
314
314
  branchId: string,
315
- storecoveId: string
315
+ storecoveId: string,
316
316
  ): Promise<StorecoveEvidenceStatus | undefined> => {
317
317
  const auth = await getAdminAuth();
318
318
  const response: Response = await fetch(
@@ -322,7 +322,7 @@ export const getStorecoveEvidenceStatus = async (
322
322
  Authorization: auth,
323
323
  [TENANT_ID_ADMIN_HEADER]: tenantId,
324
324
  },
325
- }
325
+ },
326
326
  );
327
327
 
328
328
  if (response.status === 200) {
@@ -7,7 +7,7 @@ import { SearchFinanceDocument } from '../types/search.js';
7
7
 
8
8
  export const searchFinanceDocs = async (
9
9
  tenantId: string,
10
- request: SearchRequest
10
+ request: SearchRequest,
11
11
  ): Promise<PaginatedList<SearchFinanceDocument> | NextList<SearchFinanceDocument>> => {
12
12
  const auth = await getAdminAuth();
13
13
  const response: Response = await fetch(
@@ -20,7 +20,7 @@ export const searchFinanceDocs = async (
20
20
  [TENANT_ID_ADMIN_HEADER]: tenantId,
21
21
  },
22
22
  body: JSON.stringify(request),
23
- }
23
+ },
24
24
  );
25
25
 
26
26
  if (response.status === 200) {
@@ -8,7 +8,7 @@ import { AdministrativeDocument, FinanceDocument } from '../types/documents.js';
8
8
 
9
9
  export const getFinanceDocument = async (
10
10
  tenantId: string,
11
- documentId: string
11
+ documentId: string,
12
12
  ): Promise<DataRecord<FinanceDocument, ReferenceData> | undefined> => {
13
13
  const auth = await getAdminAuth();
14
14
  const response: Response = await fetch(
@@ -18,7 +18,7 @@ export const getFinanceDocument = async (
18
18
  Authorization: auth,
19
19
  [TENANT_ID_ADMIN_HEADER]: tenantId,
20
20
  },
21
- }
21
+ },
22
22
  );
23
23
 
24
24
  if (response.status === 200) {
@@ -40,7 +40,7 @@ export const getFinanceDocument = async (
40
40
 
41
41
  export const checkDocumentStatus = async (
42
42
  tenantId: string,
43
- documentId: string
43
+ documentId: string,
44
44
  ): Promise<{ status: number }> => {
45
45
  const auth = await getAdminAuth();
46
46
  const response: Response = await fetch(
@@ -51,7 +51,7 @@ export const checkDocumentStatus = async (
51
51
  Authorization: auth,
52
52
  [TENANT_ID_ADMIN_HEADER]: tenantId,
53
53
  },
54
- }
54
+ },
55
55
  );
56
56
 
57
57
  return {
@@ -61,7 +61,7 @@ export const checkDocumentStatus = async (
61
61
 
62
62
  export const getFinanceBookingByDocId = async (
63
63
  tenantId: string,
64
- documentId: string
64
+ documentId: string,
65
65
  ): Promise<FinanceBooking | undefined> => {
66
66
  const auth = await getAdminAuth();
67
67
  const response: Response = await fetch(
@@ -71,7 +71,7 @@ export const getFinanceBookingByDocId = async (
71
71
  Authorization: auth,
72
72
  [TENANT_ID_ADMIN_HEADER]: tenantId,
73
73
  },
74
- }
74
+ },
75
75
  );
76
76
 
77
77
  if (response.status === 200) {
@@ -93,7 +93,7 @@ export const getFinanceBookingByDocId = async (
93
93
 
94
94
  export const upsertFinanceDoc = async <T extends FinanceDocument = FinanceDocument>(
95
95
  tenantId: string,
96
- doc: T
96
+ doc: T,
97
97
  ): Promise<T> => {
98
98
  const auth = await getAdminAuth();
99
99
  const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/documents/finance`, {
@@ -121,7 +121,7 @@ export const upsertFinanceDoc = async <T extends FinanceDocument = FinanceDocume
121
121
 
122
122
  export const getAdminDocument = async (
123
123
  tenantId: string,
124
- documentId: string
124
+ documentId: string,
125
125
  ): Promise<DataRecord<AdministrativeDocument, ReferenceData> | undefined> => {
126
126
  const auth = await getAdminAuth();
127
127
  const response: Response = await fetch(
@@ -131,7 +131,7 @@ export const getAdminDocument = async (
131
131
  Authorization: auth,
132
132
  [TENANT_ID_ADMIN_HEADER]: tenantId,
133
133
  },
134
- }
134
+ },
135
135
  );
136
136
 
137
137
  if (response.status === 200) {
@@ -150,7 +150,7 @@ export const getAdminDocument = async (
150
150
  export const upsertAdminDoc = async (
151
151
  tenantId: string,
152
152
  doc: AdministrativeDocument,
153
- opts?: { serviceId: string }
153
+ opts?: { serviceId: string },
154
154
  ): Promise<AdministrativeDocument> => {
155
155
  const auth = await getAdminAuth();
156
156
  const response: Response = await fetch(
@@ -164,7 +164,7 @@ export const upsertAdminDoc = async (
164
164
  [SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
165
165
  }),
166
166
  body: JSON.stringify(doc),
167
- }
167
+ },
168
168
  );
169
169
 
170
170
  if (response.status === 200) {
@@ -182,7 +182,7 @@ export const upsertAdminDoc = async (
182
182
 
183
183
  export const upsertFinanceBooking = async (
184
184
  tenantId: string,
185
- booking: FinanceBooking
185
+ booking: FinanceBooking,
186
186
  ): Promise<FinanceBooking> => {
187
187
  const auth = await getAdminAuth();
188
188
  const response: Response = await fetch(
@@ -195,7 +195,7 @@ export const upsertFinanceBooking = async (
195
195
  [TENANT_ID_ADMIN_HEADER]: tenantId,
196
196
  },
197
197
  body: JSON.stringify(booking),
198
- }
198
+ },
199
199
  );
200
200
 
201
201
  if (response.status === 200) {
@@ -226,7 +226,7 @@ export const reindexFinanceDoc = async (tenantId: string, docId: string) => {
226
226
  tenantId,
227
227
  docId,
228
228
  }),
229
- }
229
+ },
230
230
  );
231
231
 
232
232
  if (response.status === 200) {
package/src/schemas.ts CHANGED
@@ -39,7 +39,7 @@ const associationsSchema = Joi.array().items(
39
39
  businessEntityId: Joi.string().required(),
40
40
  recordId: Joi.string().required(),
41
41
  }),
42
- })
42
+ }),
43
43
  );
44
44
 
45
45
  export const lineSchema = Joi.object({
@@ -109,7 +109,7 @@ export const newFinanceDocV2Schema = Joi.object({
109
109
  .items(
110
110
  attachmentValueSchema.keys({
111
111
  contentType: Joi.string().valid('application/pdf').required(),
112
- })
112
+ }),
113
113
  )
114
114
  .max(9),
115
115
  additionalItemProperties: Joi.array().items(
@@ -119,9 +119,9 @@ export const newFinanceDocV2Schema = Joi.object({
119
119
  Joi.object({
120
120
  name: Joi.string().required(),
121
121
  value: Joi.string().required(),
122
- })
122
+ }),
123
123
  ),
124
- })
124
+ }),
125
125
  ),
126
126
  }),
127
127
  });
package/src/types/ai.ts CHANGED
@@ -74,7 +74,7 @@ export type AdminDocumentDraftPrefill = BaseDocumentDraftPrefill & {
74
74
  export type DocumentDraftPrefill = FinanceDocumentDraftPrefill | AdminDocumentDraftPrefill;
75
75
 
76
76
  export const isFinanceDocumentDraftPrefill = (
77
- doc: FinanceDocumentDraftPrefill | AdminDocumentDraftPrefill
77
+ doc: FinanceDocumentDraftPrefill | AdminDocumentDraftPrefill,
78
78
  ): doc is FinanceDocumentDraftPrefill => {
79
79
  return doc.type === DocumentCategoryType.Finance;
80
80
  };
@@ -263,30 +263,30 @@ export type NewDocumentDraft<T = NewFinanceDocumentV2 | NewAdministrativeDocumen
263
263
  };
264
264
 
265
265
  export const isFinanceDocumentV2 = (
266
- arg: FinanceDocumentV2 | FinanceDocumentV1
266
+ arg: FinanceDocumentV2 | FinanceDocumentV1,
267
267
  ): arg is FinanceDocumentV2 => {
268
268
  return (arg as FinanceDocumentV2).version == 2;
269
269
  };
270
270
 
271
271
  export const isFinanceDocumentV1 = (
272
- arg: FinanceDocumentV2 | FinanceDocumentV1
272
+ arg: FinanceDocumentV2 | FinanceDocumentV1,
273
273
  ): arg is FinanceDocumentV1 => {
274
274
  return (arg as FinanceDocumentV2).version == null;
275
275
  };
276
276
 
277
277
  export const isFinanceDocument = (
278
- arg: FinanceDocument | AdministrativeDocument | NewAdministrativeDocument | NewFinanceDocumentV2
278
+ arg: FinanceDocument | AdministrativeDocument | NewAdministrativeDocument | NewFinanceDocumentV2,
279
279
  ): arg is FinanceDocument => {
280
280
  return ['Sale Finance', 'Purchase Finance'].includes((arg as FinanceDocument).type);
281
281
  };
282
282
 
283
283
  export const isAdministrativeDocumentDraft = (
284
- draft: DocumentDraft | NewDocumentDraft
284
+ draft: DocumentDraft | NewDocumentDraft,
285
285
  ): draft is DocumentDraft<AdministrativeDocument> | NewDocumentDraft<AdministrativeDocument> =>
286
286
  draft.documentType === DocumentType.Administrative;
287
287
 
288
288
  export const isFinanceDocumentDraft = (
289
- arg: DocumentDraft | NewDocumentDraft
289
+ arg: DocumentDraft | NewDocumentDraft,
290
290
  ): arg is DocumentDraft<FinanceDocumentV2> | NewDocumentDraft<FinanceDocumentV2> => {
291
291
  return arg.documentType === DocumentType.Finance;
292
292
  };
@@ -17,7 +17,7 @@ export type SupportedAssociationEntity = GlobalBusinessEntity;
17
17
 
18
18
  export const getAssociationForBusinessEntity = (
19
19
  businessEntityId: BusinessEntityIds,
20
- record: SupportedAssociationEntity
20
+ record: SupportedAssociationEntity,
21
21
  ): Association => ({
22
22
  businessEntityId,
23
23
  recordId: record.id,
@@ -28,7 +28,7 @@ export const getAssociationForBusinessEntity = (
28
28
 
29
29
  export const getAssociationForSearchBusinessEntity = (
30
30
  businessEntityId: BusinessEntityIds,
31
- entity: GlobalSearchEntity
31
+ entity: GlobalSearchEntity,
32
32
  ): Association => {
33
33
  const record = getMainEntityFromSearchEntity(businessEntityId, entity);
34
34
  return {
@@ -42,7 +42,7 @@ export const getAssociationForSearchBusinessEntity = (
42
42
 
43
43
  export const getExternalVehicleSaleAssociation = (
44
44
  vehicle: Vehicle,
45
- externalSaleId: string
45
+ externalSaleId: string,
46
46
  ): Association => ({
47
47
  ...getAssociationForBusinessEntity(BusinessEntityIds.Vehicles, vehicle),
48
48
  businessEntityId: BusinessEntityIds.ExternalVehicleSale,
@@ -5,8 +5,8 @@ import {
5
5
  FinanceDocumentSubtype,
6
6
  NewFinanceDocumentLine,
7
7
  } from '../types/documents.js';
8
- import { FinanceLineV1 } from '../types/legacy.js';
9
8
  import { LeasingFinanceLineCode } from '../types/leasing.js';
9
+ import { FinanceLineV1 } from '../types/legacy.js';
10
10
  import { VatCode } from '../types/vat.js';
11
11
  import { getAssociationForBusinessEntity, SupportedAssociationEntity } from './associations.js';
12
12
  import { getLineAmounts } from './finance.js';
@@ -26,7 +26,7 @@ const hasValidLeasingLineCode = (code: string) =>
26
26
  const mapFinanceDocumentLineToMappedLine = (
27
27
  subtype: FinanceDocumentSubtype,
28
28
  line: FinanceDocumentLine,
29
- vatCodes: VatCode[] = []
29
+ vatCodes: VatCode[] = [],
30
30
  ): MappedFinanceLine => {
31
31
  const vatCode = vatCodes.find((c) => c.code === line.vatCode);
32
32
  const vatData = getVatCodeLineData(subtype, vatCode);
@@ -42,7 +42,7 @@ const mapFinanceDocumentLineToMappedLine = (
42
42
  const mapFinanceLineV1ToMappedLine = (
43
43
  subtype: FinanceDocumentSubtype,
44
44
  line: FinanceLineV1,
45
- vatCodes: VatCode[]
45
+ vatCodes: VatCode[],
46
46
  ): MappedFinanceLine => {
47
47
  const v2Code = getAccountingCodeForV1VatCode(line.vatCode);
48
48
  const vatCode = vatCodes.find((c) => c.code === v2Code);
@@ -70,7 +70,7 @@ const mapFinanceLineV1ToMappedLine = (
70
70
  export const mapFinanceLine = (
71
71
  subtype: FinanceDocumentSubtype,
72
72
  line: FinanceLine,
73
- vatCodes: VatCode[] = []
73
+ vatCodes: VatCode[] = [],
74
74
  ): MappedFinanceLine => {
75
75
  return isV1Line(line)
76
76
  ? mapFinanceLineV1ToMappedLine(subtype, line, vatCodes)
@@ -88,7 +88,7 @@ export const getExternalSaleVehicleIds = (lines: MappedFinanceLine[]): string[]
88
88
  ...(line.associations
89
89
  ?.filter(
90
90
  ({ businessEntityId, tags }) =>
91
- BusinessEntityIds.ExternalVehicleSale === businessEntityId && tags == null
91
+ BusinessEntityIds.ExternalVehicleSale === businessEntityId && tags == null,
92
92
  )
93
93
  .map(({ recordId, linkTo }) => linkTo?.recordId ?? recordId) ?? []),
94
94
  ];
@@ -100,7 +100,7 @@ export const getExternalSaleVehicleIds = (lines: MappedFinanceLine[]): string[]
100
100
  */
101
101
  export const enrichLinesWithVehicleTags = <T extends MappedFinanceLine>(
102
102
  lines: T[],
103
- vehicleMap: Map<string, SupportedAssociationEntity>
103
+ vehicleMap: Map<string, SupportedAssociationEntity>,
104
104
  ): T[] =>
105
105
  lines.map((line) => ({
106
106
  ...line,
@@ -118,7 +118,7 @@ export const enrichLinesWithVehicleTags = <T extends MappedFinanceLine>(
118
118
  }
119
119
  const vehicleAssociation = getAssociationForBusinessEntity(
120
120
  BusinessEntityIds.Vehicles,
121
- vehicle
121
+ vehicle,
122
122
  );
123
123
  return {
124
124
  ...association,
@@ -23,12 +23,12 @@ export const documentGoesToAccounting = (
23
23
  | FinanceDocumentV2
24
24
  | DocumentDraft<FinanceDocumentV2>
25
25
  | FinanceDocumentGenerateRequest
26
- | FinanceDocumentV1
26
+ | FinanceDocumentV1,
27
27
  ): boolean => {
28
28
  return (
29
29
  !!doc.subtype &&
30
30
  [FinanceDocumentSubtype.Invoice, FinanceDocumentSubtype.CreditNote].includes(
31
- doc.subtype as FinanceDocumentSubtype
31
+ doc.subtype as FinanceDocumentSubtype,
32
32
  )
33
33
  );
34
34
  };
@@ -38,7 +38,7 @@ export const documentGoesToStorecove = (
38
38
  | FinanceDocumentV2
39
39
  | DocumentDraft<FinanceDocumentV2>
40
40
  | FinanceDocumentGenerateRequest
41
- | FinanceDocumentV1
41
+ | FinanceDocumentV1,
42
42
  ): boolean => {
43
43
  if (!doc.organizationSummary) {
44
44
  return false;
@@ -65,7 +65,7 @@ export const getAccountingDescription = (doc: FinanceDocumentV2): string => {
65
65
 
66
66
  const uniqueAssociations = uniqBy(
67
67
  associations,
68
- (a) => `${equivalentEntityIds[a.businessEntityId] ?? a.businessEntityId}_${a.recordId}`
68
+ (a) => `${equivalentEntityIds[a.businessEntityId] ?? a.businessEntityId}_${a.recordId}`,
69
69
  );
70
70
 
71
71
  if (uniqueAssociations.length !== 1) {
@@ -89,7 +89,7 @@ export const getAccountingDescription = (doc: FinanceDocumentV2): string => {
89
89
 
90
90
  export const getTotalExcl = <T extends FinanceDocument['lines']>(
91
91
  lines: T,
92
- unitPrice: (line: T[0], index: number) => any
92
+ unitPrice: (line: T[0], index: number) => any,
93
93
  ) => {
94
94
  return lines.length === 0
95
95
  ? new Decimal(0)
@@ -100,7 +100,7 @@ export const getTotalVat = <T extends FinanceDocument['lines'], L = T[0]>(
100
100
  currency: string,
101
101
  lines: T,
102
102
  unitPrice: (doc: L, index: number) => any,
103
- vatCoefficient: (doc: L, index: number) => any
103
+ vatCoefficient: (doc: L, index: number) => any,
104
104
  ) => {
105
105
  return lines.length === 0
106
106
  ? new Decimal(0)
@@ -108,9 +108,9 @@ export const getTotalVat = <T extends FinanceDocument['lines'], L = T[0]>(
108
108
  currency,
109
109
  Decimal.sum(
110
110
  ...lines.map((line, i) =>
111
- Decimal.mul(line.quantity, unitPrice(line, i)).mul(vatCoefficient(line, i))
112
- )
113
- )
111
+ Decimal.mul(line.quantity, unitPrice(line, i)).mul(vatCoefficient(line, i)),
112
+ ),
113
+ ),
114
114
  );
115
115
  };
116
116
 
@@ -119,7 +119,7 @@ export const getDocumentTotals = (
119
119
  | FinanceDocument
120
120
  | DocumentDraft<FinanceDocumentV2>
121
121
  | NewDocumentDraft<FinanceDocumentV2>
122
- | FinanceDocumentGenerateRequest
122
+ | FinanceDocumentGenerateRequest,
123
123
  ) => {
124
124
  let totalVat: Decimal;
125
125
  let totalExcl: Decimal;
@@ -138,7 +138,7 @@ export const getDocumentTotals = (
138
138
  const getUnitPriceExcl = (line: FinanceDocumentLine) => line.unitPriceExcl;
139
139
 
140
140
  totalVat = getTotalVat(currency, lines, getUnitPriceExcl, (line) =>
141
- new Decimal(line.vatPercentage).div(100)
141
+ new Decimal(line.vatPercentage).div(100),
142
142
  );
143
143
  totalExcl = getTotalExcl(lines, getUnitPriceExcl);
144
144
  }
@@ -155,7 +155,7 @@ export const getRoundedDocumentTotal = (
155
155
  | FinanceDocument
156
156
  | DocumentDraft<FinanceDocumentV2>
157
157
  | NewDocumentDraft<FinanceDocumentV2>
158
- | FinanceDocumentGenerateRequest
158
+ | FinanceDocumentGenerateRequest,
159
159
  ) => {
160
160
  let total: FinanceDocumentV2['total'] | undefined;
161
161
 
@@ -192,7 +192,7 @@ export const getRoundedDocumentTotal = (
192
192
  export const getRoundedLinesTotals = (
193
193
  currency: string,
194
194
  lines: { quantity: string; unitPriceExcl: string; vatPercentage: string }[],
195
- rate = '1'
195
+ rate = '1',
196
196
  ) => {
197
197
  let totalWithoutVat = new Decimal('0');
198
198
  let vatTotal = new Decimal('0');
@@ -237,14 +237,14 @@ export const isGeneratingAttachment = (doc: FinanceDocument) =>
237
237
  // - the unit price is divided by the number of associations
238
238
  export const filterDocumentLinesForRecord = (
239
239
  doc: FinanceDocument,
240
- recordId: string // vehicleId, opportunityId, or externalVehicleSaleId
240
+ recordId: string, // vehicleId, opportunityId, or externalVehicleSaleId
241
241
  ): FinanceDocument => {
242
242
  const filteredLines = isFinanceDocumentV2(doc)
243
243
  ? doc.lines
244
244
  .filter((line) =>
245
245
  line.associations?.some(
246
- (assoc) => assoc.recordId === recordId || assoc.linkTo?.recordId === recordId
247
- )
246
+ (assoc) => assoc.recordId === recordId || assoc.linkTo?.recordId === recordId,
247
+ ),
248
248
  )
249
249
  .map((line) => ({
250
250
  ...line,
@@ -252,7 +252,7 @@ export const filterDocumentLinesForRecord = (
252
252
  amountExcl: calculateDistributedPrice(line.amountExcl, line.associations?.length || 1),
253
253
  unitPriceExcl: calculateDistributedPrice(
254
254
  line.unitPriceExcl,
255
- line.associations?.length || 1
255
+ line.associations?.length || 1,
256
256
  ),
257
257
  }))
258
258
  : doc.lines
@@ -264,13 +264,13 @@ export const filterDocumentLinesForRecord = (
264
264
  v1Ass.opportunityId === recordId ||
265
265
  v1Ass.id === recordId
266
266
  );
267
- })
267
+ }),
268
268
  )
269
269
  .map((line) => ({
270
270
  ...line,
271
271
  unitPriceExclusive: calculateDistributedPrice(
272
272
  line.unitPriceExclusive,
273
- getAllV1Associations(line.associations).length || 1
273
+ getAllV1Associations(line.associations).length || 1,
274
274
  ),
275
275
  }));
276
276
 
@@ -287,7 +287,7 @@ const calculateDistributedPrice = (price: string, count: number): string => {
287
287
  const getAllV1Associations = (ass: FinanceLineV1['associations']) => {
288
288
  const allAss = uniqBy(
289
289
  [...(ass?.sales ?? []), ...(ass?.purchases ?? []), ...(ass.others ?? [])],
290
- (ass) => ass.vehicleId
290
+ (ass) => ass.vehicleId,
291
291
  );
292
292
  return allAss;
293
293
  };
package/src/utils/vat.ts CHANGED
@@ -9,7 +9,7 @@ import { VatCode } from '../types/vat.js';
9
9
 
10
10
  export const getVatCodeLineData = (
11
11
  subtype: FinanceDocumentSubtype,
12
- vatCode: VatCode | undefined
12
+ vatCode: VatCode | undefined,
13
13
  ) => {
14
14
  const reason =
15
15
  subtype === FinanceDocumentSubtype.CreditNote
@@ -39,7 +39,7 @@ export const getAccountingCodeForV1VatCode = (vatCode: string): string | undefin
39
39
  export const getSaleVatCodeForCustomer = (
40
40
  branchCountry: string,
41
41
  customerCountry: string,
42
- vatCodes: VatCode[]
42
+ vatCodes: VatCode[],
43
43
  ) => {
44
44
  const isSameCountry = branchCountry.toUpperCase() === customerCountry.toUpperCase();
45
45
  const isSaleInEU = isEUCountry(customerCountry);
@@ -47,8 +47,8 @@ export const getSaleVatCodeForCustomer = (
47
47
  isSameCountry || !branchCountry
48
48
  ? STANDARD_VAT_CODE_ID
49
49
  : isSaleInEU
50
- ? SALE_EU_INTRA_COMMUNITY_VAT_CODE_ID
51
- : SALE_EU_EXTRA_COMMUNITY_VAT_CODE_ID;
50
+ ? SALE_EU_INTRA_COMMUNITY_VAT_CODE_ID
51
+ : SALE_EU_EXTRA_COMMUNITY_VAT_CODE_ID;
52
52
 
53
53
  const vatCode = vatCodes?.find((code) => code.id === vatCodeId);
54
54
  return vatCode;
@@ -58,7 +58,7 @@ export const getSaleVatCodeDataForCustomer = (
58
58
  subtype: FinanceDocumentSubtype,
59
59
  branchCountry: string,
60
60
  customerCountry: string,
61
- vatCodes: VatCode[]
61
+ vatCodes: VatCode[],
62
62
  ) => {
63
63
  const vatCode = getSaleVatCodeForCustomer(branchCountry, customerCountry, vatCodes);
64
64
  return getVatCodeLineData(subtype, vatCode);
@@ -7,5 +7,5 @@ export const isPrivateVisibility = (
7
7
  | DocumentCategory
8
8
  | FinanceDocumentV1
9
9
  | FinanceDocumentV2
10
- | DocumentDraft<FinanceDocumentV2>
10
+ | DocumentDraft<FinanceDocumentV2>,
11
11
  ) => 'visibility' in catOrDoc && catOrDoc.visibility === DocumentCategoryVisibility.Private;