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
@@ -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;
@@ -0,0 +1,8 @@
1
+ import { Document, DocumentConstructorProps } from "../document";
2
+ import { Word } from "../../fields";
3
+ export declare class MindeeVisionV1 extends Document {
4
+ /** List of words found on the page. */
5
+ allWords: Word[];
6
+ constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
7
+ toString(): string;
8
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MindeeVisionV1 = void 0;
4
+ const document_1 = require("../document");
5
+ const fields_1 = require("../../fields");
6
+ class MindeeVisionV1 extends document_1.Document {
7
+ constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
8
+ super({
9
+ inputSource: inputSource,
10
+ pageId: pageId,
11
+ orientation: orientation,
12
+ fullText: fullText,
13
+ extras: extras,
14
+ });
15
+ /** List of words found on the page. */
16
+ this.allWords = [];
17
+ if (prediction.all_words !== undefined) {
18
+ prediction.all_words.map((prediction) => {
19
+ this.allWords.push(prediction);
20
+ });
21
+ }
22
+ }
23
+ toString() {
24
+ const fullText = new fields_1.FullText();
25
+ fullText.words = this.allWords;
26
+ return fullText.toString();
27
+ }
28
+ }
29
+ exports.MindeeVisionV1 = MindeeVisionV1;
@@ -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;
@@ -0,0 +1,24 @@
1
+ import { Document, DocumentConstructorProps } from "../document";
2
+ import { CompanyRegistration, DateField, Locale, TextField } from "../../fields";
3
+ export declare class ProofOfAddressV1 extends Document {
4
+ /** ISO date yyyy-mm-dd. Works both for European and US dates. */
5
+ issuanceDate: DateField;
6
+ /** All extrated ISO date yyyy-mm-dd. Works both for European and US dates. */
7
+ dates: DateField[];
8
+ /** Address of the document's issuer. */
9
+ issuerAddress: TextField;
10
+ /** Generic: VAT NUMBER, TAX ID, COMPANY REGISTRATION NUMBER or country specific. */
11
+ issuerCompanyRegistration: CompanyRegistration[];
12
+ /** Name of the person or company issuing the document. */
13
+ issuerName: TextField;
14
+ /** ISO 639-1 code, works best with ca, de, en, es, fr, it, nl and pt. */
15
+ locale: Locale;
16
+ /** Address of supplier. */
17
+ recipientAddress: TextField;
18
+ /** Generic: VAT NUMBER, TAX ID, COMPANY REGISTRATION NUMBER or country specific. */
19
+ recipientCompanyRegistration: CompanyRegistration[];
20
+ /** Name of the document's recipient. */
21
+ recipientName: TextField;
22
+ constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
23
+ toString(): string;
24
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProofOfAddressV1 = void 0;
4
+ const document_1 = require("../document");
5
+ const fields_1 = require("../../fields");
6
+ class ProofOfAddressV1 extends document_1.Document {
7
+ constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
8
+ super({
9
+ inputSource: inputSource,
10
+ pageId: pageId,
11
+ orientation: orientation,
12
+ extras: extras,
13
+ });
14
+ /** All extrated ISO date yyyy-mm-dd. Works both for European and US dates. */
15
+ this.dates = [];
16
+ /** Generic: VAT NUMBER, TAX ID, COMPANY REGISTRATION NUMBER or country specific. */
17
+ this.issuerCompanyRegistration = [];
18
+ /** Generic: VAT NUMBER, TAX ID, COMPANY REGISTRATION NUMBER or country specific. */
19
+ this.recipientCompanyRegistration = [];
20
+ this.locale = new fields_1.Locale({
21
+ prediction: prediction.locale,
22
+ valueKey: "language",
23
+ });
24
+ this.issuanceDate = new fields_1.DateField({
25
+ prediction: prediction.date,
26
+ pageId: pageId,
27
+ });
28
+ prediction.dates.map((prediction) => this.dates.push(new fields_1.DateField({
29
+ prediction: prediction,
30
+ pageId: pageId,
31
+ })));
32
+ this.issuerAddress = new fields_1.TextField({
33
+ prediction: prediction.issuer_address,
34
+ pageId: pageId,
35
+ });
36
+ prediction.issuer_company_registration.map((prediction) => this.issuerCompanyRegistration.push(new fields_1.CompanyRegistration({
37
+ prediction: prediction,
38
+ pageId: pageId,
39
+ })));
40
+ this.issuerName = new fields_1.TextField({
41
+ prediction: prediction.issuer_name,
42
+ pageId: pageId,
43
+ });
44
+ prediction.recipient_company_registration.map((prediction) => this.recipientCompanyRegistration.push(new fields_1.CompanyRegistration({
45
+ prediction: prediction,
46
+ pageId: pageId,
47
+ })));
48
+ this.recipientAddress = new fields_1.TextField({
49
+ prediction: prediction.recipient_address,
50
+ pageId: pageId,
51
+ });
52
+ this.recipientName = new fields_1.TextField({
53
+ prediction: prediction.recipient_name,
54
+ pageId: pageId,
55
+ });
56
+ }
57
+ toString() {
58
+ const outStr = `----- Proof of Address V1 -----
59
+ Filename: ${this.filename}
60
+ Locale: ${this.locale}
61
+ Issuer name: ${this.issuerName}
62
+ Issuer Address: ${this.issuerAddress}
63
+ Issuer Company Registrations: ${this.issuerCompanyRegistration
64
+ .map((icr) => icr.value)
65
+ .join(", ")}
66
+ Recipient name: ${this.recipientName}
67
+ Recipient Address: ${this.recipientAddress}
68
+ Recipient Company Registrations: ${this.recipientCompanyRegistration
69
+ .map((rcr) => rcr.value)
70
+ .join(", ")}
71
+ Issuance Date: ${this.issuanceDate}
72
+ Dates: ${this.dates.map((rcr) => rcr.value).join("\n ")}
73
+ ----------------------
74
+ `;
75
+ return ProofOfAddressV1.cleanOutString(outStr);
76
+ }
77
+ }
78
+ exports.ProofOfAddressV1 = ProofOfAddressV1;
@@ -1,18 +1,17 @@
1
1
  import { Document, DocumentConstructorProps } from "../document";
