mindee 3.7.3 → 3.8.0
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/CHANGELOG.md +14 -0
- package/package.json +3 -3
- package/src/cli.js +7 -3
- package/src/client.js +4 -1
- package/src/documents/documentConfig.d.ts +1 -1
- package/src/documents/documentConfig.js +1 -1
- package/src/documents/financialDocument/financialDocumentV1.js +27 -42
- package/src/documents/index.d.ts +1 -0
- package/src/documents/index.js +3 -1
- package/src/documents/invoice/invoiceV3.d.ts +2 -2
- package/src/documents/invoice/invoiceV3.js +83 -98
- package/src/documents/invoice/invoiceV4.d.ts +2 -2
- package/src/documents/invoice/invoiceV4.js +21 -34
- package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +1 -1
- package/src/documents/proofOfAddress/proofOfAddressV1.js +2 -2
- package/src/documents/receipt/receiptV3.d.ts +1 -1
- package/src/documents/receipt/receiptV3.js +34 -48
- package/src/documents/receipt/receiptV4.js +16 -30
- package/src/documents/receipt/receiptV5.d.ts +43 -0
- package/src/documents/receipt/receiptV5.js +135 -0
- package/src/documents/receipt/receiptV5LineItem.d.ts +16 -0
- package/src/documents/receipt/receiptV5LineItem.js +40 -0
- package/src/documents/us/bankCheck/bankCheckV1.js +0 -1
- package/src/fields/amount.js +1 -1
- package/src/fields/index.d.ts +1 -1
- package/src/fields/index.js +2 -1
- package/src/fields/tax.d.ts +7 -0
- package/src/fields/tax.js +70 -14
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v3.8.0 - 2023-05-25
|
|
4
|
+
### Changes
|
|
5
|
+
* :sparkles: add support for receipt v5
|
|
6
|
+
* :sparkles: print taxes in table layout
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## v3.7.4 - 2023-04-20
|
|
10
|
+
### Changes
|
|
11
|
+
* :white_check_mark: minor improvements to tests
|
|
12
|
+
|
|
13
|
+
### Fixes
|
|
14
|
+
* :bug: fix for options not being passed properly in the CLI tool
|
|
15
|
+
|
|
16
|
+
|
|
3
17
|
## v3.7.3 - 2023-04-11
|
|
4
18
|
### Changes
|
|
5
19
|
* :arrow_up: upgrade to TypeScript 5.0.3
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindee",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Mindee Client Library for Node.js",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "bin/mindee.js",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"eslint": "^8.32.0",
|
|
49
49
|
"eslint-config-prettier": "^8.6.0",
|
|
50
50
|
"eslint-plugin-prettier": "^4.2.1",
|
|
51
|
-
"typedoc": "~0.23",
|
|
52
51
|
"mocha": "^10.1.0",
|
|
53
52
|
"prettier": "^2.8.1",
|
|
54
53
|
"ts-node": "^10.9.1",
|
|
55
|
-
"
|
|
54
|
+
"typedoc": "~0.23",
|
|
55
|
+
"typescript": "^5.0.4"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"commander": "~9.4.1",
|
package/src/cli.js
CHANGED
|
@@ -72,7 +72,7 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
72
72
|
"receipt",
|
|
73
73
|
{
|
|
74
74
|
displayName: "Expense Receipt",
|
|
75
|
-
docClass: _1.
|
|
75
|
+
docClass: _1.ReceiptV5,
|
|
76
76
|
fullText: true,
|
|
77
77
|
async: false,
|
|
78
78
|
sync: true,
|
|
@@ -294,7 +294,9 @@ function addAction(prog) {
|
|
|
294
294
|
if (prog.name() === COMMAND_CUSTOM) {
|
|
295
295
|
prog.action(function (inputPath, options, command) {
|
|
296
296
|
const allOptions = {
|
|
297
|
-
...
|
|
297
|
+
...prog.parent?.parent?.opts(),
|
|
298
|
+
...prog.parent?.opts(),
|
|
299
|
+
...prog.opts(),
|
|
298
300
|
...options,
|
|
299
301
|
};
|
|
300
302
|
return routeSwitchboard(command, inputPath, allOptions);
|
|
@@ -303,7 +305,9 @@ function addAction(prog) {
|
|
|
303
305
|
else {
|
|
304
306
|
prog.action(function (inputPath, options, command) {
|
|
305
307
|
const allOptions = {
|
|
306
|
-
...
|
|
308
|
+
...prog.parent?.parent?.opts(),
|
|
309
|
+
...prog.parent?.opts(),
|
|
310
|
+
...prog.opts(),
|
|
307
311
|
...options,
|
|
308
312
|
};
|
|
309
313
|
return routeSwitchboard(command, inputPath, allOptions);
|
package/src/client.js
CHANGED
|
@@ -51,7 +51,7 @@ class DocumentClient {
|
|
|
51
51
|
if (this.inputSource === undefined) {
|
|
52
52
|
throw new Error("The 'enqueue' function requires an input document.");
|
|
53
53
|
}
|
|
54
|
-
return await docConfig.
|
|
54
|
+
return await docConfig.predictAsync({
|
|
55
55
|
inputDoc: this.inputSource,
|
|
56
56
|
includeWords: this.getBooleanParam(params.fullText),
|
|
57
57
|
pageOptions: params.pageOptions,
|
|
@@ -136,6 +136,9 @@ class Client {
|
|
|
136
136
|
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ReceiptV4.name], new documentConfig_1.DocumentConfig(documents_1.ReceiptV4, [
|
|
137
137
|
new api_1.StandardEndpoint("expense_receipts", "4", this.apiKey),
|
|
138
138
|
]));
|
|
139
|
+
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ReceiptV5.name], new documentConfig_1.DocumentConfig(documents_1.ReceiptV5, [
|
|
140
|
+
new api_1.StandardEndpoint("expense_receipts", "5", this.apiKey),
|
|
141
|
+
]));
|
|
139
142
|
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.PassportV1.name], new documentConfig_1.DocumentConfig(documents_1.PassportV1, [
|
|
140
143
|
new api_1.StandardEndpoint("passport", "1", this.apiKey),
|
|
141
144
|
]));
|
|
@@ -19,7 +19,7 @@ export declare class DocumentConfig<DocType extends Document> {
|
|
|
19
19
|
pageOptions?: PageOptions;
|
|
20
20
|
cropper: boolean;
|
|
21
21
|
}): Promise<Response<DocType>>;
|
|
22
|
-
|
|
22
|
+
predictAsync(params: {
|
|
23
23
|
inputDoc: InputSource;
|
|
24
24
|
includeWords: boolean;
|
|
25
25
|
pageOptions?: PageOptions;
|
|
@@ -19,7 +19,7 @@ class DocumentConfig {
|
|
|
19
19
|
const response = await this.predictRequest(params.inputDoc, params.includeWords, params.cropper);
|
|
20
20
|
return this.buildResult(response, params.inputDoc);
|
|
21
21
|
}
|
|
22
|
-
async
|
|
22
|
+
async predictAsync(params) {
|
|
23
23
|
this.checkApiKeys();
|
|
24
24
|
await params.inputDoc.init();
|
|
25
25
|
if (params.pageOptions !== undefined) {
|
|
@@ -24,17 +24,14 @@ class FinancialDocumentV1 extends document_1.Document {
|
|
|
24
24
|
this.supplierCompanyRegistrations = [];
|
|
25
25
|
/** The company registration information for the customer. */
|
|
26
26
|
this.customerCompanyRegistrations = [];
|
|
27
|
-
/** The list of the taxes. */
|
|
28
|
-
this.taxes = [];
|
|
29
27
|
/** Line items details. */
|
|
30
28
|
this.lineItems = [];
|
|
31
29
|
this.locale = new fields_1.Locale({
|
|
32
30
|
prediction: prediction.locale,
|
|
33
31
|
valueKey: "language",
|
|
34
32
|
});
|
|
35
|
-
this.documentType = new fields_1.
|
|
33
|
+
this.documentType = new fields_1.ClassificationField({
|
|
36
34
|
prediction: prediction.document_type,
|
|
37
|
-
valueKey: "value",
|
|
38
35
|
});
|
|
39
36
|
this.referenceNumbers = prediction.reference_numbers.map(function (prediction) {
|
|
40
37
|
return new fields_1.TextField({
|
|
@@ -44,17 +41,14 @@ class FinancialDocumentV1 extends document_1.Document {
|
|
|
44
41
|
});
|
|
45
42
|
this.totalAmount = new fields_1.Amount({
|
|
46
43
|
prediction: prediction.total_amount,
|
|
47
|
-
valueKey: "value",
|
|
48
44
|
pageId: pageId,
|
|
49
45
|
});
|
|
50
46
|
this.totalTax = new fields_1.Amount({
|
|
51
47
|
prediction: prediction.total_tax,
|
|
52
|
-
valueKey: "value",
|
|
53
48
|
pageId: pageId,
|
|
54
49
|
});
|
|
55
50
|
this.totalNet = new fields_1.Amount({
|
|
56
51
|
prediction: prediction.total_net,
|
|
57
|
-
valueKey: "value",
|
|
58
52
|
pageId: pageId,
|
|
59
53
|
});
|
|
60
54
|
this.date = new fields_1.DateField({
|
|
@@ -105,7 +99,6 @@ class FinancialDocumentV1 extends document_1.Document {
|
|
|
105
99
|
})));
|
|
106
100
|
this.tip = new fields_1.Amount({
|
|
107
101
|
prediction: prediction.tip,
|
|
108
|
-
valueKey: "value",
|
|
109
102
|
pageId: pageId,
|
|
110
103
|
});
|
|
111
104
|
this.category = new fields_1.TextField({
|
|
@@ -120,17 +113,9 @@ class FinancialDocumentV1 extends document_1.Document {
|
|
|
120
113
|
prediction: prediction.time,
|
|
121
114
|
pageId: pageId,
|
|
122
115
|
});
|
|
123
|
-
|
|
124
|
-
prediction: taxPrediction,
|
|
125
|
-
pageId: pageId,
|
|
126
|
-
valueKey: "value",
|
|
127
|
-
rateKey: "rate",
|
|
128
|
-
codeKey: "code",
|
|
129
|
-
baseKey: "base",
|
|
130
|
-
})));
|
|
116
|
+
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
|
|
131
117
|
}
|
|
132
118
|
toString() {
|
|
133
|
-
const taxes = this.taxes.map((item) => item.toString()).join("\n ");
|
|
134
119
|
const referenceNumbers = this.referenceNumbers
|
|
135
120
|
.map((item) => item.toString())
|
|
136
121
|
.join(", ");
|
|
@@ -149,31 +134,31 @@ class FinancialDocumentV1 extends document_1.Document {
|
|
|
149
134
|
"\n Code | QTY | Price | Amount | Tax (Rate) | Description\n ";
|
|
150
135
|
lineItems += this.lineItems.map((item) => item.toString()).join("\n ");
|
|
151
136
|
}
|
|
152
|
-
const outStr =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
Supplier
|
|
165
|
-
Supplier
|
|
166
|
-
Supplier
|
|
167
|
-
|
|
168
|
-
Customer
|
|
169
|
-
Customer
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
Total
|
|
174
|
-
Total
|
|
175
|
-
|
|
176
|
-
|
|
137
|
+
const outStr = `Financial Document V1 Prediction
|
|
138
|
+
================================
|
|
139
|
+
:Filename: ${this.filename}
|
|
140
|
+
:Document type: ${this.documentType}
|
|
141
|
+
:Category: ${this.category}
|
|
142
|
+
:Subcategory: ${this.subCategory}
|
|
143
|
+
:Locale: ${this.locale}
|
|
144
|
+
:Invoice number: ${this.invoiceNumber}
|
|
145
|
+
:Reference numbers: ${referenceNumbers}
|
|
146
|
+
:Date: ${this.date}
|
|
147
|
+
:Due date: ${this.dueDate}
|
|
148
|
+
:Time: ${this.time}
|
|
149
|
+
:Supplier name: ${this.supplierName}
|
|
150
|
+
:Supplier address: ${this.supplierAddress}
|
|
151
|
+
:Supplier company registrations: ${supplierCompanyRegistration}
|
|
152
|
+
:Supplier payment details: ${paymentDetails}
|
|
153
|
+
:Customer name: ${this.customerName}
|
|
154
|
+
:Customer address: ${this.customerAddress}
|
|
155
|
+
:Customer company registrations: ${customerCompanyRegistration}
|
|
156
|
+
:Tip: ${this.tip}
|
|
157
|
+
:Taxes: ${this.taxes}
|
|
158
|
+
:Total tax: ${this.totalTax}
|
|
159
|
+
:Total net: ${this.totalNet}
|
|
160
|
+
:Total amount: ${this.totalAmount}
|
|
161
|
+
:Line Items: ${lineItems}
|
|
177
162
|
`;
|
|
178
163
|
return FinancialDocumentV1.cleanOutString(outStr);
|
|
179
164
|
}
|
package/src/documents/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { InvoiceV4 } from "./invoice/invoiceV4";
|
|
|
3
3
|
export { InvoiceSplitterV1, PageGroup, } from "./invoiceSplitter/invoiceSplitterV1";
|
|
4
4
|
export { ReceiptV3 } from "./receipt/receiptV3";
|
|
5
5
|
export { ReceiptV4 } from "./receipt/receiptV4";
|
|
6
|
+
export { ReceiptV5 } from "./receipt/receiptV5";
|
|
6
7
|
export { PassportV1 } from "./passport/passportV1";
|
|
7
8
|
export { FinancialDocumentV0 } from "./financialDocument/financialDocumentV0";
|
|
8
9
|
export { FinancialDocumentV1 } from "./financialDocument/financialDocumentV1";
|
package/src/documents/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.CropperV1 = exports.getLineItems = exports.CustomV1 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.PassportV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PageGroup = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
|
|
26
|
+
exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.CropperV1 = exports.getLineItems = exports.CustomV1 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.PassportV1 = exports.ReceiptV5 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PageGroup = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
|
|
27
27
|
var invoiceV3_1 = require("./invoice/invoiceV3");
|
|
28
28
|
Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return invoiceV3_1.InvoiceV3; } });
|
|
29
29
|
var invoiceV4_1 = require("./invoice/invoiceV4");
|
|
@@ -35,6 +35,8 @@ var receiptV3_1 = require("./receipt/receiptV3");
|
|
|
35
35
|
Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function () { return receiptV3_1.ReceiptV3; } });
|
|
36
36
|
var receiptV4_1 = require("./receipt/receiptV4");
|
|
37
37
|
Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return receiptV4_1.ReceiptV4; } });
|
|
38
|
+
var receiptV5_1 = require("./receipt/receiptV5");
|
|
39
|
+
Object.defineProperty(exports, "ReceiptV5", { enumerable: true, get: function () { return receiptV5_1.ReceiptV5; } });
|
|
38
40
|
var passportV1_1 = require("./passport/passportV1");
|
|
39
41
|
Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function () { return passportV1_1.PassportV1; } });
|
|
40
42
|
var financialDocumentV0_1 = require("./financialDocument/financialDocumentV0");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { BaseField,
|
|
2
|
+
import { BaseField, Taxes, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration } from "../../fields";
|
|
3
3
|
export declare class InvoiceV3 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
/** Total amount with the tax amount of the purchase. */
|
|
@@ -31,7 +31,7 @@ export declare class InvoiceV3 extends Document {
|
|
|
31
31
|
/** The address of the customer. */
|
|
32
32
|
customerAddress: TextField;
|
|
33
33
|
/** The list of the taxes. */
|
|
34
|
-
taxes:
|
|
34
|
+
taxes: Taxes;
|
|
35
35
|
/** The payment information. */
|
|
36
36
|
paymentDetails: PaymentDetails[];
|
|
37
37
|
/** The company registration information for the customer. */
|
|
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
5
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
6
|
};
|
|
7
|
-
var _InvoiceV3_instances,
|
|
7
|
+
var _InvoiceV3_instances, _InvoiceV3_checklist, _InvoiceV3_reconstruct;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.InvoiceV3 = void 0;
|
|
10
10
|
const document_1 = require("../document");
|
|
@@ -39,18 +39,77 @@ class InvoiceV3 extends document_1.Document {
|
|
|
39
39
|
_InvoiceV3_instances.add(this);
|
|
40
40
|
/** The company regitration information. */
|
|
41
41
|
this.companyRegistration = [];
|
|
42
|
-
/** The list of the taxes. */
|
|
43
|
-
this.taxes = [];
|
|
44
42
|
/** The payment information. */
|
|
45
43
|
this.paymentDetails = [];
|
|
46
44
|
/** The company registration information for the customer. */
|
|
47
45
|
this.customerCompanyRegistration = [];
|
|
48
|
-
|
|
46
|
+
this.locale = new fields_1.Locale({
|
|
47
|
+
prediction: prediction.locale,
|
|
48
|
+
valueKey: "language",
|
|
49
|
+
});
|
|
50
|
+
this.documentType = new fields_1.BaseField({
|
|
51
|
+
prediction: prediction.document_type,
|
|
52
|
+
});
|
|
53
|
+
this.totalIncl = new fields_1.Amount({
|
|
54
|
+
prediction: prediction.total_incl,
|
|
55
|
+
pageId: pageId,
|
|
56
|
+
});
|
|
57
|
+
this.totalAmount = this.totalIncl;
|
|
58
|
+
this.totalTax = new fields_1.Amount({
|
|
59
|
+
prediction: { value: undefined, confidence: 0.0 },
|
|
60
|
+
pageId: pageId,
|
|
61
|
+
});
|
|
62
|
+
this.totalNet = new fields_1.Amount({
|
|
63
|
+
prediction: prediction.total_excl,
|
|
64
|
+
pageId: pageId,
|
|
65
|
+
});
|
|
66
|
+
this.date = new fields_1.DateField({
|
|
67
|
+
prediction: prediction.date,
|
|
68
|
+
pageId,
|
|
69
|
+
});
|
|
70
|
+
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
|
|
71
|
+
this.companyRegistration = prediction.company_registration.map(function (prediction) {
|
|
72
|
+
return new fields_1.CompanyRegistration({
|
|
73
|
+
prediction: prediction,
|
|
74
|
+
pageId: pageId,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
this.dueDate = new fields_1.DateField({
|
|
78
|
+
prediction: prediction.due_date,
|
|
79
|
+
pageId: pageId,
|
|
80
|
+
});
|
|
81
|
+
this.invoiceNumber = new fields_1.TextField({
|
|
82
|
+
prediction: prediction.invoice_number,
|
|
83
|
+
pageId: pageId,
|
|
84
|
+
});
|
|
85
|
+
this.supplier = new fields_1.TextField({
|
|
86
|
+
prediction: prediction.supplier,
|
|
87
|
+
pageId: pageId,
|
|
88
|
+
});
|
|
89
|
+
this.supplierAddress = new fields_1.TextField({
|
|
90
|
+
prediction: prediction.supplier_address,
|
|
91
|
+
pageId: pageId,
|
|
92
|
+
});
|
|
93
|
+
this.customerName = new fields_1.TextField({
|
|
94
|
+
prediction: prediction.customer,
|
|
95
|
+
pageId: pageId,
|
|
96
|
+
});
|
|
97
|
+
this.customerAddress = new fields_1.TextField({
|
|
98
|
+
prediction: prediction.customer_address,
|
|
99
|
+
pageId: pageId,
|
|
100
|
+
});
|
|
101
|
+
prediction.customer_company_registration.map((prediction) => this.customerCompanyRegistration.push(new fields_1.CompanyRegistration({
|
|
102
|
+
prediction: prediction,
|
|
103
|
+
pageId: pageId,
|
|
104
|
+
})));
|
|
105
|
+
prediction.payment_details.map((prediction) => this.paymentDetails.push(new fields_1.PaymentDetails({
|
|
106
|
+
prediction: prediction,
|
|
107
|
+
pageId: pageId,
|
|
108
|
+
})));
|
|
49
109
|
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_checklist).call(this);
|
|
50
110
|
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_reconstruct).call(this);
|
|
51
111
|
}
|
|
52
112
|
toString() {
|
|
53
|
-
const taxes = this.taxes.map((item) => item.toString()).join("\n ");
|
|
54
113
|
const paymentDetails = this.paymentDetails
|
|
55
114
|
.map((item) => item.toString())
|
|
56
115
|
.join("\n ");
|
|
@@ -60,104 +119,30 @@ class InvoiceV3 extends document_1.Document {
|
|
|
60
119
|
const companyRegistration = this.companyRegistration
|
|
61
120
|
.map((item) => item.toString())
|
|
62
121
|
.join("; ");
|
|
63
|
-
const outStr =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Total amount
|
|
68
|
-
|
|
69
|
-
Invoice
|
|
70
|
-
|
|
71
|
-
Supplier
|
|
72
|
-
|
|
73
|
-
Customer
|
|
74
|
-
Customer
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
122
|
+
const outStr = `Invoice V3 Prediction
|
|
123
|
+
=====================
|
|
124
|
+
:Filename: ${this.filename}
|
|
125
|
+
:Invoice number: ${this.invoiceNumber}
|
|
126
|
+
:Total amount: ${this.totalIncl}
|
|
127
|
+
:Total net: ${this.totalExcl}
|
|
128
|
+
:Invoice date: ${this.date}
|
|
129
|
+
:Invoice due date: ${this.dueDate}
|
|
130
|
+
:Supplier name: ${this.supplier}
|
|
131
|
+
:Supplier address: ${this.supplierAddress}
|
|
132
|
+
:Customer name: ${this.customerName}
|
|
133
|
+
:Customer company registration: ${customerCompanyRegistration}
|
|
134
|
+
:Customer address: ${this.customerAddress}
|
|
135
|
+
:Payment details: ${paymentDetails}
|
|
136
|
+
:Company numbers: ${companyRegistration}
|
|
137
|
+
:Taxes: ${this.taxes}
|
|
138
|
+
:Total tax: ${this.totalTax}
|
|
139
|
+
:Locale: ${this.locale}
|
|
81
140
|
`;
|
|
82
141
|
return InvoiceV3.cleanOutString(outStr);
|
|
83
142
|
}
|
|
84
143
|
}
|
|
85
144
|
exports.InvoiceV3 = InvoiceV3;
|
|
86
|
-
_InvoiceV3_instances = new WeakSet(),
|
|
87
|
-
this.locale = new fields_1.Locale({
|
|
88
|
-
prediction: apiPrediction.locale,
|
|
89
|
-
valueKey: "language",
|
|
90
|
-
});
|
|
91
|
-
this.documentType = new fields_1.BaseField({
|
|
92
|
-
prediction: apiPrediction.document_type,
|
|
93
|
-
valueKey: "value",
|
|
94
|
-
});
|
|
95
|
-
this.totalIncl = new fields_1.Amount({
|
|
96
|
-
prediction: apiPrediction.total_incl,
|
|
97
|
-
valueKey: "value",
|
|
98
|
-
pageId: pageId,
|
|
99
|
-
});
|
|
100
|
-
this.totalAmount = this.totalIncl;
|
|
101
|
-
this.totalTax = new fields_1.Amount({
|
|
102
|
-
prediction: { value: undefined, confidence: 0.0 },
|
|
103
|
-
valueKey: "value",
|
|
104
|
-
pageId: pageId,
|
|
105
|
-
});
|
|
106
|
-
this.totalNet = new fields_1.Amount({
|
|
107
|
-
prediction: apiPrediction.total_excl,
|
|
108
|
-
valueKey: "value",
|
|
109
|
-
pageId: pageId,
|
|
110
|
-
});
|
|
111
|
-
this.date = new fields_1.DateField({
|
|
112
|
-
prediction: apiPrediction.date,
|
|
113
|
-
pageId,
|
|
114
|
-
});
|
|
115
|
-
apiPrediction.taxes.map((prediction) => this.taxes.push(new fields_1.TaxField({
|
|
116
|
-
prediction: prediction,
|
|
117
|
-
pageId: pageId,
|
|
118
|
-
valueKey: "value",
|
|
119
|
-
rateKey: "rate",
|
|
120
|
-
codeKey: "code",
|
|
121
|
-
})));
|
|
122
|
-
this.companyRegistration = apiPrediction.company_registration.map(function (prediction) {
|
|
123
|
-
return new fields_1.CompanyRegistration({
|
|
124
|
-
prediction: prediction,
|
|
125
|
-
pageId: pageId,
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
this.dueDate = new fields_1.DateField({
|
|
129
|
-
prediction: apiPrediction.due_date,
|
|
130
|
-
pageId: pageId,
|
|
131
|
-
});
|
|
132
|
-
this.invoiceNumber = new fields_1.TextField({
|
|
133
|
-
prediction: apiPrediction.invoice_number,
|
|
134
|
-
pageId: pageId,
|
|
135
|
-
});
|
|
136
|
-
this.supplier = new fields_1.TextField({
|
|
137
|
-
prediction: apiPrediction.supplier,
|
|
138
|
-
pageId: pageId,
|
|
139
|
-
});
|
|
140
|
-
this.supplierAddress = new fields_1.TextField({
|
|
141
|
-
prediction: apiPrediction.supplier_address,
|
|
142
|
-
pageId: pageId,
|
|
143
|
-
});
|
|
144
|
-
this.customerName = new fields_1.TextField({
|
|
145
|
-
prediction: apiPrediction.customer,
|
|
146
|
-
pageId: pageId,
|
|
147
|
-
});
|
|
148
|
-
this.customerAddress = new fields_1.TextField({
|
|
149
|
-
prediction: apiPrediction.customer_address,
|
|
150
|
-
pageId: pageId,
|
|
151
|
-
});
|
|
152
|
-
apiPrediction.customer_company_registration.map((prediction) => this.customerCompanyRegistration.push(new fields_1.CompanyRegistration({
|
|
153
|
-
prediction: prediction,
|
|
154
|
-
pageId: pageId,
|
|
155
|
-
})));
|
|
156
|
-
apiPrediction.payment_details.map((prediction) => this.paymentDetails.push(new fields_1.PaymentDetails({
|
|
157
|
-
prediction: prediction,
|
|
158
|
-
pageId: pageId,
|
|
159
|
-
})));
|
|
160
|
-
}, _InvoiceV3_checklist = function _InvoiceV3_checklist() {
|
|
145
|
+
_InvoiceV3_instances = new WeakSet(), _InvoiceV3_checklist = function _InvoiceV3_checklist() {
|
|
161
146
|
this.checklist = {
|
|
162
147
|
taxesMatchTotalIncl: (0, checks_1.taxesMatchTotalIncl)(this),
|
|
163
148
|
taxesMatchTotalExcl: (0, checks_1.taxesMatchTotalExcl)(this),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { ClassificationField,
|
|
2
|
+
import { ClassificationField, Taxes, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration } from "../../fields";
|
|
3
3
|
import { InvoiceLineItem } from "./invoiceLineItem";
|
|
4
4
|
/** Invoice V4 */
|
|
5
5
|
export declare class InvoiceV4 extends Document {
|
|
@@ -37,7 +37,7 @@ export declare class InvoiceV4 extends Document {
|
|
|
37
37
|
/** The company registration information for the customer. */
|
|
38
38
|
customerCompanyRegistrations: CompanyRegistration[];
|
|
39
39
|
/** The list of the taxes. */
|
|
40
|
-
taxes:
|
|
40
|
+
taxes: Taxes;
|
|
41
41
|
/** Line items details. */
|
|
42
42
|
lineItems: InvoiceLineItem[];
|
|
43
43
|
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
@@ -31,8 +31,6 @@ class InvoiceV4 extends document_1.Document {
|
|
|
31
31
|
this.supplierCompanyRegistrations = [];
|
|
32
32
|
/** The company registration information for the customer. */
|
|
33
33
|
this.customerCompanyRegistrations = [];
|
|
34
|
-
/** The list of the taxes. */
|
|
35
|
-
this.taxes = [];
|
|
36
34
|
/** Line items details. */
|
|
37
35
|
this.lineItems = [];
|
|
38
36
|
this.locale = new fields_1.Locale({
|
|
@@ -41,7 +39,6 @@ class InvoiceV4 extends document_1.Document {
|
|
|
41
39
|
});
|
|
42
40
|
this.documentType = new fields_1.ClassificationField({
|
|
43
41
|
prediction: prediction.document_type,
|
|
44
|
-
valueKey: "value",
|
|
45
42
|
});
|
|
46
43
|
this.referenceNumbers = prediction.reference_numbers.map(function (prediction) {
|
|
47
44
|
return new fields_1.TextField({
|
|
@@ -51,30 +48,21 @@ class InvoiceV4 extends document_1.Document {
|
|
|
51
48
|
});
|
|
52
49
|
this.totalAmount = new fields_1.Amount({
|
|
53
50
|
prediction: prediction.total_amount,
|
|
54
|
-
valueKey: "value",
|
|
55
51
|
pageId: pageId,
|
|
56
52
|
});
|
|
57
53
|
this.totalTax = new fields_1.Amount({
|
|
58
54
|
prediction: { value: undefined, confidence: 0.0 },
|
|
59
|
-
valueKey: "value",
|
|
60
55
|
pageId: pageId,
|
|
61
56
|
});
|
|
62
57
|
this.totalNet = new fields_1.Amount({
|
|
63
58
|
prediction: prediction.total_net,
|
|
64
|
-
valueKey: "value",
|
|
65
59
|
pageId: pageId,
|
|
66
60
|
});
|
|
67
61
|
this.date = new fields_1.DateField({
|
|
68
62
|
prediction: prediction.date,
|
|
69
63
|
pageId,
|
|
70
64
|
});
|
|
71
|
-
|
|
72
|
-
prediction: prediction,
|
|
73
|
-
pageId: pageId,
|
|
74
|
-
valueKey: "value",
|
|
75
|
-
rateKey: "rate",
|
|
76
|
-
codeKey: "code",
|
|
77
|
-
})));
|
|
65
|
+
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
|
|
78
66
|
this.supplierCompanyRegistrations =
|
|
79
67
|
prediction.supplier_company_registrations.map(function (prediction) {
|
|
80
68
|
return new fields_1.CompanyRegistration({
|
|
@@ -121,7 +109,6 @@ class InvoiceV4 extends document_1.Document {
|
|
|
121
109
|
__classPrivateFieldGet(this, _InvoiceV4_instances, "m", _InvoiceV4_reconstruct).call(this);
|
|
122
110
|
}
|
|
123
111
|
toString() {
|
|
124
|
-
const taxes = this.taxes.map((item) => item.toString()).join("\n ");
|
|
125
112
|
const referenceNumbers = this.referenceNumbers
|
|
126
113
|
.map((item) => item.toString())
|
|
127
114
|
.join(", ");
|
|
@@ -140,26 +127,26 @@ class InvoiceV4 extends document_1.Document {
|
|
|
140
127
|
"\n Code | QTY | Price | Amount | Tax (Rate) | Description\n ";
|
|
141
128
|
lineItems += this.lineItems.map((item) => item.toString()).join("\n ");
|
|
142
129
|
}
|
|
143
|
-
const outStr =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
Invoice
|
|
150
|
-
|
|
151
|
-
Supplier
|
|
152
|
-
Supplier
|
|
153
|
-
Supplier
|
|
154
|
-
|
|
155
|
-
Customer
|
|
156
|
-
Customer
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
Total
|
|
161
|
-
Total
|
|
162
|
-
|
|
130
|
+
const outStr = `Invoice V4 Prediction
|
|
131
|
+
=====================
|
|
132
|
+
:Filename: ${this.filename}
|
|
133
|
+
:Locale: ${this.locale}
|
|
134
|
+
:Invoice number: ${this.invoiceNumber}
|
|
135
|
+
:Reference numbers: ${referenceNumbers}
|
|
136
|
+
:Invoice date: ${this.date}
|
|
137
|
+
:Invoice due date: ${this.dueDate}
|
|
138
|
+
:Supplier name: ${this.supplierName}
|
|
139
|
+
:Supplier address: ${this.supplierAddress}
|
|
140
|
+
:Supplier company registrations: ${companyRegistration}
|
|
141
|
+
:Supplier payment details: ${paymentDetails}
|
|
142
|
+
:Customer name: ${this.customerName}
|
|
143
|
+
:Customer company registrations: ${customerCompanyRegistration}
|
|
144
|
+
:Customer address: ${this.customerAddress}
|
|
145
|
+
:Line Items: ${lineItems}
|
|
146
|
+
:Taxes: ${this.taxes}
|
|
147
|
+
:Total tax: ${this.totalTax}
|
|
148
|
+
:Total net: ${this.totalNet}
|
|
149
|
+
:Total amount: ${this.totalAmount}
|
|
163
150
|
`;
|
|
164
151
|
return InvoiceV4.cleanOutString(outStr);
|
|
165
152
|
}
|
|
@@ -2,7 +2,7 @@ import { Document, DocumentConstructorProps } from "../document";
|
|
|
2
2
|
import { CompanyRegistration, DateField, Locale, TextField } from "../../fields";
|
|
3
3
|
export declare class ProofOfAddressV1 extends Document {
|
|
4
4
|
/** ISO date yyyy-mm-dd. Works both for European and US dates. */
|
|
5
|
-
|
|
5
|
+
date: DateField;
|
|
6
6
|
/** All extrated ISO date yyyy-mm-dd. Works both for European and US dates. */
|
|
7
7
|
dates: DateField[];
|
|
8
8
|
/** Address of the document's issuer. */
|
|
@@ -20,7 +20,7 @@ class ProofOfAddressV1 extends document_1.Document {
|
|
|
20
20
|
this.locale = new fields_1.Locale({
|
|
21
21
|
prediction: prediction.locale,
|
|
22
22
|
});
|
|
23
|
-
this.
|
|
23
|
+
this.date = new fields_1.DateField({
|
|
24
24
|
prediction: prediction.date,
|
|
25
25
|
pageId: pageId,
|
|
26
26
|
});
|
|
@@ -68,7 +68,7 @@ Recipient Company Registrations: ${this.recipientCompanyRegistration
|
|
|
68
68
|
.join(", ")}
|
|
69
69
|
Recipient Address: ${this.recipientAddress}
|
|
70
70
|
Dates: ${this.dates.map((rcr) => rcr.value).join("\n ")}
|
|
71
|
-
Date of Issue: ${this.
|
|
71
|
+
Date of Issue: ${this.date}
|
|
72
72
|
----------------------
|
|
73
73
|
`;
|
|
74
74
|
return ProofOfAddressV1.cleanOutString(outStr);
|
|
@@ -18,7 +18,7 @@ export declare class ReceiptV3 extends Document {
|
|
|
18
18
|
totalTax: Amount;
|
|
19
19
|
/** Total amount without tax of the purchase. */
|
|
20
20
|
totalExcl: Amount;
|
|
21
|
-
/** List of different
|
|
21
|
+
/** List of different taxes. */
|
|
22
22
|
taxes: TaxField[];
|
|
23
23
|
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
24
24
|
toString(): string;
|