Skip to content

Commit a5a6686

Browse files
committed
add new invoice fields to finannial docs
1 parent 834dfe2 commit a5a6686

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

mindee/documents/financial_document.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def __init__(
3838
self.vat_number = None
3939
self.total_tax = None
4040
self.time = None
41+
self.supplier_address = None
42+
self.customer_name = None
43+
self.customer_company_registration = None
44+
self.customer_address = None
4145

4246
# need this for building from prediction
4347
self.input_file = input_file
@@ -70,6 +74,10 @@ def build_from_api_prediction(self, api_prediction, page_n=0):
7074
self.orientation = invoice.orientation
7175
self.total_tax = invoice.total_tax
7276
self.time = Field({"value": None, "confidence": 0.0})
77+
self.supplier_address = invoice.supplier_address
78+
self.customer_name = invoice.customer_name
79+
self.customer_company_registration = invoice.customer_company_registration
80+
self.customer_address = invoice.customer_address
7381
else:
7482
receipt = Receipt(api_prediction, self.input_file, page_n=page_n)
7583
self.orientation = receipt.orientation
@@ -85,6 +93,12 @@ def build_from_api_prediction(self, api_prediction, page_n=0):
8593
self.invoice_number = Field({"value": None, "confidence": 0.0})
8694
self.payment_details = []
8795
self.company_number = []
96+
self.supplier_address = Field({"value": None, "confidence": 0.0})
97+
self.customer_name = Field({"value": None, "confidence": 0.0})
98+
self.customer_company_registration = Field(
99+
{"value": None, "confidence": 0.0}
100+
)
101+
self.customer_address = Field({"value": None, "confidence": 0.0})
88102

89103
def __str__(self) -> str:
90104
return (
@@ -96,6 +110,10 @@ def __str__(self) -> str:
96110
"Date: %s\n"
97111
"Invoice due date: %s\n"
98112
"Supplier name: %s\n"
113+
f"Supplier address: {self.supplier_address}\n"
114+
f"Customer name: {self.customer_name}\n"
115+
f"Customer company registration: {self.customer_company_registration}\n"
116+
f"Customer address: {self.customer_address}\n"
99117
"Taxes: %s\n"
100118
"Total taxes: %s\n"
101119
"----------------------"

tests/documents/test_financial_doc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,15 @@ def invoice_pred():
5454

5555
def test_constructor_1(financial_doc_from_invoice_object):
5656
assert financial_doc_from_invoice_object.date.value == "2020-02-17"
57+
assert (
58+
financial_doc_from_invoice_object.supplier_address.value
59+
== "156 University Ave, Toronto ON, Canada M5H 2H7"
60+
)
5761

5862

5963
def test_constructor_2(financial_doc_from_receipt_object):
6064
assert financial_doc_from_receipt_object.date.value == "2016-02-26"
65+
assert financial_doc_from_receipt_object.supplier_address.value is None
6166

6267

6368
def test_all_na_receipt(financial_doc_from_receipt_object_all_na):

0 commit comments

Comments
 (0)