Invoice fields
General fields structure
Each invoice object contains a set of different fields.
To access an invoice object, you need to create a mindee.Client
and call the Client.
invoice.parse
method:
const { Client } = require("mindee");
const mindeeClient = new Client({
invoiceToken: "yourInvoiceToken"
});
mindeeClient.invoice.parse(
"path/to/file.jpg",
'path',
version = "2",
cutPdf = true,
includeWords = false
)
.then((res) => {
console.log(res.invoice);
})
.catch((err) => {
console.error(err);
});
Whatever the field type, each of them contains the four following attributes:
- Value: (Str or Float depending on the field type), corresponds to the field value. Set to None if the field was not extracted. For reconstructed fields, the value attribute might not be present in the field (this will be changed in a later version of the node.js SDK)
- Probability: (Float), the confidence score of the field prediction.
- bbox:(Array[Float]), contains the relative vertices coordinates of the bounding box containing the field in the image. If the field is not written, the bbox is an empty array.
- reconstructed: (Bool), True if the field was reconstructed using other fields.
- pageNumber: (int), the page number of the extracted field
Depending on the Field type, there can be extra attributes.
Total amounts
invoice.totalIncl: Total amount including taxes
invoice.totalExcl: Total amount excluding taxes
invoice.totalTax: Total tax value reconstructed from tax lines
mindeeClient.invoice.parse(
"invoice.png",
'path',
)
.then((res) => {
console.log(res.invoice.totalIncl);
console.log(res.invoice.totalExcl);
console.log(res.invoice.totalTax);
})
.catch((err) => {
console.error(err);
});
{
pageNumber: 0,
reconstructed: false,
value: 38.92,
probability: 0.99,
bbox: [
[ 0.865, 0.641 ],
[ 0.955, 0.641 ],
[ 0.955, 0.675 ],
[ 0.865, 0.675 ]
]
}
{
pageNumber: 0,
reconstructed: false,
value: 36.72,
probability: 0.99,
bbox: [
[ 0.898, 0.709 ],
[ 0.955, 0.709 ],
[ 0.955, 0.734 ],
[ 0.898, 0.734 ]
]
}
{
pageNumber: 0,
reconstructed: true,
value: 2.2,
probability: 0.9801,
bbox: []
}
Taxes
invoice.taxes: Array of Tax fields
Each of the tax fields has two extra attributes:
- rate: (Float), Optional tax rate.
mindeeClient.invoice.parse(
"invoice.png",
'path',
)
.then((res) => {
console.log(res.invoice.taxes);
})
.catch((err) => {
console.error(err);
});
[
{
pageNumber: 0,
reconstructed: false,
value: 1.7,
probability: 1,
bbox: [ [Array], [Array], [Array], [Array] ],
rate: 20
}
]
Dates
Each date field comes with an extra attribute:
- dateObject:: (Datetime), DateTime object
invoice.invoiceDate: Issuance date of the invoice
invoice.dueDate: Due date of payment of the invoice
mindeeClient.invoice.parse(
"invoice.png",
'path',
)
.then((res) => {
console.log(res.invoice.invoiceDate);
console.log(res.invoice.dueDate);
})
.catch((err) => {
console.error(err);
});
{
pageNumber: 0,
reconstructed: false,
value: '2021-01-28',
probability: 0.99,
bbox: [
[ 0.395, 0.448 ],
[ 0.474, 0.448 ],
[ 0.474, 0.462 ],
[ 0.395, 0.462 ]
],
dateObject: '2021-01-28T00:00:00.000Z'
}
{
pageNumber: 0,
reconstructed: false,
value: '2021-01-28',
probability: 0.94,
bbox: [
[ 0.394, 0.448 ],
[ 0.474, 0.448 ],
[ 0.474, 0.464 ],
[ 0.394, 0.464 ]
],
dateObject: '2021-01-28T00:00:00.000Z'
}
Supplier information
invoice.supplier: Supplier name as written in the invoice
invoice.paymentDetails: List of Supplier's payment details written in the invoice
invoice.companyNumber: Supplier's company number
mindeeClient.invoice.parse(
"invoice.png",
'path',
)
.then((res) => {
console.log(res.invoice.supplier);
console.log(res.invoice.paymentDetails);
console.log(res.invoice.companyNumber);
})
.catch((err) => {
console.error(err);
});
{
pageNumber: 0,
reconstructed: false,
value: 'Google',
probability: 0.18,
bbox: [
[ 0.125, 0.074 ],
[ 0.172, 0.074 ],
[ 0.172, 0.083 ],
[ 0.125, 0.083 ]
]
}
[
{
pageNumber: 0,
reconstructed: false,
value: 'EE657700xxxxxx265345',
probability: 0.97,
bbox: [ [Array], [Array], [Array], [Array] ],
iban: 'EE6xxxxxxxxxx345',
swift: 'LxxxxxE22'
}
]
[
{
pageNumber: 0,
reconstructed: false,
value: '513xxxx80',
probability: 0.9,
bbox: [ [Array], [Array], [Array], [Array] ],
type: 'NIF'
},
{
pageNumber: 0,
reconstructed: false,
value: 'Pxxxxxx004',
probability: 0.99,
bbox: [ [Array], [Array], [Array], [Array] ],
type: 'VAT NUMBER'
}
]
Locale and currency
locale: Language ISO code
Contains an extra attribute:
- currency: (String), ISO currency code
mindeeClient.invoice.parse(
"invoice.png",
'path',
)
.then((res) => {
console.log(res.invoice.locale);
})
.catch((err) => {
console.error(err);
});
{
pageNumber: 0,
reconstructed: false,
probability: 0,
bbox: [],
language: 'pt',
currency: 'EUR'
}
InvoiceNumber
mindeeClient.invoice.parse(
"invoice.png",
'path',
)
.then((res) => {
console.log(res.invoice.invoiceNumber);
})
.catch((err) => {
console.error(err);
});
{
pageNumber: 0,
reconstructed: false,
value: 'Fxxxxxx1/4',
probability: 0.98,
bbox: [
[ 0.805, 0.09 ],
[ 0.954, 0.09 ],
[ 0.954, 0.112 ],
[ 0.805, 0.112 ]
]
}