@@ -111,26 +111,26 @@ def test__str__receipt(financial_doc_from_receipt_object):
111111# Business tests from receipt
112112def test__receipt_reconstruct_total_excl_from_total_and_taxes_1 (receipt_pred ):
113113 # no incl implies no reconstruct for total excl
114- receipt_pred ["total_incl" ] = {"value" : "N/A" , "probability " : 0.0 }
115- receipt_pred ["taxes" ] = [{"rate" : 20 , "value" : 9.5 , "probability " : 0.9 }]
114+ receipt_pred ["total_incl" ] = {"value" : "N/A" , "confidence " : 0.0 }
115+ receipt_pred ["taxes" ] = [{"rate" : 20 , "value" : 9.5 , "confidence " : 0.9 }]
116116 financial_doc = FinancialDocument (receipt_pred )
117117 assert financial_doc .total_excl .value is None
118118
119119
120120def test__receipt_reconstruct_total_excl_from_total_and_taxes_2 (receipt_pred ):
121121 # no taxes implies no reconstruct for total excl
122- receipt_pred ["total_incl" ] = {"value" : 12.54 , "probability " : 0.0 }
122+ receipt_pred ["total_incl" ] = {"value" : 12.54 , "confidence " : 0.0 }
123123 receipt_pred ["taxes" ] = []
124124 financial_doc = FinancialDocument (receipt_pred )
125125 assert financial_doc .total_excl .value is None
126126
127127
128128def test__receipt_reconstruct_total_excl_from_total_and_taxes_3 (receipt_pred ):
129129 # working example
130- receipt_pred ["total_incl" ] = {"value" : 12.54 , "probability " : 0.5 }
130+ receipt_pred ["total_incl" ] = {"value" : 12.54 , "confidence " : 0.5 }
131131 receipt_pred ["taxes" ] = [
132- {"rate" : 20 , "value" : 0.5 , "probability " : 0.1 },
133- {"rate" : 10 , "value" : 4.25 , "probability " : 0.6 },
132+ {"rate" : 20 , "value" : 0.5 , "confidence " : 0.1 },
133+ {"rate" : 10 , "value" : 4.25 , "confidence " : 0.6 },
134134 ]
135135 financial_doc = FinancialDocument (receipt_pred )
136136 assert financial_doc .total_excl .probability == 0.03
@@ -147,8 +147,8 @@ def test__receipt_reconstruct_total_tax_1(receipt_pred):
147147def test__receipt_reconstruct_total_tax_2 (receipt_pred ):
148148 # working example
149149 receipt_pred ["taxes" ] = [
150- {"rate" : 20 , "value" : 10.2 , "probability " : 0.5 },
151- {"rate" : 10 , "value" : 40.0 , "probability " : 0.1 },
150+ {"rate" : 20 , "value" : 10.2 , "confidence " : 0.5 },
151+ {"rate" : 10 , "value" : 40.0 , "confidence " : 0.1 },
152152 ]
153153 financial_doc = FinancialDocument (receipt_pred )
154154 assert financial_doc .total_tax .value == 50.2
@@ -157,10 +157,10 @@ def test__receipt_reconstruct_total_tax_2(receipt_pred):
157157
158158def test__receipt_taxes_match_total_incl_1 (receipt_pred ):
159159 # matching example
160- receipt_pred ["total_incl" ] = {"value" : 507.25 , "probability " : 0.6 }
160+ receipt_pred ["total_incl" ] = {"value" : 507.25 , "confidence " : 0.6 }
161161 receipt_pred ["taxes" ] = [
162- {"rate" : 20 , "value" : 10.99 , "probability " : 0.5 },
163- {"rate" : 10 , "value" : 40.12 , "probability " : 0.1 },
162+ {"rate" : 20 , "value" : 10.99 , "confidence " : 0.5 },
163+ {"rate" : 10 , "value" : 40.12 , "confidence " : 0.1 },
164164 ]
165165 financial_doc = FinancialDocument (receipt_pred )
166166 assert financial_doc .checklist ["taxes_match_total_incl" ] is True
@@ -171,46 +171,46 @@ def test__receipt_taxes_match_total_incl_1(receipt_pred):
171171
172172def test__receipt_taxes_match_total_incl_2 (receipt_pred ):
173173 # not matching example with close error
174- receipt_pred ["total_incl" ] = {"value" : 507.25 , "probability " : 0.6 }
174+ receipt_pred ["total_incl" ] = {"value" : 507.25 , "confidence " : 0.6 }
175175 receipt_pred ["taxes" ] = [
176- {"rate" : 20 , "value" : 10.9 , "probability " : 0.5 },
177- {"rate" : 10 , "value" : 40.12 , "probability " : 0.1 },
176+ {"rate" : 20 , "value" : 10.9 , "confidence " : 0.5 },
177+ {"rate" : 10 , "value" : 40.12 , "confidence " : 0.1 },
178178 ]
179179 financial_doc = FinancialDocument (receipt_pred )
180180 assert financial_doc .checklist ["taxes_match_total_incl" ] is False
181181
182182
183183def test__receipt_taxes_match_total_incl_3 (receipt_pred ):
184184 # sanity check with null tax
185- receipt_pred ["total_incl" ] = {"value" : 507.25 , "probability " : 0.6 }
186- receipt_pred ["taxes" ] = [{"rate" : 20 , "value" : 0.0 , "probability " : 0.5 }]
185+ receipt_pred ["total_incl" ] = {"value" : 507.25 , "confidence " : 0.6 }
186+ receipt_pred ["taxes" ] = [{"rate" : 20 , "value" : 0.0 , "confidence " : 0.5 }]
187187 financial_doc = FinancialDocument (receipt_pred )
188188 assert financial_doc .checklist ["taxes_match_total_incl" ] is False
189189
190190
191191# Business tests from invoice
192192def test__invoice_reconstruct_total_excl_from_total_and_taxes_1 (invoice_pred ):
193193 # no incl implies no reconstruct for total excl
194- invoice_pred ["total_incl" ] = {"amount" : "N/A" , "probability " : 0.0 }
195- invoice_pred ["taxes" ] = [{"rate" : 20 , "amount" : 9.5 , "probability " : 0.9 }]
194+ invoice_pred ["total_incl" ] = {"amount" : "N/A" , "confidence " : 0.0 }
195+ invoice_pred ["taxes" ] = [{"rate" : 20 , "amount" : 9.5 , "confidence " : 0.9 }]
196196 financial_doc = FinancialDocument (invoice_pred )
197197 assert financial_doc .total_excl .value is None
198198
199199
200200def test__invoice_reconstruct_total_excl_from_total_and_taxes_2 (invoice_pred ):
201201 # no taxes implies no reconstruct for total excl
202- invoice_pred ["total_incl" ] = {"amount" : 12.54 , "probability " : 0.0 }
202+ invoice_pred ["total_incl" ] = {"amount" : 12.54 , "confidence " : 0.0 }
203203 invoice_pred ["taxes" ] = []
204204 financial_doc = FinancialDocument (invoice_pred )
205205 assert financial_doc .total_excl .value is None
206206
207207
208208def test__invoice_reconstruct_total_excl_from_total_and_taxes_3 (invoice_pred ):
209209 # working example
210- invoice_pred ["total_incl" ] = {"value" : 12.54 , "probability " : 0.5 }
210+ invoice_pred ["total_incl" ] = {"value" : 12.54 , "confidence " : 0.5 }
211211 invoice_pred ["taxes" ] = [
212- {"rate" : 20 , "value" : 0.5 , "probability " : 0.1 },
213- {"rate" : 10 , "value" : 4.25 , "probability " : 0.6 },
212+ {"rate" : 20 , "value" : 0.5 , "confidence " : 0.1 },
213+ {"rate" : 10 , "value" : 4.25 , "confidence " : 0.6 },
214214 ]
215215 financial_doc = FinancialDocument (invoice_pred )
216216 assert financial_doc .total_excl .probability == 0.03
@@ -227,8 +227,8 @@ def test__invoice_reconstruct_total_tax_1(invoice_pred):
227227def test__invoice_reconstruct_total_tax_2 (invoice_pred ):
228228 # working example
229229 invoice_pred ["taxes" ] = [
230- {"rate" : 20 , "value" : 10.2 , "probability " : 0.5 },
231- {"rate" : 10 , "value" : 40.0 , "probability " : 0.1 },
230+ {"rate" : 20 , "value" : 10.2 , "confidence " : 0.5 },
231+ {"rate" : 10 , "value" : 40.0 , "confidence " : 0.1 },
232232 ]
233233 financial_doc = FinancialDocument (invoice_pred )
234234 assert financial_doc .total_tax .value == 50.2
@@ -237,10 +237,10 @@ def test__invoice_reconstruct_total_tax_2(invoice_pred):
237237
238238def test__invoice_taxes_match_total_incl_1 (invoice_pred ):
239239 # matching example
240- invoice_pred ["total_incl" ] = {"value" : 507.25 , "probability " : 0.6 }
240+ invoice_pred ["total_incl" ] = {"value" : 507.25 , "confidence " : 0.6 }
241241 invoice_pred ["taxes" ] = [
242- {"rate" : 20 , "value" : 10.99 , "probability " : 0.5 },
243- {"rate" : 10 , "value" : 40.12 , "probability " : 0.1 },
242+ {"rate" : 20 , "value" : 10.99 , "confidence " : 0.5 },
243+ {"rate" : 10 , "value" : 40.12 , "confidence " : 0.1 },
244244 ]
245245 financial_doc = FinancialDocument (invoice_pred )
246246 assert financial_doc .checklist ["taxes_match_total_incl" ] is True
@@ -251,27 +251,27 @@ def test__invoice_taxes_match_total_incl_1(invoice_pred):
251251
252252def test__invoice_taxes_match_total_incl_2 (invoice_pred ):
253253 # not matching example with close error
254- invoice_pred ["total_incl" ] = {"value" : 507.25 , "probability " : 0.6 }
254+ invoice_pred ["total_incl" ] = {"value" : 507.25 , "confidence " : 0.6 }
255255 invoice_pred ["taxes" ] = [
256- {"rate" : 20 , "value" : 10.9 , "probability " : 0.5 },
257- {"rate" : 10 , "value" : 40.12 , "probability " : 0.1 },
256+ {"rate" : 20 , "value" : 10.9 , "confidence " : 0.5 },
257+ {"rate" : 10 , "value" : 40.12 , "confidence " : 0.1 },
258258 ]
259259 financial_doc = FinancialDocument (invoice_pred )
260260 assert financial_doc .checklist ["taxes_match_total_incl" ] is False
261261
262262
263263def test__invoice_taxes_match_total_incl_3 (invoice_pred ):
264264 # sanity check with null tax
265- invoice_pred ["total_incl" ] = {"value" : 507.25 , "probability " : 0.6 }
266- invoice_pred ["taxes" ] = [{"rate" : 20 , "value" : 0.0 , "probability " : 0.5 }]
265+ invoice_pred ["total_incl" ] = {"value" : 507.25 , "confidence " : 0.6 }
266+ invoice_pred ["taxes" ] = [{"rate" : 20 , "value" : 0.0 , "confidence " : 0.5 }]
267267 financial_doc = FinancialDocument (invoice_pred )
268268 assert financial_doc .checklist ["taxes_match_total_incl" ] is False
269269
270270
271271def test__shouldnt_raise_when_tax_rate_none (invoice_pred ):
272272 # sanity check with null tax
273- invoice_pred ["total_incl" ] = {"value" : 507.25 , "probability " : 0.6 }
274- invoice_pred ["taxes" ] = [{"rate" : "N/A" , "value" : 0.0 , "probability " : 0.5 }]
273+ invoice_pred ["total_incl" ] = {"value" : 507.25 , "confidence " : 0.6 }
274+ invoice_pred ["taxes" ] = [{"rate" : "N/A" , "value" : 0.0 , "confidence " : 0.5 }]
275275 financial_doc = FinancialDocument (invoice_pred )
276276 assert financial_doc .checklist ["taxes_match_total_incl" ] is False
277277
0 commit comments