Receipt fields

 

 

General fields structure

 

Each receipt object contains a set of different fields.

 

To access a receipt object, you need to create a mindee.Client and call the Client.receipt.parse method:

 

const { Client } = require("mindee");

const mindeeClient = new Client({
  receiptToken: "yourReceiptToken"
});

mindeeClient.receipt.parse(
  "path/to/file.jpg",
  'path',
  version = "3",
  cutPdf = true,
  includeWords = false
)
  .then((res) => {
    console.log(res.receipt);
  })
  .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

 

receipt.totalIncl: Total amount including taxes

receipt.totalExcl: Total amount excluding taxes

receipt.totalTax: Total tax value reconstructed from tax lines

 


mindeeClient.receipt.parse(
  "path/to/file.jpg",
  'path'
)
  .then((res) => {
    console.log(res.receipt.totalIncl);
    console.log(res.receipt.totalExcl);
    console.log(res.receipt.totalTax);
  })
  .catch((err) => {
    console.error(err);
  });

 

For a single receipt, this code print in your console something like:

 

{
  pageNumber: 0,
  reconstructed: false,
  value: 10.2,
  probability: 1,
  bbox: [
    [ 0.549, 0.619 ],
    [ 0.715, 0.619 ],
    [ 0.715, 0.64 ],
    [ 0.549, 0.64 ]
  ]
}
{
  pageNumber: 0,
  reconstructed: true,
  value: 8.5,
  probability: 1,
  bbox: []
}
{
  pageNumber: 0,
  reconstructed: true,
  value: 1.7,
  probability: 1,
  bbox: []
}

 

Taxes

 

receipt.taxes: Array of Tax fields

Each of the tax fields has two extra attributes:

 

  • code: (String), Optional tax code. (HST, GST... for Canadian; City Tax, State tax for US, etc..)
  • rate: (Float), Optional tax rate.

 

mindeeClient.receipt.parse(
  "path/to/file.jpg",
  'path'
)
  .then((res) => {
    console.log(res.receipt.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 

 

 

 receipt.date: Payment date of the receipt

 

mindeeClient.receipt.parse(
  "path/to/file.jpg",
  'path'
)
  .then((res) => {
    console.log(res.receipt.taxes);
  })
  .catch((err) => {
    console.error(err);
  });

 

{
  pageNumber: 0,
  reconstructed: false,
  value: '2016-02-26',
  probability: 0.99,
  bbox: [
    [ 0.479, 0.173 ],
    [ 0.613, 0.173 ],
    [ 0.613, 0.197 ],
    [ 0.479, 0.197 ]
  ],
  dateObject: '2016-02-26T00:00:00.000Z'
}

 

 

Supplier information

 

 receipt.supplier: Supplier name as written in the receipt (logo)

 

mindeeClient.receipt.parse(
  "path/to/file.jpg",
  'path'
)
  .then((res) => {
    console.log(res.receipt.merchantName);
  })
  .catch((err) => {
    console.error(err);
  });

 

{
  pageNumber: 0,
  reconstructed: false,
  value: 'CLACHAN',
  probability: 0.71,
  bbox: [
    [ 0.394, 0.068 ],
    [ 0.477, 0.068 ],
    [ 0.477, 0.087 ],
    [ 0.394, 0.087 ]
  ]
}

 

 

Locale and currency

 

locale: Language ISO code

Contains an extra attribute:

 

  • currency: (String), ISO currency code

 

mindeeClient.receipt.parse(
  "path/to/file.jpg",
  'path'
)
  .then((res) => {
    console.log(res.receipt.locale);
  })
  .catch((err) => {
    console.error(err);
  });

 

{
  pageNumber: 0,
  reconstructed: false,
  value: 'en-GB',
  probability: 0.82,
  bbox: [],
  language: 'en',
  country: 'GB',
  currency: 'GBP'
}

 

 

 Category

 

category: Receipt category among the list:  toll, food, parking, transport, accommodation, gasoline, miscellaneous

 

mindeeClient.receipt.parse(
  "path/to/file.jpg",
  'path'
)
  .then((res) => {
    console.log(res.receipt.category);
  })
  .catch((err) => {
    console.error(err);
  });

 

{
  pageNumber: 0,
  reconstructed: false,
  value: 'food',
  probability: 0.99,
  bbox: []
}

 

 

 Time

 

time: Time of purchase with 24 hours formatting (hh:mm)

 

mindeeClient.receipt.parse(
  "path/to/file.jpg",
  'path'
)
  .then((res) => {
    console.log(res.receipt.time);
  })
  .catch((err) => {
    console.error(err);
  });

 

{
  pageNumber: 0,
  reconstructed: false,
  value: '15:20',
  probability: 0.99,
  bbox: [
    [ 0.62, 0.173 ],
    [ 0.681, 0.173 ],
    [ 0.681, 0.191 ],
    [ 0.62, 0.191 ]
  ]
}