mindee 3.4.1 → 3.5.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v3.5.0 - 2023-01-17
4
+ ### Changes
5
+ * :memo: updates to class documentation
6
+ * :sparkles: Add invoice splitter support (beta)
7
+
8
+ ### Fixes
9
+ * :bug: fix for CLI command option description
10
+
3
11
  ## v3.4.1 - 2023-01-05
4
12
  ### Changes
5
13
  * :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.5.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
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 (receipt or invoice)",
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,7 +102,7 @@ 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
  },
@@ -159,7 +167,7 @@ function cli() {
159
167
  }
160
168
  if (name === COMMAND_CUSTOM) {
161
169
  prog.requiredOption("-u, --user <username>", "API account name for the endpoint");
162
- prog.option("-v, --version <version>", "API account name for the endpoint");
170
+ prog.option("-v, --version <version>", "Version for the endpoint, use the latest version if not specified.");
163
171
  prog.argument("<endpoint_name>", "API endpoint name");
164
172
  }
165
173
  prog.argument("<input_path>", "Full path to the file");
package/src/client.js CHANGED
@@ -86,6 +86,9 @@ class Client {
86
86
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.InvoiceV4.name], new documentConfig_1.DocumentConfig(documents_1.InvoiceV4, [
87
87
  new api_1.StandardEndpoint("invoices", "4", this.apiKey),
88
88
  ]));
89
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.InvoiceSplitterV1.name], new documentConfig_1.DocumentConfig(documents_1.InvoiceSplitterV1, [
90
+ new api_1.StandardEndpoint("invoice_splitter_beta", "1", this.apiKey),
91
+ ]));
89
92
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ReceiptV3.name], new documentConfig_1.DocumentConfig(documents_1.ReceiptV3, [
90
93
  new api_1.StandardEndpoint("expense_receipts", "3", this.apiKey),
91
94
  ]));
@@ -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,
@@ -1,11 +1,12 @@
1
1
  import { Document, DocumentConstructorProps } from "../../document";
2
2
  import { TextField } from "../../../fields";
