mindee 3.4.1 → 3.6.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/package.json +3 -3
  3. package/src/cli.js +27 -11
  4. package/src/client.js +13 -1
  5. package/src/documents/documentConfig.d.ts +2 -2
  6. package/src/documents/documentConfig.js +4 -4
  7. package/src/documents/eu/licensePlate/licensePlateV1.d.ts +1 -1
  8. package/src/documents/eu/licensePlate/licensePlateV1.js +1 -1
  9. package/src/documents/financialDocument/financialDocumentV0.d.ts +28 -0
  10. package/src/documents/financialDocument/financialDocumentV0.js +140 -0
  11. package/src/documents/financialDocument/financialDocumentV1.d.ts +44 -15
  12. package/src/documents/financialDocument/financialDocumentV1.js +154 -110
  13. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +4 -3
  14. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +1 -0
  15. package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +3 -3
  16. package/src/documents/fr/carteVitale/carteVitaleV1.js +3 -3
  17. package/src/documents/fr/idCard/idCardV1.d.ts +1 -1
  18. package/src/documents/index.d.ts +4 -0
  19. package/src/documents/index.js +10 -1
  20. package/src/documents/invoice/invoiceV4.d.ts +1 -0
  21. package/src/documents/invoice/invoiceV4.js +85 -86
  22. package/src/documents/invoiceSplitter/invoiceSplitterV1.d.ts +14 -0
  23. package/src/documents/invoiceSplitter/invoiceSplitterV1.js +46 -0
  24. package/src/documents/mindeeVision/mindeeVisionV1.d.ts +8 -0
  25. package/src/documents/mindeeVision/mindeeVisionV1.js +29 -0
  26. package/src/documents/passport/passportV1.d.ts +5 -5
  27. package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +24 -0
  28. package/src/documents/proofOfAddress/proofOfAddressV1.js +78 -0
  29. package/src/documents/receipt/receiptV4.d.ts +4 -5
  30. package/src/documents/receipt/receiptV4.js +55 -66
  31. package/src/documents/us/bankCheck/bankCheckV1.d.ts +3 -3
  32. package/src/fields/tax.d.ts +5 -1
  33. package/src/fields/tax.js +10 -1
  34. package/src/index.d.ts +1 -1
  35. package/src/index.js +2 -1
  36. package/src/documents/receipt/tax.d.ts +0 -25
  37. package/src/documents/receipt/tax.js +0 -40
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v3.6.0 - 2023-02-01
4
+ ### Changes
5
+ * :sparkles: Add support for the mindee_vision API (for internal testing)
6
+ * :sparkles: support Proof of Address V1
7
+ * :sparkles: Add support for: financial document v1
8
+ * :arrow_up: update jsdoc
9
+
10
+ ### ¡Warning!
11
+ The `FinancialDocumentV1` class now uses an actual API call to the new route `financial_document`.
12
+ Previously, determining whether a document is an invoice or a receipt was done internally by this library.
13
+
14
+ The API call way is **much** better, however some fields have been renamed compared to the internal handling.
15
+ This was done so field names now match exactly `Invoice` and `Receipt` classes.
16
+
17
+ As such, we encourage users to migrate to the new field structure.
18
+
19
+ If this is problematic, it's possible to use the deprecated way.
20
+ Simply pass `FinancialDocumentV0` to the `parse` method.
21
+ Usage is otherwise identical.
22
+
23
+ ## v3.5.0 - 2023-01-17
24
+ ### Changes
25
+ * :memo: updates to class documentation
26
+ * :sparkles: Add invoice splitter support (beta)
27
+
28
+ ### Fixes
29
+ * :bug: fix for CLI command option description
30
+
3
31
  ## v3.4.1 - 2023-01-05
4
32
  ### Changes
5
33
  * :label: Added typing information, get rid of `any` type in various places
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "3.4.1",
3
+ "version": "3.6.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
@@ -12,7 +12,7 @@
12
12
  "test": "mocha 'tests/**/*.spec.ts'",
13
13
  "lint-fix": "eslint '**/*.ts' --fix",
14
14
  "lint": "eslint '**/*.ts' --report-unused-disable-directives && echo 'Your .ts files look good.'",
15
- "docs": "jsdoc -r src -d docs"
15
+ "docs": "jsdoc -r dist/src -d docs"
16
16
  },
