@@ -20,6 +20,10 @@ class Invoice(Document):
2020 due_date : Date
2121 taxes : List [Tax ] = []
2222 supplier : Field
23+ supplier_address : Field
24+ customer_name : Field
25+ customer_company_registration : Field
26+ customer_address : Field
2327 payment_details : List [PaymentDetails ] = []
2428 company_number : List [Field ] = []
2529 total_tax : Amount
@@ -51,6 +55,9 @@ def build_from_api_prediction(self, api_prediction: dict, page_n=0):
5155 :param page_n: Page number for multi pages pdf input
5256 :return: (void) set the object attributes with api prediction values
5357 """
58+ if page_n is not None :
59+ self .orientation = Orientation (api_prediction ["orientation" ], page_n = page_n )
60+
5461 self .company_number = [
5562 Field (company_reg , extra_fields = {"type" }, page_n = page_n )
5663 for company_reg in api_prediction ["company_registration" ]
@@ -65,9 +72,14 @@ def build_from_api_prediction(self, api_prediction: dict, page_n=0):
6572 self .locale = Locale (
6673 api_prediction ["locale" ], value_key = "language" , page_n = page_n
6774 )
68- if page_n is not None :
69- self .orientation = Orientation (api_prediction ["orientation" ], page_n = page_n )
7075 self .supplier = Field (api_prediction ["supplier" ], page_n = page_n )
76+ self .supplier_address = Field (api_prediction ["supplier_address" ], page_n = page_n )
77+ self .customer_name = Field (api_prediction ["customer" ], page_n = page_n )
78+ self .customer_company_registration = Field (
79+ api_prediction ["customer_company_registration" ], page_n = page_n
80+ )
81+ self .customer_address = Field (api_prediction ["customer_address" ], page_n = page_n )
82+
7183 self .taxes = [
7284 Tax (tax_prediction , page_n = page_n , value_key = "value" )
7385 for tax_prediction in api_prediction ["taxes" ]
@@ -93,16 +105,20 @@ def __str__(self) -> str:
93105 return (
94106 "-----Invoice data-----\n "
95107 f"Filename: { self .filename } \n "
96- f"Invoice number: { self .invoice_number .value } \n "
97- f"Total amount including taxes: { self .total_incl .value } \n "
98- f"Total amount excluding taxes: { self .total_excl .value } \n "
99- f"Invoice date: { self .invoice_date .value } \n "
100- f"Invoice due date: { self .due_date .value } \n "
101- f"Supplier name: { self .supplier .value } \n "
108+ f"Invoice number: { self .invoice_number } \n "
109+ f"Total amount including taxes: { self .total_incl } \n "
110+ f"Total amount excluding taxes: { self .total_excl } \n "
111+ f"Invoice date: { self .invoice_date } \n "
112+ f"Invoice due date: { self .due_date } \n "
113+ f"Supplier name: { self .supplier } \n "
114+ f"Supplier address: { self .supplier_address } \n "
115+ f"Customer name: { self .customer_name } \n "
116+ f"Customer company registration: { self .customer_company_registration } \n "
117+ f"Customer address: { self .customer_address } \n "
102118 f"Payment details: { payments } \n "
103119 f"Company numbers: { company_numbers } \n "
104120 f"Taxes: { taxes } \n "
105- f"Total taxes: { self .total_tax . value } \n "
121+ f"Total taxes: { self .total_tax } \n "
106122 f"Locale: { self .locale } \n "
107123 "----------------------"
108124 )
0 commit comments