Comparing version 3.7.4 to 3.8.0
# CHANGELOG | ||
## v3.8.0 - 2023-05-25 | ||
### Changes | ||
* :sparkles: add support for receipt v5 | ||
* :sparkles: print taxes in table layout | ||
## v3.7.4 - 2023-04-20 | ||
@@ -4,0 +10,0 @@ ### Changes |
{ | ||
"name": "mindee", | ||
"version": "3.7.4", | ||
"version": "3.8.0", | ||
"description": "Mindee Client Library for Node.js", | ||
@@ -51,7 +51,7 @@ "main": "src/index.js", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"typedoc": "~0.23", | ||
"mocha": "^10.1.0", | ||
"prettier": "^2.8.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.0.3" | ||
"typedoc": "~0.23", | ||
"typescript": "^5.0.4" | ||
}, | ||
@@ -58,0 +58,0 @@ "dependencies": { |
@@ -75,3 +75,3 @@ "use strict"; | ||
displayName: "Expense Receipt", | ||
docClass: _1.ReceiptV4, | ||
docClass: _1.ReceiptV5, | ||
fullText: true, | ||
@@ -78,0 +78,0 @@ async: false, |
@@ -54,3 +54,3 @@ "use strict"; | ||
} | ||
return await docConfig.asyncPredict({ | ||
return await docConfig.predictAsync({ | ||
inputDoc: this.inputSource, | ||
@@ -140,2 +140,5 @@ includeWords: this.getBooleanParam(params.fullText), | ||
])); | ||
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ReceiptV5.name], new documentConfig_1.DocumentConfig(documents_1.ReceiptV5, [ | ||
new api_1.StandardEndpoint("expense_receipts", "5", this.apiKey), | ||
])); | ||
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.PassportV1.name], new documentConfig_1.DocumentConfig(documents_1.PassportV1, [ | ||
@@ -142,0 +145,0 @@ new api_1.StandardEndpoint("passport", "1", this.apiKey), |
@@ -22,3 +22,3 @@ import { InputSource } from "../inputs"; | ||
}): Promise<Response<DocType>>; | ||
asyncPredict(params: { | ||
predictAsync(params: { | ||
inputDoc: InputSource; | ||
@@ -25,0 +25,0 @@ includeWords: boolean; |
@@ -22,3 +22,3 @@ "use strict"; | ||
} | ||
async asyncPredict(params) { | ||
async predictAsync(params) { | ||
this.checkApiKeys(); | ||
@@ -25,0 +25,0 @@ await params.inputDoc.init(); |
@@ -27,4 +27,2 @@ "use strict"; | ||
this.customerCompanyRegistrations = []; | ||
/** The list of the taxes. */ | ||
this.taxes = []; | ||
/** Line items details. */ | ||
@@ -36,5 +34,4 @@ this.lineItems = []; | ||
}); | ||
this.documentType = new fields_1.BaseField({ | ||
this.documentType = new fields_1.ClassificationField({ | ||
prediction: prediction.document_type, | ||
valueKey: "value", | ||
}); | ||
@@ -49,3 +46,2 @@ this.referenceNumbers = prediction.reference_numbers.map(function (prediction) { | ||
prediction: prediction.total_amount, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -55,3 +51,2 @@ }); | ||
prediction: prediction.total_tax, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -61,3 +56,2 @@ }); | ||
prediction: prediction.total_net, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -113,3 +107,2 @@ }); | ||
prediction: prediction.tip, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -129,13 +122,5 @@ }); | ||
}); | ||
prediction.taxes.map((taxPrediction) => this.taxes.push(new fields_1.TaxField({ | ||
prediction: taxPrediction, | ||
pageId: pageId, | ||
valueKey: "value", | ||
rateKey: "rate", | ||
codeKey: "code", | ||
baseKey: "base", | ||
}))); | ||
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId); | ||
} | ||
toString() { | ||
const taxes = this.taxes.map((item) => item.toString()).join("\n "); | ||
const referenceNumbers = this.referenceNumbers | ||
@@ -159,27 +144,27 @@ .map((item) => item.toString()) | ||
} | ||
const outStr = `----- Financial Document V1 ----- | ||
Filename: ${this.filename} | ||
Document type: ${this.documentType} | ||
Category: ${this.category} | ||
Subcategory: ${this.subCategory} | ||
Locale: ${this.locale} | ||
Invoice number: ${this.invoiceNumber} | ||
Reference numbers: ${referenceNumbers} | ||
Date: ${this.date} | ||
Due date: ${this.dueDate} | ||
Time: ${this.time} | ||
Supplier name: ${this.supplierName} | ||
Supplier address: ${this.supplierAddress} | ||
Supplier company registrations: ${supplierCompanyRegistration} | ||
Supplier payment details: ${paymentDetails} | ||
Customer name: ${this.customerName} | ||
Customer address: ${this.customerAddress} | ||
Customer company registrations: ${customerCompanyRegistration} | ||
Tip: ${this.tip} | ||
Taxes: ${taxes} | ||
Total tax: ${this.totalTax} | ||
Total net: ${this.totalNet} | ||
Total amount: ${this.totalAmount} | ||
Line Items: ${lineItems} | ||
---------------------- | ||
const outStr = `Financial Document V1 Prediction | ||
================================ | ||
:Filename: ${this.filename} | ||
:Document type: ${this.documentType} | ||
:Category: ${this.category} | ||
:Subcategory: ${this.subCategory} | ||
:Locale: ${this.locale} | ||
:Invoice number: ${this.invoiceNumber} | ||
:Reference numbers: ${referenceNumbers} | ||
:Date: ${this.date} | ||
:Due date: ${this.dueDate} | ||
:Time: ${this.time} | ||
:Supplier name: ${this.supplierName} | ||
:Supplier address: ${this.supplierAddress} | ||
:Supplier company registrations: ${supplierCompanyRegistration} | ||
:Supplier payment details: ${paymentDetails} | ||
:Customer name: ${this.customerName} | ||
:Customer address: ${this.customerAddress} | ||
:Customer company registrations: ${customerCompanyRegistration} | ||
:Tip: ${this.tip} | ||
:Taxes: ${this.taxes} | ||
:Total tax: ${this.totalTax} | ||
:Total net: ${this.totalNet} | ||
:Total amount: ${this.totalAmount} | ||
:Line Items: ${lineItems} | ||
`; | ||
@@ -186,0 +171,0 @@ return FinancialDocumentV1.cleanOutString(outStr); |
@@ -6,2 +6,3 @@ export { InvoiceV3 } from "./invoice/invoiceV3"; | ||
export { ReceiptV4 } from "./receipt/receiptV4"; | ||
export { ReceiptV5 } from "./receipt/receiptV5"; | ||
export { PassportV1 } from "./passport/passportV1"; | ||
@@ -8,0 +9,0 @@ export { FinancialDocumentV0 } from "./financialDocument/financialDocumentV0"; |
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
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; | ||
var invoiceV3_1 = require("./invoice/invoiceV3"); | ||
@@ -39,2 +39,4 @@ Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return invoiceV3_1.InvoiceV3; } }); | ||
Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return receiptV4_1.ReceiptV4; } }); | ||
var receiptV5_1 = require("./receipt/receiptV5"); | ||
Object.defineProperty(exports, "ReceiptV5", { enumerable: true, get: function () { return receiptV5_1.ReceiptV5; } }); | ||
var passportV1_1 = require("./passport/passportV1"); | ||
@@ -41,0 +43,0 @@ Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function () { return passportV1_1.PassportV1; } }); |
import { Document, DocumentConstructorProps } from "../document"; | ||
import { BaseField, TaxField, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration } from "../../fields"; | ||
import { BaseField, Taxes, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration } from "../../fields"; | ||
export declare class InvoiceV3 extends Document { | ||
@@ -34,3 +34,3 @@ #private; | ||
/** The list of the taxes. */ | ||
taxes: TaxField[]; | ||
taxes: Taxes; | ||
/** The payment information. */ | ||
@@ -37,0 +37,0 @@ paymentDetails: PaymentDetails[]; |
@@ -7,3 +7,3 @@ "use strict"; | ||
}; | ||
var _InvoiceV3_instances, _InvoiceV3_initFromApiPrediction, _InvoiceV3_checklist, _InvoiceV3_reconstruct; | ||
var _InvoiceV3_instances, _InvoiceV3_checklist, _InvoiceV3_reconstruct; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -43,4 +43,2 @@ exports.InvoiceV3 = void 0; | ||
this.companyRegistration = []; | ||
/** The list of the taxes. */ | ||
this.taxes = []; | ||
/** The payment information. */ | ||
@@ -50,3 +48,65 @@ this.paymentDetails = []; | ||
this.customerCompanyRegistration = []; | ||
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_initFromApiPrediction).call(this, prediction, pageId); | ||
this.locale = new fields_1.Locale({ | ||
prediction: prediction.locale, | ||
valueKey: "language", | ||
}); | ||
this.documentType = new fields_1.BaseField({ | ||
prediction: prediction.document_type, | ||
}); | ||
this.totalIncl = new fields_1.Amount({ | ||
prediction: prediction.total_incl, | ||
pageId: pageId, | ||
}); | ||
this.totalAmount = this.totalIncl; | ||
this.totalTax = new fields_1.Amount({ | ||
prediction: { value: undefined, confidence: 0.0 }, | ||
pageId: pageId, | ||
}); | ||
this.totalNet = new fields_1.Amount({ | ||
prediction: prediction.total_excl, | ||
pageId: pageId, | ||
}); | ||
this.date = new fields_1.DateField({ | ||
prediction: prediction.date, | ||
pageId, | ||
}); | ||
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId); | ||
this.companyRegistration = prediction.company_registration.map(function (prediction) { | ||
return new fields_1.CompanyRegistration({ | ||
prediction: prediction, | ||
pageId: pageId, | ||
}); | ||
}); | ||
this.dueDate = new fields_1.DateField({ | ||
prediction: prediction.due_date, | ||
pageId: pageId, | ||
}); | ||
this.invoiceNumber = new fields_1.TextField({ | ||
prediction: prediction.invoice_number, | ||
pageId: pageId, | ||
}); | ||
this.supplier = new fields_1.TextField({ | ||
prediction: prediction.supplier, | ||
pageId: pageId, | ||
}); | ||
this.supplierAddress = new fields_1.TextField({ | ||
prediction: prediction.supplier_address, | ||
pageId: pageId, | ||
}); | ||
this.customerName = new fields_1.TextField({ | ||
prediction: prediction.customer, | ||
pageId: pageId, | ||
}); | ||
this.customerAddress = new fields_1.TextField({ | ||
prediction: prediction.customer_address, | ||
pageId: pageId, | ||
}); | ||
prediction.customer_company_registration.map((prediction) => this.customerCompanyRegistration.push(new fields_1.CompanyRegistration({ | ||
prediction: prediction, | ||
pageId: pageId, | ||
}))); | ||
prediction.payment_details.map((prediction) => this.paymentDetails.push(new fields_1.PaymentDetails({ | ||
prediction: prediction, | ||
pageId: pageId, | ||
}))); | ||
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_checklist).call(this); | ||
@@ -56,3 +116,2 @@ __classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_reconstruct).call(this); | ||
toString() { | ||
const taxes = this.taxes.map((item) => item.toString()).join("\n "); | ||
const paymentDetails = this.paymentDetails | ||
@@ -67,20 +126,20 @@ .map((item) => item.toString()) | ||
.join("; "); | ||
const outStr = `----- Invoice V3 ----- | ||
Filename: ${this.filename} | ||
Invoice number: ${this.invoiceNumber} | ||
Total amount including taxes: ${this.totalIncl} | ||
Total amount excluding taxes: ${this.totalExcl} | ||
Invoice date: ${this.date} | ||
Invoice due date: ${this.dueDate} | ||
Supplier name: ${this.supplier} | ||
Supplier address: ${this.supplierAddress} | ||
Customer name: ${this.customerName} | ||
Customer company registration: ${customerCompanyRegistration} | ||
Customer address: ${this.customerAddress} | ||
Payment details: ${paymentDetails} | ||
Company numbers: ${companyRegistration} | ||
Taxes: ${taxes} | ||
Total taxes: ${this.totalTax} | ||
Locale: ${this.locale} | ||
---------------------- | ||
const outStr = `Invoice V3 Prediction | ||
===================== | ||
:Filename: ${this.filename} | ||
:Invoice number: ${this.invoiceNumber} | ||
:Total amount: ${this.totalIncl} | ||
:Total net: ${this.totalExcl} | ||
:Invoice date: ${this.date} | ||
:Invoice due date: ${this.dueDate} | ||
:Supplier name: ${this.supplier} | ||
:Supplier address: ${this.supplierAddress} | ||
:Customer name: ${this.customerName} | ||
:Customer company registration: ${customerCompanyRegistration} | ||
:Customer address: ${this.customerAddress} | ||
:Payment details: ${paymentDetails} | ||
:Company numbers: ${companyRegistration} | ||
:Taxes: ${this.taxes} | ||
:Total tax: ${this.totalTax} | ||
:Locale: ${this.locale} | ||
`; | ||
@@ -91,77 +150,3 @@ return InvoiceV3.cleanOutString(outStr); | ||
exports.InvoiceV3 = InvoiceV3; | ||
_InvoiceV3_instances = new WeakSet(), _InvoiceV3_initFromApiPrediction = function _InvoiceV3_initFromApiPrediction(apiPrediction, pageId) { | ||
this.locale = new fields_1.Locale({ | ||
prediction: apiPrediction.locale, | ||
valueKey: "language", | ||
}); | ||
this.documentType = new fields_1.BaseField({ | ||
prediction: apiPrediction.document_type, | ||
valueKey: "value", | ||
}); | ||
this.totalIncl = new fields_1.Amount({ | ||
prediction: apiPrediction.total_incl, | ||
valueKey: "value", | ||
pageId: pageId, | ||
}); | ||
this.totalAmount = this.totalIncl; | ||
this.totalTax = new fields_1.Amount({ | ||
prediction: { value: undefined, confidence: 0.0 }, | ||
valueKey: "value", | ||
pageId: pageId, | ||
}); | ||
this.totalNet = new fields_1.Amount({ | ||
prediction: apiPrediction.total_excl, | ||
valueKey: "value", | ||
pageId: pageId, | ||
}); | ||
this.date = new fields_1.DateField({ | ||
prediction: apiPrediction.date, | ||
pageId, | ||
}); | ||
apiPrediction.taxes.map((prediction) => this.taxes.push(new fields_1.TaxField({ | ||
prediction: prediction, | ||
pageId: pageId, | ||
valueKey: "value", | ||
rateKey: "rate", | ||
codeKey: "code", | ||
}))); | ||
this.companyRegistration = apiPrediction.company_registration.map(function (prediction) { | ||
return new fields_1.CompanyRegistration({ | ||
prediction: prediction, | ||
pageId: pageId, | ||
}); | ||
}); | ||
this.dueDate = new fields_1.DateField({ | ||
prediction: apiPrediction.due_date, | ||
pageId: pageId, | ||
}); | ||
this.invoiceNumber = new fields_1.TextField({ | ||
prediction: apiPrediction.invoice_number, | ||
pageId: pageId, | ||
}); | ||
this.supplier = new fields_1.TextField({ | ||
prediction: apiPrediction.supplier, | ||
pageId: pageId, | ||
}); | ||
this.supplierAddress = new fields_1.TextField({ | ||
prediction: apiPrediction.supplier_address, | ||
pageId: pageId, | ||
}); | ||
this.customerName = new fields_1.TextField({ | ||
prediction: apiPrediction.customer, | ||
pageId: pageId, | ||
}); | ||
this.customerAddress = new fields_1.TextField({ | ||
prediction: apiPrediction.customer_address, | ||
pageId: pageId, | ||
}); | ||
apiPrediction.customer_company_registration.map((prediction) => this.customerCompanyRegistration.push(new fields_1.CompanyRegistration({ | ||
prediction: prediction, | ||
pageId: pageId, | ||
}))); | ||
apiPrediction.payment_details.map((prediction) => this.paymentDetails.push(new fields_1.PaymentDetails({ | ||
prediction: prediction, | ||
pageId: pageId, | ||
}))); | ||
}, _InvoiceV3_checklist = function _InvoiceV3_checklist() { | ||
_InvoiceV3_instances = new WeakSet(), _InvoiceV3_checklist = function _InvoiceV3_checklist() { | ||
this.checklist = { | ||
@@ -168,0 +153,0 @@ taxesMatchTotalIncl: (0, checks_1.taxesMatchTotalIncl)(this), |
import { Document, DocumentConstructorProps } from "../document"; | ||
import { ClassificationField, TaxField, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration } from "../../fields"; | ||
import { ClassificationField, Taxes, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration } from "../../fields"; | ||
import { InvoiceLineItem } from "./invoiceLineItem"; | ||
@@ -40,3 +40,3 @@ /** Invoice V4 */ | ||
/** The list of the taxes. */ | ||
taxes: TaxField[]; | ||
taxes: Taxes; | ||
/** Line items details. */ | ||
@@ -43,0 +43,0 @@ lineItems: InvoiceLineItem[]; |
@@ -34,4 +34,2 @@ "use strict"; | ||
this.customerCompanyRegistrations = []; | ||
/** The list of the taxes. */ | ||
this.taxes = []; | ||
/** Line items details. */ | ||
@@ -45,3 +43,2 @@ this.lineItems = []; | ||
prediction: prediction.document_type, | ||
valueKey: "value", | ||
}); | ||
@@ -56,3 +53,2 @@ this.referenceNumbers = prediction.reference_numbers.map(function (prediction) { | ||
prediction: prediction.total_amount, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -62,3 +58,2 @@ }); | ||
prediction: { value: undefined, confidence: 0.0 }, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -68,3 +63,2 @@ }); | ||
prediction: prediction.total_net, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -76,9 +70,3 @@ }); | ||
}); | ||
prediction.taxes.map((prediction) => this.taxes.push(new fields_1.TaxField({ | ||
prediction: prediction, | ||
pageId: pageId, | ||
valueKey: "value", | ||
rateKey: "rate", | ||
codeKey: "code", | ||
}))); | ||
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId); | ||
this.supplierCompanyRegistrations = | ||
@@ -130,3 +118,2 @@ prediction.supplier_company_registrations.map(function (prediction) { | ||
toString() { | ||
const taxes = this.taxes.map((item) => item.toString()).join("\n "); | ||
const referenceNumbers = this.referenceNumbers | ||
@@ -150,22 +137,22 @@ .map((item) => item.toString()) | ||
} | ||
const outStr = `----- Invoice V4 ----- | ||
Filename: ${this.filename} | ||
Locale: ${this.locale} | ||
Invoice number: ${this.invoiceNumber} | ||
Reference numbers: ${referenceNumbers} | ||
Invoice date: ${this.date} | ||
Invoice due date: ${this.dueDate} | ||
Supplier name: ${this.supplierName} | ||
Supplier address: ${this.supplierAddress} | ||
Supplier company registrations: ${companyRegistration} | ||
Supplier payment details: ${paymentDetails} | ||
Customer name: ${this.customerName} | ||
Customer company registrations: ${customerCompanyRegistration} | ||
Customer address: ${this.customerAddress} | ||
Line Items: ${lineItems} | ||
Taxes: ${taxes} | ||
Total taxes: ${this.totalTax} | ||
Total amount excluding taxes: ${this.totalNet} | ||
Total amount including taxes: ${this.totalAmount} | ||
---------------------- | ||
const outStr = `Invoice V4 Prediction | ||
===================== | ||
:Filename: ${this.filename} | ||
:Locale: ${this.locale} | ||
:Invoice number: ${this.invoiceNumber} | ||
:Reference numbers: ${referenceNumbers} | ||
:Invoice date: ${this.date} | ||
:Invoice due date: ${this.dueDate} | ||
:Supplier name: ${this.supplierName} | ||
:Supplier address: ${this.supplierAddress} | ||
:Supplier company registrations: ${companyRegistration} | ||
:Supplier payment details: ${paymentDetails} | ||
:Customer name: ${this.customerName} | ||
:Customer company registrations: ${customerCompanyRegistration} | ||
:Customer address: ${this.customerAddress} | ||
:Line Items: ${lineItems} | ||
:Taxes: ${this.taxes} | ||
:Total tax: ${this.totalTax} | ||
:Total net: ${this.totalNet} | ||
:Total amount: ${this.totalAmount} | ||
`; | ||
@@ -172,0 +159,0 @@ return InvoiceV4.cleanOutString(outStr); |
@@ -5,3 +5,3 @@ import { Document, DocumentConstructorProps } from "../document"; | ||
/** ISO date yyyy-mm-dd. Works both for European and US dates. */ | ||
issuanceDate: DateField; | ||
date: DateField; | ||
/** All extrated ISO date yyyy-mm-dd. Works both for European and US dates. */ | ||
@@ -8,0 +8,0 @@ dates: DateField[]; |
@@ -23,3 +23,3 @@ "use strict"; | ||
}); | ||
this.issuanceDate = new fields_1.DateField({ | ||
this.date = new fields_1.DateField({ | ||
prediction: prediction.date, | ||
@@ -72,3 +72,3 @@ pageId: pageId, | ||
Dates: ${this.dates.map((rcr) => rcr.value).join("\n ")} | ||
Date of Issue: ${this.issuanceDate} | ||
Date of Issue: ${this.date} | ||
---------------------- | ||
@@ -75,0 +75,0 @@ `; |
@@ -21,3 +21,3 @@ import { Document, DocumentConstructorProps } from "../document"; | ||
totalExcl: Amount; | ||
/** List of different taxe. */ | ||
/** List of different taxes. */ | ||
taxes: TaxField[]; | ||
@@ -24,0 +24,0 @@ constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps); |
@@ -7,3 +7,3 @@ "use strict"; | ||
}; | ||
var _ReceiptV3_instances, _ReceiptV3_initFromApiPrediction, _ReceiptV3_checklist, _ReceiptV3_taxesMatchTotal, _ReceiptV3_reconstruct, _ReceiptV3_reconstructTotalExclFromTCCAndTaxes, _ReceiptV3_reconstructTotalTax; | ||
var _ReceiptV3_instances, _ReceiptV3_checklist, _ReceiptV3_taxesMatchTotal, _ReceiptV3_reconstruct, _ReceiptV3_reconstructTotalExclFromTCCAndTaxes, _ReceiptV3_reconstructTotalTax; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -23,4 +23,2 @@ exports.ReceiptV3 = void 0; | ||
_ReceiptV3_instances.add(this); | ||
/** List of different taxe. */ | ||
this.taxes = []; | ||
this.locale = new fields_1.Locale({ | ||
@@ -31,3 +29,2 @@ prediction: prediction.locale, | ||
prediction: { value: undefined, confidence: 0 }, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -37,6 +34,24 @@ }); | ||
prediction: { value: undefined, confidence: 0 }, | ||
valueKey: "value", | ||
pageId: pageId, | ||
}); | ||
__classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_initFromApiPrediction).call(this, prediction, pageId); | ||
this.totalIncl = new fields_1.Amount({ | ||
prediction: prediction.total_incl, | ||
pageId: pageId, | ||
}); | ||
this.date = new fields_1.DateField({ | ||
prediction: prediction.date, | ||
pageId: pageId, | ||
}); | ||
this.category = new fields_1.ClassificationField({ | ||
prediction: prediction.category, | ||
}); | ||
this.merchantName = new fields_1.TextField({ | ||
prediction: prediction.supplier, | ||
pageId: pageId, | ||
}); | ||
this.time = new fields_1.TextField({ | ||
prediction: prediction.time, | ||
pageId: pageId, | ||
}); | ||
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId); | ||
__classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_checklist).call(this); | ||
@@ -46,15 +61,14 @@ __classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_reconstruct).call(this); | ||
toString() { | ||
const taxes = this.taxes.map((item) => item.toString()).join("\n "); | ||
const outStr = `-----Receipt data----- | ||
Filename: ${this.filename} | ||
Total amount including taxes: ${this.totalIncl} | ||
Total amount excluding taxes: ${this.totalExcl} | ||
Date: ${this.date} | ||
Category: ${this.category} | ||
Time: ${this.time} | ||
Merchant name: ${this.merchantName} | ||
Taxes: ${taxes} | ||
Total taxes: ${this.totalTax} | ||
Locale: ${this.locale} | ||
---------------------- | ||
const outStr = `Receipt V3 Prediction | ||
===================== | ||
:Filename: ${this.filename} | ||
:Total amount: ${this.totalIncl} | ||
:Total net: ${this.totalExcl} | ||
:Date: ${this.date} | ||
:Category: ${this.category} | ||
:Time: ${this.time} | ||
:Merchant name: ${this.merchantName} | ||
:Taxes: ${this.taxes} | ||
:Total tax: ${this.totalTax} | ||
:Locale: ${this.locale} | ||
`; | ||
@@ -65,31 +79,3 @@ return ReceiptV3.cleanOutString(outStr); | ||
exports.ReceiptV3 = ReceiptV3; | ||
_ReceiptV3_instances = new WeakSet(), _ReceiptV3_initFromApiPrediction = function _ReceiptV3_initFromApiPrediction(apiPrediction, pageId) { | ||
this.totalIncl = new fields_1.Amount({ | ||
prediction: apiPrediction.total_incl, | ||
valueKey: "value", | ||
pageId: pageId, | ||
}); | ||
this.date = new fields_1.DateField({ | ||
prediction: apiPrediction.date, | ||
pageId: pageId, | ||
}); | ||
this.category = new fields_1.ClassificationField({ | ||
prediction: apiPrediction.category, | ||
}); | ||
this.merchantName = new fields_1.TextField({ | ||
prediction: apiPrediction.supplier, | ||
pageId: pageId, | ||
}); | ||
this.time = new fields_1.TextField({ | ||
prediction: apiPrediction.time, | ||
pageId: pageId, | ||
}); | ||
apiPrediction.taxes.map((taxPrediction) => this.taxes.push(new fields_1.TaxField({ | ||
prediction: taxPrediction, | ||
pageId: pageId, | ||
valueKey: "value", | ||
rateKey: "rate", | ||
codeKey: "code", | ||
}))); | ||
}, _ReceiptV3_checklist = function _ReceiptV3_checklist() { | ||
_ReceiptV3_instances = new WeakSet(), _ReceiptV3_checklist = function _ReceiptV3_checklist() { | ||
this.checklist = { taxesMatchTotalIncl: __classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_taxesMatchTotal).call(this) }; | ||
@@ -96,0 +82,0 @@ }, _ReceiptV3_taxesMatchTotal = function _ReceiptV3_taxesMatchTotal() { |
@@ -15,4 +15,2 @@ "use strict"; | ||
}); | ||
/** List of taxes detected on the receipt. */ | ||
this.taxes = []; | ||
this.locale = new fields_1.Locale({ | ||
@@ -23,3 +21,2 @@ prediction: prediction.locale, | ||
prediction: prediction.total_tax, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -29,3 +26,2 @@ }); | ||
prediction: prediction.total_amount, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -35,3 +31,2 @@ }); | ||
prediction: prediction.total_net, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -41,3 +36,2 @@ }); | ||
prediction: prediction.tip, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -67,28 +61,20 @@ }); | ||
}); | ||
prediction.taxes.map((taxPrediction) => this.taxes.push(new fields_1.TaxField({ | ||
prediction: taxPrediction, | ||
pageId: pageId, | ||
valueKey: "value", | ||
rateKey: "rate", | ||
codeKey: "code", | ||
baseKey: "base", | ||
}))); | ||
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId); | ||
} | ||
toString() { | ||
const taxes = this.taxes.map((item) => item.toString()).join("\n "); | ||
const outStr = `----- Receipt V4 ----- | ||
Filename: ${this.filename} | ||
Total amount: ${this.totalAmount} | ||
Total net: ${this.totalNet} | ||
Tip: ${this.tip} | ||
Date: ${this.date} | ||
Category: ${this.category} | ||
Subcategory: ${this.subCategory} | ||
Document type: ${this.documentType} | ||
Time: ${this.time} | ||
Supplier name: ${this.supplier} | ||
Taxes: ${taxes} | ||
Total taxes: ${this.totalTax} | ||
Locale: ${this.locale} | ||
---------------------- | ||
const outStr = `Receipt V4 Prediction | ||
===================== | ||
:Filename: ${this.filename} | ||
:Total amount: ${this.totalAmount} | ||
:Total net: ${this.totalNet} | ||
:Tip: ${this.tip} | ||
:Date: ${this.date} | ||
:Category: ${this.category} | ||
:Subcategory: ${this.subCategory} | ||
:Document type: ${this.documentType} | ||
:Time: ${this.time} | ||
:Supplier name: ${this.supplier} | ||
:Taxes: ${this.taxes} | ||
:Total tax: ${this.totalTax} | ||
:Locale: ${this.locale} | ||
`; | ||
@@ -95,0 +81,0 @@ return ReceiptV4.cleanOutString(outStr); |
@@ -26,3 +26,2 @@ "use strict"; | ||
prediction: prediction.amount, | ||
valueKey: "value", | ||
pageId: pageId, | ||
@@ -29,0 +28,0 @@ }); |
@@ -20,3 +20,3 @@ "use strict"; | ||
*/ | ||
constructor({ prediction, valueKey = "amount", reconstructed = false, pageId = undefined, }) { | ||
constructor({ prediction, valueKey = "value", reconstructed = false, pageId = undefined, }) { | ||
super({ prediction, valueKey, reconstructed, pageId }); | ||
@@ -23,0 +23,0 @@ /** The value. */ |
export { ClassificationField } from "./classification"; | ||
export { TaxField } from "./tax"; | ||
export { Taxes, TaxField } from "./tax"; | ||
export { PaymentDetails } from "./paymentDetails"; | ||
@@ -4,0 +4,0 @@ export { OrientationField } from "./orientation"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TextField = exports.PositionField = exports.CompanyRegistration = exports.FullText = exports.BaseField = exports.DateField = exports.Amount = exports.Locale = exports.OrientationField = exports.PaymentDetails = exports.TaxField = exports.ClassificationField = void 0; | ||
exports.TextField = exports.PositionField = exports.CompanyRegistration = exports.FullText = exports.BaseField = exports.DateField = exports.Amount = exports.Locale = exports.OrientationField = exports.PaymentDetails = exports.TaxField = exports.Taxes = exports.ClassificationField = void 0; | ||
var classification_1 = require("./classification"); | ||
Object.defineProperty(exports, "ClassificationField", { enumerable: true, get: function () { return classification_1.ClassificationField; } }); | ||
var tax_1 = require("./tax"); | ||
Object.defineProperty(exports, "Taxes", { enumerable: true, get: function () { return tax_1.Taxes; } }); | ||
Object.defineProperty(exports, "TaxField", { enumerable: true, get: function () { return tax_1.TaxField; } }); | ||
@@ -8,0 +9,0 @@ var paymentDetails_1 = require("./paymentDetails"); |
@@ -13,2 +13,3 @@ import { StringDict } from "./base"; | ||
export declare class TaxField extends Field { | ||
#private; | ||
/** The tax amount. */ | ||
@@ -34,4 +35,10 @@ value?: number; | ||
constructor({ prediction, valueKey, rateKey, codeKey, baseKey, reconstructed, pageId, }: TaxConstructor); | ||
toTableLine(): string; | ||
toString(): string; | ||
} | ||
export declare class Taxes extends Array<TaxField> { | ||
#private; | ||
init(prediction: StringDict[], pageId: number | undefined): this; | ||
toString(): string; | ||
} | ||
export {}; |
"use strict"; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
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"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _TaxField_instances, _TaxField_printableValues, _Taxes_instances, _Taxes_lineSeparator; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TaxField = void 0; | ||
exports.Taxes = exports.TaxField = void 0; | ||
const field_1 = require("./field"); | ||
@@ -18,2 +24,3 @@ const amount_1 = require("./amount"); | ||
super({ prediction, valueKey, reconstructed, pageId }); | ||
_TaxField_instances.add(this); | ||
/** The tax amount. */ | ||
@@ -43,19 +50,68 @@ this.value = undefined; | ||
} | ||
toTableLine() { | ||
const printable = __classPrivateFieldGet(this, _TaxField_instances, "m", _TaxField_printableValues).call(this); | ||
return ("| " + | ||
printable.base.padEnd(13) + | ||
" | " + | ||
printable.code.padEnd(6) + | ||
" | " + | ||
printable.rate.padEnd(8) + | ||
" | " + | ||
printable.value.padEnd(13) + | ||
" |"); | ||
} | ||
toString() { | ||
let outStr = ""; | ||
if (this.value !== undefined) { | ||
outStr += `${(0, amount_1.floatToString)(this.value)}`; | ||
const printable = __classPrivateFieldGet(this, _TaxField_instances, "m", _TaxField_printableValues).call(this); | ||
return ("Base: " + | ||
printable.base + | ||
", Code: " + | ||
printable.code + | ||
", Rate (%): " + | ||
printable.rate + | ||
", Amount: " + | ||
printable.value).trim(); | ||
} | ||
} | ||
exports.TaxField = TaxField; | ||
_TaxField_instances = new WeakSet(), _TaxField_printableValues = function _TaxField_printableValues() { | ||
return { | ||
code: this.code ?? "", | ||
base: this.base !== undefined ? (0, amount_1.floatToString)(this.base) : "", | ||
rate: this.rate !== undefined ? (0, amount_1.floatToString)(this.rate) : "", | ||
value: this.value !== undefined ? (0, amount_1.floatToString)(this.value) : "", | ||
}; | ||
}; | ||
class Taxes extends Array { | ||
constructor() { | ||
super(...arguments); | ||
_Taxes_instances.add(this); | ||
} | ||
init(prediction, pageId) { | ||
for (const entry of prediction) { | ||
this.push(new TaxField({ | ||
prediction: entry, | ||
pageId: pageId, | ||
})); | ||
} | ||
if (this.rate !== undefined) { | ||
outStr += ` ${(0, amount_1.floatToString)(this.rate)}%`; | ||
return this; | ||
} | ||
toString() { | ||
let outStr = ` | ||
${__classPrivateFieldGet(this, _Taxes_instances, "m", _Taxes_lineSeparator).call(this, "-")} | ||
| Base | Code | Rate (%) | Amount | | ||
${__classPrivateFieldGet(this, _Taxes_instances, "m", _Taxes_lineSeparator).call(this, "=")}`; | ||
for (const entry of this.entries()) { | ||
outStr += `\n ${entry[1].toTableLine()}\n${__classPrivateFieldGet(this, _Taxes_instances, "m", _Taxes_lineSeparator).call(this, "-")}`; | ||
} | ||
if (this.code !== undefined) { | ||
outStr += ` ${this.code}`; | ||
} | ||
if (this.base !== undefined) { | ||
outStr += ` ${(0, amount_1.floatToString)(this.base)}`; | ||
} | ||
return outStr.trim(); | ||
return outStr; | ||
} | ||
} | ||
exports.TaxField = TaxField; | ||
exports.Taxes = Taxes; | ||
_Taxes_instances = new WeakSet(), _Taxes_lineSeparator = function _Taxes_lineSeparator(char) { | ||
let outStr = " "; | ||
outStr += `+${char.repeat(15)}`; | ||
outStr += `+${char.repeat(8)}`; | ||
outStr += `+${char.repeat(10)}`; | ||
outStr += `+${char.repeat(15)}`; | ||
return outStr + "+"; | ||
}; |
@@ -1,4 +0,4 @@ | ||
export { CustomV1, Document, FinancialDocumentV0, FinancialDocumentV1, InvoiceV3, InvoiceV4, InvoiceSplitterV1, PassportV1, ReceiptV3, ReceiptV4, CropperV1, ShippingContainerV1, MindeeVisionV1, ProofOfAddressV1, fr, us, eu, } from "./documents"; | ||
export { CustomV1, Document, FinancialDocumentV0, FinancialDocumentV1, InvoiceV3, InvoiceV4, InvoiceSplitterV1, PassportV1, ReceiptV3, ReceiptV4, ReceiptV5, CropperV1, ShippingContainerV1, MindeeVisionV1, ProofOfAddressV1, fr, us, eu, } from "./documents"; | ||
export { Client, ClientOptions, CustomConfigParams, DocumentClient, PredictOptions, } from "./client"; | ||
export { ResponseSig, Response, AsyncPredictResponse } from "./api"; | ||
export { InputSource, PageOptionsOperation } from "./inputs"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PageOptionsOperation = exports.InputSource = exports.AsyncPredictResponse = exports.Response = exports.DocumentClient = exports.Client = exports.eu = exports.us = exports.fr = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.ShippingContainerV1 = exports.CropperV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.Document = exports.CustomV1 = void 0; | ||
exports.PageOptionsOperation = exports.InputSource = exports.AsyncPredictResponse = exports.Response = exports.DocumentClient = exports.Client = exports.eu = exports.us = exports.fr = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.ShippingContainerV1 = exports.CropperV1 = exports.ReceiptV5 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.Document = exports.CustomV1 = void 0; | ||
var documents_1 = require("./documents"); | ||
@@ -15,2 +15,3 @@ Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return documents_1.CustomV1; } }); | ||
Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return documents_1.ReceiptV4; } }); | ||
Object.defineProperty(exports, "ReceiptV5", { enumerable: true, get: function () { return documents_1.ReceiptV5; } }); | ||
Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return documents_1.CropperV1; } }); | ||
@@ -17,0 +18,0 @@ Object.defineProperty(exports, "ShippingContainerV1", { enumerable: true, get: function () { return documents_1.ShippingContainerV1; } }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
259849
136
6188