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.
- package/CHANGELOG.md +17 -0
- package/package.json +3 -3
- package/src/cli.js +1 -1
- package/src/client.js +4 -1
- package/src/documents/documentConfig.d.ts +1 -1
- package/src/documents/documentConfig.js +3 -3
- package/src/documents/financialDocument/financialDocumentV1.d.ts +39 -36
- package/src/documents/financialDocument/financialDocumentV1.js +124 -108
- package/src/documents/financialDocument/financialDocumentV1LineItem.d.ts +40 -0
- package/src/documents/financialDocument/financialDocumentV1LineItem.js +107 -0
- package/src/documents/index.d.ts +1 -0
- package/src/documents/index.js +3 -1
- package/src/documents/invoice/invoiceV3.d.ts +2 -2
- package/src/documents/invoice/invoiceV3.js +83 -98
- package/src/documents/invoice/invoiceV4.d.ts +2 -2
- package/src/documents/invoice/invoiceV4.js +21 -34
- package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +1 -1
- package/src/documents/proofOfAddress/proofOfAddressV1.js +2 -2
- package/src/documents/receipt/receiptV3.d.ts +1 -1
- package/src/documents/receipt/receiptV3.js +34 -48
- package/src/documents/receipt/receiptV4.js +16 -30
- package/src/documents/receipt/receiptV5.d.ts +43 -0
- package/src/documents/receipt/receiptV5.js +140 -0
- package/src/documents/receipt/receiptV5LineItem.d.ts +34 -0
- package/src/documents/receipt/receiptV5LineItem.js +81 -0
- package/src/documents/us/bankCheck/bankCheckV1.js +0 -1
- package/src/fields/amount.js +1 -1
- package/src/fields/index.d.ts +1 -1
- package/src/fields/index.js +2 -1
- package/src/fields/locale.d.ts +1 -1
- package/src/fields/locale.js +2 -1
- package/src/fields/paymentDetails.d.ts +5 -5
- package/src/fields/tax.d.ts +19 -0
- package/src/fields/tax.js +82 -14
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
|
@@ -0,0 +1,107 @@
|
|
|
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 _FinancialDocumentV1LineItem_instances, _FinancialDocumentV1LineItem_printableValues;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FinancialDocumentV1LineItem = void 0;
|
|
10
|
+
const amount_1 = require("../../fields/amount");
|
|
11
|
+
/**
|
|
12
|
+
* List of line item details.
|
|
13
|
+
*/
|
|
14
|
+
class FinancialDocumentV1LineItem {
|
|
15
|
+
constructor({ prediction }) {
|
|
16
|
+
_FinancialDocumentV1LineItem_instances.add(this);
|
|
17
|
+
/** Confidence score */
|
|
18
|
+
this.confidence = 0.0;
|
|
19
|
+
/**
|
|
20
|
+
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
21
|
+
* the field in the document.
|
|
22
|
+
*/
|
|
23
|
+
this.polygon = [];
|
|
24
|
+
this.description = prediction["description"];
|
|
25
|
+
this.productCode = prediction["product_code"];
|
|
26
|
+
this.quantity = +parseFloat(prediction["quantity"]).toFixed(3);
|
|
27
|
+
if (isNaN(this.quantity)) {
|
|
28
|
+
this.quantity = null;
|
|
29
|
+
}
|
|
30
|
+
this.taxAmount = +parseFloat(prediction["tax_amount"]).toFixed(3);
|
|
31
|
+
if (isNaN(this.taxAmount)) {
|
|
32
|
+
this.taxAmount = null;
|
|
33
|
+
}
|
|
34
|
+
this.taxRate = +parseFloat(prediction["tax_rate"]).toFixed(3);
|
|
35
|
+
if (isNaN(this.taxRate)) {
|
|
36
|
+
this.taxRate = null;
|
|
37
|
+
}
|
|
38
|
+
this.totalAmount = +parseFloat(prediction["total_amount"]).toFixed(3);
|
|
39
|
+
if (isNaN(this.totalAmount)) {
|
|
40
|
+
this.totalAmount = null;
|
|
41
|
+
}
|
|
42
|
+
this.unitPrice = +parseFloat(prediction["unit_price"]).toFixed(3);
|
|
43
|
+
if (isNaN(this.unitPrice)) {
|
|
44
|
+
this.unitPrice = null;
|
|
45
|
+
}
|
|
46
|
+
this.pageId = prediction["page_id"];
|
|
47
|
+
this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
|
|
48
|
+
if (prediction["polygon"]) {
|
|
49
|
+
this.polygon = prediction.polygon;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Default string representation.
|
|
54
|
+
*/
|
|
55
|
+
toString() {
|
|
56
|
+
const printable = __classPrivateFieldGet(this, _FinancialDocumentV1LineItem_instances, "m", _FinancialDocumentV1LineItem_printableValues).call(this);
|
|
57
|
+
return ("Description: " +
|
|
58
|
+
printable.description +
|
|
59
|
+
"Product code: " +
|
|
60
|
+
printable.productCode +
|
|
61
|
+
"Quantity: " +
|
|
62
|
+
printable.quantity +
|
|
63
|
+
"Tax Amount: " +
|
|
64
|
+
printable.taxAmount +
|
|
65
|
+
"Tax Rate (%): " +
|
|
66
|
+
printable.taxRate +
|
|
67
|
+
"Total Amount: " +
|
|
68
|
+
printable.totalAmount +
|
|
69
|
+
"Unit Price: " +
|
|
70
|
+
printable.unitPrice).trim();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Output in a format suitable for inclusion in an rST table.
|
|
74
|
+
*/
|
|
75
|
+
toTableLine() {
|
|
76
|
+
const printable = __classPrivateFieldGet(this, _FinancialDocumentV1LineItem_instances, "m", _FinancialDocumentV1LineItem_printableValues).call(this);
|
|
77
|
+
return ("| " +
|
|
78
|
+
(printable.description.length > 33
|
|
79
|
+
? printable.description.substring(0, 33) + "..."
|
|
80
|
+
: printable.description).padEnd(36) +
|
|
81
|
+
" | " +
|
|
82
|
+
printable.productCode.padEnd(12) +
|
|
83
|
+
" | " +
|
|
84
|
+
printable.quantity.padEnd(8) +
|
|
85
|
+
" | " +
|
|
86
|
+
printable.taxAmount.padEnd(10) +
|
|
87
|
+
" | " +
|
|
88
|
+
printable.taxRate.padEnd(12) +
|
|
89
|
+
" | " +
|
|
90
|
+
printable.totalAmount.padEnd(12) +
|
|
91
|
+
" | " +
|
|
92
|
+
printable.unitPrice.padEnd(10) +
|
|
93
|
+
" |");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.FinancialDocumentV1LineItem = FinancialDocumentV1LineItem;
|
|
97
|
+
_FinancialDocumentV1LineItem_instances = new WeakSet(), _FinancialDocumentV1LineItem_printableValues = function _FinancialDocumentV1LineItem_printableValues() {
|
|
98
|
+
return {
|
|
99
|
+
description: this.description ?? "",
|
|
100
|
+
productCode: this.productCode ?? "",
|
|
101
|
+
quantity: this.quantity !== null ? (0, amount_1.floatToString)(this.quantity) : "",
|
|
102
|
+
taxAmount: this.taxAmount !== null ? (0, amount_1.floatToString)(this.taxAmount) : "",
|
|
103
|
+
taxRate: this.taxRate !== null ? (0, amount_1.floatToString)(this.taxRate) : "",
|
|
104
|
+
totalAmount: this.totalAmount !== null ? (0, amount_1.floatToString)(this.totalAmount) : "",
|
|
105
|
+
unitPrice: this.unitPrice !== null ? (0, amount_1.floatToString)(this.unitPrice) : "",
|
|
106
|
+
};
|
|
107
|
+
};
|
package/src/documents/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { InvoiceV4 } from "./invoice/invoiceV4";
|
|
|
3
3
|
export { InvoiceSplitterV1, PageGroup, } from "./invoiceSplitter/invoiceSplitterV1";
|
|
4
4
|
export { ReceiptV3 } from "./receipt/receiptV3";
|
|
5
5
|
export { ReceiptV4 } from "./receipt/receiptV4";
|
|
6
|
+
export { ReceiptV5 } from "./receipt/receiptV5";
|
|
6
7
|
export { PassportV1 } from "./passport/passportV1";
|
|
7
8
|
export { FinancialDocumentV0 } from "./financialDocument/financialDocumentV0";
|
|
8
9
|
export { FinancialDocumentV1 } from "./financialDocument/financialDocumentV1";
|
package/src/documents/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.CropperV1 = exports.getLineItems = exports.CustomV1 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.PassportV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PageGroup = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
|
|
26
|
+
exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.CropperV1 = exports.getLineItems = exports.CustomV1 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.PassportV1 = exports.ReceiptV5 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PageGroup = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
|
|
27
27
|
var invoiceV3_1 = require("./invoice/invoiceV3");
|
|
28
28
|
Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return invoiceV3_1.InvoiceV3; } });
|
|
29
29
|
var invoiceV4_1 = require("./invoice/invoiceV4");
|
|
@@ -35,6 +35,8 @@ var receiptV3_1 = require("./receipt/receiptV3");
|
|
|
35
35
|
Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function () { return receiptV3_1.ReceiptV3; } });
|
|
36
36
|
var receiptV4_1 = require("./receipt/receiptV4");
|
|
37
37
|
Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return receiptV4_1.ReceiptV4; } });
|
|
38
|
+
var receiptV5_1 = require("./receipt/receiptV5");
|
|
39
|
+
Object.defineProperty(exports, "ReceiptV5", { enumerable: true, get: function () { return receiptV5_1.ReceiptV5; } });
|
|
38
40
|
var passportV1_1 = require("./passport/passportV1");
|
|
39
41
|
Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function () { return passportV1_1.PassportV1; } });
|
|
40
42
|
var financialDocumentV0_1 = require("./financialDocument/financialDocumentV0");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { BaseField,
|
|
2
|
+
import { BaseField, Taxes, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration } from "../../fields";
|
|
3
3
|
export declare class InvoiceV3 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
/** Total amount with the tax amount of the purchase. */
|
|
@@ -31,7 +31,7 @@ export declare class InvoiceV3 extends Document {
|
|
|
31
31
|
/** The address of the customer. */
|
|
32
32
|
customerAddress: TextField;
|
|
33
33
|
/** The list of the taxes. */
|
|
34
|
-
taxes:
|
|
34
|
+
taxes: Taxes;
|
|
35
35
|
/** The payment information. */
|
|
36
36
|
paymentDetails: PaymentDetails[];
|
|
37
37
|
/** The company registration information for the customer. */
|
|
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
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
5
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
6
|
};
|
|
7
|
-
var _InvoiceV3_instances,
|
|
7
|
+
var _InvoiceV3_instances, _InvoiceV3_checklist, _InvoiceV3_reconstruct;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.InvoiceV3 = void 0;
|
|
10
10
|
const document_1 = require("../document");
|
|
@@ -39,18 +39,77 @@ class InvoiceV3 extends document_1.Document {
|
|
|
39
39
|
_InvoiceV3_instances.add(this);
|
|
40
40
|
/** The company regitration information. */
|
|
41
41
|
this.companyRegistration = [];
|
|
42
|
-
/** The list of the taxes. */
|
|
43
|
-
this.taxes = [];
|
|
44
42
|
/** The payment information. */
|
|
45
43
|
this.paymentDetails = [];
|
|
46
44
|
/** The company registration information for the customer. */
|
|
47
45
|
this.customerCompanyRegistration = [];
|
|
48
|
-
|
|
46
|
+
this.locale = new fields_1.Locale({
|
|
47
|
+
prediction: prediction.locale,
|
|
48
|
+
valueKey: "language",
|
|
49
|
+
});
|
|
50
|
+
this.documentType = new fields_1.BaseField({
|
|
51
|
+
prediction: prediction.document_type,
|
|
52
|
+
});
|
|
53
|
+
this.totalIncl = new fields_1.Amount({
|
|
54
|
+
prediction: prediction.total_incl,
|
|
55
|
+
pageId: pageId,
|
|
56
|
+
});
|
|
57
|
+
this.totalAmount = this.totalIncl;
|
|
58
|
+
this.totalTax = new fields_1.Amount({
|
|
59
|
+
prediction: { value: undefined, confidence: 0.0 },
|
|
60
|
+
pageId: pageId,
|
|
61
|
+
});
|
|
62
|
+
this.totalNet = new fields_1.Amount({
|
|
63
|
+
prediction: prediction.total_excl,
|
|
64
|
+
pageId: pageId,
|
|
65
|
+
});
|
|
66
|
+
this.date = new fields_1.DateField({
|
|
67
|
+
prediction: prediction.date,
|
|
68
|
+
pageId,
|
|
69
|
+
});
|
|
70
|
+
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
|
|
71
|
+
this.companyRegistration = prediction.company_registration.map(function (prediction) {
|
|
72
|
+
return new fields_1.CompanyRegistration({
|
|
73
|
+
prediction: prediction,
|
|
74
|
+
pageId: pageId,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
this.dueDate = new fields_1.DateField({
|
|
78
|
+
prediction: prediction.due_date,
|
|
79
|
+
pageId: pageId,
|
|
80
|
+
});
|
|
81
|
+
this.invoiceNumber = new fields_1.TextField({
|
|
82
|
+
prediction: prediction.invoice_number,
|
|
83
|
+
pageId: pageId,
|
|
84
|
+
});
|
|
85
|
+
this.supplier = new fields_1.TextField({
|
|
86
|
+
prediction: prediction.supplier,
|
|
87
|
+
pageId: pageId,
|
|
88
|
+
});
|
|
89
|
+
this.supplierAddress = new fields_1.TextField({
|
|
90
|
+
prediction: prediction.supplier_address,
|
|
91
|
+
pageId: pageId,
|
|
92
|
+
});
|
|
93
|
+
this.customerName = new fields_1.TextField({
|
|
94
|
+
prediction: prediction.customer,
|
|
95
|
+
pageId: pageId,
|
|
96
|
+
});
|
|
97
|
+
this.customerAddress = new fields_1.TextField({
|
|
98
|
+
prediction: prediction.customer_address,
|
|
99
|
+
pageId: pageId,
|
|
100
|
+
});
|
|
101
|
+
prediction.customer_company_registration.map((prediction) => this.customerCompanyRegistration.push(new fields_1.CompanyRegistration({
|
|
102
|
+
prediction: prediction,
|
|
103
|
+
pageId: pageId,
|
|
104
|
+
})));
|
|
105
|
+
prediction.payment_details.map((prediction) => this.paymentDetails.push(new fields_1.PaymentDetails({
|
|
106
|
+
prediction: prediction,
|
|
107
|
+
pageId: pageId,
|
|
108
|
+
})));
|
|
49
109
|
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_checklist).call(this);
|
|
50
110
|
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_reconstruct).call(this);
|
|
51
111
|
}
|
|
52
112
|
toString() {
|
|
53
|
-
const taxes = this.taxes.map((item) => item.toString()).join("\n ");
|
|
54
113
|
const paymentDetails = this.paymentDetails
|
|
55
114
|
.map((item) => item.toString())
|
|
56
115
|
.join("\n ");
|
|
@@ -60,104 +119,30 @@ class InvoiceV3 extends document_1.Document {
|
|
|
60
119
|
const companyRegistration = this.companyRegistration
|
|
61
120
|
.map((item) => item.toString())
|
|
62
121
|
.join("; ");
|
|
63
|
-
const outStr =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Total amount
|
|
68
|
-
|
|
69
|
-
Invoice
|
|
70
|
-
|
|
71
|
-
Supplier
|
|
72
|
-
|
|
73
|
-
Customer
|
|
74
|
-
Customer
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
122
|
+
const outStr = `Invoice V3 Prediction
|
|
123
|
+
=====================
|
|
124
|
+
:Filename: ${this.filename}
|
|
125
|
+
:Invoice number: ${this.invoiceNumber}
|
|
126
|
+
:Total amount: ${this.totalIncl}
|
|
127
|
+
:Total net: ${this.totalExcl}
|
|
128
|
+
:Invoice date: ${this.date}
|
|
129
|
+
:Invoice due date: ${this.dueDate}
|
|
130
|
+
:Supplier name: ${this.supplier}
|
|
131
|
+
:Supplier address: ${this.supplierAddress}
|
|
132
|
+
:Customer name: ${this.customerName}
|
|
133
|
+
:Customer company registration: ${customerCompanyRegistration}
|
|
134
|
+
:Customer address: ${this.customerAddress}
|
|
135
|
+
:Payment details: ${paymentDetails}
|
|
136
|
+
:Company numbers: ${companyRegistration}
|
|
137
|
+
:Taxes: ${this.taxes}
|
|
138
|
+
:Total tax: ${this.totalTax}
|
|
139
|
+
:Locale: ${this.locale}
|
|
81
140
|
`;
|
|
82
141
|
return InvoiceV3.cleanOutString(outStr);
|
|
83
142
|
}
|
|
84
143
|
}
|
|
85
144
|
exports.InvoiceV3 = InvoiceV3;
|
|
86
|
-
_InvoiceV3_instances = new WeakSet(),
|
|
87
|
-
this.locale = new fields_1.Locale({
|
|
88
|
-
prediction: apiPrediction.locale,
|
|
89
|
-
valueKey: "language",
|
|
90
|
-
});
|
|
91
|
-
this.documentType = new fields_1.BaseField({
|
|
92
|
-
prediction: apiPrediction.document_type,
|
|
93
|
-
valueKey: "value",
|
|
94
|
-
});
|
|
95
|
-
this.totalIncl = new fields_1.Amount({
|
|
96
|
-
prediction: apiPrediction.total_incl,
|
|
97
|
-
valueKey: "value",
|
|
98
|
-
pageId: pageId,
|
|
99
|
-
});
|
|
100
|
-
this.totalAmount = this.totalIncl;
|
|
101
|
-
this.totalTax = new fields_1.Amount({
|
|
102
|
-
prediction: { value: undefined, confidence: 0.0 },
|
|
103
|
-
valueKey: "value",
|
|
104
|
-
pageId: pageId,
|
|
105
|
-
});
|
|
106
|
-
this.totalNet = new fields_1.Amount({
|
|
107
|
-
prediction: apiPrediction.total_excl,
|
|
108
|
-
valueKey: "value",
|
|
109
|
-
pageId: pageId,
|
|
110
|
-
});
|
|
111
|
-
this.date = new fields_1.DateField({
|
|
112
|
-
prediction: apiPrediction.date,
|
|
113
|
-
pageId,
|
|
114
|
-
});
|
|
115
|
-
apiPrediction.taxes.map((prediction) => this.taxes.push(new fields_1.TaxField({
|
|
116
|
-
prediction: prediction,
|
|
117
|
-
pageId: pageId,
|
|
118
|
-
valueKey: "value",
|
|
119
|
-
rateKey: "rate",
|
|
120
|
-
codeKey: "code",
|
|
121
|
-
})));
|
|
122
|
-
this.companyRegistration = apiPrediction.company_registration.map(function (prediction) {
|
|
123
|
-
return new fields_1.CompanyRegistration({
|
|
124
|
-
prediction: prediction,
|
|
125
|
-
pageId: pageId,
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
this.dueDate = new fields_1.DateField({
|
|
129
|
-
prediction: apiPrediction.due_date,
|
|
130
|
-
pageId: pageId,
|
|
131
|
-
});
|
|
132
|
-
this.invoiceNumber = new fields_1.TextField({
|
|
133
|
-
prediction: apiPrediction.invoice_number,
|
|
134
|
-
pageId: pageId,
|
|
135
|
-
});
|
|
136
|
-
this.supplier = new fields_1.TextField({
|
|
137
|
-
prediction: apiPrediction.supplier,
|
|
138
|
-
pageId: pageId,
|
|
139
|
-
});
|
|
140
|
-
this.supplierAddress = new fields_1.TextField({
|
|
141
|
-
prediction: apiPrediction.supplier_address,
|
|
142
|
-
pageId: pageId,
|
|
143
|
-
});
|
|
144
|
-
this.customerName = new fields_1.TextField({
|
|
145
|
-
prediction: apiPrediction.customer,
|
|
146
|
-
pageId: pageId,
|
|
147
|
-
});
|
|
148
|
-
this.customerAddress = new fields_1.TextField({
|
|
149
|
-
prediction: apiPrediction.customer_address,
|
|
150
|
-
pageId: pageId,
|
|
151
|
-
});
|
|
152
|
-
apiPrediction.customer_company_registration.map((prediction) => this.customerCompanyRegistration.push(new fields_1.CompanyRegistration({
|
|
153
|
-
prediction: prediction,
|
|
154
|
-
pageId: pageId,
|
|
155
|
-
})));
|
|
156
|
-
apiPrediction.payment_details.map((prediction) => this.paymentDetails.push(new fields_1.PaymentDetails({
|
|
157
|
-
prediction: prediction,
|
|
158
|
-
pageId: pageId,
|
|
159
|
-
})));
|
|
160
|
-
}, _InvoiceV3_checklist = function _InvoiceV3_checklist() {
|
|
145
|
+
_InvoiceV3_instances = new WeakSet(), _InvoiceV3_checklist = function _InvoiceV3_checklist() {
|
|
161
146
|
this.checklist = {
|
|
162
147
|
taxesMatchTotalIncl: (0, checks_1.taxesMatchTotalIncl)(this),
|
|
163
148
|
taxesMatchTotalExcl: (0, checks_1.taxesMatchTotalExcl)(this),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { ClassificationField,
|
|
2
|
+
import { ClassificationField, Taxes, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration } from "../../fields";
|
|
3
3
|
import { InvoiceLineItem } from "./invoiceLineItem";
|
|
4
4
|
/** Invoice V4 */
|
|
5
5
|
export declare class InvoiceV4 extends Document {
|
|
@@ -37,7 +37,7 @@ export declare class InvoiceV4 extends Document {
|
|
|
37
37
|
/** The company registration information for the customer. */
|
|
38
38
|
customerCompanyRegistrations: CompanyRegistration[];
|
|
39
39
|
/** The list of the taxes. */
|
|
40
|
-
taxes:
|
|
40
|
+
taxes: Taxes;
|
|
41
41
|
/** Line items details. */
|
|
42
42
|
lineItems: InvoiceLineItem[];
|
|
43
43
|
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
@@ -31,8 +31,6 @@ class InvoiceV4 extends document_1.Document {
|
|
|
31
31
|
this.supplierCompanyRegistrations = [];
|
|
32
32
|
/** The company registration information for the customer. */
|
|
33
33
|
this.customerCompanyRegistrations = [];
|
|
34
|
-
/** The list of the taxes. */
|
|
35
|
-
this.taxes = [];
|
|
36
34
|
/** Line items details. */
|
|
37
35
|
this.lineItems = [];
|
|
38
36
|
this.locale = new fields_1.Locale({
|
|
@@ -41,7 +39,6 @@ class InvoiceV4 extends document_1.Document {
|
|
|
41
39
|
});
|
|
42
40
|
this.documentType = new fields_1.ClassificationField({
|
|
43
41
|
prediction: prediction.document_type,
|
|
44
|
-
valueKey: "value",
|
|
45
42
|
});
|
|
46
43
|
this.referenceNumbers = prediction.reference_numbers.map(function (prediction) {
|
|
47
44
|
return new fields_1.TextField({
|
|
@@ -51,30 +48,21 @@ class InvoiceV4 extends document_1.Document {
|
|
|
51
48
|
});
|
|
52
49
|
this.totalAmount = new fields_1.Amount({
|
|
53
50
|
prediction: prediction.total_amount,
|
|
54
|
-
valueKey: "value",
|
|
55
51
|
pageId: pageId,
|
|
56
52
|
});
|
|
57
53
|
this.totalTax = new fields_1.Amount({
|
|
58
54
|
prediction: { value: undefined, confidence: 0.0 },
|
|
59
|
-
valueKey: "value",
|
|
60
55
|
pageId: pageId,
|
|
61
56
|
});
|
|
62
57
|
this.totalNet = new fields_1.Amount({
|
|
63
58
|
prediction: prediction.total_net,
|
|
64
|
-
valueKey: "value",
|
|
65
59
|
pageId: pageId,
|
|
66
60
|
});
|
|
67
61
|
this.date = new fields_1.DateField({
|
|
68
62
|
prediction: prediction.date,
|
|
69
63
|
pageId,
|
|
70
64
|
});
|
|
71
|
-
|
|
72
|
-
prediction: prediction,
|
|
73
|
-
pageId: pageId,
|
|
74
|
-
valueKey: "value",
|
|
75
|
-
rateKey: "rate",
|
|
76
|
-
codeKey: "code",
|
|
77
|
-
})));
|
|
65
|
+
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
|
|
78
66
|
this.supplierCompanyRegistrations =
|
|
79
67
|
prediction.supplier_company_registrations.map(function (prediction) {
|
|
80
68
|
return new fields_1.CompanyRegistration({
|
|
@@ -121,7 +109,6 @@ class InvoiceV4 extends document_1.Document {
|
|
|
121
109
|
__classPrivateFieldGet(this, _InvoiceV4_instances, "m", _InvoiceV4_reconstruct).call(this);
|
|
122
110
|
}
|
|
123
111
|
toString() {
|
|
124
|
-
const taxes = this.taxes.map((item) => item.toString()).join("\n ");
|
|
125
112
|
const referenceNumbers = this.referenceNumbers
|
|
126
113
|
.map((item) => item.toString())
|
|
127
114
|
.join(", ");
|
|
@@ -140,26 +127,26 @@ class InvoiceV4 extends document_1.Document {
|
|
|
140
127
|
"\n Code | QTY | Price | Amount | Tax (Rate) | Description\n ";
|
|
141
128
|
lineItems += this.lineItems.map((item) => item.toString()).join("\n ");
|
|
142
129
|
}
|
|
143
|
-
const outStr =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
Invoice
|
|
150
|
-
|
|
151
|
-
Supplier
|
|
152
|
-
Supplier
|
|
153
|
-
Supplier
|
|
154
|
-
|
|
155
|
-
Customer
|
|
156
|
-
Customer
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
Total
|
|
161
|
-
Total
|
|
162
|
-
|
|
130
|
+
const outStr = `Invoice V4 Prediction
|
|
131
|
+
=====================
|
|
132
|
+
:Filename: ${this.filename}
|
|
133
|
+
:Locale: ${this.locale}
|
|
134
|
+
:Invoice number: ${this.invoiceNumber}
|
|
135
|
+
:Reference numbers: ${referenceNumbers}
|
|
136
|
+
:Invoice date: ${this.date}
|
|
137
|
+
:Invoice due date: ${this.dueDate}
|
|
138
|
+
:Supplier name: ${this.supplierName}
|
|
139
|
+
:Supplier address: ${this.supplierAddress}
|
|
140
|
+
:Supplier company registrations: ${companyRegistration}
|
|
141
|
+
:Supplier payment details: ${paymentDetails}
|
|
142
|
+
:Customer name: ${this.customerName}
|
|
143
|
+
:Customer company registrations: ${customerCompanyRegistration}
|
|
144
|
+
:Customer address: ${this.customerAddress}
|
|
145
|
+
:Line Items: ${lineItems}
|
|
146
|
+
:Taxes: ${this.taxes}
|
|
147
|
+
:Total tax: ${this.totalTax}
|
|
148
|
+
:Total net: ${this.totalNet}
|
|
149
|
+
:Total amount: ${this.totalAmount}
|
|
163
150
|
`;
|
|
164
151
|
return InvoiceV4.cleanOutString(outStr);
|
|
165
152
|
}
|
|
@@ -2,7 +2,7 @@ import { Document, DocumentConstructorProps } from "../document";
|
|
|
2
2
|
import { CompanyRegistration, DateField, Locale, TextField } from "../../fields";
|
|
3
3
|
export declare class ProofOfAddressV1 extends Document {
|
|
4
4
|
/** ISO date yyyy-mm-dd. Works both for European and US dates. */
|
|
5
|
-
|
|
5
|
+
date: DateField;
|
|
6
6
|
/** All extrated ISO date yyyy-mm-dd. Works both for European and US dates. */
|
|
7
7
|
dates: DateField[];
|
|
8
8
|
/** Address of the document's issuer. */
|
|
@@ -20,7 +20,7 @@ class ProofOfAddressV1 extends document_1.Document {
|
|
|
20
20
|
this.locale = new fields_1.Locale({
|
|
21
21
|
prediction: prediction.locale,
|
|
22
22
|
});
|
|
23
|
-
this.
|
|
23
|
+
this.date = new fields_1.DateField({
|
|
24
24
|
prediction: prediction.date,
|
|
25
25
|
pageId: pageId,
|
|
26
26
|
});
|
|
@@ -68,7 +68,7 @@ Recipient Company Registrations: ${this.recipientCompanyRegistration
|
|
|
68
68
|
.join(", ")}
|
|
69
69
|
Recipient Address: ${this.recipientAddress}
|
|
70
70
|
Dates: ${this.dates.map((rcr) => rcr.value).join("\n ")}
|
|
71
|
-
Date of Issue: ${this.
|
|
71
|
+
Date of Issue: ${this.date}
|
|
72
72
|
----------------------
|
|
73
73
|
`;
|
|
74
74
|
return ProofOfAddressV1.cleanOutString(outStr);
|
|
@@ -18,7 +18,7 @@ export declare class ReceiptV3 extends Document {
|
|
|
18
18
|
totalTax: Amount;
|
|
19
19
|
/** Total amount without tax of the purchase. */
|
|
20
20
|
totalExcl: Amount;
|
|
21
|
-
/** List of different
|
|
21
|
+
/** List of different taxes. */
|
|
22
22
|
taxes: TaxField[];
|
|
23
23
|
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
24
24
|
toString(): string;
|
|
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
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
5
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
6
|
};
|
|
7
|
-
var _ReceiptV3_instances,
|
|
7
|
+
var _ReceiptV3_instances, _ReceiptV3_checklist, _ReceiptV3_taxesMatchTotal, _ReceiptV3_reconstruct, _ReceiptV3_reconstructTotalExclFromTCCAndTaxes, _ReceiptV3_reconstructTotalTax;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ReceiptV3 = void 0;
|
|
10
10
|
const document_1 = require("../document");
|
|
@@ -19,73 +19,59 @@ class ReceiptV3 extends document_1.Document {
|
|
|
19
19
|
fullText: fullText,
|
|
20
20
|
});
|
|
21
21
|
_ReceiptV3_instances.add(this);
|
|
22
|
-
/** List of different taxe. */
|
|
23
|
-
this.taxes = [];
|
|
24
22
|
this.locale = new fields_1.Locale({
|
|
25
23
|
prediction: prediction.locale,
|
|
26
24
|
});
|
|
27
25
|
this.totalTax = new fields_1.Amount({
|
|
28
26
|
prediction: { value: undefined, confidence: 0 },
|
|
29
|
-
valueKey: "value",
|
|
30
27
|
pageId: pageId,
|
|
31
28
|
});
|
|
32
29
|
this.totalExcl = new fields_1.Amount({
|
|
33
30
|
prediction: { value: undefined, confidence: 0 },
|
|
34
|
-
valueKey: "value",
|
|
35
31
|
pageId: pageId,
|
|
36
32
|
});
|
|
37
|
-
|
|
33
|
+
this.totalIncl = new fields_1.Amount({
|
|
34
|
+
prediction: prediction.total_incl,
|
|
35
|
+
pageId: pageId,
|
|
36
|
+
});
|
|
37
|
+
this.date = new fields_1.DateField({
|
|
38
|
+
prediction: prediction.date,
|
|
39
|
+
pageId: pageId,
|
|
40
|
+
});
|
|
41
|
+
this.category = new fields_1.ClassificationField({
|
|
42
|
+
prediction: prediction.category,
|
|
43
|
+
});
|
|
44
|
+
this.merchantName = new fields_1.TextField({
|
|
45
|
+
prediction: prediction.supplier,
|
|
46
|
+
pageId: pageId,
|
|
47
|
+
});
|
|
48
|
+
this.time = new fields_1.TextField({
|
|
49
|
+
prediction: prediction.time,
|
|
50
|
+
pageId: pageId,
|
|
51
|
+
});
|
|
52
|
+
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
|
|
38
53
|
__classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_checklist).call(this);
|
|
39
54
|
__classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_reconstruct).call(this);
|
|
40
55
|
}
|
|
41
56
|
toString() {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
Filename: ${this.filename}
|
|
45
|
-
Total amount
|
|
46
|
-
Total
|
|
47
|
-
Date: ${this.date}
|
|
48
|
-
Category: ${this.category}
|
|
49
|
-
Time: ${this.time}
|
|
50
|
-
Merchant name: ${this.merchantName}
|
|
51
|
-
Taxes: ${taxes}
|
|
52
|
-
Total
|
|
53
|
-
Locale: ${this.locale}
|
|
54
|
-
----------------------
|
|
57
|
+
const outStr = `Receipt V3 Prediction
|
|
58
|
+
=====================
|
|
59
|
+
:Filename: ${this.filename}
|
|
60
|
+
:Total amount: ${this.totalIncl}
|
|
61
|
+
:Total net: ${this.totalExcl}
|
|
62
|
+
:Date: ${this.date}
|
|
63
|
+
:Category: ${this.category}
|
|
64
|
+
:Time: ${this.time}
|
|
65
|
+
:Merchant name: ${this.merchantName}
|
|
66
|
+
:Taxes: ${this.taxes}
|
|
67
|
+
:Total tax: ${this.totalTax}
|
|
68
|
+
:Locale: ${this.locale}
|
|
55
69
|
`;
|
|
56
70
|
return ReceiptV3.cleanOutString(outStr);
|
|
57
71
|
}
|
|
58
72
|
}
|
|
59
73
|
exports.ReceiptV3 = ReceiptV3;
|
|
60
|
-
_ReceiptV3_instances = new WeakSet(),
|
|
61
|
-
this.totalIncl = new fields_1.Amount({
|
|
62
|
-
prediction: apiPrediction.total_incl,
|
|
63
|
-
valueKey: "value",
|
|
64
|
-
pageId: pageId,
|
|
65
|
-
});
|
|
66
|
-
this.date = new fields_1.DateField({
|
|
67
|
-
prediction: apiPrediction.date,
|
|
68
|
-
pageId: pageId,
|
|
69
|
-
});
|
|
70
|
-
this.category = new fields_1.ClassificationField({
|
|
71
|
-
prediction: apiPrediction.category,
|
|
72
|
-
});
|
|
73
|
-
this.merchantName = new fields_1.TextField({
|
|
74
|
-
prediction: apiPrediction.supplier,
|
|
75
|
-
pageId: pageId,
|
|
76
|
-
});
|
|
77
|
-
this.time = new fields_1.TextField({
|
|
78
|
-
prediction: apiPrediction.time,
|
|
79
|
-
pageId: pageId,
|
|
80
|
-
});
|
|
81
|
-
apiPrediction.taxes.map((taxPrediction) => this.taxes.push(new fields_1.TaxField({
|
|
82
|
-
prediction: taxPrediction,
|
|
83
|
-
pageId: pageId,
|
|
84
|
-
valueKey: "value",
|
|
85
|
-
rateKey: "rate",
|
|
86
|
-
codeKey: "code",
|
|
87
|
-
})));
|
|
88
|
-
}, _ReceiptV3_checklist = function _ReceiptV3_checklist() {
|
|
74
|
+
_ReceiptV3_instances = new WeakSet(), _ReceiptV3_checklist = function _ReceiptV3_checklist() {
|
|
89
75
|
this.checklist = { taxesMatchTotalIncl: __classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_taxesMatchTotal).call(this) };
|
|
90
76
|
}, _ReceiptV3_taxesMatchTotal = function _ReceiptV3_taxesMatchTotal() {
|
|
91
77
|
// Check taxes and total amount exist
|