mindee 3.7.4 → 3.9.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 (36) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/package.json +3 -3
  3. package/src/cli.js +1 -1
  4. package/src/client.js +4 -1
  5. package/src/documents/documentConfig.d.ts +1 -1
  6. package/src/documents/documentConfig.js +3 -3
  7. package/src/documents/financialDocument/financialDocumentV1.d.ts +39 -36
  8. package/src/documents/financialDocument/financialDocumentV1.js +124 -108
  9. package/src/documents/financialDocument/financialDocumentV1LineItem.d.ts +40 -0
  10. package/src/documents/financialDocument/financialDocumentV1LineItem.js +107 -0
  11. package/src/documents/index.d.ts +1 -0
  12. package/src/documents/index.js +3 -1
  13. package/src/documents/invoice/invoiceV3.d.ts +2 -2
  14. package/src/documents/invoice/invoiceV3.js +83 -98
  15. package/src/documents/invoice/invoiceV4.d.ts +2 -2
  16. package/src/documents/invoice/invoiceV4.js +21 -34
  17. package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +1 -1
  18. package/src/documents/proofOfAddress/proofOfAddressV1.js +2 -2
  19. package/src/documents/receipt/receiptV3.d.ts +1 -1
  20. package/src/documents/receipt/receiptV3.js +34 -48
  21. package/src/documents/receipt/receiptV4.js +16 -30
  22. package/src/documents/receipt/receiptV5.d.ts +43 -0
  23. package/src/documents/receipt/receiptV5.js +140 -0
  24. package/src/documents/receipt/receiptV5LineItem.d.ts +34 -0
  25. package/src/documents/receipt/receiptV5LineItem.js +81 -0
  26. package/src/documents/us/bankCheck/bankCheckV1.js +0 -1
  27. package/src/fields/amount.js +1 -1
  28. package/src/fields/index.d.ts +1 -1
  29. package/src/fields/index.js +2 -1
  30. package/src/fields/locale.d.ts +1 -1
  31. package/src/fields/locale.js +2 -1
  32. package/src/fields/paymentDetails.d.ts +5 -5
  33. package/src/fields/tax.d.ts +19 -0
  34. package/src/fields/tax.js +82 -14
  35. package/src/index.d.ts +1 -1
  36. package/src/index.js +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v3.9.0 - 2023-06-06
4
+ ### Changes
5
+ * :sparkles: support for financial document v1.1
6
+ * :recycle: change http status code handling for async requests
7
+
8
+ ### Fixes
9
+ * :bug: fix typing in PaymentDetails
10
+ * :bug: locale value should always be set
11
+ * :bug: add missing class properties on new line items
12
+
13
+
14
+ ## v3.8.0 - 2023-05-25
15
+ ### Changes
16
+ * :sparkles: add support for receipt v5
17
+ * :sparkles: print taxes in table layout
18
+
19
+
3
20
  ## v3.7.4 - 2023-04-20
4
21
  ### Changes
5
22
  * :white_check_mark: minor improvements to tests
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "3.7.4",
3
+ "version": "3.9.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
- "typescript": "^5.0.3"
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.ReceiptV4,
75
+ docClass: _1.ReceiptV5,
76
76
  fullText: true,
77
77
  async: false,