3
+ /** French bank account information (RIB) */
3
4
  export declare class BankAccountDetailsV1 extends Document {
4
- /** The IBAN number. */
5
+ /** The account's IBAN. */
5
6
  iban: TextField;
6
- /** The account holder name. */
7
+ /** The account holder's name. */
7
8
  accountHolderName: TextField;
8
- /** The SWIFT value. */
9
+ /** The bank's SWIFT code. */
9
10
  swift: TextField;
10
11
  constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
11
12
  toString(): string;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BankAccountDetailsV1 = void 0;
4
4
  const document_1 = require("../../document");
5
5
  const fields_1 = require("../../../fields");
6
+ /** French bank account information (RIB) */
6
7
  class BankAccountDetailsV1 extends document_1.Document {
7
8
  constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
8
9
  super({
@@ -1,12 +1,12 @@
1
1
  import { Document, DocumentConstructorProps } from "../../document";
2
2
  import { TextField, DateField } from "../../../fields";
3
3
  export declare class CarteVitaleV1 extends Document {
4
- /** The list of the names of the person. */
4
+ /** List of given (first) names of the cardholder. */
5
5
  givenNames: TextField[];
6
6
  /** The surname of the person. */
7
7
  surname: TextField;
8
- /** The ID number of the card. */
9
- idNumber: TextField;
8
+ /** The social security number of the cardholder. */
9
+ socialSecurity: TextField;
10
10
  /** The issuance date of the card. */
11
11
  issuanceDate: DateField;
12
12
  constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
@@ -11,9 +11,9 @@ class CarteVitaleV1 extends document_1.Document {
11
11
  orientation: orientation,
12
12
  extras: extras,
13
13
  });
14
- /** The list of the names of the person. */
14
+ /** List of given (first) names of the cardholder. */
15
15
  this.givenNames = [];
16
- this.idNumber = new fields_1.TextField({
16
+ this.socialSecurity = new fields_1.TextField({
17
17
  prediction: prediction.social_security,
18
18
  pageId: pageId,
19
19
  });
@@ -35,7 +35,7 @@ class CarteVitaleV1 extends document_1.Document {
35
35
  Filename: ${this.filename}
36
36
  Given names: ${this.givenNames.map((name) => name.value).join(" ")}
37
37
  Surname: ${this.surname}
38
- ID Number: ${this.idNumber}
38
+ Social Security Number: ${this.socialSecurity}
39
39
  Issuance date: ${this.issuanceDate}
40
40
  ----------------------
41
41
  `;
@@ -3,7 +3,7 @@ import { TextField, DateField, BaseField } from "../../../fields";
3
3
  export declare class IdCardV1 extends Document {
4
4
  /** The authority which has issued the card. */
5
5
  authority: TextField;
6
- /** Indicates if it is the recto, the verso or the both of it. */
6
+ /** Indicates if it is the recto side, the verso side or both. */
7
7
  documentSide: BaseField;
8
8
  /** The id number of the card. */
9
9
  idNumber: TextField;
@@ -1,5 +1,6 @@
1
1
  export { InvoiceV3 } from "./invoice/invoiceV3";
2
2
  export { InvoiceV4 } from "./invoice/invoiceV4";
3
+ export { InvoiceSplitterV1, PageGroup, } from "./invoiceSplitter/invoiceSplitterV1";
3
4
  export { ReceiptV3 } from "./receipt/receiptV3";
4
5
  export { ReceiptV4 } from "./receipt/receiptV4";
5
6
  export { PassportV1 } from "./passport/passportV1";
@@ -23,11 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.CropperV1 = exports.CustomV1 = exports.FinancialDocumentV1 = exports.PassportV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
26
+ exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.CropperV1 = exports.CustomV1 = exports.FinancialDocumentV1 = exports.PassportV1 = 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");
30
30
  Object.defineProperty(exports, "InvoiceV4", { enumerable: true, get: function () { return invoiceV4_1.InvoiceV4; } });
31
+ var invoiceSplitterV1_1 = require("./invoiceSplitter/invoiceSplitterV1");
32
+ Object.defineProperty(exports, "InvoiceSplitterV1", { enumerable: true, get: function () { return invoiceSplitterV1_1.InvoiceSplitterV1; } });
33
+ Object.defineProperty(exports, "PageGroup", { enumerable: true, get: function () { return invoiceSplitterV1_1.PageGroup; } });
31
34
  var receiptV3_1 = require("./receipt/receiptV3");
32
35
  Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function () { return receiptV3_1.ReceiptV3; } });
33
36
  var receiptV4_1 = require("./receipt/receiptV4");
@@ -0,0 +1,14 @@
1
+ import { Document, DocumentConstructorProps } from "../document";
2
+ export declare class PageGroup {
3
+ pageIndexes: number[];
4
+ constructor(prediction: {
5
+ [index: string]: number[];
6
+ });
7
+ toString(): string;
8
+ }
9
+ export declare class InvoiceSplitterV1 extends Document {
10
+ /** List of page indexes that belong to the same invoice in the PDF. */
11
+ invoicePageGroups: PageGroup[];
12
+ constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
13
+ toString(): string;
14
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvoiceSplitterV1 = exports.PageGroup = void 0;
4
+ const document_1 = require("../document");
5
+ class PageGroup {
6
+ constructor(prediction) {
7
+ this.pageIndexes = [];
8
+ this.pageIndexes = prediction.page_indexes;
9
+ }
10
+ toString() {
11
+ return `page indexes: ${this.pageIndexes.join(", ")}`;
12
+ }
13
+ }
14
+ exports.PageGroup = PageGroup;
15
+ class InvoiceSplitterV1 extends document_1.Document {
16
+ constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
17
+ super({
18
+ inputSource: inputSource,
19
+ pageId: pageId,
20
+ orientation: orientation,
21
+ fullText: fullText,
22
+ extras: extras,
23
+ });
24
+ /** List of page indexes that belong to the same invoice in the PDF. */
25
+ this.invoicePageGroups = [];
26
+ if (prediction.invoice_page_groups !== undefined) {
27
+ prediction.invoice_page_groups.map((prediction) => this.invoicePageGroups.push(new PageGroup(prediction)));
28
+ }
29
+ }
30
+ toString() {
31
+ let invoicePageGroups = "\n";
32
+ if (this.invoicePageGroups.length > 0) {
33
+ invoicePageGroups = "\n ";
34
+ invoicePageGroups += this.invoicePageGroups
35
+ .map((item) => item.toString())
36
+ .join("\n ");
37
+ }
38
+ const outStr = `----- Invoice Splitter V1 -----
39
+ Filename: ${this.filename}
40
+ Invoice Page Groups: ${invoicePageGroups}
41
+ ----------------------
42
+ `;
43
+ return InvoiceSplitterV1.cleanOutString(outStr);
44
+ }
45
+ }
46
+ exports.InvoiceSplitterV1 = InvoiceSplitterV1;
@@ -10,23 +10,23 @@ export declare class PassportV1 extends Document {
10
10
  birthDate: DateField;
11
11
  /** The expiration date of the passport. */
12
12
  expiryDate: DateField;
13
- /** The issuance date.*/
13
+ /** The issuance date of the passport. */
14
14
  issuanceDate: DateField;
15
15
  /** The place of birth of the passport holder. */
16
16
  birthPlace: TextField;
17
17
  /** The sex or gender of the passport holder. */
18
18
  gender: TextField;
19
- /** The surname of the person. */
19
+ /** The surname (last name) of the passport holder. */
20
20
  surname: TextField;
21
- /** The value of the first mrz line. */
21
+ /** The value of the first MRZ line. */
22
22
  mrz1: TextField;
23
- /** The value of the second mrz line. */
23
+ /** The value of the second MRZ line. */
24
24
  mrz2: TextField;
25
25
  /** List of first (given) names of the passport holder. */
26
26
  givenNames: TextField[];
27
27
  /** The full name of the passport holder. */
28
28
  fullName: TextField;
29
- /** All the mrz values combined. */
29
+ /** All the MRZ values combined. */
30
30
  mrz: TextField;
31
31
  constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
32
32
  static convertMRZDateToDatetime(dateString: string): Date;
@@ -6,13 +6,13 @@ export declare class ReceiptV4 extends Document {
6
6
  locale: Locale;
7
7
  /** The purchase date. */
8
8
  date: DateField;
9
- /** The type of purchase. */
9
+ /** The receipt category among predefined classes. */
10
10
  category: TextField;
11
- /** The receipt sub category among predefined classes. */
11
+ /** The receipt sub-category among predefined classes. */
12
12
  subCategory: TextField;
13
- /** The receipt document type provdes the information whether the document is an expense receipt or a credit card receipt. */
13
+ /** Whether the document is an expense receipt or a credit card receipt. */
14
14
  documentType: TextField;
15
- /** Merchant's name as seen on the receipt. */
15
+ /** The name of the supplier or merchant, as seen on the receipt. */
16
16
  supplier: TextField;
17
17
  /** Time as seen on the receipt in HH:MM format. */
18
18
  time: TextField;
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ReceiptV4 = void 0;
10
10
  const document_1 = require("../document");
11
11
  const fields_1 = require("../../fields");
12
- const tax_1 = require("./tax");
13
12
  class ReceiptV4 extends document_1.Document {
14
13
  constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
15
14
  super({
@@ -94,7 +93,7 @@ _ReceiptV4_instances = new WeakSet(), _ReceiptV4_initFromApiPrediction = functio
94
93
  prediction: apiPrediction.time,
95
94
  pageId: pageId,
96
95
  });
97
- apiPrediction.taxes.map((taxPrediction) => this.taxes.push(new tax_1.ReceiptTaxField({
96
+ apiPrediction.taxes.map((taxPrediction) => this.taxes.push(new fields_1.TaxField({
98
97
  prediction: taxPrediction,
99
98
  pageId: pageId,
100
99
  valueKey: "value",
@@ -3,9 +3,9 @@ import { TextField, DateField, PositionField, Amount } from "../../../fields";
3
3
  export declare class BankCheckV1 extends Document {
4
4
  /** Payer's bank account number. */
5
5
  accountNumber: TextField;
6
- /** Total including taxes. */
6
+ /** Amount to be paid. */
7
7
  amount: Amount;
8
- /** Payer's bank account number. */
8
+ /** The check number. */
9
9
  checkNumber: TextField;
10
10
  /** Check's position in the image. */
11
11
  checkPosition: PositionField;
@@ -15,7 +15,7 @@ export declare class BankCheckV1 extends Document {
15
15
  payees: TextField[];
16
16
  /** Payer's bank account routing number. */
17
17
  routingNumber: TextField;
18
- /** Signatures' positions in the image. */
18
+ /** The positions of the signatures on the image. */
19
19
  signaturesPositions: PositionField;
20
20
  constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
21
21
  toString(): string;
@@ -5,6 +5,7 @@ interface TaxConstructor {
5
5
  valueKey?: string;
6
6
  rateKey?: string;
7
7
  codeKey?: string;
8
+ baseKey?: string;
8
9
  reconstructed?: boolean;
9
10
  pageId?: number;
10
11
  }
@@ -15,6 +16,8 @@ export declare class TaxField extends Field {
15
16
  rate?: number;
16
17
  /** The tax code (HST, GST... for Canadian; City Tax, State tax for US, etc..). */
17
18
  code?: string;
19
+ /** The tax base */
20
+ base?: number;
18
21
  /** The document page on which the information was found. */
19
22
  pageId: number;
20
23
  /**
@@ -22,10 +25,11 @@ export declare class TaxField extends Field {
22
25
  * @param {String} valueKey - Key to use in the prediction dict to get the tax value
23
26
  * @param {String} rateKey - Key to use to get the tax rate in the prediction dict
24
27
  * @param {String} codeKey - Key to use to get the tax code in the prediction dict
28
+ * @param {String} baseKey - Key to use to get the base tax in the prediction dict
25
29
  * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
26
30
  * @param {Integer} pageNumber - Page ID for multi-page document
27
31
  */
28
- constructor({ prediction, valueKey, rateKey, codeKey, reconstructed, pageId, }: TaxConstructor);
32
+ constructor({ prediction, valueKey, rateKey, codeKey, baseKey, reconstructed, pageId, }: TaxConstructor);
29
33
  toString(): string;
30
34
  }
31
35
  export {};
package/src/fields/tax.js CHANGED
@@ -9,10 +9,11 @@ class TaxField extends field_1.Field {
9
9
  * @param {String} valueKey - Key to use in the prediction dict to get the tax value
10
10
  * @param {String} rateKey - Key to use to get the tax rate in the prediction dict
11
11
  * @param {String} codeKey - Key to use to get the tax code in the prediction dict
12
+ * @param {String} baseKey - Key to use to get the base tax in the prediction dict
12
13
  * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
13
14
  * @param {Integer} pageNumber - Page ID for multi-page document
14
15
  */
15
- constructor({ prediction, valueKey = "value", rateKey = "rate", codeKey = "code", reconstructed = false, pageId = undefined, }) {
16
+ constructor({ prediction, valueKey = "value", rateKey = "rate", codeKey = "code", baseKey = "base", reconstructed = false, pageId = undefined, }) {
16
17
  super({ prediction, valueKey, reconstructed, pageId });
17
18
  /** The tax amount. */
18
19
  this.value = undefined;
@@ -20,6 +21,8 @@ class TaxField extends field_1.Field {
20
21
  this.rate = undefined;
21
22
  /** The tax code (HST, GST... for Canadian; City Tax, State tax for US, etc..). */
22
23
  this.code = undefined;
24
+ /** The tax base */
25
+ this.base = undefined;
23
26
  this.rate = +parseFloat(prediction[rateKey]);
24
27
  if (isNaN(this.rate))
25
28
  this.rate = undefined;
@@ -32,6 +35,9 @@ class TaxField extends field_1.Field {
32
35
  this.value = undefined;
33
36
  this.confidence = 0.0;
34
37
  }
38
+ this.base = parseFloat(prediction[baseKey]);
39
+ if (isNaN(this.base))
40
+ this.base = undefined;
35
41
  }
36
42
  toString() {
37
43
  let outStr = "";
@@ -44,6 +50,9 @@ class TaxField extends field_1.Field {
44
50
  if (this.code !== undefined) {
45
51
  outStr += ` ${this.code}`;
46
52
  }
53
+ if (this.base !== undefined) {
54
+ outStr += ` ${(0, amount_1.floatToString)(this.base)}`;
55
+ }
47
56
  return outStr.trim();
48
57
  }
49
58
  }
@@ -1,25 +0,0 @@
1
- import { TaxField } from "../../fields";
2
- interface ReceiptTaxConstructor {
3
- prediction: any;
4
- valueKey?: string;
5
- rateKey?: string;
6
- codeKey?: string;
7
- baseKey?: string;
8
- reconstructed?: boolean;
9
- pageId?: number;
10
- }
11
- export declare class ReceiptTaxField extends TaxField {
12
- /** The tax base */
13
- base?: number;
14
- /**
15
- * @param {Object} prediction - Prediction object from HTTP response
16
- * @param {String} valueKey - Key to use in the prediction dict to get the tax value
17
- * @param {String} rateKey - Key to use to get the tax rate in the prediction dict
18
- * @param {String} codeKey - Key to use to get the tax code in the prediction dict
19
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
20
- * @param {Integer} pageNumber - Page ID for multi-page document
21
- */
22
- constructor({ prediction, valueKey, rateKey, codeKey, baseKey, reconstructed, pageId, }: ReceiptTaxConstructor);
23
- toString(): string;
24
- }
25
- export {};
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReceiptTaxField = void 0;
4
- const fields_1 = require("../../fields");
5
- const amount_1 = require("../../fields/amount");
6
- class ReceiptTaxField extends fields_1.TaxField {
7
- /**
8
- * @param {Object} prediction - Prediction object from HTTP response
9
- * @param {String} valueKey - Key to use in the prediction dict to get the tax value
10
- * @param {String} rateKey - Key to use to get the tax rate in the prediction dict
11
- * @param {String} codeKey - Key to use to get the tax code in the prediction dict
12
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
13
- * @param {Integer} pageNumber - Page ID for multi-page document
14
- */
15
- constructor({ prediction, valueKey = "value", rateKey = "rate", codeKey = "code", baseKey = "base", reconstructed = false, pageId = undefined, }) {
16
- super({ prediction, valueKey, rateKey, codeKey, reconstructed, pageId });
17
- /** The tax base */
18
- this.base = undefined;
19
- this.base = parseFloat(prediction[baseKey]);
20
- if (isNaN(this.base))
21
- this.base = undefined;
22
- }
23
- toString() {
24
- let outStr = "";
25
- if (this.value !== undefined) {
26
- outStr += `${(0, amount_1.floatToString)(this.value)}`;
27
- }
28
- if (this.rate !== undefined) {
29
- outStr += ` ${(0, amount_1.floatToString)(this.rate)}%`;
30
- }
31
- if (this.code !== undefined) {
32
- outStr += ` ${this.code}`;
33
- }
34
- if (this.base !== undefined) {
35
- outStr += ` ${this.base}`;
36
- }
37
- return outStr.trim();
38
- }
39
- }
40
- exports.ReceiptTaxField = ReceiptTaxField;