@bisondesk/documents-sdk 1.0.396 → 1.0.397

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.
@@ -1,16 +1,38 @@
1
- import { Association, FinanceDocumentSubtype } from './documents.js';
1
+ import { Association, FinanceDocument, FinanceDocumentSubtype } from './documents.js';
2
2
 
3
- export type FinanceDocumentEvent = {
3
+ type BaseFinanceDocumentEvent = {
4
4
  id: string;
5
5
  actionAt: string;
6
- action: 'create' | 'update' | 'delete';
7
6
  userId: string;
8
7
  tenantId: string;
9
8
  type: 'Sale Finance' | 'Purchase Finance';
10
9
  subtype: 'Invoice' | 'Credit Note' | 'Proforma' | 'Purchase Order' | FinanceDocumentSubtype;
11
- version?: string;
10
+ version?: FinanceDocument['version'];
12
11
  };
13
12
 
13
+ export type FinanceDocumentCreateEvent = BaseFinanceDocumentEvent & {
14
+ action: 'create';
15
+ document: FinanceDocument;
16
+ previousDocument?: undefined;
17
+ };
18
+
19
+ export type FinanceDocumentUpdateEvent = BaseFinanceDocumentEvent & {
20
+ action: 'update';
21
+ document: FinanceDocument;
22
+ previousDocument: FinanceDocument;
23
+ };
24
+
25
+ export type FinanceDocumentDeleteEvent = BaseFinanceDocumentEvent & {
26
+ action: 'delete';
27
+ document?: undefined;
28
+ previousDocument: FinanceDocument;
29
+ };
30
+
31
+ export type FinanceDocumentEvent =
32
+ | FinanceDocumentCreateEvent
33
+ | FinanceDocumentUpdateEvent
34
+ | FinanceDocumentDeleteEvent;
35
+
14
36
  export type AdminDocumentEvent = {
15
37
  id: string;
16
38
  actionAt: string;
@@ -40,6 +40,12 @@ export type FinanceDocumentV1 = {
40
40
  username: string;
41
41
  };
42
42
 
43
+ total: {
44
+ amountExcl: string;
45
+ amount: string;
46
+ vatAmount: string;
47
+ };
48
+
43
49
  organizationSummary?: {
44
50
  id: string;
45
51
  code: string;
@@ -45,7 +45,8 @@ export const getAccountingDescription = (doc: FinanceDocumentV2): string => {
45
45
  BusinessEntityIds.Vehicles,
46
46
  BusinessEntityIds.Opportunities,
47
47
  BusinessEntityIds.ExternalVehicleSale,
48
- ].includes(firstAssociation.businessEntityId)
48
+ ].includes(firstAssociation.businessEntityId) &&
49
+ firstAssociation.tags != null
49
50
  ) {
50
51
  return `${firstAssociation.tags?.slice(0, 3).join(' ')} ${doc.reference}`.trim();
51
52
  }