Skip to content

Commit cf90f04

Browse files
authored
✨ update Invoice to v4.5 (#225)
1 parent a09d018 commit cf90f04

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

docs/extras/guide/invoices_v4.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ A `InvoiceV4LineItem` implements the following attributes:
205205
# Attributes
206206
The following fields are extracted for Invoice V4:
207207

208+
## Billing Address
209+
**billing_address** ([StringField](#stringfield)): The customer's address used for billing.
210+
211+
```py
212+
print(result.document.inference.prediction.billing_address.value)
213+
```
214+
208215
## Customer Address
209216
**customer_address** ([StringField](#stringfield)): The address of the customer.
210217

@@ -278,6 +285,13 @@ for reference_numbers_elem in result.document.inference.prediction.reference_num
278285
print(reference_numbers_elem.value)
279286
```
280287

288+
## Shipping Address
289+
**shipping_address** ([StringField](#stringfield)): Customer's delivery address.
290+
291+
```py
292+
print(result.document.inference.prediction.shipping_address.value)
293+
```
294+
281295
## Supplier Address
282296
**supplier_address** ([StringField](#stringfield)): The address of the supplier or merchant.
283297

mindee/product/invoice/invoice_v4_document.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
class InvoiceV4Document(Prediction):
1818
"""Document data for Invoice, API version 4."""
1919

20+
billing_address: StringField
21+
"""The customer's address used for billing."""
2022
customer_address: StringField
2123
"""The address of the customer."""
2224
customer_company_registrations: List[CompanyRegistrationField]
@@ -37,6 +39,8 @@ class InvoiceV4Document(Prediction):
3739
"""The locale detected on the document."""
3840
reference_numbers: List[StringField]
3941
"""List of Reference numbers, including PO number."""
42+
shipping_address: StringField
43+
"""Customer's delivery address."""
4044
supplier_address: StringField
4145
"""The address of the supplier or merchant."""
4246
supplier_company_registrations: List[CompanyRegistrationField]
@@ -66,6 +70,10 @@ def __init__(
6670
:param page_id: Page number for multi pages pdf input
6771
"""
6872
super().__init__(raw_prediction, page_id)
73+
self.billing_address = StringField(
74+
raw_prediction["billing_address"],
75+
page_id=page_id,
76+
)
6977
self.customer_address = StringField(
7078
raw_prediction["customer_address"],
7179
page_id=page_id,
@@ -106,6 +114,10 @@ def __init__(
106114
StringField(prediction, page_id=page_id)
107115
for prediction in raw_prediction["reference_numbers"]
108116
]
117+
self.shipping_address = StringField(
118+
raw_prediction["shipping_address"],
119+
page_id=page_id,
120+
)
109121
self.supplier_address = StringField(
110122
raw_prediction["supplier_address"],
111123
page_id=page_id,
@@ -202,6 +214,8 @@ def __str__(self) -> str:
202214
f":Customer Company Registrations: {customer_company_registrations}\n"
203215
)
204216
out_str += f":Customer Address: {self.customer_address}\n"
217+
out_str += f":Shipping Address: {self.shipping_address}\n"
218+
out_str += f":Billing Address: {self.billing_address}\n"
205219
out_str += f":Document Type: {self.document_type}\n"
206220
out_str += f":Line Items: {self._line_items_to_str()}\n"
207221
return clean_out_string(out_str)

tests/product/invoice/test_invoice_v4.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,6 @@ def test_empty_doc(empty_doc: Document[InvoiceV4Document, Page[InvoiceV4Document
7171
assert prediction.customer_name.value is None
7272
assert len(prediction.customer_company_registrations) == 0
7373
assert prediction.customer_address.value is None
74+
assert prediction.shipping_address.value is None
75+
assert prediction.billing_address.value is None
7476
assert len(prediction.line_items) == 0

0 commit comments

Comments
 (0)