2
2
  import { Amount, DateField, TextField, Locale, TaxField } from "../../fields";
3
3
  export declare class ReceiptV4 extends Document {
4
- #private;
5
4
  /** Where the purchase was made, the language, and the currency. */
6
5
  locale: Locale;
7
6
  /** The purchase date. */
8
7
  date: DateField;
9
- /** The type of purchase. */
8
+ /** The receipt category among predefined classes. */
10
9
  category: TextField;
11
- /** The receipt sub category among predefined classes. */
10
+ /** The receipt sub-category among predefined classes. */
12
11
  subCategory: TextField;
13
- /** The receipt document type provdes the information whether the document is an expense receipt or a credit card receipt. */
12
+ /** Whether the document is an expense receipt or a credit card receipt. */
14
13
  documentType: TextField;
15
- /** Merchant's name as seen on the receipt. */
14
+ /** The name of the supplier or merchant, as seen on the receipt. */
16
15
  supplier: TextField;
17
16
  /** Time as seen on the receipt in HH:MM format. */
18
17
  time: TextField;
@@ -1,15 +1,8 @@
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 _ReceiptV4_instances, _ReceiptV4_initFromApiPrediction;
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
3
  exports.ReceiptV4 = void 0;
10
4
  const document_1 = require("../document");
11
5
  const fields_1 = require("../../fields");
12
- const tax_1 = require("./tax");
13
6
  class ReceiptV4 extends document_1.Document {
14
7
  constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
15
8
  super({
@@ -19,10 +12,63 @@ class ReceiptV4 extends document_1.Document {
19
12
  extras: extras,
20
13
  fullText: fullText,
21
14
  });
22
- _ReceiptV4_instances.add(this);
23
15
  /** List of taxes detected on the receipt. */
24
16
  this.taxes = [];
25
- __classPrivateFieldGet(this, _ReceiptV4_instances, "m", _ReceiptV4_initFromApiPrediction).call(this, prediction, pageId);
17
+ this.locale = new fields_1.Locale({
18
+ prediction: prediction.locale,
19
+ });
20
+ this.totalTax = new fields_1.Amount({
21
+ prediction: prediction.total_tax,
22
+ valueKey: "value",
23
+ pageId: pageId,
24
+ });
25
+ this.totalAmount = new fields_1.Amount({
26
+ prediction: prediction.total_amount,
27
+ valueKey: "value",
28
+ pageId: pageId,
29
+ });
30
+ this.totalNet = new fields_1.Amount({
31
+ prediction: prediction.total_net,
32
+ valueKey: "value",
33
+ pageId: pageId,
34
+ });
35
+ this.tip = new fields_1.Amount({
36
+ prediction: prediction.tip,
37
+ valueKey: "value",
38
+ pageId: pageId,
39
+ });
40
+ this.date = new fields_1.DateField({
41
+ prediction: prediction.date,
42
+ pageId: pageId,
43
+ });
44
+ this.category = new fields_1.TextField({
45
+ prediction: prediction.category,
46
+ pageId: pageId,
47
+ });
48
+ this.subCategory = new fields_1.TextField({
49
+ prediction: prediction.subcategory,
50
+ pageId: pageId,
51
+ });
52
+ this.documentType = new fields_1.TextField({
53
+ prediction: prediction.document_type,
54
+ pageId: pageId,
55
+ });
56
+ this.supplier = new fields_1.TextField({
57
+ prediction: prediction.supplier,
58
+ pageId: pageId,
59
+ });
60
+ this.time = new fields_1.TextField({
61
+ prediction: prediction.time,
62
+ pageId: pageId,
63
+ });
64
+ prediction.taxes.map((taxPrediction) => this.taxes.push(new fields_1.TaxField({
65
+ prediction: taxPrediction,
66
+ pageId: pageId,
67
+ valueKey: "value",
68
+ rateKey: "rate",
69
+ codeKey: "code",
70
+ baseKey: "base",
71
+ })));
26
72
  }
27
73
  toString() {
28
74
  const taxes = this.taxes.map((item) => item.toString()).join("\n ");
@@ -46,60 +92,3 @@ Locale: ${this.locale}
46
92
  }
47
93
  }
48
94
  exports.ReceiptV4 = ReceiptV4;
49
- _ReceiptV4_instances = new WeakSet(), _ReceiptV4_initFromApiPrediction = function _ReceiptV4_initFromApiPrediction(apiPrediction, pageId) {
50
- this.locale = new fields_1.Locale({
51
- prediction: apiPrediction.locale,
52
- });
53
- this.totalTax = new fields_1.Amount({
54
- prediction: apiPrediction.total_tax,
55
- valueKey: "value",
56
- pageId: pageId,
57
- });
58
- this.totalAmount = new fields_1.Amount({
59
- prediction: apiPrediction.total_amount,
60
- valueKey: "value",
61
- pageId: pageId,
62
- });
63
- this.totalNet = new fields_1.Amount({
64
- prediction: apiPrediction.total_net,
65
- valueKey: "value",
66
- pageId: pageId,
67
- });
68
- this.tip = new fields_1.Amount({
69
- prediction: apiPrediction.tip,
70
- valueKey: "value",
71
- pageId: pageId,
72
- });
73
- this.date = new fields_1.DateField({
74
- prediction: apiPrediction.date,
75
- pageId: pageId,
76
- });
77
- this.category = new fields_1.TextField({
78
- prediction: apiPrediction.category,
79
- pageId: pageId,
80
- });
81
- this.subCategory = new fields_1.TextField({
82
- prediction: apiPrediction.subcategory,
83
- pageId: pageId,
84
- });
85
- this.documentType = new fields_1.TextField({
86
- prediction: apiPrediction.document_type,
87
- pageId: pageId,
88
- });
89
- this.supplier = new fields_1.TextField({
90
- prediction: apiPrediction.supplier,
91
- pageId: pageId,
92
- });
93
- this.time = new fields_1.TextField({
94
- prediction: apiPrediction.time,
95
- pageId: pageId,
96
- });
97
- apiPrediction.taxes.map((taxPrediction) => this.taxes.push(new tax_1.ReceiptTaxField({
98
- prediction: taxPrediction,
99
- pageId: pageId,
100
- valueKey: "value",
101
- rateKey: "rate",
102
- codeKey: "code",
103
- baseKey: "base",
104
- })));
105
- };
@@ -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
  }
