22
33from mindee .documents .base import Document , TypeApiPrediction , clean_out_string
44from mindee .fields .amount import AmountField
5+ from mindee .fields .classification import ClassificationField
56from mindee .fields .date import DateField
67from mindee .fields .locale import LocaleField
78from mindee .fields .tax import TaxField
@@ -17,11 +18,11 @@ class ReceiptV4(Document):
1718 """Date the receipt was issued"""
1819 time : TextField
1920 """Time the receipt was issued, in HH: MM format."""
20- category : TextField
21+ category : ClassificationField
2122 """The type, or service category, of the purchase."""
22- subcategory : TextField
23+ subcategory : ClassificationField
2324 """The receipt sub category among predefined classes."""
24- document_type : TextField
25+ document_type : ClassificationField
2526 """Whether the document is an expense receipt or a credit card receipt."""
2627 supplier : TextField
2728 """The merchant, or supplier, as found on the receipt."""
@@ -70,9 +71,13 @@ def _build_from_api_prediction(
7071 self .total_tax = AmountField (api_prediction ["total_tax" ], page_n = page_n )
7172 self .tip = AmountField (api_prediction ["tip" ], page_n = page_n )
7273 self .date = DateField (api_prediction ["date" ], page_n = page_n )
73- self .category = TextField (api_prediction ["category" ], page_n = page_n )
74- self .subcategory = TextField (api_prediction ["subcategory" ], page_n = page_n )
75- self .document_type = TextField (api_prediction ["document_type" ], page_n = page_n )
74+ self .category = ClassificationField (api_prediction ["category" ], page_n = page_n )
75+ self .subcategory = ClassificationField (
76+ api_prediction ["subcategory" ], page_n = page_n
77+ )
78+ self .document_type = ClassificationField (
79+ api_prediction ["document_type" ], page_n = page_n
80+ )
7681 self .supplier = TextField (
7782 api_prediction ["supplier" ], value_key = "value" , page_n = page_n
7883 )
0 commit comments