Class: Mindee::Product::Receipt::ReceiptV5Document
- Inherits:
-
Mindee::Parsing::Common::Prediction
- Object
- Mindee::Parsing::Common::Prediction
- Mindee::Product::Receipt::ReceiptV5Document
- Includes:
- Mindee::Parsing::Standard
- Defined in:
- lib/mindee/product/receipt/receipt_v5_document.rb
Overview
Receipt API version 5.3 document data.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#category ⇒ Mindee::Parsing::Standard::ClassificationField
readonly
The purchase category among predefined classes.
-
#date ⇒ Mindee::Parsing::Standard::DateField
readonly
The date the purchase was made.
-
#document_type ⇒ Mindee::Parsing::Standard::ClassificationField
readonly
One of: 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'.
-
#line_items ⇒ Array<Mindee::Product::Receipt::ReceiptV5LineItem>
readonly
List of line item details.
-
#locale ⇒ Mindee::Parsing::Standard::LocaleField
readonly
The locale detected on the document.
-
#receipt_number ⇒ Mindee::Parsing::Standard::StringField
readonly
The receipt number or identifier.
-
#subcategory ⇒ Mindee::Parsing::Standard::ClassificationField
readonly
The purchase subcategory among predefined classes for transport and food.
-
#supplier_address ⇒ Mindee::Parsing::Standard::StringField
readonly
The address of the supplier or merchant.
-
#supplier_company_registrations ⇒ Array<Mindee::Parsing::Standard::CompanyRegistrationField>
readonly
List of company registrations associated to the supplier.
-
#supplier_name ⇒ Mindee::Parsing::Standard::StringField
readonly
The name of the supplier or merchant.
-
#supplier_phone_number ⇒ Mindee::Parsing::Standard::StringField
readonly
The phone number of the supplier or merchant.
-
#taxes ⇒ Mindee::Parsing::Standard::Taxes
readonly
List of tax lines information.
-
#time ⇒ Mindee::Parsing::Standard::StringField
readonly
The time the purchase was made.
-
#tip ⇒ Mindee::Parsing::Standard::AmountField
readonly
The total amount of tip and gratuity.
-
#total_amount ⇒ Mindee::Parsing::Standard::AmountField
readonly
The total amount paid: includes taxes, discounts, fees, tips, and gratuity.
-
#total_net ⇒ Mindee::Parsing::Standard::AmountField
readonly
The net amount paid: does not include taxes, fees, and discounts.
-
#total_tax ⇒ Mindee::Parsing::Standard::AmountField
readonly
The total amount of taxes.
Instance Method Summary collapse
-
#initialize(prediction, page_id) ⇒ ReceiptV5Document
constructor
A new instance of ReceiptV5Document.
- #to_s ⇒ String
Constructor Details
#initialize(prediction, page_id) ⇒ ReceiptV5Document
Returns a new instance of ReceiptV5Document.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 66 def initialize(prediction, page_id) super() @category = ClassificationField.new(prediction['category'], page_id) @date = DateField.new(prediction['date'], page_id) @document_type = ClassificationField.new(prediction['document_type'], page_id) @line_items = [] prediction['line_items'].each do |item| @line_items.push(ReceiptV5LineItem.new(item, page_id)) end @locale = LocaleField.new(prediction['locale'], page_id) @receipt_number = StringField.new(prediction['receipt_number'], page_id) @subcategory = ClassificationField.new(prediction['subcategory'], page_id) @supplier_address = StringField.new(prediction['supplier_address'], page_id) @supplier_company_registrations = [] prediction['supplier_company_registrations'].each do |item| @supplier_company_registrations.push(CompanyRegistrationField.new(item, page_id)) end @supplier_name = StringField.new(prediction['supplier_name'], page_id) @supplier_phone_number = StringField.new(prediction['supplier_phone_number'], page_id) @taxes = Taxes.new(prediction['taxes'], page_id) @time = StringField.new(prediction['time'], page_id) @tip = AmountField.new(prediction['tip'], page_id) @total_amount = AmountField.new(prediction['total_amount'], page_id) @total_net = AmountField.new(prediction['total_net'], page_id) @total_tax = AmountField.new(prediction['total_tax'], page_id) end |
Instance Attribute Details
#category ⇒ Mindee::Parsing::Standard::ClassificationField (readonly)
The purchase category among predefined classes.
14 15 16 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 14 def category @category end |
#date ⇒ Mindee::Parsing::Standard::DateField (readonly)
The date the purchase was made.
17 18 19 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 17 def date @date end |
#document_type ⇒ Mindee::Parsing::Standard::ClassificationField (readonly)
One of: 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'.
20 21 22 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 20 def document_type @document_type end |
#line_items ⇒ Array<Mindee::Product::Receipt::ReceiptV5LineItem> (readonly)
List of line item details.
23 24 25 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 23 def line_items @line_items end |
#locale ⇒ Mindee::Parsing::Standard::LocaleField (readonly)
The locale detected on the document.
26 27 28 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 26 def locale @locale end |
#receipt_number ⇒ Mindee::Parsing::Standard::StringField (readonly)
The receipt number or identifier.
29 30 31 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 29 def receipt_number @receipt_number end |
#subcategory ⇒ Mindee::Parsing::Standard::ClassificationField (readonly)
The purchase subcategory among predefined classes for transport and food.
32 33 34 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 32 def subcategory @subcategory end |
#supplier_address ⇒ Mindee::Parsing::Standard::StringField (readonly)
The address of the supplier or merchant.
35 36 37 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 35 def supplier_address @supplier_address end |
#supplier_company_registrations ⇒ Array<Mindee::Parsing::Standard::CompanyRegistrationField> (readonly)
List of company registrations associated to the supplier.
38 39 40 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 38 def supplier_company_registrations @supplier_company_registrations end |
#supplier_name ⇒ Mindee::Parsing::Standard::StringField (readonly)
The name of the supplier or merchant.
41 42 43 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 41 def supplier_name @supplier_name end |
#supplier_phone_number ⇒ Mindee::Parsing::Standard::StringField (readonly)
The phone number of the supplier or merchant.
44 45 46 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 44 def supplier_phone_number @supplier_phone_number end |
#taxes ⇒ Mindee::Parsing::Standard::Taxes (readonly)
List of tax lines information.
47 48 49 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 47 def taxes @taxes end |
#time ⇒ Mindee::Parsing::Standard::StringField (readonly)
The time the purchase was made.
50 51 52 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 50 def time @time end |
#tip ⇒ Mindee::Parsing::Standard::AmountField (readonly)
The total amount of tip and gratuity.
53 54 55 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 53 def tip @tip end |
#total_amount ⇒ Mindee::Parsing::Standard::AmountField (readonly)
The total amount paid: includes taxes, discounts, fees, tips, and gratuity.
56 57 58 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 56 def total_amount @total_amount end |
#total_net ⇒ Mindee::Parsing::Standard::AmountField (readonly)
The net amount paid: does not include taxes, fees, and discounts.
59 60 61 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 59 def total_net @total_net end |
#total_tax ⇒ Mindee::Parsing::Standard::AmountField (readonly)
The total amount of taxes.
62 63 64 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 62 def total_tax @total_tax end |
Instance Method Details
#to_s ⇒ String
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/mindee/product/receipt/receipt_v5_document.rb', line 94 def to_s supplier_company_registrations = @supplier_company_registrations.join("\n #{' ' * 32}") line_items = line_items_to_s out_str = String.new out_str << "\n:Expense Locale: #{@locale}".rstrip out_str << "\n:Purchase Category: #{@category}".rstrip out_str << "\n:Purchase Subcategory: #{@subcategory}".rstrip out_str << "\n:Document Type: #{@document_type}".rstrip out_str << "\n:Purchase Date: #{@date}".rstrip out_str << "\n:Purchase Time: #{@time}".rstrip out_str << "\n:Total Amount: #{@total_amount}".rstrip out_str << "\n:Total Net: #{@total_net}".rstrip out_str << "\n:Total Tax: #{@total_tax}".rstrip out_str << "\n:Tip and Gratuity: #{@tip}".rstrip out_str << "\n:Taxes:#{@taxes}".rstrip out_str << "\n:Supplier Name: #{@supplier_name}".rstrip out_str << "\n:Supplier Company Registrations: #{supplier_company_registrations}".rstrip out_str << "\n:Supplier Address: #{@supplier_address}".rstrip out_str << "\n:Supplier Phone Number: #{@supplier_phone_number}".rstrip out_str << "\n:Receipt Number: #{@receipt_number}".rstrip out_str << "\n:Line Items:" out_str << line_items out_str[1..].to_s end |