package/src/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { CustomV1, Document, FinancialDocumentV1, InvoiceV3, InvoiceV4, PassportV1, ReceiptV3, ReceiptV4, CropperV1, ShippingContainerV1, fr, us, eu, } from "./documents";
1
+ export { CustomV1, Document, FinancialDocumentV0, FinancialDocumentV1, InvoiceV3, InvoiceV4, PassportV1, ReceiptV3, ReceiptV4, CropperV1, ShippingContainerV1, fr, us, eu, } from "./documents";
2
2
  export { Client, ClientOptions, CustomConfigParams, PredictOptions, } from "./client";
3
3
  export { ResponseSig, Response } from "./api";
4
4
  export { InputSource, PageOptionsOperation } from "./inputs";
package/src/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PageOptionsOperation = exports.InputSource = exports.Response = exports.Client = exports.eu = exports.us = exports.fr = exports.ShippingContainerV1 = exports.CropperV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceV4 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.Document = exports.CustomV1 = void 0;
3
+ exports.PageOptionsOperation = exports.InputSource = exports.Response = exports.Client = exports.eu = exports.us = exports.fr = exports.ShippingContainerV1 = exports.CropperV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceV4 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.Document = exports.CustomV1 = void 0;
4
4
  var documents_1 = require("./documents");
5
5
  Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return documents_1.CustomV1; } });
6
6
  Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return documents_1.Document; } });
7
+ Object.defineProperty(exports, "FinancialDocumentV0", { enumerable: true, get: function () { return documents_1.FinancialDocumentV0; } });
7
8
  Object.defineProperty(exports, "FinancialDocumentV1", { enumerable: true, get: function () { return documents_1.FinancialDocumentV1; } });
8
9
  Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return documents_1.InvoiceV3; } });
9
10
  Object.defineProperty(exports, "InvoiceV4", { enumerable: true, get: function () { return documents_1.InvoiceV4; } });
@@ -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;