Skip to content

Commit 55ffe1b

Browse files
authored
✨ add support for financial document v1.6 and invoice 4.6 (#233)
1 parent e6845ce commit 55ffe1b

File tree

8 files changed

+209
-116
lines changed

8 files changed

+209
-116
lines changed

docs/extras/guide/financial_document_v1.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ A `FinancialDocumentV1LineItem` implements the following attributes:
215215
# Attributes
216216
The following fields are extracted for Financial Document V1:
217217

218+
## Billing Address
219+
**billing_address** ([StringField](#stringfield)): The customer's address used for billing.
220+
221+
```py
222+
print(result.document.inference.prediction.billing_address.value)
223+
```
224+
218225
## Purchase Category
219226
**category** ([ClassificationField](#classificationfield)): The purchase category among predefined classes.
220227

@@ -237,6 +244,13 @@ for customer_company_registrations_elem in result.document.inference.prediction.
237244
print(customer_company_registrations_elem.value)
238245
```
239246

247+
## Customer ID
248+
**customer_id** ([StringField](#stringfield)): The customer account number or identifier from the supplier.
249+
250+
```py
251+
print(result.document.inference.prediction.customer_id.value)
252+
```
253+
240254
## Customer Name
241255
**customer_name** ([StringField](#stringfield)): The name of the customer.
242256

@@ -295,6 +309,13 @@ for reference_numbers_elem in result.document.inference.prediction.reference_num
295309
print(reference_numbers_elem.value)
296310
```
297311

312+
## Shipping Address
313+
**shipping_address** ([StringField](#stringfield)): The customer's address used for shipping.
314+
315+
```py
316+
print(result.document.inference.prediction.shipping_address.value)
317+
```
318+
298319
## Purchase Subcategory
299320
**subcategory** ([ClassificationField](#classificationfield)): The purchase subcategory among predefined classes for transport and food.
300321

@@ -317,6 +338,13 @@ for supplier_company_registrations_elem in result.document.inference.prediction.
317338
print(supplier_company_registrations_elem.value)
318339
```
319340

341+
## Supplier Email
342+
**supplier_email** ([StringField](#stringfield)): The email of the supplier or merchant.
343+
344+
```py
345+
print(result.document.inference.prediction.supplier_email.value)
346+
```
347+
320348
## Supplier Name
321349
**supplier_name** ([StringField](#stringfield)): The name of the supplier or merchant.
322350

@@ -339,6 +367,13 @@ for supplier_payment_details_elem in result.document.inference.prediction.suppli
339367
print(result.document.inference.prediction.supplier_phone_number.value)
340368
```
341369

370+
## Supplier Website
371+
**supplier_website** ([StringField](#stringfield)): The website URL of the supplier or merchant.
372+
373+
```py
374+
print(result.document.inference.prediction.supplier_website.value)
375+
```
376+
342377
## Taxes
343378
**taxes** (List[[TaxField](#taxes)]): List of tax lines information.
344379

docs/extras/guide/invoices_v4.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ for customer_company_registrations_elem in result.document.inference.prediction.
231231
print(customer_company_registrations_elem.value)
232232
```
233233

234+
## Customer ID
235+
**customer_id** ([StringField](#stringfield)): The customer account number or identifier from the supplier.
236+
237+
```py
238+
print(result.document.inference.prediction.customer_id.value)
239+
```
240+
234241
## Customer Name
235242
**customer_name** ([StringField](#stringfield)): The name of the customer or client.
236243

@@ -311,6 +318,13 @@ for supplier_company_registrations_elem in result.document.inference.prediction.
311318
print(supplier_company_registrations_elem.value)
312319
```
313320

321+
## Supplier Email
322+
**supplier_email** ([StringField](#stringfield)): The email of the supplier or merchant.
323+
324+
```py
325+
print(result.document.inference.prediction.supplier_email.value)
326+
```
327+
314328
## Supplier Name
315329
**supplier_name** ([StringField](#stringfield)): The name of the supplier or merchant.
316330

@@ -326,6 +340,20 @@ for supplier_payment_details_elem in result.document.inference.prediction.suppli
326340
print(supplier_payment_details_elem.value)
327341
```
328342

343+
## Supplier Phone Number
344+
**supplier_phone_number** ([StringField](#stringfield)): The phone number of the supplier or merchant.
345+
346+
```py
347+
print(result.document.inference.prediction.supplier_phone_number.value)
348+
```
349+
350+
## Supplier Website
351+
**supplier_website** ([StringField](#stringfield)): The website URL of the supplier or merchant.
352+
353+
```py
354+
print(result.document.inference.prediction.supplier_website.value)
355+
```
356+
329357
## Taxes
330358
**taxes** (List[[TaxField](#taxes)]): List of tax line details.
331359

mindee/product/financial_document/financial_document_v1_document.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@
1919
class FinancialDocumentV1Document(Prediction):
2020
"""Document data for Financial Document, API version 1."""
2121

22+
billing_address: StringField
23+
"""The customer's address used for billing."""
2224
category: ClassificationField
2325
"""The purchase category among predefined classes."""
2426
customer_address: StringField
2527
"""The address of the customer."""
2628
customer_company_registrations: List[CompanyRegistrationField]
2729
"""List of company registrations associated to the customer."""
30+
customer_id: StringField
31+
"""The customer account number or identifier from the supplier."""
2832
customer_name: StringField
2933
"""The name of the customer."""
3034
date: DateField
@@ -41,18 +45,24 @@ class FinancialDocumentV1Document(Prediction):
4145
"""The locale detected on the document."""
4246
reference_numbers: List[StringField]
4347
"""List of Reference numbers, including PO number."""
48+
shipping_address: StringField
49+
"""The customer's address used for shipping."""
4450
subcategory: ClassificationField
4551
"""The purchase subcategory among predefined classes for transport and food."""
4652
supplier_address: StringField
4753
"""The address of the supplier or merchant."""
4854
supplier_company_registrations: List[CompanyRegistrationField]
4955
"""List of company registrations associated to the supplier."""
56+
supplier_email: StringField
57+
"""The email of the supplier or merchant."""
5058
supplier_name: StringField
5159
"""The name of the supplier or merchant."""
5260
supplier_payment_details: List[PaymentDetailsField]
5361
"""List of payment details associated to the supplier."""
5462
supplier_phone_number: StringField
5563
"""The phone number of the supplier or merchant."""
64+
supplier_website: StringField
65+
"""The website URL of the supplier or merchant."""
5666
taxes: Taxes
5767
"""List of tax lines information."""
5868
time: StringField
@@ -78,6 +88,10 @@ def __init__(
7888
:param page_id: Page number for multi pages pdf input
7989
"""
8090
super().__init__(raw_prediction, page_id)
91+
self.billing_address = StringField(
92+
raw_prediction["billing_address"],
93+
page_id=page_id,
94+
)
8195
self.category = ClassificationField(
8296
raw_prediction["category"],
8397
page_id=page_id,
@@ -90,6 +104,10 @@ def __init__(
90104
CompanyRegistrationField(prediction, page_id=page_id)
91105
for prediction in raw_prediction["customer_company_registrations"]
92106
]
107+
self.customer_id = StringField(
108+
raw_prediction["customer_id"],
109+
page_id=page_id,
110+
)
93111
self.customer_name = StringField(
94112
raw_prediction["customer_name"],
95113
page_id=page_id,
@@ -122,6 +140,10 @@ def __init__(
122140
StringField(prediction, page_id=page_id)
123141
for prediction in raw_prediction["reference_numbers"]
124142
]
143+
self.shipping_address = StringField(
144+
raw_prediction["shipping_address"],
145+
page_id=page_id,
146+
)
125147
self.subcategory = ClassificationField(
126148
raw_prediction["subcategory"],
127149
page_id=page_id,
@@ -134,6 +156,10 @@ def __init__(
134156
CompanyRegistrationField(prediction, page_id=page_id)
135157
for prediction in raw_prediction["supplier_company_registrations"]
136158
]
159+
self.supplier_email = StringField(
160+
raw_prediction["supplier_email"],
161+
page_id=page_id,
162+
)
137163
self.supplier_name = StringField(
138164
raw_prediction["supplier_name"],
139165
page_id=page_id,
@@ -146,6 +172,10 @@ def __init__(
146172
raw_prediction["supplier_phone_number"],
147173
page_id=page_id,
148174
)
175+
self.supplier_website = StringField(
176+
raw_prediction["supplier_website"],
177+
page_id=page_id,
178+
)
149179
self.taxes = Taxes(raw_prediction["taxes"], page_id=page_id)
150180
self.time = StringField(
151181
raw_prediction["time"],
@@ -230,10 +260,15 @@ def __str__(self) -> str:
230260
out_str += f":Supplier Address: {self.supplier_address}\n"
231261
out_str += f":Supplier Phone Number: {self.supplier_phone_number}\n"
232262
out_str += f":Customer Name: {self.customer_name}\n"
263+
out_str += f":Supplier Website: {self.supplier_website}\n"
264+
out_str += f":Supplier Email: {self.supplier_email}\n"
233265
out_str += (
234266
f":Customer Company Registrations: {customer_company_registrations}\n"
235267
)
236268
out_str += f":Customer Address: {self.customer_address}\n"
269+
out_str += f":Customer ID: {self.customer_id}\n"
270+
out_str += f":Shipping Address: {self.shipping_address}\n"
271+
out_str += f":Billing Address: {self.billing_address}\n"
237272
out_str += f":Document Type: {self.document_type}\n"
238273
out_str += f":Purchase Subcategory: {self.subcategory}\n"
239274
out_str += f":Purchase Category: {self.category}\n"

mindee/product/invoice/invoice_v4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class InvoiceV4(Inference):
8-
"""Inference prediction for Invoice, API version 4."""
8+
"""Invoice API version 4 inference prediction."""
99

1010
prediction: InvoiceV4Document
1111
"""Document-level prediction."""

mindee/product/invoice/invoice_v4_document.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515

1616

1717
class InvoiceV4Document(Prediction):
18-
"""Document data for Invoice, API version 4."""
18+
"""Invoice API version 4.6 document data."""
1919

2020
billing_address: StringField
2121
"""The customer's address used for billing."""
2222
customer_address: StringField
2323
"""The address of the customer."""
2424
customer_company_registrations: List[CompanyRegistrationField]
2525
"""List of company registrations associated to the customer."""
26+
customer_id: StringField
27+
"""The customer account number or identifier from the supplier."""
2628
customer_name: StringField
2729
"""The name of the customer or client."""
2830
date: DateField
@@ -45,10 +47,16 @@ class InvoiceV4Document(Prediction):
4547
"""The address of the supplier or merchant."""
4648
supplier_company_registrations: List[CompanyRegistrationField]
4749
"""List of company registrations associated to the supplier."""
50+
supplier_email: StringField
51+
"""The email of the supplier or merchant."""
4852
supplier_name: StringField
4953
"""The name of the supplier or merchant."""
5054
supplier_payment_details: List[PaymentDetailsField]
5155
"""List of payment details associated to the supplier."""
56+
supplier_phone_number: StringField
57+
"""The phone number of the supplier or merchant."""
58+
supplier_website: StringField
59+
"""The website URL of the supplier or merchant."""
5260
taxes: Taxes
5361
"""List of tax line details."""
5462
total_amount: AmountField
@@ -82,6 +90,10 @@ def __init__(
8290
CompanyRegistrationField(prediction, page_id=page_id)
8391
for prediction in raw_prediction["customer_company_registrations"]
8492
]
93+
self.customer_id = StringField(
94+
raw_prediction["customer_id"],
95+
page_id=page_id,
96+
)
8597
self.customer_name = StringField(
8698
raw_prediction["customer_name"],
8799
page_id=page_id,
@@ -126,6 +138,10 @@ def __init__(
126138
CompanyRegistrationField(prediction, page_id=page_id)
127139
for prediction in raw_prediction["supplier_company_registrations"]
128140
]
141+
self.supplier_email = StringField(
142+
raw_prediction["supplier_email"],
143+
page_id=page_id,
144+
)
129145
self.supplier_name = StringField(
130146
raw_prediction["supplier_name"],
131147
page_id=page_id,
@@ -134,6 +150,14 @@ def __init__(
134150
PaymentDetailsField(prediction, page_id=page_id)
135151
for prediction in raw_prediction["supplier_payment_details"]
136152
]
153+
self.supplier_phone_number = StringField(
154+
raw_prediction["supplier_phone_number"],
155+
page_id=page_id,
156+
)
157+
self.supplier_website = StringField(
158+
raw_prediction["supplier_website"],
159+
page_id=page_id,
160+
)
137161
self.taxes = Taxes(raw_prediction["taxes"], page_id=page_id)
138162
self.total_amount = AmountField(
139163
raw_prediction["total_amount"],
@@ -209,11 +233,15 @@ def __str__(self) -> str:
209233
f":Supplier Company Registrations: {supplier_company_registrations}\n"
210234
)
211235
out_str += f":Supplier Address: {self.supplier_address}\n"
236+
out_str += f":Supplier Phone Number: {self.supplier_phone_number}\n"
237+
out_str += f":Supplier Website: {self.supplier_website}\n"
238+
out_str += f":Supplier Email: {self.supplier_email}\n"
212239
out_str += f":Customer Name: {self.customer_name}\n"
213240
out_str += (
214241
f":Customer Company Registrations: {customer_company_registrations}\n"
215242
)
216243
out_str += f":Customer Address: {self.customer_address}\n"
244+
out_str += f":Customer ID: {self.customer_id}\n"
217245
out_str += f":Shipping Address: {self.shipping_address}\n"
218246
out_str += f":Billing Address: {self.billing_address}\n"
219247
out_str += f":Document Type: {self.document_type}\n"

0 commit comments

Comments
 (0)