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
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BankAccountDetailsV2 = void 0;
|
|
4
|
+
const document_1 = require("../../document");
|
|
5
|
+
const fields_1 = require("../../../fields");
|
|
6
|
+
const bankAccountDetailsV2Bban_1 = require("./bankAccountDetailsV2Bban");
|
|
7
|
+
/**
|
|
8
|
+
* Document data for Bank Account Details, API version 2.
|
|
9
|
+
*/
|
|
10
|
+
class BankAccountDetailsV2 extends document_1.Document {
|
|
11
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
12
|
+
super({
|
|
13
|
+
inputSource: inputSource,
|
|
14
|
+
pageId: pageId,
|
|
15
|
+
orientation: orientation,
|
|
16
|
+
extras: extras,
|
|
17
|
+
fullText: fullText,
|
|
18
|
+
});
|
|
19
|
+
this.accountHoldersNames = new fields_1.TextField({
|
|
20
|
+
prediction: prediction["account_holders_names"],
|
|
21
|
+
pageId: pageId,
|
|
22
|
+
});
|
|
23
|
+
this.bban = new bankAccountDetailsV2Bban_1.BankAccountDetailsV2Bban({
|
|
24
|
+
prediction: prediction["bban"],
|
|
25
|
+
pageId: pageId,
|
|
26
|
+
});
|
|
27
|
+
this.iban = new fields_1.TextField({
|
|
28
|
+
prediction: prediction["iban"],
|
|
29
|
+
pageId: pageId,
|
|
30
|
+
});
|
|
31
|
+
this.swiftCode = new fields_1.TextField({
|
|
32
|
+
prediction: prediction["swift_code"],
|
|
33
|
+
pageId: pageId,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
toString() {
|
|
37
|
+
const outStr = `FR Bank Account Details V2 Prediction
|
|
38
|
+
=====================================
|
|
39
|
+
:Filename: ${this.filename}
|
|
40
|
+
:Account Holder's Names: ${this.accountHoldersNames}
|
|
41
|
+
:Basic Bank Account Number: ${this.bban.toFieldList()}
|
|
42
|
+
:IBAN: ${this.iban}
|
|
43
|
+
:SWIFT Code: ${this.swiftCode}
|
|
44
|
+
`;
|
|
45
|
+
return BankAccountDetailsV2.cleanOutString(outStr);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.BankAccountDetailsV2 = BankAccountDetailsV2;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StringDict } from "../../../fields";
|
|
2
|
+
import { Polygon } from "../../../geometry";
|
|
3
|
+
/**
|
|
4
|
+
* Full extraction of BBAN, including: branch code, bank code, account and key.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BankAccountDetailsV2Bban {
|
|
7
|
+
#private;
|
|
8
|
+
/** The BBAN bank code outputted as a string. */
|
|
9
|
+
bbanBankCode: string | null;
|
|
10
|
+
/** The BBAN branch code outputted as a string. */
|
|
11
|
+
bbanBranchCode: string | null;
|
|
12
|
+
/** The BBAN key outputted as a string. */
|
|
13
|
+
bbanKey: string | null;
|
|
14
|
+
/** The BBAN Account number outputted as a string. */
|
|
15
|
+
bbanNumber: string | null;
|
|
16
|
+
/** Confidence score */
|
|
17
|
+
confidence: number;
|
|
18
|
+
/** The document page on which the information was found. */
|
|
19
|
+
pageId: number;
|
|
20
|
+
/**
|
|
21
|
+
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
22
|
+
* the field in the document.
|
|
23
|
+
*/
|
|
24
|
+
polygon: Polygon;
|
|
25
|
+
constructor({ prediction }: StringDict);
|
|
26
|
+
/**
|
|
27
|
+
* Default string representation.
|
|
28
|
+
*/
|
|
29
|
+
toString(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Output in a format suitable for inclusion in a field list.
|
|
32
|
+
*/
|
|
33
|
+
toFieldList(): string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 _BankAccountDetailsV2Bban_instances, _BankAccountDetailsV2Bban_printableValues;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BankAccountDetailsV2Bban = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Full extraction of BBAN, including: branch code, bank code, account and key.
|
|
12
|
+
*/
|
|
13
|
+
class BankAccountDetailsV2Bban {
|
|
14
|
+
constructor({ prediction }) {
|
|
15
|
+
_BankAccountDetailsV2Bban_instances.add(this);
|
|
16
|
+
/** Confidence score */
|
|
17
|
+
this.confidence = 0.0;
|
|
18
|
+
/**
|
|
19
|
+
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
20
|
+
* the field in the document.
|
|
21
|
+
*/
|
|
22
|
+
this.polygon = [];
|
|
23
|
+
this.bbanBankCode = prediction["bban_bank_code"];
|
|
24
|
+
this.bbanBranchCode = prediction["bban_branch_code"];
|
|
25
|
+
this.bbanKey = prediction["bban_key"];
|
|
26
|
+
this.bbanNumber = prediction["bban_number"];
|
|
27
|
+
this.pageId = prediction["page_id"];
|
|
28
|
+
this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
|
|
29
|
+
if (prediction["polygon"]) {
|
|
30
|
+
this.polygon = prediction.polygon;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Default string representation.
|
|
35
|
+
*/
|
|
36
|
+
toString() {
|
|
37
|
+
const printable = __classPrivateFieldGet(this, _BankAccountDetailsV2Bban_instances, "m", _BankAccountDetailsV2Bban_printableValues).call(this);
|
|
38
|
+
return ("Bank Code: " +
|
|
39
|
+
printable.bbanBankCode +
|
|
40
|
+
", Branch Code: " +
|
|
41
|
+
printable.bbanBranchCode +
|
|
42
|
+
", Key: " +
|
|
43
|
+
printable.bbanKey +
|
|
44
|
+
", Account Number: " +
|
|
45
|
+
printable.bbanNumber);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Output in a format suitable for inclusion in a field list.
|
|
49
|
+
*/
|
|
50
|
+
toFieldList() {
|
|
51
|
+
const printable = __classPrivateFieldGet(this, _BankAccountDetailsV2Bban_instances, "m", _BankAccountDetailsV2Bban_printableValues).call(this);
|
|
52
|
+
return `
|
|
53
|
+
:Bank Code: ${printable.bbanBankCode}
|
|
54
|
+
:Branch Code: ${printable.bbanBranchCode}
|
|
55
|
+
:Key: ${printable.bbanKey}
|
|
56
|
+
:Account Number: ${printable.bbanNumber}`.trimEnd();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.BankAccountDetailsV2Bban = BankAccountDetailsV2Bban;
|
|
60
|
+
_BankAccountDetailsV2Bban_instances = new WeakSet(), _BankAccountDetailsV2Bban_printableValues = function _BankAccountDetailsV2Bban_printableValues() {
|
|
61
|
+
return {
|
|
62
|
+
bbanBankCode: this.bbanBankCode ?? "",
|
|
63
|
+
bbanBranchCode: this.bbanBranchCode ?? "",
|
|
64
|
+
bbanKey: this.bbanKey ?? "",
|
|
65
|
+
bbanNumber: this.bbanNumber ?? "",
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { IdCardV1 } from "./idCard/idCardV1";
|
|
2
2
|
export { BankAccountDetailsV1 } from "./bankAccountDetails/bankAccountDetailsV1";
|
|
3
|
+
export { BankAccountDetailsV2 } from "./bankAccountDetails/bankAccountDetailsV2";
|
|
3
4
|
export { CarteVitaleV1 } from "./carteVitale/carteVitaleV1";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CarteVitaleV1 = exports.BankAccountDetailsV1 = exports.IdCardV1 = void 0;
|
|
3
|
+
exports.CarteVitaleV1 = exports.BankAccountDetailsV2 = exports.BankAccountDetailsV1 = exports.IdCardV1 = void 0;
|
|
4
4
|
var idCardV1_1 = require("./idCard/idCardV1");
|
|
5
5
|
Object.defineProperty(exports, "IdCardV1", { enumerable: true, get: function () { return idCardV1_1.IdCardV1; } });
|
|
6
6
|
var bankAccountDetailsV1_1 = require("./bankAccountDetails/bankAccountDetailsV1");
|
|
7
7
|
Object.defineProperty(exports, "BankAccountDetailsV1", { enumerable: true, get: function () { return bankAccountDetailsV1_1.BankAccountDetailsV1; } });
|
|
8
|
+
var bankAccountDetailsV2_1 = require("./bankAccountDetails/bankAccountDetailsV2");
|
|
9
|
+
Object.defineProperty(exports, "BankAccountDetailsV2", { enumerable: true, get: function () { return bankAccountDetailsV2_1.BankAccountDetailsV2; } });
|
|
8
10
|
var carteVitaleV1_1 = require("./carteVitale/carteVitaleV1");
|
|
9
11
|
Object.defineProperty(exports, "CarteVitaleV1", { enumerable: true, get: function () { return carteVitaleV1_1.CarteVitaleV1; } });
|
package/src/documents/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export { getLineItems } from "./custom/lineitems";
|
|
|
12
12
|
export { CropperV1 } from "./cropper/cropperV1";
|
|
13
13
|
export { MindeeVisionV1 } from "./mindeeVision/mindeeVisionV1";
|
|
14
14
|
export { ProofOfAddressV1 } from "./proofOfAddress/proofOfAddressV1";
|
|
15
|
-
export { ShippingContainerV1 } from "./shippingContainer/shippingContainerV1";
|
|
16
15
|
export { Document, DocumentConstructorProps, DocumentSig } from "./document";
|
|
17
16
|
export * as fr from "./fr";
|
|
18
17
|
export * as us from "./us";
|
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.
|
|
26
|
+
exports.eu = exports.us = exports.fr = exports.Document = 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");
|
|
@@ -53,8 +53,6 @@ var mindeeVisionV1_1 = require("./mindeeVision/mindeeVisionV1");
|
|
|
53
53
|
Object.defineProperty(exports, "MindeeVisionV1", { enumerable: true, get: function () { return mindeeVisionV1_1.MindeeVisionV1; } });
|
|
54
54
|
var proofOfAddressV1_1 = require("./proofOfAddress/proofOfAddressV1");
|
|
55
55
|
Object.defineProperty(exports, "ProofOfAddressV1", { enumerable: true, get: function () { return proofOfAddressV1_1.ProofOfAddressV1; } });
|
|
56
|
-
var shippingContainerV1_1 = require("./shippingContainer/shippingContainerV1");
|
|
57
|
-
Object.defineProperty(exports, "ShippingContainerV1", { enumerable: true, get: function () { return shippingContainerV1_1.ShippingContainerV1; } });
|
|
58
56
|
var document_1 = require("./document");
|
|
59
57
|
Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return document_1.Document; } });
|
|
60
58
|
exports.fr = __importStar(require("./fr"));
|
|
@@ -2,42 +2,42 @@ import { Document, DocumentConstructorProps } from "../document";
|
|
|
2
2
|
import { Amount, ClassificationField, CompanyRegistration, DateField, Locale, TaxField, TextField } from "../../fields";
|
|
3
3
|
import { ReceiptV5LineItem } from "./receiptV5LineItem";
|
|
4
4
|
/**
|
|
5
|
-
* Document data for Receipt, API version 5.
|
|
5
|
+
* Document data for Expense Receipt, API version 5.
|
|
6
6
|
*/
|
|
7
7
|
export declare class ReceiptV5 extends Document {
|
|
8
8
|
#private;
|
|
9
|
-
/** The
|
|
10
|
-
locale: Locale;
|
|
11
|
-
/** The receipt category among predefined classes. */
|
|
9
|
+
/** The purchase category among predefined classes. */
|
|
12
10
|
category: ClassificationField;
|
|
13
|
-
/** The receipt sub category among predefined classes for transport and food. */
|
|
14
|
-
subcategory: ClassificationField;
|
|
15
|
-
/** The receipt document type provides the information whether the document is an expense receipt or a credit card receipt. */
|
|
16
|
-
documentType: ClassificationField;
|
|
17
11
|
/** The date the purchase was made. */
|
|
18
12
|
date: DateField;
|
|
19
|
-
/**
|
|
13
|
+
/** One of: 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'. */
|
|
14
|
+
documentType: ClassificationField;
|
|
15
|
+
/** List of line item details. */
|
|
16
|
+
lineItems: ReceiptV5LineItem[];
|
|
17
|
+
/** The locale detected on the document. */
|
|
18
|
+
locale: Locale;
|
|
19
|
+
/** The purchase subcategory among predefined classes for transport and food. */
|
|
20
|
+
subcategory: ClassificationField;
|
|
21
|
+
/** The address of the supplier or merchant. */
|
|
22
|
+
supplierAddress: TextField;
|
|
23
|
+
/** List of company registrations associated to the supplier. */
|
|
24
|
+
supplierCompanyRegistrations: CompanyRegistration[];
|
|
25
|
+
/** The name of the supplier or merchant. */
|
|
26
|
+
supplierName: TextField;
|
|
27
|
+
/** The phone number of the supplier or merchant. */
|
|
28
|
+
supplierPhoneNumber: TextField;
|
|
29
|
+
/** List of tax lines information. */
|
|
30
|
+
taxes: TaxField[];
|
|
31
|
+
/** The time the purchase was made. */
|
|
20
32
|
time: TextField;
|
|
21
|
-
/** The total amount
|
|
33
|
+
/** The total amount of tip and gratuity. */
|
|
34
|
+
tip: Amount;
|
|
35
|
+
/** The total amount paid: includes taxes, discounts, fees, tips, and gratuity. */
|
|
22
36
|
totalAmount: Amount;
|
|
23
|
-
/** The
|
|
37
|
+
/** The net amount paid: does not include taxes, fees, and discounts. */
|
|
24
38
|
totalNet: Amount;
|
|
25
39
|
/** The total amount of taxes. */
|
|
26
40
|
totalTax: Amount;
|
|
27
|
-
/** The total amount of tip and gratuity. */
|
|
28
|
-
tip: Amount;
|
|
29
|
-
/** List of tax lines information including: Amount, tax rate, tax base amount and tax code. */
|
|
30
|
-
taxes: TaxField[];
|
|
31
|
-
/** The name of the supplier or merchant. */
|
|
32
|
-
supplierName: TextField;
|
|
33
|
-
/** List of supplier company registrations or identifiers. */
|
|
34
|
-
supplierCompanyRegistrations: CompanyRegistration[];
|
|
35
|
-
/** The address of the supplier or merchant returned as a single string. */
|
|
36
|
-
supplierAddress: TextField;
|
|
37
|
-
/** The Phone number of the supplier or merchant returned as a single string. */
|
|
38
|
-
supplierPhoneNumber: TextField;
|
|
39
|
-
/** Full extraction of lines, including: description, quantity, unit price and total. */
|
|
40
|
-
lineItems: ReceiptV5LineItem[];
|
|
41
41
|
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
42
42
|
toString(): string;
|
|
43
43
|
}
|
|
@@ -11,7 +11,7 @@ const document_1 = require("../document");
|
|
|
11
11
|
const fields_1 = require("../../fields");
|
|
12
12
|
const receiptV5LineItem_1 = require("./receiptV5LineItem");
|
|
13
13
|
/**
|
|
14
|
-
* Document data for Receipt, API version 5.
|
|
14
|
+
* Document data for Expense Receipt, API version 5.
|
|
15
15
|
*/
|
|
16
16
|
class ReceiptV5 extends document_1.Document {
|
|
17
17
|
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
@@ -23,85 +23,85 @@ class ReceiptV5 extends document_1.Document {
|
|
|
23
23
|
fullText: fullText,
|
|
24
24
|
});
|
|
25
25
|
_ReceiptV5_instances.add(this);
|
|
26
|
-
/** List of
|
|
27
|
-
this.supplierCompanyRegistrations = [];
|
|
28
|
-
/** Full extraction of lines, including: description, quantity, unit price and total. */
|
|
26
|
+
/** List of line item details. */
|
|
29
27
|
this.lineItems = [];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
28
|
+
/** List of company registrations associated to the supplier. */
|
|
29
|
+
this.supplierCompanyRegistrations = [];
|
|
33
30
|
this.category = new fields_1.ClassificationField({
|
|
34
31
|
prediction: prediction["category"],
|
|
35
32
|
});
|
|
36
|
-
this.
|
|
37
|
-
prediction: prediction["
|
|
33
|
+
this.date = new fields_1.DateField({
|
|
34
|
+
prediction: prediction["date"],
|
|
35
|
+
pageId: pageId,
|
|
38
36
|
});
|
|
39
37
|
this.documentType = new fields_1.ClassificationField({
|
|
40
38
|
prediction: prediction["document_type"],
|
|
41
39
|
});
|
|
42
|
-
|
|
43
|
-
prediction:
|
|
40
|
+
prediction["line_items"].map((itemPrediction) => this.lineItems.push(new receiptV5LineItem_1.ReceiptV5LineItem({
|
|
41
|
+
prediction: itemPrediction,
|
|
44
42
|
pageId: pageId,
|
|
43
|
+
})));
|
|
44
|
+
this.locale = new fields_1.Locale({
|
|
45
|
+
prediction: prediction["locale"],
|
|
45
46
|
});
|
|
46
|
-
this.
|
|
47
|
-
prediction: prediction["
|
|
47
|
+
this.subcategory = new fields_1.ClassificationField({
|
|
48
|
+
prediction: prediction["subcategory"],
|
|
49
|
+
});
|
|
50
|
+
this.supplierAddress = new fields_1.TextField({
|
|
51
|
+
prediction: prediction["supplier_address"],
|
|
48
52
|
pageId: pageId,
|
|
49
53
|
});
|
|
50
|
-
|
|
51
|
-
prediction:
|
|
54
|
+
prediction["supplier_company_registrations"].map((itemPrediction) => this.supplierCompanyRegistrations.push(new fields_1.CompanyRegistration({
|
|
55
|
+
prediction: itemPrediction,
|
|
56
|
+
pageId: pageId,
|
|
57
|
+
})));
|
|
58
|
+
this.supplierName = new fields_1.TextField({
|
|
59
|
+
prediction: prediction["supplier_name"],
|
|
52
60
|
pageId: pageId,
|
|
53
61
|
});
|
|
54
|
-
this.
|
|
55
|
-
prediction: prediction["
|
|
62
|
+
this.supplierPhoneNumber = new fields_1.TextField({
|
|
63
|
+
prediction: prediction["supplier_phone_number"],
|
|
56
64
|
pageId: pageId,
|
|
57
65
|
});
|
|
58
|
-
this.
|
|
59
|
-
|
|
66
|
+
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
|
|
67
|
+
this.time = new fields_1.TextField({
|
|
68
|
+
prediction: prediction["time"],
|
|
60
69
|
pageId: pageId,
|
|
61
70
|
});
|
|
62
71
|
this.tip = new fields_1.Amount({
|
|
63
72
|
prediction: prediction["tip"],
|
|
64
73
|
pageId: pageId,
|
|
65
74
|
});
|
|
66
|
-
this.
|
|
67
|
-
|
|
68
|
-
prediction: prediction["supplier_name"],
|
|
75
|
+
this.totalAmount = new fields_1.Amount({
|
|
76
|
+
prediction: prediction["total_amount"],
|
|
69
77
|
pageId: pageId,
|
|
70
78
|
});
|
|
71
|
-
|
|
72
|
-
prediction:
|
|
73
|
-
pageId: pageId,
|
|
74
|
-
})));
|
|
75
|
-
this.supplierAddress = new fields_1.TextField({
|
|
76
|
-
prediction: prediction["supplier_address"],
|
|
79
|
+
this.totalNet = new fields_1.Amount({
|
|
80
|
+
prediction: prediction["total_net"],
|
|
77
81
|
pageId: pageId,
|
|
78
82
|
});
|
|
79
|
-
this.
|
|
80
|
-
prediction: prediction["
|
|
83
|
+
this.totalTax = new fields_1.Amount({
|
|
84
|
+
prediction: prediction["total_tax"],
|
|
81
85
|
pageId: pageId,
|
|
82
86
|
});
|
|
83
|
-
prediction["line_items"].map((itemPrediction) => this.lineItems.push(new receiptV5LineItem_1.ReceiptV5LineItem({
|
|
84
|
-
prediction: itemPrediction,
|
|
85
|
-
pageId: pageId,
|
|
86
|
-
})));
|
|
87
87
|
}
|
|
88
88
|
toString() {
|
|
89
89
|
const outStr = `Receipt V5 Prediction
|
|
90
90
|
=====================
|
|
91
91
|
:Filename: ${this.filename}
|
|
92
92
|
:Expense Locale: ${this.locale}
|
|
93
|
-
:
|
|
94
|
-
:
|
|
93
|
+
:Purchase Category: ${this.category}
|
|
94
|
+
:Purchase Subcategory: ${this.subcategory}
|
|
95
95
|
:Document Type: ${this.documentType}
|
|
96
96
|
:Purchase Date: ${this.date}
|
|
97
97
|
:Purchase Time: ${this.time}
|
|
98
98
|
:Total Amount: ${this.totalAmount}
|
|
99
|
-
:Total
|
|
99
|
+
:Total Net: ${this.totalNet}
|
|
100
100
|
:Total Tax: ${this.totalTax}
|
|
101
101
|
:Tip and Gratuity: ${this.tip}
|
|
102
102
|
:Taxes: ${this.taxes}
|
|
103
103
|
:Supplier Name: ${this.supplierName}
|
|
104
|
-
:Supplier Company Registrations: ${this.supplierCompanyRegistrations.join(
|
|
104
|
+
:Supplier Company Registrations: ${this.supplierCompanyRegistrations.join(`${" ".repeat(32)}`)}
|
|
105
105
|
:Supplier Address: ${this.supplierAddress}
|
|
106
106
|
:Supplier Phone Number: ${this.supplierPhoneNumber}
|
|
107
107
|
:Line Items: ${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsToString).call(this)}
|
|
@@ -118,17 +118,19 @@ _ReceiptV5_instances = new WeakSet(), _ReceiptV5_lineItemsSeparator = function _
|
|
|
118
118
|
outStr += `+${char.repeat(12)}`;
|
|
119
119
|
return outStr + "+";
|
|
120
120
|
}, _ReceiptV5_lineItemsToString = function _ReceiptV5_lineItemsToString() {
|
|
121
|
-
if (!this.lineItems) {
|
|
121
|
+
if (!this.lineItems || this.lineItems.length === 0) {
|
|
122
122
|
return "";
|
|
123
123
|
}
|
|
124
124
|
const lines = this.lineItems
|
|
125
|
-
.map((item) =>
|
|
125
|
+
.map((item) => item.toTableLine())
|
|
126
126
|
.join(`\n${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsSeparator).call(this, "-")}\n `);
|
|
127
127
|
let outStr = "";
|
|
128
|
-
outStr += `\n${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsSeparator).call(this, "-")}`;
|
|
129
|
-
outStr +=
|
|
130
|
-
|
|
131
|
-
outStr +=
|
|
128
|
+
outStr += `\n${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsSeparator).call(this, "-")}\n `;
|
|
129
|
+
outStr += " | Description ";
|
|
130
|
+
outStr += " | Quantity";
|
|
131
|
+
outStr += " | Total Amount";
|
|
132
|
+
outStr += " | Unit Price";
|
|
133
|
+
outStr += ` |\n${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsSeparator).call(this, "=")}`;
|
|
132
134
|
outStr += `\n ${lines}`;
|
|
133
135
|
outStr += `\n${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsSeparator).call(this, "-")}`;
|
|
134
136
|
return outStr;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { StringDict } from "../../fields";
|
|
2
|
+
import { Polygon } from "../../geometry";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* List of line item details.
|
|
4
5
|
*/
|
|
5
6
|
export declare class ReceiptV5LineItem {
|
|
7
|
+
#private;
|
|
6
8
|
/** The item description. */
|
|
7
9
|
description: string | null;
|
|
8
10
|
/** The item quantity. */
|
|
@@ -11,6 +13,22 @@ export declare class ReceiptV5LineItem {
|
|
|
11
13
|
totalAmount: number | null;
|
|
12
14
|
/** The item unit price. */
|
|
13
15
|
unitPrice: number | null;
|
|
16
|
+
/** Confidence score */
|
|
17
|
+
confidence: number;
|
|
18
|
+
/** The document page on which the information was found. */
|
|
19
|
+
pageId: number;
|
|
20
|
+
/**
|
|
21
|
+
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
22
|
+
* the field in the document.
|
|
23
|
+
*/
|
|
24
|
+
polygon: Polygon;
|
|
14
25
|
constructor({ prediction }: StringDict);
|
|
26
|
+
/**
|
|
27
|
+
* Default string representation.
|
|
28
|
+
*/
|
|
15
29
|
toString(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Output in a format suitable for inclusion in an rST table.
|
|
32
|
+
*/
|
|
33
|
+
toTableLine(): string;
|
|
16
34
|
}
|
|
@@ -1,12 +1,26 @@
|
|
|
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 _ReceiptV5LineItem_instances, _ReceiptV5LineItem_printableValues;
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.ReceiptV5LineItem = void 0;
|
|
4
10
|
const amount_1 = require("../../fields/amount");
|
|
5
11
|
/**
|
|
6
|
-
*
|
|
12
|
+
* List of line item details.
|
|
7
13
|
*/
|
|
8
14
|
class ReceiptV5LineItem {
|
|
9
15
|
constructor({ prediction }) {
|
|
16
|
+
_ReceiptV5LineItem_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 = [];
|
|
10
24
|
this.description = prediction["description"];
|
|
11
25
|
this.quantity = +parseFloat(prediction["quantity"]).toFixed(3);
|
|
12
26
|
if (isNaN(this.quantity)) {
|
|
@@ -20,21 +34,48 @@ class ReceiptV5LineItem {
|
|
|
20
34
|
if (isNaN(this.unitPrice)) {
|
|
21
35
|
this.unitPrice = null;
|
|
22
36
|
}
|
|
37
|
+
this.pageId = prediction["page_id"];
|
|
38
|
+
this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
|
|
39
|
+
if (prediction["polygon"]) {
|
|
40
|
+
this.polygon = prediction.polygon;
|
|
41
|
+
}
|
|
23
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Default string representation.
|
|
45
|
+
*/
|
|
24
46
|
toString() {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
47
|
+
const printable = __classPrivateFieldGet(this, _ReceiptV5LineItem_instances, "m", _ReceiptV5LineItem_printableValues).call(this);
|
|
48
|
+
return ("Description: " +
|
|
49
|
+
printable.description +
|
|
50
|
+
"Quantity: " +
|
|
51
|
+
printable.quantity +
|
|
52
|
+
"Total Amount: " +
|
|
53
|
+
printable.totalAmount +
|
|
54
|
+
"Unit Price: " +
|
|
55
|
+
printable.unitPrice).trim();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Output in a format suitable for inclusion in an rST table.
|
|
59
|
+
*/
|
|
60
|
+
toTableLine() {
|
|
61
|
+
const printable = __classPrivateFieldGet(this, _ReceiptV5LineItem_instances, "m", _ReceiptV5LineItem_printableValues).call(this);
|
|
29
62
|
return ("| " +
|
|
30
|
-
description.padEnd(36) +
|
|
63
|
+
printable.description.padEnd(36) +
|
|
31
64
|
" | " +
|
|
32
|
-
quantity.padEnd(8) +
|
|
65
|
+
printable.quantity.padEnd(8) +
|
|
33
66
|
" | " +
|
|
34
|
-
totalAmount.padEnd(12) +
|
|
67
|
+
printable.totalAmount.padEnd(12) +
|
|
35
68
|
" | " +
|
|
36
|
-
unitPrice.padEnd(10) +
|
|
69
|
+
printable.unitPrice.padEnd(10) +
|
|
37
70
|
" |");
|
|
38
71
|
}
|
|
39
72
|
}
|
|
40
73
|
exports.ReceiptV5LineItem = ReceiptV5LineItem;
|
|
74
|
+
_ReceiptV5LineItem_instances = new WeakSet(), _ReceiptV5LineItem_printableValues = function _ReceiptV5LineItem_printableValues() {
|
|
75
|
+
return {
|
|
76
|
+
description: this.description ?? "",
|
|
77
|
+
quantity: this.quantity !== null ? (0, amount_1.floatToString)(this.quantity) : "",
|
|
78
|
+
totalAmount: this.totalAmount !== null ? (0, amount_1.floatToString)(this.totalAmount) : "",
|
|
79
|
+
unitPrice: this.unitPrice !== null ? (0, amount_1.floatToString)(this.unitPrice) : "",
|
|
80
|
+
};
|
|
81
|
+
};
|
package/src/fields/amount.d.ts
CHANGED
package/src/fields/amount.js
CHANGED
package/src/fields/base.d.ts
CHANGED
package/src/fields/base.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClassificationField = void 0;
|
|
4
4
|
const base_1 = require("./base");
|
|
5
|
+
/**
|
|
6
|
+
* Represents a classifier value.
|
|
7
|
+
*/
|
|
5
8
|
class ClassificationField extends base_1.BaseField {
|
|
6
9
|
constructor({ prediction, valueKey = "value", reconstructed = false, }) {
|
|
7
10
|
super({ prediction, valueKey, reconstructed });
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CompanyRegistration = void 0;
|
|
4
4
|
const field_1 = require("./field");
|
|
5
|
+
/**
|
|
6
|
+
* A company registration item.
|
|
7
|
+
*/
|
|
5
8
|
class CompanyRegistration extends field_1.Field {
|
|
6
9
|
constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
|
|
7
10
|
super({ prediction, valueKey, reconstructed, pageId });
|
package/src/fields/date.d.ts
CHANGED
package/src/fields/date.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DateField = void 0;
|
|
4
4
|
const field_1 = require("./field");
|
|
5
|
+
/**
|
|
6
|
+
* A field containing a date value.
|
|
7
|
+
*/
|
|
5
8
|
class DateField extends field_1.Field {
|
|
6
9
|
/**
|
|
7
10
|
* @param {Object} prediction - Prediction object from HTTP response
|