@@ -124,8 +124,10 @@ def __str__(self) -> str:
124124 customer_company_registration = "; " .join (
125125 [str (n .value ) for n in self .customer_company_registration ]
126126 )
127- payments = ", " .join ([str (p ) for p in self .payment_details ])
128- taxes = ", " .join (f"{ t } " for t in self .taxes )
127+ payment_details = "\n " .join (
128+ [str (p ) for p in self .payment_details ]
129+ )
130+ taxes = "\n " .join (f"{ t } " for t in self .taxes )
129131 return (
130132 "-----Invoice data-----\n "
131133 f"Filename: { self .filename } \n "
@@ -139,7 +141,7 @@ def __str__(self) -> str:
139141 f"Customer name: { self .customer_name } \n "
140142 f"Customer company registration: { customer_company_registration } \n "
141143 f"Customer address: { self .customer_address } \n "
142- f"Payment details: { payments } \n "
144+ f"Payment details: { payment_details } \n "
143145 f"Company numbers: { company_numbers } \n "
144146 f"Taxes: { taxes } \n "
145147 f"Total taxes: { self .total_tax } \n "
@@ -174,8 +176,8 @@ def __taxes_match_total_incl(self) -> bool:
174176 return False
175177
176178 # Reconstruct total_incl from taxes
177- total_vat = 0
178- reconstructed_total = 0
179+ total_vat = 0.0
180+ reconstructed_total = 0.0
179181 for tax in self .taxes :
180182 if tax .value is None or tax .rate is None or tax .rate == 0 :
181183 return False
@@ -211,8 +213,8 @@ def __taxes_match_total_excl(self) -> bool:
211213 return False
212214
213215 # Reconstruct total excl from taxes
214- total_vat = 0
215- reconstructed_total = 0
216+ total_vat = 0.0
217+ reconstructed_total = 0.0
216218 for tax in self .taxes :
217219 if tax .value is None or tax .rate is None or tax .rate == 0 :
218220 return False
@@ -254,7 +256,7 @@ def __taxes_plus_total_excl_match_total_incl(self) -> bool:
254256 return False
255257
256258 # Reconstruct total_incl
257- total_vat = 0
259+ total_vat = 0.0
258260 for tax in self .taxes :
259261 if tax .value is not None :
260262 total_vat += tax .value
@@ -288,13 +290,11 @@ def __reconstruct_total_incl_from_taxes_plus_excl(self) -> None:
288290 multiplied by total_excl confidence
289291 """
290292 # Check total_tax, total excl exist and total incl is not set
291- if (
293+ if not (
292294 self .total_excl .value is None
293295 or len (self .taxes ) == 0
294296 or self .total_incl .value is not None
295297 ):
296- pass
297- else :
298298 total_incl = {
299299 "value" : sum (
300300 [tax .value if tax .value is not None else 0 for tax in self .taxes ]
@@ -319,17 +319,15 @@ def __reconstruct_total_excl_from_tcc_and_taxes(self) -> None:
319319 or len (self .taxes ) == 0
320320 or self .total_excl .value is not None
321321 ):
322- pass
323- else :
324- total_excl = {
325- "value" : self .total_incl .value
326- - sum (
327- [tax .value if tax .value is not None else 0 for tax in self .taxes ]
328- ),
329- "confidence" : field_array_confidence (self .taxes )
330- * self .total_incl .confidence ,
331- }
332- self .total_excl = Amount (total_excl , value_key = "value" , reconstructed = True )
322+ return
323+
324+ total_excl = {
325+ "value" : self .total_incl .value
326+ - sum ([tax .value if tax .value is not None else 0 for tax in self .taxes ]),
327+ "confidence" : field_array_confidence (self .taxes )
328+ * self .total_incl .confidence ,
329+ }
330+ self .total_excl = Amount (total_excl , value_key = "value" , reconstructed = True )
333331
334332 def __reconstruct_total_tax_from_tax_lines (self ) -> None :
335333 """
@@ -362,14 +360,11 @@ def __reconstruct_total_tax_from_incl_and_excl(self) -> None:
362360 or self .total_excl .value is None
363361 or self .total_incl .value is None
364362 ):
365- pass
366- else :
363+ return
367364
368- total_tax = {
369- "value" : self .total_incl .value - self .total_excl .value ,
370- "confidence" : self .total_incl .confidence * self .total_excl .confidence ,
371- }
372- if total_tax ["value" ] >= 0 :
373- self .total_tax = Amount (
374- total_tax , value_key = "value" , reconstructed = True
375- )
365+ total_tax = {
366+ "value" : self .total_incl .value - self .total_excl .value ,
367+ "confidence" : self .total_incl .confidence * self .total_excl .confidence ,
368+ }
369+ if total_tax ["value" ] >= 0 :
370+ self .total_tax = Amount (total_tax , value_key = "value" , reconstructed = True )
0 commit comments