@@ -14,38 +14,46 @@ mindee_client = Client(api_key="my-api-key")
1414# Load a file from disk
1515input_doc = mindee_client.doc_from_path(" /path/to/the/file.ext" )
1616
17- # Parse the document as an Invoice by passing the appropriate type
18- api_response = input_doc.parse(documents.TypeInvoiceV4)
17+ # Parse the Invoice by passing the appropriate type
18+ result = input_doc.parse(documents.TypeInvoiceV4)
1919
20- print (api_response.document)
20+ # Print a brief summary of the parsed data
21+ print (result.document)
2122```
2223
2324Output:
2425```
25- ----- Invoice V4 -----
26- Filename: a74eaa5-c8e283b-sample_invoice.jpeg
27- Locale: en; en; CAD;
28- Invoice number: 14
29- Reference numbers: AD29094
30- Invoice date: 2018-09-25
31- Invoice due date: 2018-09-25
32- Supplier name: TURNPIKE DESIGNS CO.
33- Supplier address: 156 University Ave, Toronto ON, Canada M5H 2H7
34- Supplier company registrations:
35- Supplier payment details:
36- Customer name: JIRO DOI
37- Customer company registrations:
38- Customer address: 1954 Bloon Street West Toronto, ON, M6P 3K9 Canada
39- Line Items:
26+ Invoice V4 Prediction
27+ =====================
28+ :Filename:
29+ :Locale: fr; fr; EUR;
30+ :Invoice number: 0042004801351
31+ :Reference numbers: AD29094
32+ :Invoice date: 2020-02-17
33+ :Invoice due date: 2020-02-17
34+ :Supplier name: TURNPIKE DESIGNS CO.
35+ :Supplier address: 156 University Ave, Toronto ON, Canada M5H 2H7
36+ :Supplier company registrations: 501124705; FR33501124705
37+ :Supplier payment details: FR7640254025476501124705368;
38+ :Customer name: JIRO DOI
39+ :Customer company registrations: FR00000000000; 111222333
40+ :Customer address: 1954 Bloon Street West Toronto, ON, M6P 3K9 Canada
41+ :Line Items:
4042 Code | QTY | Price | Amount | Tax (Rate) | Description
41- | 1.00 | 65.00 | 65.00 | | Platinum web hosting package Dow...
42- | 3.00 | 2100.00 | 2100.00 | | 2 page website design Includes b...
43- | 1.00 | 250.00 | 250.00 | | Mobile designs Includes responsi...
44- Taxes: 193.20 8.00%
45- Total taxes: 193.20
46- Total amount excluding taxes: 2415.00
47- Total amount including taxes: 2608.20
48- ----------------------
43+ | | | 4.31 | (2.10%) | PQ20 ETIQ ULTRA RESIS METAXXDC
44+ | 1.00 | 65.00 | 75.00 | 10.00 | Platinum web hosting package Dow...
45+ XXX81125600010 | 1.00 | 250.01 | 275.51 | 25.50 (10.20%) | a long string describing the ite...
46+ ABC456 | 200.30 | 8.101 | 1622.63 | 121.70 (7.50%) | Liquid perfection
47+ | | | | | CARTOUCHE L NR BROTHER TN247BK
48+ :Taxes:
49+ +---------------+--------+----------+---------------+
50+ | Base | Code | Rate (%) | Amount |
51+ +===============+========+==========+===============+
52+ | | | 20.00 | 97.98 |
53+ +---------------+--------+----------+---------------+
54+ :Total tax: 97.98
55+ :Total net: 489.97
56+ :Total amount: 587.95
4957```
5058
5159## Invoice Data Structure
@@ -64,23 +72,23 @@ Basically, we iterate over each page, and for each field, we keep the one that h
6472For example, if you send a three-page invoice, the document level will provide you with one tax, one total, and so on.
6573
6674``` python
67- print (api_response .document)
75+ print (result .document)
6876```
6977
7078### Page Level Prediction
7179For page level prediction, in a multi-page pdf we construct the document class by using a unique page of the pdf.
7280
7381``` python
7482# [InvoiceV4, InvoiceV4 ...]
75- invoice_data .pages
83+ result .pages
7684```
7785
7886### Raw HTTP Response
7987This contains the full Mindee API HTTP response object in JSON format
8088
8189``` python
8290# full HTTP request object
83- invoice_data .http_response
91+ result .http_response
8492```
8593
8694## Extracted Fields
@@ -112,21 +120,21 @@ Depending on the field type, there might be additional attributes that will be e
112120
113121``` python
114122# To get the customer name (string)
115- customer_name = invoice_data .document.customer_name.value
123+ customer_name = result .document.customer_name.value
116124```
117125
118126- ** customer_address** : Customer's address
119127
120128``` python
121129# To get the customer address (string)
122- customer_address = invoice_data .document.customer_address.value
130+ customer_address = result .document.customer_address.value
123131```
124132
125133- ** customer_company_registrations** : Customer Company Registration
126134
127135``` python
128136# To get the customer company registation (string)
129- customer_company_registrations = invoice_data .document.customer_company_registrations
137+ customer_company_registrations = result .document.customer_company_registrations
130138
131139for customer_company_registration in customer_company_registrations:
132140 # To get the type of number
@@ -143,14 +151,14 @@ for customer_company_registration in customer_company_registrations:
143151
144152``` python
145153# To get the invoice date of issuance (string)
146- invoice_date = invoice_data .document.invoice_date.value
154+ invoice_date = result .document.invoice_date.value
147155```
148156
149157- ** due_date** : Payment due date of the invoice.
150158
151159``` python
152160# To get the invoice due date (string)
153- due_date = invoice_data .document.due_date.value
161+ due_date = result .document.due_date.value
154162```
155163
156164### Locale and Currency
@@ -159,14 +167,14 @@ due_date = invoice_data.document.due_date.value
159167
160168``` python
161169# To get the total language code
162- language = invoice_data .document.locale.value
170+ language = result .document.locale.value
163171```
164172
165173- ** currency** (String): ISO currency code.
166174
167175``` python
168176# To get the invoice currency code
169- currency = invoice_data .document.locale.currency
177+ currency = result .document.locale.currency
170178```
171179
172180### Payment Information
@@ -179,7 +187,7 @@ currency = invoice_data.document.locale.currency
179187
180188``` python
181189# To get the list of payment details
182- payment_details = invoice_data .document.payment_details
190+ payment_details = result .document.payment_details
183191
184192# Loop on each object
185193for payment_detail in payment_details:
@@ -206,7 +214,7 @@ for payment_detail in payment_details:
206214
207215``` python
208216# To get the list of payment details
209- reference_numbers = invoice_data .document.reference_numbers
217+ reference_numbers = result .document.reference_numbers
210218
211219# Loop on each object
212220for reference_number in reference_numbers:
@@ -222,7 +230,7 @@ for reference_number in reference_numbers:
222230
223231``` python
224232# To get the list of company numbers
225- supplier_company_registrations = invoice_data .document.supplier_company_registrations
233+ supplier_company_registrations = result .document.supplier_company_registrations
226234
227235# Loop on each object
228236for company_registration in supplier_company_registrations:
@@ -237,14 +245,14 @@ for company_registration in supplier_company_registrations:
237245
238246``` python
239247# To get the supplier name
240- supplier_name = invoice_data .document.supplier_name.value
248+ supplier_name = result .document.supplier_name.value
241249```
242250
243251- ** supplier_address** : Supplier address as written in the invoice.
244252
245253``` python
246254# To get the supplier address
247- supplier_address = invoice_data .document.supplier_address.value
255+ supplier_address = result .document.supplier_address.value
248256```
249257
250258### Taxes
@@ -255,7 +263,7 @@ supplier_address = invoice_data.document.supplier_address.value
255263
256264``` python
257265# To get the list of taxes
258- taxes = invoice_data .document.taxes
266+ taxes = result .document.taxes
259267
260268# Loop on each Tax field
261269for tax in taxes:
@@ -275,21 +283,21 @@ for tax in taxes:
275283
276284``` python
277285# To get the total amount including taxes value (float), ex: 14.24
278- total_amount = invoice_data .document.total_amount.value
286+ total_amount = result .document.total_amount.value
279287```
280288
281289- ** total_net** : Total amount excluding taxes.
282290
283291``` python
284292# To get the total amount excluding taxes value (float), ex: 10.21
285- total_net = invoice_data .document.total_net.value
293+ total_net = result .document.total_net.value
286294```
287295
288296- ** total_tax** : Total tax value from tax lines.
289297
290298``` python
291299# To get the total tax amount value (float), ex: 8.42
292- total_tax = invoice_data .document.total_tax.value
300+ total_tax = result .document.total_tax.value
293301```
294302
295303### Line Items
@@ -307,7 +315,7 @@ total_tax = invoice_data.document.total_tax.value
307315
308316``` python
309317# Loop on line items
310- for line_item in invoice_data .document.line_items:
318+ for line_item in result .document.line_items:
311319 # Show just the description
312320 print (line_item.description)
313321
0 commit comments