78
78
  sync: true,
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.asyncPredict({
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
- asyncPredict(params: {
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 asyncPredict(params) {
22
+ async predictAsync(params) {
23
23
  this.checkApiKeys();
24
24
  await params.inputDoc.init();
25
25
  if (params.pageOptions !== undefined) {
@@ -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 >= 202) {
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 > 302) {
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 { TaxField, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration, BaseField } from "../../fields";
3
- import { InvoiceLineItem } from "../invoice/invoiceLineItem";
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
- /** Locale information. */
8
+ #private;
9
+ /** The locale detected on the document. */
9
10
  locale: Locale;
10
- /** The nature of the document. */
11
- documentType: BaseField;
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 creation date of the invoice or the purchase date. */
15
+ /** The date the purchase was made. */
15
16
  date: DateField;
16
- /** The due date of the invoice. */
17
+ /** The date on which the payment is due. */
17
18
  dueDate: DateField;
18
- /** The supplier name. */
19
- supplierName: TextField;
20
- /** The supplier address. */
21
- supplierAddress: TextField;
22
- /** The payment information. */
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 company registration information. */
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 invoice number. */
27
- invoiceNumber: TextField;
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
- /** 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. */
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 invoiceLineItem_1 = require("../invoice/invoiceLineItem");
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,169 +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
- /** List of Reference numbers including PO number. */
25
+ _FinancialDocumentV1_instances.add(this);
26
+ /** List of Reference numbers, including PO number. */
20
27
  this.referenceNumbers = [];
21
- /** The payment information. */
28
+ /** List of payment details associated to the supplier. */
22
29
  this.supplierPaymentDetails = [];
23
- /** The supplier company registration information. */
30
+ /** List of company registrations associated to the supplier. */
24
31
  this.supplierCompanyRegistrations = [];
25
- /** The company registration information for the customer. */
32
+ /** List of company registrations associated to the customer. */
26
33
  this.customerCompanyRegistrations = [];
27
- /** The list of the taxes. */
28
- this.taxes = [];
29
- /** Line items details. */
34
+ /** List of line item details. */
30
35
  this.lineItems = [];
31
36
  this.locale = new fields_1.Locale({
32
- prediction: prediction.locale,
37
+ prediction: prediction["locale"],
33
38
  valueKey: "language",
34
39
  });
35
- this.documentType = new fields_1.BaseField({
36
- prediction: prediction.document_type,
37
- valueKey: "value",
38
- });
39
- this.referenceNumbers = prediction.reference_numbers.map(function (prediction) {
40
- return new fields_1.TextField({
41
- prediction: prediction,
42
- pageId: pageId,
43
- });
40
+ this.invoiceNumber = new fields_1.TextField({
41
+ prediction: prediction["invoice_number"],
42
+ pageId: pageId,
44
43
  });
45
- this.totalAmount = new fields_1.Amount({
46
- prediction: prediction.total_amount,
47
- valueKey: "value",
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"],
48
50
  pageId: pageId,
49
51
  });
50
- this.totalTax = new fields_1.Amount({
51
- prediction: prediction.total_tax,
52
- valueKey: "value",
52
+ this.dueDate = new fields_1.DateField({
53
+ prediction: prediction["due_date"],
53
54
  pageId: pageId,
54
55
  });
55
56
  this.totalNet = new fields_1.Amount({
56
- prediction: prediction.total_net,
57
- valueKey: "value",
57
+ prediction: prediction["total_net"],
58
58
  pageId: pageId,
59
59
  });
60
- this.date = new fields_1.DateField({
61
- prediction: prediction.date,
62
- pageId,
63
- });
64
- this.dueDate = new fields_1.DateField({
65
- prediction: prediction.due_date,
60
+ this.totalAmount = new fields_1.Amount({
61
+ prediction: prediction["total_amount"],
66
62
  pageId: pageId,
67
63
  });
68
- this.invoiceNumber = new fields_1.TextField({
69
- prediction: prediction.invoice_number,
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,
70
67
  pageId: pageId,
71
- });
68
+ })));
72
69
  this.supplierName = new fields_1.TextField({
73
- prediction: prediction.supplier_name,
70
+ prediction: prediction["supplier_name"],
74
71
  pageId: pageId,
75
72
  });
73
+ prediction["supplier_company_registrations"].map((itemPrediction) => this.supplierCompanyRegistrations.push(new fields_1.CompanyRegistration({
74
+ prediction: itemPrediction,
75
+ pageId: pageId,
76
+ })));
76
77
  this.supplierAddress = new fields_1.TextField({
77
- prediction: prediction.supplier_address,
78
+ prediction: prediction["supplier_address"],
78
79
  pageId: pageId,
79
80
  });
80
- this.supplierCompanyRegistrations =
81
- prediction.supplier_company_registrations.map(function (prediction) {
82
- return new fields_1.CompanyRegistration({
83
- prediction: prediction,
84
- pageId: pageId,
85
- });
86
- });
87
- this.customerName = new fields_1.TextField({
88
- prediction: prediction.customer_name,
81
+ this.supplierPhoneNumber = new fields_1.TextField({
82
+ prediction: prediction["supplier_phone_number"],
89
83
  pageId: pageId,
90
84
  });
91
- this.customerAddress = new fields_1.TextField({
92
- prediction: prediction.customer_address,
85
+ this.customerName = new fields_1.TextField({
86
+ prediction: prediction["customer_name"],
93
87
  pageId: pageId,
94
88
  });
95
- prediction.customer_company_registrations.map((prediction) => this.customerCompanyRegistrations.push(new fields_1.CompanyRegistration({
96
- prediction: prediction,
97
- pageId: pageId,
98
- })));
99
- prediction.supplier_payment_details.map((prediction) => this.supplierPaymentDetails.push(new fields_1.PaymentDetails({
100
- prediction: prediction,
89
+ prediction["customer_company_registrations"].map((itemPrediction) => this.customerCompanyRegistrations.push(new fields_1.CompanyRegistration({
90
+ prediction: itemPrediction,
101
91
  pageId: pageId,
102
92
  })));
103
- prediction.line_items.map((prediction) => this.lineItems.push(new invoiceLineItem_1.InvoiceLineItem({
104
- prediction: prediction,
105
- })));
106
- this.tip = new fields_1.Amount({
107
- prediction: prediction.tip,
108
- valueKey: "value",
93
+ this.customerAddress = new fields_1.TextField({
94
+ prediction: prediction["customer_address"],
109
95
  pageId: pageId,
110
96
  });
111
- this.category = new fields_1.TextField({
112
- prediction: prediction.category,
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"],
113
108
  pageId: pageId,
114
109
  });
115
- this.subCategory = new fields_1.TextField({
116
- prediction: prediction.subcategory,
110
+ this.tip = new fields_1.Amount({
111
+ prediction: prediction["tip"],
117
112
  pageId: pageId,
118
113
  });
119
114
  this.time = new fields_1.TextField({
120
- prediction: prediction.time,
115
+ prediction: prediction["time"],
121
116
  pageId: pageId,
122
117
  });
123
- prediction.taxes.map((taxPrediction) => this.taxes.push(new fields_1.TaxField({
124
- prediction: taxPrediction,
118
+ prediction["line_items"].map((itemPrediction) => this.lineItems.push(new financialDocumentV1LineItem_1.FinancialDocumentV1LineItem({
119
+ prediction: itemPrediction,
125
120
  pageId: pageId,
126
- valueKey: "value",
127
- rateKey: "rate",
128
- codeKey: "code",
129
- baseKey: "base",
130
121
  })));
131
122
  }
132
123
  toString() {
133
- const taxes = this.taxes.map((item) => item.toString()).join("\n ");
134
124
  const referenceNumbers = this.referenceNumbers
135
125
  .map((item) => item.toString())
136
126
  .join(", ");
137
- const paymentDetails = this.supplierPaymentDetails
127
+ const supplierPaymentDetails = this.supplierPaymentDetails
138
128
  .map((item) => item.toString())
139
129
  .join("\n ");
140
- const customerCompanyRegistration = this.customerCompanyRegistrations
130
+ const customerCompanyRegistrations = this.customerCompanyRegistrations
141
131
  .map((item) => item.toString())
142
132
  .join("; ");
143
- const supplierCompanyRegistration = this.supplierCompanyRegistrations
133
+ const supplierCompanyRegistrations = this.supplierCompanyRegistrations
144
134
  .map((item) => item.toString())
145
135
  .join("; ");
146
- let lineItems = "";
147
- if (this.lineItems.length > 0) {
148
- lineItems =
149
- "\n Code | QTY | Price | Amount | Tax (Rate) | Description\n ";
150
- lineItems += this.lineItems.map((item) => item.toString()).join("\n ");
151
- }
152
- const outStr = `----- Financial Document V1 -----
153
- Filename: ${this.filename}
154
- Document type: ${this.documentType}
155
- Category: ${this.category}
156
- Subcategory: ${this.subCategory}
157
- Locale: ${this.locale}
158
- Invoice number: ${this.invoiceNumber}
159
- Reference numbers: ${referenceNumbers}
160
- Date: ${this.date}
161
- Due date: ${this.dueDate}
162
- Time: ${this.time}
163
- Supplier name: ${this.supplierName}
164
- Supplier address: ${this.supplierAddress}
165
- Supplier company registrations: ${supplierCompanyRegistration}
166
- Supplier payment details: ${paymentDetails}
167
- Customer name: ${this.customerName}
168
- Customer address: ${this.customerAddress}
169
- Customer company registrations: ${customerCompanyRegistration}
170
- Tip: ${this.tip}
171
- Taxes: ${taxes}
172
- Total tax: ${this.totalTax}
173
- Total net: ${this.totalNet}
174
- Total amount: ${this.totalAmount}
175
- Line Items: ${lineItems}
176
- ----------------------
136
+ const outStr = `Financial Document V1 Prediction
137
+ ================================
138
+ :Filename: ${this.filename}
139
+ :Locale: ${this.locale}
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}
148
+ :Supplier name: ${this.supplierName}
149
+ :Supplier Company Registrations: ${customerCompanyRegistrations}
150
+ :Supplier Address: ${this.supplierAddress}
151
+ :Supplier Phone Number: ${this.supplierPhoneNumber}
152
+ :Customer name: ${this.customerName}
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)}
177
162
  `;
178
163
  return FinancialDocumentV1.cleanOutString(outStr);
179
164
  }
180
165
  }
181
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
+ }