mindee 3.8.0 → 3.10.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 +18 -0
- package/package.json +1 -1
- package/src/cli.js +0 -10
- package/src/client.js +3 -3
- package/src/documents/documentConfig.js +2 -2
- package/src/documents/financialDocument/financialDocumentV1.d.ts +39 -36
- package/src/documents/financialDocument/financialDocumentV1.js +120 -89
- package/src/documents/financialDocument/financialDocumentV1LineItem.d.ts +40 -0
- package/src/documents/financialDocument/financialDocumentV1LineItem.js +107 -0
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +18 -0
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.js +48 -0
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +34 -0
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +67 -0
- package/src/documents/fr/index.d.ts +1 -0
- package/src/documents/fr/index.js +3 -1
- package/src/documents/index.d.ts +0 -1
- package/src/documents/index.js +1 -3
- package/src/documents/receipt/receiptV5.d.ts +25 -25
- package/src/documents/receipt/receiptV5.js +46 -44
- package/src/documents/receipt/receiptV5LineItem.d.ts +19 -1
- package/src/documents/receipt/receiptV5LineItem.js +50 -9
- package/src/fields/amount.d.ts +3 -0
- package/src/fields/amount.js +3 -0
- package/src/fields/base.d.ts +3 -0
- package/src/fields/base.js +3 -0
- package/src/fields/classification.d.ts +3 -0
- package/src/fields/classification.js +3 -0
- package/src/fields/companyRegistration.d.ts +3 -0
- package/src/fields/companyRegistration.js +3 -0
- package/src/fields/date.d.ts +3 -0
- package/src/fields/date.js +3 -0
- package/src/fields/field.d.ts +3 -0
- package/src/fields/field.js +3 -0
- package/src/fields/fullText.d.ts +3 -0
- package/src/fields/fullText.js +3 -0
- package/src/fields/locale.d.ts +4 -1
- package/src/fields/locale.js +5 -1
- package/src/fields/orientation.d.ts +3 -0
- package/src/fields/orientation.js +3 -0
- package/src/fields/paymentDetails.d.ts +8 -5
- package/src/fields/paymentDetails.js +3 -0
- package/src/fields/position.d.ts +3 -0
- package/src/fields/position.js +3 -0
- package/src/fields/tax.d.ts +12 -0
- package/src/fields/tax.js +12 -0
- package/src/fields/text.d.ts +3 -0
- package/src/fields/text.js +3 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -2
- package/src/documents/shippingContainer/shippingContainerV1.d.ts +0 -12
- package/src/documents/shippingContainer/shippingContainerV1.js +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v3.10.0 - 2023-07-04
|
|
4
|
+
### Changes
|
|
5
|
+
* :sparkles: add support for FR Bank Account Details V2
|
|
6
|
+
* :recycle: update printing syntax & unit test for Receipt v5
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## v3.9.0 - 2023-06-06
|
|
10
|
+
### Changes
|
|
11
|
+
* :sparkles: support for financial document v1.1
|
|
12
|
+
* :recycle: change http status code handling for async requests
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Fixes
|
|
16
|
+
* :bug: fix typing in PaymentDetails
|
|
17
|
+
* :bug: locale value should always be set
|
|
18
|
+
* :bug: add missing class properties on new line items
|
|
19
|
+
|
|
20
|
+
|
|
3
21
|
## v3.8.0 - 2023-05-25
|
|
4
22
|
### Changes
|
|
5
23
|
* :sparkles: add support for receipt v5
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -148,16 +148,6 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
148
148
|
sync: true,
|
|
149
149
|
},
|
|
150
150
|
],
|
|
151
|
-
[
|
|
152
|
-
"shipping-container",
|
|
153
|
-
{
|
|
154
|
-
displayName: "Shipping Container",
|
|
155
|
-
docClass: _1.ShippingContainerV1,
|
|
156
|
-
fullText: false,
|
|
157
|
-
async: false,
|
|
158
|
-
sync: true,
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
151
|
[
|
|
162
152
|
"mvision",
|
|
163
153
|
{
|
package/src/client.js
CHANGED
|
@@ -154,15 +154,15 @@ class Client {
|
|
|
154
154
|
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.BankAccountDetailsV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.BankAccountDetailsV1, [
|
|
155
155
|
new api_1.StandardEndpoint("bank_account_details", "1", this.apiKey),
|
|
156
156
|
]));
|
|
157
|
+
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.BankAccountDetailsV2.name], new documentConfig_1.DocumentConfig(documents_1.fr.BankAccountDetailsV2, [
|
|
158
|
+
new api_1.StandardEndpoint("bank_account_details", "2", this.apiKey),
|
|
159
|
+
]));
|
|
157
160
|
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.CarteVitaleV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.CarteVitaleV1, [
|
|
158
161
|
new api_1.StandardEndpoint("carte_vitale", "1", this.apiKey),
|
|
159
162
|
]));
|
|
160
163
|
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.eu.LicensePlateV1.name], new documentConfig_1.DocumentConfig(documents_1.eu.LicensePlateV1, [
|
|
161
164
|
new api_1.StandardEndpoint("license_plates", "1", this.apiKey),
|
|
162
165
|
]));
|
|
163
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ShippingContainerV1.name], new documentConfig_1.DocumentConfig(documents_1.ShippingContainerV1, [
|
|
164
|
-
new api_1.StandardEndpoint("shipping_containers", "1", this.apiKey),
|
|
165
|
-
]));
|
|
166
166
|
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.MindeeVisionV1.name], new documentConfig_1.DocumentConfig(documents_1.MindeeVisionV1, [
|
|
167
167
|
new api_1.StandardEndpoint("mindee_vision", "1", this.apiKey),
|
|
168
168
|
]));
|
|
@@ -27,7 +27,7 @@ class DocumentConfig {
|
|
|
27
27
|
}
|
|
28
28
|
const response = await this.endpoints[0].predictAsyncReqPost(params.inputDoc, params.includeWords, params.cropper);
|
|
29
29
|
const statusCode = response.messageObj.statusCode;
|
|
30
|
-
if (statusCode === undefined || statusCode >=
|
|
30
|
+
if (statusCode === undefined || statusCode >= 300) {
|
|
31
31
|
this.handleError(response, statusCode);
|
|
32
32
|
}
|
|
33
33
|
return new api_1.AsyncPredictResponse(response.data);
|
|
@@ -38,7 +38,7 @@ class DocumentConfig {
|
|
|
38
38
|
const queueStatusCode = queueResponse.messageObj.statusCode;
|
|
39
39
|
if (queueStatusCode === undefined ||
|
|
40
40
|
queueStatusCode < 200 ||
|
|
41
|
-
queueStatusCode
|
|
41
|
+
queueStatusCode >= 400) {
|
|
42
42
|
this.handleError(queueResponse, queueStatusCode);
|
|
43
43
|
}
|
|
44
44
|
if (queueStatusCode === 302 &&
|
|
@@ -1,54 +1,57 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Amount, ClassificationField, CompanyRegistration, DateField, Locale, PaymentDetails, TaxField, TextField } from "../../fields";
|
|
3
|
+
import { FinancialDocumentV1LineItem } from "./financialDocumentV1LineItem";
|
|
4
4
|
/**
|
|
5
|
-
* Financial Document.
|
|
5
|
+
* Document data for Financial Document, API version 1.
|
|
6
6
|
*/
|
|
7
7
|
export declare class FinancialDocumentV1 extends Document {
|
|
8
|
-
|
|
8
|
+
#private;
|
|
9
|
+
/** The locale detected on the document. */
|
|
9
10
|
locale: Locale;
|
|
10
|
-
/** The
|
|
11
|
-
|
|
12
|
-
/** List of Reference numbers including PO number. */
|
|
11
|
+
/** The invoice number or identifier. */
|
|
12
|
+
invoiceNumber: TextField;
|
|
13
|
+
/** List of Reference numbers, including PO number. */
|
|
13
14
|
referenceNumbers: TextField[];
|
|
14
|
-
/** The
|
|
15
|
+
/** The date the purchase was made. */
|
|
15
16
|
date: DateField;
|
|
16
|
-
/** The
|
|
17
|
+
/** The date on which the payment is due. */
|
|
17
18
|
dueDate: DateField;
|
|
18
|
-
/** The
|
|
19
|
-
|
|
20
|
-
/** The
|
|
21
|
-
|
|
22
|
-
/**
|
|
19
|
+
/** The net amount paid: does not include taxes, fees, and discounts. */
|
|
20
|
+
totalNet: Amount;
|
|
21
|
+
/** The total amount paid: includes taxes, tips, fees, and other charges. */
|
|
22
|
+
totalAmount: Amount;
|
|
23
|
+
/** List of tax lines information. */
|
|
24
|
+
taxes: TaxField[];
|
|
25
|
+
/** List of payment details associated to the supplier. */
|
|
23
26
|
supplierPaymentDetails: PaymentDetails[];
|
|
24
|
-
/** The supplier
|
|
27
|
+
/** The name of the supplier or merchant. */
|
|
28
|
+
supplierName: TextField;
|
|
29
|
+
/** List of company registrations associated to the supplier. */
|
|
25
30
|
supplierCompanyRegistrations: CompanyRegistration[];
|
|
26
|
-
/** The
|
|
27
|
-
|
|
31
|
+
/** The address of the supplier or merchant. */
|
|
32
|
+
supplierAddress: TextField;
|
|
33
|
+
/** The phone number of the supplier or merchant. */
|
|
34
|
+
supplierPhoneNumber: TextField;
|
|
28
35
|
/** The name of the customer. */
|
|
29
36
|
customerName: TextField;
|
|
37
|
+
/** List of company registrations associated to the customer. */
|
|
38
|
+
customerCompanyRegistrations: CompanyRegistration[];
|
|
30
39
|
/** The address of the customer. */
|
|
31
40
|
customerAddress: TextField;
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
/** The
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
/** The
|
|
39
|
-
category: TextField;
|
|
40
|
-
/** The receipt sub-category among predefined classes. */
|
|
41
|
-
subCategory: TextField;
|
|
42
|
-
/** Time as seen on the receipt in HH:MM format. */
|
|
43
|
-
time: TextField;
|
|
44
|
-
/** Total amount of tip and gratuity. */
|
|
45
|
-
tip: Amount;
|
|
46
|
-
/** total spent including taxes, discounts, fees, tips, and gratuity. */
|
|
47
|
-
totalAmount: Amount;
|
|
48
|
-
/** Total amount of the purchase excluding taxes. */
|
|
49
|
-
totalNet: Amount;
|
|
50
|
-
/** Total tax amount of the purchase. */
|
|
41
|
+
/** One of: 'INVOICE', 'CREDIT NOTE', 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'. */
|
|
42
|
+
documentType: ClassificationField;
|
|
43
|
+
/** The purchase subcategory among predefined classes for transport and food. */
|
|
44
|
+
subcategory: ClassificationField;
|
|
45
|
+
/** The purchase category among predefined classes. */
|
|
46
|
+
category: ClassificationField;
|
|
47
|
+
/** The total amount of taxes. */
|
|
51
48
|
totalTax: Amount;
|
|
49
|
+
/** The total amount of tip and gratuity */
|
|
50
|
+
tip: Amount;
|
|
51
|
+
/** The time the purchase was made. */
|
|
52
|
+
time: TextField;
|
|
53
|
+
/** List of line item details. */
|
|
54
|
+
lineItems: FinancialDocumentV1LineItem[];
|
|
52
55
|
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
53
56
|
toString(): string;
|
|
54
57
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _FinancialDocumentV1_instances, _FinancialDocumentV1_lineItemsSeparator, _FinancialDocumentV1_lineItemsToString;
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.FinancialDocumentV1 = void 0;
|
|
4
10
|
const document_1 = require("../document");
|
|
5
11
|
const fields_1 = require("../../fields");
|
|
6
|
-
const
|
|
12
|
+
const financialDocumentV1LineItem_1 = require("./financialDocumentV1LineItem");
|
|
7
13
|
/**
|
|
8
|
-
* Financial Document.
|
|
14
|
+
* Document data for Financial Document, API version 1.
|
|
9
15
|
*/
|
|
10
16
|
class FinancialDocumentV1 extends document_1.Document {
|
|
11
17
|
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
@@ -13,154 +19,179 @@ class FinancialDocumentV1 extends document_1.Document {
|
|
|
13
19
|
inputSource: inputSource,
|
|
14
20
|
pageId: pageId,
|
|
15
21
|
orientation: orientation,
|
|
16
|
-
fullText: fullText,
|
|
17
22
|
extras: extras,
|
|
23
|
+
fullText: fullText,
|
|
18
24
|
});
|
|
19
|
-
|
|
25
|
+
_FinancialDocumentV1_instances.add(this);
|
|
26
|
+
/** List of Reference numbers, including PO number. */
|
|
20
27
|
this.referenceNumbers = [];
|
|
21
|
-
/**
|
|
28
|
+
/** List of payment details associated to the supplier. */
|
|
22
29
|
this.supplierPaymentDetails = [];
|
|
23
|
-
/**
|
|
30
|
+
/** List of company registrations associated to the supplier. */
|
|
24
31
|
this.supplierCompanyRegistrations = [];
|
|
25
|
-
/**
|
|
32
|
+
/** List of company registrations associated to the customer. */
|
|
26
33
|
this.customerCompanyRegistrations = [];
|
|
27
|
-
/**
|
|
34
|
+
/** List of line item details. */
|
|
28
35
|
this.lineItems = [];
|
|
29
36
|
this.locale = new fields_1.Locale({
|
|
30
|
-
prediction: prediction
|
|
37
|
+
prediction: prediction["locale"],
|
|
31
38
|
valueKey: "language",
|
|
32
39
|
});
|
|
33
|
-
this.
|
|
34
|
-
prediction: prediction
|
|
35
|
-
|
|
36
|
-
this.referenceNumbers = prediction.reference_numbers.map(function (prediction) {
|
|
37
|
-
return new fields_1.TextField({
|
|
38
|
-
prediction: prediction,
|
|
39
|
-
pageId: pageId,
|
|
40
|
-
});
|
|
40
|
+
this.invoiceNumber = new fields_1.TextField({
|
|
41
|
+
prediction: prediction["invoice_number"],
|
|
42
|
+
pageId: pageId,
|
|
41
43
|
});
|
|
42
|
-
|
|
43
|
-
prediction:
|
|
44
|
+
prediction["reference_numbers"].map((itemPrediction) => this.referenceNumbers.push(new fields_1.TextField({
|
|
45
|
+
prediction: itemPrediction,
|
|
46
|
+
pageId: pageId,
|
|
47
|
+
})));
|
|
48
|
+
this.date = new fields_1.DateField({
|
|
49
|
+
prediction: prediction["date"],
|
|
44
50
|
pageId: pageId,
|
|
45
51
|
});
|
|
46
|
-
this.
|
|
47
|
-
prediction: prediction
|
|
52
|
+
this.dueDate = new fields_1.DateField({
|
|
53
|
+
prediction: prediction["due_date"],
|
|
48
54
|
pageId: pageId,
|
|
49
55
|
});
|
|
50
56
|
this.totalNet = new fields_1.Amount({
|
|
51
|
-
prediction: prediction
|
|
57
|
+
prediction: prediction["total_net"],
|
|
52
58
|
pageId: pageId,
|
|
53
59
|
});
|
|
54
|
-
this.
|
|
55
|
-
prediction: prediction
|
|
56
|
-
pageId,
|
|
57
|
-
});
|
|
58
|
-
this.dueDate = new fields_1.DateField({
|
|
59
|
-
prediction: prediction.due_date,
|
|
60
|
+
this.totalAmount = new fields_1.Amount({
|
|
61
|
+
prediction: prediction["total_amount"],
|
|
60
62
|
pageId: pageId,
|
|
61
63
|
});
|
|
62
|
-
this.
|
|
63
|
-
|
|
64
|
+
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
|
|
65
|
+
prediction["supplier_payment_details"].map((itemPrediction) => this.supplierPaymentDetails.push(new fields_1.PaymentDetails({
|
|
66
|
+
prediction: itemPrediction,
|
|
64
67
|
pageId: pageId,
|
|
65
|
-
});
|
|
68
|
+
})));
|
|
66
69
|
this.supplierName = new fields_1.TextField({
|
|
67
|
-
prediction: prediction
|
|
70
|
+
prediction: prediction["supplier_name"],
|
|
68
71
|
pageId: pageId,
|
|
69
72
|
});
|
|
73
|
+
prediction["supplier_company_registrations"].map((itemPrediction) => this.supplierCompanyRegistrations.push(new fields_1.CompanyRegistration({
|
|
74
|
+
prediction: itemPrediction,
|
|
75
|
+
pageId: pageId,
|
|
76
|
+
})));
|
|
70
77
|
this.supplierAddress = new fields_1.TextField({
|
|
71
|
-
prediction: prediction
|
|
78
|
+
prediction: prediction["supplier_address"],
|
|
72
79
|
pageId: pageId,
|
|
73
80
|
});
|
|
74
|
-
this.
|
|
75
|
-
prediction
|
|
76
|
-
return new fields_1.CompanyRegistration({
|
|
77
|
-
prediction: prediction,
|
|
78
|
-
pageId: pageId,
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
this.customerName = new fields_1.TextField({
|
|
82
|
-
prediction: prediction.customer_name,
|
|
81
|
+
this.supplierPhoneNumber = new fields_1.TextField({
|
|
82
|
+
prediction: prediction["supplier_phone_number"],
|
|
83
83
|
pageId: pageId,
|
|
84
84
|
});
|
|
85
|
-
this.
|
|
86
|
-
prediction: prediction
|
|
85
|
+
this.customerName = new fields_1.TextField({
|
|
86
|
+
prediction: prediction["customer_name"],
|
|
87
87
|
pageId: pageId,
|
|
88
88
|
});
|
|
89
|
-
prediction
|
|
90
|
-
prediction:
|
|
91
|
-
pageId: pageId,
|
|
92
|
-
})));
|
|
93
|
-
prediction.supplier_payment_details.map((prediction) => this.supplierPaymentDetails.push(new fields_1.PaymentDetails({
|
|
94
|
-
prediction: prediction,
|
|
89
|
+
prediction["customer_company_registrations"].map((itemPrediction) => this.customerCompanyRegistrations.push(new fields_1.CompanyRegistration({
|
|
90
|
+
prediction: itemPrediction,
|
|
95
91
|
pageId: pageId,
|
|
96
92
|
})));
|
|
97
|
-
|
|
98
|
-
prediction: prediction,
|
|
99
|
-
})));
|
|
100
|
-
this.tip = new fields_1.Amount({
|
|
101
|
-
prediction: prediction.tip,
|
|
93
|
+
this.customerAddress = new fields_1.TextField({
|
|
94
|
+
prediction: prediction["customer_address"],
|
|
102
95
|
pageId: pageId,
|
|
103
96
|
});
|
|
104
|
-
this.
|
|
105
|
-
prediction: prediction
|
|
97
|
+
this.documentType = new fields_1.ClassificationField({
|
|
98
|
+
prediction: prediction["document_type"],
|
|
99
|
+
});
|
|
100
|
+
this.subcategory = new fields_1.ClassificationField({
|
|
101
|
+
prediction: prediction["subcategory"],
|
|
102
|
+
});
|
|
103
|
+
this.category = new fields_1.ClassificationField({
|
|
104
|
+
prediction: prediction["category"],
|
|
105
|
+
});
|
|
106
|
+
this.totalTax = new fields_1.Amount({
|
|
107
|
+
prediction: prediction["total_tax"],
|
|
106
108
|
pageId: pageId,
|
|
107
109
|
});
|
|
108
|
-
this.
|
|
109
|
-
prediction: prediction
|
|
110
|
+
this.tip = new fields_1.Amount({
|
|
111
|
+
prediction: prediction["tip"],
|
|
110
112
|
pageId: pageId,
|
|
111
113
|
});
|
|
112
114
|
this.time = new fields_1.TextField({
|
|
113
|
-
prediction: prediction
|
|
115
|
+
prediction: prediction["time"],
|
|
114
116
|
pageId: pageId,
|
|
115
117
|
});
|
|
116
|
-
|
|
118
|
+
prediction["line_items"].map((itemPrediction) => this.lineItems.push(new financialDocumentV1LineItem_1.FinancialDocumentV1LineItem({
|
|
119
|
+
prediction: itemPrediction,
|
|
120
|
+
pageId: pageId,
|
|
121
|
+
})));
|
|
117
122
|
}
|
|
118
123
|
toString() {
|
|
119
124
|
const referenceNumbers = this.referenceNumbers
|
|
120
125
|
.map((item) => item.toString())
|
|
121
126
|
.join(", ");
|
|
122
|
-
const
|
|
127
|
+
const supplierPaymentDetails = this.supplierPaymentDetails
|
|
123
128
|
.map((item) => item.toString())
|
|
124
129
|
.join("\n ");
|
|
125
|
-
const
|
|
130
|
+
const customerCompanyRegistrations = this.customerCompanyRegistrations
|
|
126
131
|
.map((item) => item.toString())
|
|
127
132
|
.join("; ");
|
|
128
|
-
const
|
|
133
|
+
const supplierCompanyRegistrations = this.supplierCompanyRegistrations
|
|
129
134
|
.map((item) => item.toString())
|
|
130
135
|
.join("; ");
|
|
131
|
-
let lineItems = "";
|
|
132
|
-
if (this.lineItems.length > 0) {
|
|
133
|
-
lineItems =
|
|
134
|
-
"\n Code | QTY | Price | Amount | Tax (Rate) | Description\n ";
|
|
135
|
-
lineItems += this.lineItems.map((item) => item.toString()).join("\n ");
|
|
136
|
-
}
|
|
137
136
|
const outStr = `Financial Document V1 Prediction
|
|
138
137
|
================================
|
|
139
138
|
:Filename: ${this.filename}
|
|
140
|
-
:Document type: ${this.documentType}
|
|
141
|
-
:Category: ${this.category}
|
|
142
|
-
:Subcategory: ${this.subCategory}
|
|
143
139
|
:Locale: ${this.locale}
|
|
144
|
-
:Invoice
|
|
145
|
-
:Reference
|
|
146
|
-
:Date: ${this.date}
|
|
147
|
-
:Due
|
|
148
|
-
:
|
|
140
|
+
:Invoice Number: ${this.invoiceNumber}
|
|
141
|
+
:Reference Numbers: ${referenceNumbers}
|
|
142
|
+
:Purchase Date: ${this.date}
|
|
143
|
+
:Due Date: ${this.dueDate}
|
|
144
|
+
:Total Net: ${this.totalNet}
|
|
145
|
+
:Total Amount: ${this.totalAmount}
|
|
146
|
+
:Taxes: ${this.taxes}
|
|
147
|
+
:Supplier Payment Details: ${supplierPaymentDetails}
|
|
149
148
|
:Supplier name: ${this.supplierName}
|
|
150
|
-
:Supplier
|
|
151
|
-
:Supplier
|
|
152
|
-
:Supplier
|
|
149
|
+
:Supplier Company Registrations: ${customerCompanyRegistrations}
|
|
150
|
+
:Supplier Address: ${this.supplierAddress}
|
|
151
|
+
:Supplier Phone Number: ${this.supplierPhoneNumber}
|
|
153
152
|
:Customer name: ${this.customerName}
|
|
154
|
-
:Customer
|
|
155
|
-
:Customer
|
|
156
|
-
:
|
|
157
|
-
:
|
|
158
|
-
:
|
|
159
|
-
:Total
|
|
160
|
-
:
|
|
161
|
-
:
|
|
153
|
+
:Customer Company Registrations: ${supplierCompanyRegistrations}
|
|
154
|
+
:Customer Address: ${this.customerAddress}
|
|
155
|
+
:Document Type: ${this.documentType}
|
|
156
|
+
:Purchase Subcategory: ${this.subcategory}
|
|
157
|
+
:Purchase Category: ${this.category}
|
|
158
|
+
:Total Tax: ${this.totalTax}
|
|
159
|
+
:Tip and Gratuity: ${this.tip}
|
|
160
|
+
:Purchase Time: ${this.time}
|
|
161
|
+
:Line Items: ${__classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_lineItemsToString).call(this)}
|
|
162
162
|
`;
|
|
163
163
|
return FinancialDocumentV1.cleanOutString(outStr);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
exports.FinancialDocumentV1 = FinancialDocumentV1;
|
|
167
|
+
_FinancialDocumentV1_instances = new WeakSet(), _FinancialDocumentV1_lineItemsSeparator = function _FinancialDocumentV1_lineItemsSeparator(char) {
|
|
168
|
+
let outStr = " ";
|
|
169
|
+
outStr += `+${char.repeat(38)}`;
|
|
170
|
+
outStr += `+${char.repeat(14)}`;
|
|
171
|
+
outStr += `+${char.repeat(10)}`;
|
|
172
|
+
outStr += `+${char.repeat(12)}`;
|
|
173
|
+
outStr += `+${char.repeat(14)}`;
|
|
174
|
+
outStr += `+${char.repeat(14)}`;
|
|
175
|
+
outStr += `+${char.repeat(12)}`;
|
|
176
|
+
return outStr + "+";
|
|
177
|
+
}, _FinancialDocumentV1_lineItemsToString = function _FinancialDocumentV1_lineItemsToString() {
|
|
178
|
+
if (this.lineItems.length === 0) {
|
|
179
|
+
return "";
|
|
180
|
+
}
|
|
181
|
+
const lines = this.lineItems
|
|
182
|
+
.map((item) => item.toTableLine())
|
|
183
|
+
.join(`\n${__classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_lineItemsSeparator).call(this, "-")}\n `);
|
|
184
|
+
let outStr = "";
|
|
185
|
+
outStr += `\n${__classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_lineItemsSeparator).call(this, "-")}\n `;
|
|
186
|
+
outStr += " | Description ";
|
|
187
|
+
outStr += " | Product code";
|
|
188
|
+
outStr += " | Quantity";
|
|
189
|
+
outStr += " | Tax Amount";
|
|
190
|
+
outStr += " | Tax Rate (%)";
|
|
191
|
+
outStr += " | Total Amount";
|
|
192
|
+
outStr += " | Unit Price";
|
|
193
|
+
outStr += ` |\n${__classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_lineItemsSeparator).call(this, "=")}`;
|
|
194
|
+
outStr += `\n ${lines}`;
|
|
195
|
+
outStr += `\n${__classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_lineItemsSeparator).call(this, "-")}`;
|
|
196
|
+
return outStr;
|
|
197
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { StringDict } from "../../fields";
|
|
2
|
+
import { Polygon } from "../../geometry";
|
|
3
|
+
/**
|
|
4
|
+
* List of line item details.
|
|
5
|
+
*/
|
|
6
|
+
export declare class FinancialDocumentV1LineItem {
|
|
7
|
+
#private;
|
|
8
|
+
/** The item description. */
|
|
9
|
+
description: string | null;
|
|
10
|
+
/** The product code referring to the item. */
|
|
11
|
+
productCode: string | null;
|
|
12
|
+
/** The item quantity */
|
|
13
|
+
quantity: number | null;
|
|
14
|
+
/** The item tax amount. */
|
|
15
|
+
taxAmount: number | null;
|
|
16
|
+
/** The item tax rate in percentage. */
|
|
17
|
+
taxRate: number | null;
|
|
18
|
+
/** The item total amount. */
|
|
19
|
+
totalAmount: number | null;
|
|
20
|
+
/** The item unit price. */
|
|
21
|
+
unitPrice: number | null;
|
|
22
|
+
/** Confidence score */
|
|
23
|
+
confidence: number;
|
|
24
|
+
/** The document page on which the information was found. */
|
|
25
|
+
pageId: number;
|
|
26
|
+
/**
|
|
27
|
+
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
28
|
+
* the field in the document.
|
|
29
|
+
*/
|
|
30
|
+
polygon: Polygon;
|
|
31
|
+
constructor({ prediction }: StringDict);
|
|
32
|
+
/**
|
|
33
|
+
* Default string representation.
|
|
34
|
+
*/
|
|
35
|
+
toString(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Output in a format suitable for inclusion in an rST table.
|
|
38
|
+
*/
|
|
39
|
+
toTableLine(): string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _FinancialDocumentV1LineItem_instances, _FinancialDocumentV1LineItem_printableValues;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FinancialDocumentV1LineItem = void 0;
|
|
10
|
+
const amount_1 = require("../../fields/amount");
|
|
11
|
+
/**
|
|
12
|
+
* List of line item details.
|
|
13
|
+
*/
|
|
14
|
+
class FinancialDocumentV1LineItem {
|
|
15
|
+
constructor({ prediction }) {
|
|
16
|
+
_FinancialDocumentV1LineItem_instances.add(this);
|
|
17
|
+
/** Confidence score */
|
|
18
|
+
this.confidence = 0.0;
|
|
19
|
+
/**
|
|
20
|
+
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
21
|
+
* the field in the document.
|
|
22
|
+
*/
|
|
23
|
+
this.polygon = [];
|
|
24
|
+
this.description = prediction["description"];
|
|
25
|
+
this.productCode = prediction["product_code"];
|
|
26
|
+
this.quantity = +parseFloat(prediction["quantity"]).toFixed(3);
|
|
27
|
+
if (isNaN(this.quantity)) {
|
|
28
|
+
this.quantity = null;
|
|
29
|
+
}
|
|
30
|
+
this.taxAmount = +parseFloat(prediction["tax_amount"]).toFixed(3);
|
|
31
|
+
if (isNaN(this.taxAmount)) {
|
|
32
|
+
this.taxAmount = null;
|
|
33
|
+
}
|
|
34
|
+
this.taxRate = +parseFloat(prediction["tax_rate"]).toFixed(3);
|
|
35
|
+
if (isNaN(this.taxRate)) {
|
|
36
|
+
this.taxRate = null;
|
|
37
|
+
}
|
|
38
|
+
this.totalAmount = +parseFloat(prediction["total_amount"]).toFixed(3);
|
|
39
|
+
if (isNaN(this.totalAmount)) {
|
|
40
|
+
this.totalAmount = null;
|
|
41
|
+
}
|
|
42
|
+
this.unitPrice = +parseFloat(prediction["unit_price"]).toFixed(3);
|
|
43
|
+
if (isNaN(this.unitPrice)) {
|
|
44
|
+
this.unitPrice = null;
|
|
45
|
+
}
|
|
46
|
+
this.pageId = prediction["page_id"];
|
|
47
|
+
this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
|
|
48
|
+
if (prediction["polygon"]) {
|
|
49
|
+
this.polygon = prediction.polygon;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Default string representation.
|
|
54
|
+
*/
|
|
55
|
+
toString() {
|
|
56
|
+
const printable = __classPrivateFieldGet(this, _FinancialDocumentV1LineItem_instances, "m", _FinancialDocumentV1LineItem_printableValues).call(this);
|
|
57
|
+
return ("Description: " +
|
|
58
|
+
printable.description +
|
|
59
|
+
"Product code: " +
|
|
60
|
+
printable.productCode +
|
|
61
|
+
"Quantity: " +
|
|
62
|
+
printable.quantity +
|
|
63
|
+
"Tax Amount: " +
|
|
64
|
+
printable.taxAmount +
|
|
65
|
+
"Tax Rate (%): " +
|
|
66
|
+
printable.taxRate +
|
|
67
|
+
"Total Amount: " +
|
|
68
|
+
printable.totalAmount +
|
|
69
|
+
"Unit Price: " +
|
|
70
|
+
printable.unitPrice).trim();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Output in a format suitable for inclusion in an rST table.
|
|
74
|
+
*/
|
|
75
|
+
toTableLine() {
|
|
76
|
+
const printable = __classPrivateFieldGet(this, _FinancialDocumentV1LineItem_instances, "m", _FinancialDocumentV1LineItem_printableValues).call(this);
|
|
77
|
+
return ("| " +
|
|
78
|
+
(printable.description.length > 33
|
|
79
|
+
? printable.description.substring(0, 33) + "..."
|
|
80
|
+
: printable.description).padEnd(36) +
|
|
81
|
+
" | " +
|
|
82
|
+
printable.productCode.padEnd(12) +
|
|
83
|
+
" | " +
|
|
84
|
+
printable.quantity.padEnd(8) +
|
|
85
|
+
" | " +
|
|
86
|
+
printable.taxAmount.padEnd(10) +
|
|
87
|
+
" | " +
|
|
88
|
+
printable.taxRate.padEnd(12) +
|
|
89
|
+
" | " +
|
|
90
|
+
printable.totalAmount.padEnd(12) +
|
|
91
|
+
" | " +
|
|
92
|
+
printable.unitPrice.padEnd(10) +
|
|
93
|
+
" |");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.FinancialDocumentV1LineItem = FinancialDocumentV1LineItem;
|
|
97
|
+
_FinancialDocumentV1LineItem_instances = new WeakSet(), _FinancialDocumentV1LineItem_printableValues = function _FinancialDocumentV1LineItem_printableValues() {
|
|
98
|
+
return {
|
|
99
|
+
description: this.description ?? "",
|
|
100
|
+
productCode: this.productCode ?? "",
|
|
101
|
+
quantity: this.quantity !== null ? (0, amount_1.floatToString)(this.quantity) : "",
|
|
102
|
+
taxAmount: this.taxAmount !== null ? (0, amount_1.floatToString)(this.taxAmount) : "",
|
|
103
|
+
taxRate: this.taxRate !== null ? (0, amount_1.floatToString)(this.taxRate) : "",
|
|
104
|
+
totalAmount: this.totalAmount !== null ? (0, amount_1.floatToString)(this.totalAmount) : "",
|
|
105
|
+
unitPrice: this.unitPrice !== null ? (0, amount_1.floatToString)(this.unitPrice) : "",
|
|
106
|
+
};
|
|
107
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Document, DocumentConstructorProps } from "../../document";
|
|
2
|
+
import { TextField } from "../../../fields";
|
|
3
|
+
import { BankAccountDetailsV2Bban } from "./bankAccountDetailsV2Bban";
|
|
4
|
+
/**
|
|
5
|
+
* Document data for Bank Account Details, API version 2.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BankAccountDetailsV2 extends Document {
|
|
8
|
+
/** Full extraction of the account holders names. */
|
|
9
|
+
accountHoldersNames: TextField;
|
|
10
|
+
/** Full extraction of BBAN, including: branch code, bank code, account and key. */
|
|
11
|
+
bban: BankAccountDetailsV2Bban;
|
|
12
|
+
/** Full extraction of the IBAN number. */
|
|
13
|
+
iban: TextField;
|
|
14
|
+
/** Full extraction of the SWIFT code. */
|
|
15
|
+
swiftCode: TextField;
|
|
16
|
+
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
17
|
+
toString(): string;
|
|
18
|
+
}
|