@bisondesk/documents-sdk 1.0.315
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/cjs/types/document-categories.js +9 -0
- package/lib/cjs/types/document-categories.js.map +1 -0
- package/lib/cjs/types/documents.js +54 -0
- package/lib/cjs/types/documents.js.map +1 -0
- package/lib/cjs/types/scans.js +3 -0
- package/lib/cjs/types/scans.js.map +1 -0
- package/lib/cjs/types/vat.js +15 -0
- package/lib/cjs/types/vat.js.map +1 -0
- package/lib/esm/types/document-categories.js +6 -0
- package/lib/esm/types/document-categories.js.map +1 -0
- package/lib/esm/types/documents.js +47 -0
- package/lib/esm/types/documents.js.map +1 -0
- package/lib/esm/types/scans.js +2 -0
- package/lib/esm/types/scans.js.map +1 -0
- package/lib/esm/types/vat.js +12 -0
- package/lib/esm/types/vat.js.map +1 -0
- package/lib/tsconfig.cjs.tsbuildinfo +1 -0
- package/lib/tsconfig.esm.tsbuildinfo +1 -0
- package/lib/types/types/document-categories.d.ts +29 -0
- package/lib/types/types/document-categories.d.ts.map +1 -0
- package/lib/types/types/documents.d.ts +186 -0
- package/lib/types/types/documents.d.ts.map +1 -0
- package/lib/types/types/scans.d.ts +6 -0
- package/lib/types/types/scans.d.ts.map +1 -0
- package/lib/types/types/vat.d.ts +25 -0
- package/lib/types/types/vat.d.ts.map +1 -0
- package/package.json +44 -0
- package/src/types/document-categories.ts +33 -0
- package/src/types/documents.ts +251 -0
- package/src/types/scans.ts +5 -0
- package/src/types/vat.ts +31 -0
- package/tsconfig.cjs.json +8 -0
- package/tsconfig.esm.json +8 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';
|
|
2
|
+
import { AttachmentValue, PhoneNumberValue, SearchPermissions } from '@bisondesk/commons-sdk/types';
|
|
3
|
+
import { FinanceBooking, FinanceDocument } from '@bisondesk/core-sdk/types/documents';
|
|
4
|
+
|
|
5
|
+
export enum AdministrativeDocType {
|
|
6
|
+
General = 'General Administrative',
|
|
7
|
+
Logistics = 'Logistics Administrative',
|
|
8
|
+
Purchase = 'Purchase Administrative',
|
|
9
|
+
Sale = 'Sale Administrative',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type Association = {
|
|
13
|
+
businessEntityId: BusinessEntityIds;
|
|
14
|
+
id: string;
|
|
15
|
+
description: string;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type FinanceDocumentLine = {
|
|
20
|
+
id: string;
|
|
21
|
+
category: string; // abstraction used to map lines to GL accounts (e.g., deposit, insurance)
|
|
22
|
+
amount: string;
|
|
23
|
+
amountExcl: string; // quantity * unit price
|
|
24
|
+
description: string;
|
|
25
|
+
foreign?: {
|
|
26
|
+
amount: string;
|
|
27
|
+
amountExcl: string;
|
|
28
|
+
unitPriceExcl: string;
|
|
29
|
+
vatAmount: string;
|
|
30
|
+
};
|
|
31
|
+
invoiceLineId?: string; // used by credit notes
|
|
32
|
+
quantity: string;
|
|
33
|
+
associations?: Association[];
|
|
34
|
+
unitPriceExcl: string;
|
|
35
|
+
vatAmount: string;
|
|
36
|
+
vatCode: string;
|
|
37
|
+
vatPercentage: string;
|
|
38
|
+
vatReason?: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type OrgSummary = {
|
|
42
|
+
id: string;
|
|
43
|
+
code: number;
|
|
44
|
+
name: string;
|
|
45
|
+
vatNumber?: string;
|
|
46
|
+
|
|
47
|
+
addressLine1?: string;
|
|
48
|
+
addressLine2?: string;
|
|
49
|
+
postcode?: string;
|
|
50
|
+
city?: string;
|
|
51
|
+
country: string;
|
|
52
|
+
|
|
53
|
+
emails?: string[];
|
|
54
|
+
phone?: PhoneNumberValue;
|
|
55
|
+
|
|
56
|
+
// TODO person name?
|
|
57
|
+
contact?: {
|
|
58
|
+
name: string;
|
|
59
|
+
username: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
language: string; // needed?
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export enum FinanceDocType {
|
|
66
|
+
Sale = 'Sale Finance',
|
|
67
|
+
Purchase = 'Purchase Finance',
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export enum FinanceDocumentGenerateSubtype {
|
|
71
|
+
Invoice = 'Invoice',
|
|
72
|
+
CreditNote = 'Credit Note',
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type BaseDocument = {
|
|
76
|
+
id: string;
|
|
77
|
+
branchId: string;
|
|
78
|
+
attachment: AttachmentValue;
|
|
79
|
+
subtype: string;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
createdBy: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type FinanceDocumentV2 = BaseDocument & {
|
|
85
|
+
version: 2.0;
|
|
86
|
+
reference: string;
|
|
87
|
+
|
|
88
|
+
type: FinanceDocType;
|
|
89
|
+
|
|
90
|
+
category: string; // abstraction used to map invoices to Journals (e.g., leasing, used trucks)
|
|
91
|
+
|
|
92
|
+
organizationSummary: OrgSummary;
|
|
93
|
+
|
|
94
|
+
dueDate?: string;
|
|
95
|
+
transferDescription?: string; // we ask clients to put this as description of the transfer
|
|
96
|
+
invoiceId?: string; // mandatory in credit notes but forbidden in invoices
|
|
97
|
+
issueDate: string;
|
|
98
|
+
lines: FinanceDocumentLine[];
|
|
99
|
+
notes?: string;
|
|
100
|
+
salesperson: {
|
|
101
|
+
name: string;
|
|
102
|
+
username: string;
|
|
103
|
+
};
|
|
104
|
+
tags: string[]; // optional values used to improve document search
|
|
105
|
+
total: {
|
|
106
|
+
amountExcl: string;
|
|
107
|
+
amount: string;
|
|
108
|
+
currencyCode: string; // from the branch
|
|
109
|
+
foreign?: {
|
|
110
|
+
amount: string;
|
|
111
|
+
amountExcl: string;
|
|
112
|
+
vatAmount: string;
|
|
113
|
+
currencyCode: string;
|
|
114
|
+
exchangeRate: string;
|
|
115
|
+
};
|
|
116
|
+
vatAmount: string;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
paidAt?: string;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export type NewFinanceDocumentV2 = Omit<
|
|
123
|
+
FinanceDocumentV2,
|
|
124
|
+
'id' | 'createdAt' | 'createdBy' | 'lines'
|
|
125
|
+
> & {
|
|
126
|
+
lines: Omit<FinanceDocumentLine, 'id'>[];
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export type AdministrativeDocument = BaseDocument & {
|
|
130
|
+
type: AdministrativeDocType;
|
|
131
|
+
tags?: string[];
|
|
132
|
+
associations?: Association[];
|
|
133
|
+
organizationSummary?: OrgSummary;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export type NewAdministrativeDocument = Omit<
|
|
137
|
+
AdministrativeDocument,
|
|
138
|
+
'id' | 'createdAt' | 'createdBy'
|
|
139
|
+
>;
|
|
140
|
+
|
|
141
|
+
export enum DraftProcessStatus {
|
|
142
|
+
// Prefill = 'Prefill',
|
|
143
|
+
// Ready = 'Ready',
|
|
144
|
+
Error = 'Error',
|
|
145
|
+
Unprocessed = 'Unprocessed',
|
|
146
|
+
Unvalidated = 'Unvalidated',
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
type DraftProcessing = {
|
|
150
|
+
status: DraftProcessStatus;
|
|
151
|
+
businessValid: boolean;
|
|
152
|
+
accountingValid: boolean;
|
|
153
|
+
rejectedAt?: string;
|
|
154
|
+
rejectedBy?: string;
|
|
155
|
+
rejectionReason?: string;
|
|
156
|
+
failedValidationRules?: string[];
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export enum DocumentType {
|
|
160
|
+
Finance = 'Finance Document',
|
|
161
|
+
Administrative = 'Administrative Document',
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type BaseDocumentDraft = BaseDocument &
|
|
165
|
+
DraftProcessing & {
|
|
166
|
+
documentType?: DocumentType;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export type DocumentDraft<T = FinanceDocumentV2 | AdministrativeDocument> = Partial<T> &
|
|
170
|
+
BaseDocumentDraft;
|
|
171
|
+
|
|
172
|
+
export enum DraftActions {
|
|
173
|
+
Delete = 'delete',
|
|
174
|
+
Validate = 'validate',
|
|
175
|
+
Submit = 'submit',
|
|
176
|
+
ValidateBusinessRules = 'validate_business_rules',
|
|
177
|
+
ValidateAccountingRules = 'validate_accounting_rules',
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export type RejectDraftRequest = {
|
|
181
|
+
reason?: string;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export type NewDocumentDraft<T = NewFinanceDocumentV2 | NewAdministrativeDocument> = Partial<T> &
|
|
185
|
+
Omit<BaseDocument, 'id' | 'createdAt' | 'createdBy' | 'subtype'> & {
|
|
186
|
+
subtype?: string;
|
|
187
|
+
documentType?: DocumentType;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export type SearchFinanceDocument = {
|
|
191
|
+
doc: FinanceDocumentV2;
|
|
192
|
+
permissions: SearchPermissions;
|
|
193
|
+
booking?: FinanceBooking;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export type SearchAdministrativeDocument = {
|
|
197
|
+
doc: AdministrativeDocument;
|
|
198
|
+
permissions: SearchPermissions;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const isFinanceDocumentV2 = (
|
|
202
|
+
arg: FinanceDocumentV2 | FinanceDocument
|
|
203
|
+
): arg is FinanceDocumentV2 => {
|
|
204
|
+
return (arg as FinanceDocumentV2).version === 2;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export const isAdministrativeDocument = (arg: any): arg is AdministrativeDocument => {
|
|
208
|
+
return Object.values(AdministrativeDocType).includes(arg.type);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export const isAdministrativeDocumentDraft = (
|
|
212
|
+
draft: DocumentDraft
|
|
213
|
+
): draft is DocumentDraft<AdministrativeDocument> =>
|
|
214
|
+
draft.documentType === DocumentType.Administrative;
|
|
215
|
+
|
|
216
|
+
export const isFinanceDocumentDraft = (
|
|
217
|
+
arg: DocumentDraft | NewDocumentDraft
|
|
218
|
+
): arg is DocumentDraft<FinanceDocumentV2> => {
|
|
219
|
+
return arg.documentType === DocumentType.Finance;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export type FinanceDocumentGenerateRequest = Omit<
|
|
223
|
+
FinanceDocumentV2,
|
|
224
|
+
'id' | 'attachment' | 'createdAt' | 'createdBy' | 'version' | 'reference' | 'lines' | 'subtype'
|
|
225
|
+
> & {
|
|
226
|
+
subtype: FinanceDocumentGenerateSubtype;
|
|
227
|
+
lines: Omit<FinanceDocumentLine, 'id'>[];
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// TODO
|
|
231
|
+
export type DocumentGenerateRequestEvent = {
|
|
232
|
+
tenantId: string;
|
|
233
|
+
docId: string;
|
|
234
|
+
request: FinanceDocumentGenerateRequest;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export type FinanceDocumentSettings<M = {}> = {
|
|
238
|
+
provider: string;
|
|
239
|
+
meta: M;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export type FinanceDocumentBisondeskSettings = {
|
|
243
|
+
[FinanceDocumentGenerateSubtype.Invoice]: {
|
|
244
|
+
prefix: string;
|
|
245
|
+
templateId: string;
|
|
246
|
+
};
|
|
247
|
+
[FinanceDocumentGenerateSubtype.CreditNote]: {
|
|
248
|
+
prefix: string;
|
|
249
|
+
templateId: string;
|
|
250
|
+
};
|
|
251
|
+
};
|
package/src/types/vat.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// subset of codes from UN 5305 used in Peppol
|
|
2
|
+
export enum InternationalTaxCodes {
|
|
3
|
+
EeaIntraCommunity = 'K',
|
|
4
|
+
Exempt = 'E',
|
|
5
|
+
Export = 'G',
|
|
6
|
+
Margin = 'F',
|
|
7
|
+
OutsideScope = 'O',
|
|
8
|
+
ReverseCharge = 'AE',
|
|
9
|
+
Standard = 'S',
|
|
10
|
+
ZeroRated = 'Z',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// TODO: Add display order? Or sort by createdAt?
|
|
14
|
+
export type VatCode = {
|
|
15
|
+
id: string;
|
|
16
|
+
branchId: string;
|
|
17
|
+
|
|
18
|
+
code: string; // accountingCode: string;
|
|
19
|
+
default: boolean;
|
|
20
|
+
description: string;
|
|
21
|
+
rate: string;
|
|
22
|
+
categoryCode: string; // invoiceCode: InternationalTaxCodes;
|
|
23
|
+
|
|
24
|
+
reason?: string; // legal text added when this code is used
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type NewVatCode = Omit<VatCode, 'id'>;
|
|
28
|
+
|
|
29
|
+
export type VatCodeDefaultUpdate = {
|
|
30
|
+
id: string;
|
|
31
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"inlineSources": true,
|
|
8
|
+
"sourceRoot": "/",
|
|
9
|
+
"composite": true,
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"outDir": "lib",
|
|
12
|
+
"declarationDir": "lib/types"
|
|
13
|
+
},
|
|
14
|
+
"include": ["src"],
|
|
15
|
+
"references": [{ "path": "../commons-sdk" }, { "path": "../core-sdk" }]
|
|
16
|
+
}
|