17
17
  "files": [
18
18
  "src/*",
@@ -47,7 +47,7 @@
47
47
  "eslint": "^8.31.0",
48
48
  "eslint-config-prettier": "^8.6.0",
49
49
  "eslint-plugin-prettier": "^4.2.1",
50
- "jsdoc": "^3.6.11",
50
+ "jsdoc": "~4.0",
51
51
  "mocha": "^10.1.0",
52
52
  "prettier": "^2.8.1",
53
53
  "ts-node": "^10.9.1",
package/src/cli.js CHANGED
@@ -22,15 +22,23 @@ const CLI_COMMAND_CONFIG = new Map([
22
22
  [
23
23
  "invoice",
24
24
  {
25
- description: "Invoice V4",
25
+ description: "Invoice",
26
26
  docClass: documents_1.InvoiceV4,
27
27
  fullText: true,
28
28
  },
29
29
  ],
30
+ [
31
+ "invoice-splitter",
32
+ {
33
+ description: "Invoice Splitter",
34
+ docClass: documents_1.InvoiceSplitterV1,
35
+ fullText: false,
36
+ },
37
+ ],
30
38
  [
31
39
  "receipt",
32
40
  {
33
- description: "Expense Receipt V4",
41
+ description: "Expense Receipt",
34
42
  docClass: documents_1.ReceiptV4,
35
43
  fullText: true,
36
44
  },
@@ -38,7 +46,7 @@ const CLI_COMMAND_CONFIG = new Map([
38
46
  [
39
47
  "passport",
40
48
  {
41
- description: "Passport V1",
49
+ description: "Passport",
42
50
  docClass: documents_1.PassportV1,
43
51
  fullText: false,
44
52
  },
@@ -46,7 +54,7 @@ const CLI_COMMAND_CONFIG = new Map([
46
54
  [
47
55
  "financial",
48
56
  {
49
- description: "Financial Document V1 (receipt or invoice)",
57
+ description: "Financial Document",
50
58
  docClass: documents_1.FinancialDocumentV1,
51
59
  fullText: true,
52
60
  },
@@ -54,7 +62,7 @@ const CLI_COMMAND_CONFIG = new Map([
54
62
  [
55
63
  "fr-id-card",
56
64
  {
57
- description: "FR ID Card V1",
65
+ description: "FR ID Card",
58
66
  docClass: documents_1.fr.IdCardV1,
59
67
  fullText: false,
60
68
  },
@@ -62,7 +70,7 @@ const CLI_COMMAND_CONFIG = new Map([
62
70
  [
63
71
  "fr-bank-account-details",
64
72
  {
65
- description: "FR Bank Account Details V1",
73
+ description: "FR Bank Account Details",
66
74
  docClass: documents_1.fr.BankAccountDetailsV1,
67
75
  fullText: false,
68
76
  },
@@ -70,7 +78,7 @@ const CLI_COMMAND_CONFIG = new Map([
70
78
  [
71
79
  "fr-carte-vitale",
72
80
  {
73
- description: "FR Carte Vitale V1",
81
+ description: "FR Carte Vitale",
74
82
  docClass: documents_1.fr.CarteVitaleV1,
75
83
  fullText: false,
76
84
  },
@@ -78,7 +86,7 @@ const CLI_COMMAND_CONFIG = new Map([
78
86
  [
79
87
  "eu-license-plate",
80
88
  {
81
- description: "EU License Plate V1",
89
+ description: "EU License Plate",
82
90
  docClass: documents_1.eu.LicensePlateV1,
83
91
  fullText: false,
84
92
  },
@@ -86,7 +94,7 @@ const CLI_COMMAND_CONFIG = new Map([
86
94
  [
87
95
  "us-bank-check",
88
96
  {
89
- description: "US Bank Check V1",
97
+ description: "US Bank Check",
90
98
  docClass: documents_1.us.BankCheckV1,
91
99
  fullText: false,
92
100
  },
@@ -94,11 +102,19 @@ const CLI_COMMAND_CONFIG = new Map([
94
102
  [
95
103
  "shipping-container",
96
104
  {
97
- description: "Shipping container V1",
105
+ description: "Shipping Container",
98
106
  docClass: documents_1.ShippingContainerV1,
99
107
  fullText: false,
100
108
  },
101
109
  ],
110
+ [
111
+ "mvision",
112
+ {
113
+ description: "Mindee Vision",
114
+ docClass: documents_1.MindeeVisionV1,
115
+ fullText: false,
116
+ },
117
+ ],
102
118
  ]);
103
119
  async function predictCall(command, inputPath, options) {
104
120
  const conf = CLI_COMMAND_CONFIG.get(command);
@@ -159,7 +175,7 @@ function cli() {
159
175
  }
160
176
  if (name === COMMAND_CUSTOM) {
161
177
  prog.requiredOption("-u, --user <username>", "API account name for the endpoint");
162
- prog.option("-v, --version <version>", "API account name for the endpoint");
178
+ prog.option("-v, --version <version>", "Version for the endpoint, use the latest version if not specified.");
163
179
  prog.argument("<endpoint_name>", "API endpoint name");
164
180
  }
165
181
  prog.argument("<input_path>", "Full path to the file");
package/src/client.js CHANGED
@@ -79,13 +79,19 @@ class Client {
79
79
  }
80
80
  // TODO: init only those endpoints we actually need.
81
81
  addStandardEndpoints() {
82
- this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.FinancialDocumentV1.name], new documentConfig_1.FinancialDocV1Config(this.apiKey));
82
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.FinancialDocumentV0.name], new documentConfig_1.FinancialDocV0Config(this.apiKey));
83
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.FinancialDocumentV1.name], new documentConfig_1.DocumentConfig(documents_1.FinancialDocumentV1, [
84
+ new api_1.StandardEndpoint("financial_document", "1", this.apiKey),
85
+ ]));
83
86
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.InvoiceV3.name], new documentConfig_1.DocumentConfig(documents_1.InvoiceV3, [
84
87
  new api_1.StandardEndpoint("invoices", "3", this.apiKey),
85
88
  ]));
86
89
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.InvoiceV4.name], new documentConfig_1.DocumentConfig(documents_1.InvoiceV4, [
87
90
  new api_1.StandardEndpoint("invoices", "4", this.apiKey),
88
91
  ]));
92
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.InvoiceSplitterV1.name], new documentConfig_1.DocumentConfig(documents_1.InvoiceSplitterV1, [
93
+ new api_1.StandardEndpoint("invoice_splitter_beta", "1", this.apiKey),
94
+ ]));
89
95
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ReceiptV3.name], new documentConfig_1.DocumentConfig(documents_1.ReceiptV3, [
90
96
  new api_1.StandardEndpoint("expense_receipts", "3", this.apiKey),
91
97
  ]));
@@ -116,6 +122,12 @@ class Client {
116
122
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ShippingContainerV1.name], new documentConfig_1.DocumentConfig(documents_1.ShippingContainerV1, [
117
123
  new api_1.StandardEndpoint("shipping_containers", "1", this.apiKey),
118
124
  ]));
125
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.MindeeVisionV1.name], new documentConfig_1.DocumentConfig(documents_1.MindeeVisionV1, [
126
+ new api_1.StandardEndpoint("mindee_vision", "1", this.apiKey),
127
+ ]));
128
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ProofOfAddressV1.name], new documentConfig_1.DocumentConfig(documents_1.ProofOfAddressV1, [
129
+ new api_1.StandardEndpoint("proof_of_address", "1", this.apiKey),
130
+ ]));
119
131
  }
120
132
  /**
121
133
  * Add a custom endpoint to the client.
@@ -1,6 +1,6 @@
1
1
  import { InputSource } from "../inputs";
2
2
  import { Response, Endpoint, predictResponse } from "../api";
3
- import { Document, FinancialDocumentV1, CustomV1, DocumentSig } from "./index";
3
+ import { Document, FinancialDocumentV0, CustomV1, DocumentSig } from "./index";
4
4
  import { PageOptions } from "../inputs";
5
5
  interface CustomDocConstructor {
6
6
  endpointName: string;
@@ -27,7 +27,7 @@ export declare class DocumentConfig<DocType extends Document> {
27
27
  export declare class CustomDocConfig extends DocumentConfig<CustomV1> {
28
28
  constructor({ endpointName, accountName, version, apiKey, }: CustomDocConstructor);
29
29
  }
30
- export declare class FinancialDocV1Config extends DocumentConfig<FinancialDocumentV1> {
30
+ export declare class FinancialDocV0Config extends DocumentConfig<FinancialDocumentV0> {
31
31
  constructor(apiKey: string);
32
32
  protected predictRequest(inputDoc: InputSource, includeWords: boolean, cropping: boolean): Promise<predictResponse>;
33
33
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FinancialDocV1Config = exports.CustomDocConfig = exports.DocumentConfig = void 0;
3
+ exports.FinancialDocV0Config = exports.CustomDocConfig = exports.DocumentConfig = void 0;
4
4
  const api_1 = require("../api");
5
5
  const index_1 = require("./index");
6
6
  const handler_1 = require("../errors/handler");
@@ -65,13 +65,13 @@ class CustomDocConfig extends DocumentConfig {
65
65
  }
66
66
  }
67
67
  exports.CustomDocConfig = CustomDocConfig;
68
- class FinancialDocV1Config extends DocumentConfig {
68
+ class FinancialDocV0Config extends DocumentConfig {
69
69
  constructor(apiKey) {
70
70
  const endpoints = [
71
71
  new api_1.StandardEndpoint("invoices", "3", apiKey),
72
72
  new api_1.StandardEndpoint("expense_receipts", "3", apiKey),
73
73
  ];
74
- super(index_1.FinancialDocumentV1, endpoints);
74
+ super(index_1.FinancialDocumentV0, endpoints);
75
75
  }
76
76
  async predictRequest(inputDoc, includeWords, cropping) {
77
77
  let endpoint;
@@ -84,4 +84,4 @@ class FinancialDocV1Config extends DocumentConfig {
84
84
  return await endpoint.predictReqPost(inputDoc, includeWords, cropping);
85
85
  }
86
86
  }
87
- exports.FinancialDocV1Config = FinancialDocV1Config;
87
+ exports.FinancialDocV0Config = FinancialDocV0Config;
@@ -1,7 +1,7 @@
1
1
  import { Document, DocumentConstructorProps } from "../../document";
2
2
  import { TextField } from "../../../fields";
3
3
  export declare class LicensePlateV1 extends Document {
4
- /** A list of license plates values. */
4
+ /** A list of license plates. */
5
5
  licensePlates: TextField[];
6
6
  constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
7
7
  toString(): string;
@@ -11,7 +11,7 @@ class LicensePlateV1 extends document_1.Document {
11
11
  orientation: orientation,
12
12
  extras: extras,
13
13
  });
14
- /** A list of license plates values. */
14
+ /** A list of license plates. */
15
15
  this.licensePlates = [];
16
16
  prediction.license_plates.map((prediction) => this.licensePlates.push(new fields_1.TextField({
17
17
  prediction: prediction,
@@ -0,0 +1,28 @@
1
+ import { Document, DocumentConstructorProps } from "../document";
2
+ import { TaxField, TextField, Amount, Locale, DateField as Date, CompanyRegistration } from "../../fields";
3
+ /**
4
+ * @deprecated You should use FinancialDocumentV1 instead.
5
+ */
6
+ export declare class FinancialDocumentV0 extends Document {
7
+ #private;
8
+ pageId: number | undefined;
9
+ locale: Locale;
10
+ totalIncl: Amount;
11
+ date: Date;
12
+ dueDate: Date;
13
+ category: TextField;
14
+ time: TextField;
15
+ taxes: TaxField[];
16
+ totalTax: Amount;
17
+ totalExcl: Amount;
18
+ supplier: TextField;
19
+ supplierAddress: TextField;
20
+ invoiceNumber: TextField;
21
+ companyRegistration: CompanyRegistration[];
22
+ customerName: TextField;
23
+ customerAddress: TextField;
24
+ paymentDetails: TextField[];
25
+ customerCompanyRegistration: CompanyRegistration[];
26
+ constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
27
+ toString(): string;
28
+ }
@@ -0,0 +1,140 @@
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 _FinancialDocumentV0_instances, _FinancialDocumentV0_initFromApiPrediction, _FinancialDocumentV0_checklist, _FinancialDocumentV0_taxesMatchTotalIncl;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.FinancialDocumentV0 = void 0;
10
+ const document_1 = require("../document");
11
+ const invoiceV3_1 = require("../invoice/invoiceV3");
12
+ const receiptV3_1 = require("../receipt/receiptV3");
13
+ const fields_1 = require("../../fields");
14
+ /**
15
+ * @deprecated You should use FinancialDocumentV1 instead.
16
+ */
17
+ class FinancialDocumentV0 extends document_1.Document {
18
+ constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
19
+ super({
20
+ inputSource: inputSource,
21
+ pageId: pageId,
22
+ orientation: orientation,
23
+ fullText: fullText,
24
+ extras: extras,
25
+ });
26
+ _FinancialDocumentV0_instances.add(this);
27
+ this.taxes = [];
28
+ this.companyRegistration = [];
29
+ this.paymentDetails = [];
30
+ this.customerCompanyRegistration = [];
31
+ __classPrivateFieldGet(this, _FinancialDocumentV0_instances, "m", _FinancialDocumentV0_initFromApiPrediction).call(this, prediction, inputSource, pageId, orientation, extras);
32
+ __classPrivateFieldGet(this, _FinancialDocumentV0_instances, "m", _FinancialDocumentV0_checklist).call(this);
33
+ }
34
+ toString() {
35
+ const outStr = `-----Financial document-----
36
+ Filename: ${this.filename}
37
+ Total amount: ${this.totalIncl.value}
38
+ Date: ${this.date.value}
39
+ Supplier: ${this.supplier.value}
40
+ Total taxes: ${this.totalTax.value}
41
+ ----------------------
42
+ `;
43
+ return FinancialDocumentV0.cleanOutString(outStr);
44
+ }
45
+ }
46
+ exports.FinancialDocumentV0 = FinancialDocumentV0;
47
+ _FinancialDocumentV0_instances = new WeakSet(), _FinancialDocumentV0_initFromApiPrediction = function _FinancialDocumentV0_initFromApiPrediction(prediction, inputFile, pageNumber, orientation, extras) {
48
+ if (Object.keys(prediction).includes("invoice_number")) {
49
+ const invoice = new invoiceV3_1.InvoiceV3({
50
+ prediction: prediction,
51
+ inputSource: inputFile,
52
+ pageId: pageNumber,
53
+ orientation: orientation,
54
+ extras: extras,
55
+ });
56
+ this.locale = invoice.locale;
57
+ this.totalIncl = invoice.totalIncl;
58
+ this.totalExcl = invoice.totalExcl;
59
+ this.date = invoice.date;
60
+ this.invoiceNumber = invoice.invoiceNumber;
61
+ this.dueDate = invoice.dueDate;
62
+ this.taxes = invoice.taxes;
63
+ this.supplier = invoice.supplier;
64
+ this.supplierAddress = invoice.supplierAddress;
65
+ this.paymentDetails = invoice.paymentDetails;
66
+ this.companyRegistration = invoice.customerCompanyRegistration;
67
+ this.orientation = invoice.orientation;
68
+ this.totalTax = invoice.totalTax;
69
+ this.time = new fields_1.TextField({
70
+ prediction: { value: undefined, confidence: 0.0 },
71
+ });
72
+ this.customerName = invoice.customerName;
73
+ this.customerAddress = invoice.customerAddress;
74
+ this.customerCompanyRegistration = invoice.customerCompanyRegistration;
75
+ }
76
+ else {
77
+ const receipt = new receiptV3_1.ReceiptV3({
78
+ prediction: prediction,
79
+ inputSource: inputFile,
80
+ pageId: pageNumber,
81
+ orientation: orientation,
82
+ extras: extras,
83
+ });
84
+ this.orientation = receipt.orientation;
85
+ this.date = receipt.date;
86
+ this.dueDate = receipt.date;
87
+ this.taxes = receipt.taxes;
88
+ this.locale = receipt.locale;
89
+ this.totalIncl = receipt.totalIncl;
90
+ this.totalExcl = receipt.totalExcl;
91
+ this.supplier = receipt.merchantName;
92
+ this.supplierAddress = new fields_1.TextField({
93
+ prediction: { value: undefined, confidence: 0.0 },
94
+ });
95
+ this.time = receipt.time;
96
+ this.totalTax = receipt.totalTax;
97
+ this.invoiceNumber = new fields_1.TextField({
98
+ prediction: { value: undefined, confidence: 0.0 },
99
+ });
100
+ this.customerName = new fields_1.TextField({
101
+ prediction: { value: undefined, confidence: 0.0 },
102
+ });
103
+ this.customerAddress = new fields_1.TextField({
104
+ prediction: { value: undefined, confidence: 0.0 },
105
+ });
106
+ }
107
+ }, _FinancialDocumentV0_checklist = function _FinancialDocumentV0_checklist() {
108
+ this.checklist = {
109
+ taxesMatchTotalIncl: __classPrivateFieldGet(this, _FinancialDocumentV0_instances, "m", _FinancialDocumentV0_taxesMatchTotalIncl).call(this),
110
+ };
111
+ }, _FinancialDocumentV0_taxesMatchTotalIncl = function _FinancialDocumentV0_taxesMatchTotalIncl() {
112
+ // Check taxes and total include exist
113
+ if (this.taxes.length === 0 || this.totalIncl.value === undefined)
114
+ return false;
115
+ // Reconstruct totalIncl from taxes
116
+ let totalVat = 0;
117
+ let reconstructedTotal = 0;
118
+ this.taxes.forEach((tax) => {
119
+ if (tax.value === undefined || !tax.rate)
120
+ return false;
121
+ totalVat += tax.value;
122
+ reconstructedTotal += tax.value + (100 * tax.value) / tax.rate;
123
+ });
124
+ // Sanity check
125
+ if (totalVat <= 0)
126
+ return false;
127
+ // Crate epsilon
128
+ const eps = 1 / (100 * totalVat);
129
+ if (this.totalIncl.value * (1 - eps) - 0.02 <= reconstructedTotal &&
130
+ reconstructedTotal <= this.totalIncl.value * (1 + eps) + 0.02) {
131
+ this.taxes = this.taxes.map((tax) => ({
132
+ ...tax,
133
+ confidence: 1.0,
134
+ }));
135
+ this.totalTax.confidence = 1.0;
136
+ this.totalIncl.confidence = 1.0;
137
+ return true;
138
+ }
139
+ return false;
140
+ };
@@ -1,25 +1,54 @@
1
1
  import { Document, DocumentConstructorProps } from "../document";
2
- import { TaxField, TextField, Amount, Locale, DateField as Date, CompanyRegistration } from "../../fields";
2
+ import { TaxField, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration, BaseField } from "../../fields";
3
+ import { InvoiceLineItem } from "../invoice/invoiceLineItem";
4
+ /**
5
+ * Financial Document.
6
+ */
3
7
  export declare class FinancialDocumentV1 extends Document {
4
- #private;
5
- pageId: number | undefined;
8
+ /** Locale information. */
6
9
  locale: Locale;
7
- totalIncl: Amount;
8
- date: Date;
9
- dueDate: Date;
10
- category: TextField;
11
- time: TextField;
12
- taxes: TaxField[];
13
- totalTax: Amount;
14
- totalExcl: Amount;
15
- supplier: TextField;
10
+ /** The nature of the document. */
11
+ documentType: BaseField;
12
+ /** List of Reference numbers including PO number. */
13
+ referenceNumbers: TextField[];
14
+ /** The creation date of the invoice or the purchase date. */
15
+ date: DateField;
16
+ /** The due date of the invoice. */
17
+ dueDate: DateField;
18
+ /** The supplier name. */
19
+ supplierName: TextField;
20
+ /** The supplier address. */
16
21
  supplierAddress: TextField;
22
+ /** The payment information. */
23
+ supplierPaymentDetails: PaymentDetails[];
24
+ /** The supplier company registration information. */
25
+ supplierCompanyRegistrations: CompanyRegistration[];
26
+ /** The invoice number. */
17
27
  invoiceNumber: TextField;
18
- companyRegistration: CompanyRegistration[];
28
+ /** The name of the customer. */
19
29
  customerName: TextField;
30
+ /** The address of the customer. */
20
31
  customerAddress: TextField;
21
- paymentDetails: TextField[];
22
- customerCompanyRegistration: CompanyRegistration[];
32
+ /** The company registration information for the customer. */
33
+ customerCompanyRegistrations: CompanyRegistration[];
34
+ /** The list of the taxes. */
35
+ taxes: TaxField[];
36
+ /** Line items details. */
37
+ lineItems: InvoiceLineItem[];
38
+ /** The receipt category among predefined classes. */
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. */
51
+ totalTax: Amount;
23
52
  constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
24
53
  toString(): string;
25
54
  }