Class: Mindee::V1::Product::Receipt::ReceiptV5Document
- Inherits:
-
Mindee::V1::Parsing::Common::Prediction
- Object
- Mindee::V1::Parsing::Common::Prediction
- Mindee::V1::Product::Receipt::ReceiptV5Document
- Includes:
- Mindee::V1::Parsing::Standard
- Defined in:
- lib/mindee/v1/product/receipt/receipt_v5_document.rb
Overview
Receipt API version 5.4 document data.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#category ⇒ Mindee::V1::Parsing::Standard::ClassificationField
readonly
The purchase category of the receipt.
-
#date ⇒ Mindee::V1::Parsing::Standard::DateField
readonly
The date the purchase was made.
-
#document_type ⇒ Mindee::V1::Parsing::Standard::ClassificationField
readonly
The type of receipt: EXPENSE RECEIPT or CREDIT CARD RECEIPT.
-
#line_items ⇒ Mindee::V1::Product::Receipt::ReceiptV5LineItems
readonly
List of all line items on the receipt.
-
#locale ⇒ Mindee::V1::Parsing::Standard::LocaleField
readonly
The locale of the document.
-
#receipt_number ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
The receipt number or identifier.
-
#subcategory ⇒ Mindee::V1::Parsing::Standard::ClassificationField
readonly
The purchase subcategory of the receipt for transport and food.
-
#supplier_address ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
The address of the supplier or merchant.
-
#supplier_company_registrations ⇒ Array<Mindee::V1::Parsing::Standard::CompanyRegistrationField>
readonly
List of company registration numbers associated to the supplier.
-
#supplier_name ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
The name of the supplier or merchant.
-
#supplier_phone_number ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
The phone number of the supplier or merchant.
-
#taxes ⇒ Mindee::V1::Parsing::Standard::Taxes
readonly
The list of taxes present on the receipt.
-
#time ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
The time the purchase was made.
-
#tip ⇒ Mindee::V1::Parsing::Standard::AmountField
readonly
The total amount of tip and gratuity.
-
#total_amount ⇒ Mindee::V1::Parsing::Standard::AmountField
readonly
The total amount paid: includes taxes, discounts, fees, tips, and gratuity.
-
#total_net ⇒ Mindee::V1::Parsing::Standard::AmountField
readonly
The net amount paid: does not include taxes, fees, and discounts.
-
#total_tax ⇒ Mindee::V1::Parsing::Standard::AmountField
readonly
The sum of all 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.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 68 def initialize(prediction, page_id) super @category = Parsing::Standard::ClassificationField.new( prediction['category'], page_id ) @date = Parsing::Standard::DateField.new(prediction['date'], page_id) @document_type = Parsing::Standard::ClassificationField.new( prediction['document_type'], page_id ) @line_items = Product::Receipt::ReceiptV5LineItems.new(prediction['line_items'], page_id) @locale = Parsing::Standard::LocaleField.new( prediction['locale'], page_id ) @receipt_number = Parsing::Standard::StringField.new( prediction['receipt_number'], page_id ) @subcategory = Parsing::Standard::ClassificationField.new( prediction['subcategory'], page_id ) @supplier_address = Parsing::Standard::StringField.new( prediction['supplier_address'], page_id ) @supplier_company_registrations = [] # : Array[Parsing::Standard::CompanyRegistrationField] prediction['supplier_company_registrations'].each do |item| @supplier_company_registrations.push(Parsing::Standard::CompanyRegistrationField.new(item, page_id)) end @supplier_name = Parsing::Standard::StringField.new( prediction['supplier_name'], page_id ) @supplier_phone_number = Parsing::Standard::StringField.new( prediction['supplier_phone_number'], page_id ) @taxes = Parsing::Standard::Taxes.new(prediction['taxes'], page_id) @time = Parsing::Standard::StringField.new(prediction['time'], page_id) @tip = Parsing::Standard::AmountField.new(prediction['tip'], page_id) @total_amount = Parsing::Standard::AmountField.new( prediction['total_amount'], page_id ) @total_net = Parsing::Standard::AmountField.new( prediction['total_net'], page_id ) @total_tax = Parsing::Standard::AmountField.new( prediction['total_tax'], page_id ) end |
Instance Attribute Details
#category ⇒ Mindee::V1::Parsing::Standard::ClassificationField (readonly)
The purchase category of the receipt.
16 17 18 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 16 def category @category end |
#date ⇒ Mindee::V1::Parsing::Standard::DateField (readonly)
The date the purchase was made.
19 20 21 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 19 def date @date end |
#document_type ⇒ Mindee::V1::Parsing::Standard::ClassificationField (readonly)
The type of receipt: EXPENSE RECEIPT or CREDIT CARD RECEIPT.
22 23 24 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 22 def document_type @document_type end |
#line_items ⇒ Mindee::V1::Product::Receipt::ReceiptV5LineItems (readonly)
List of all line items on the receipt.
25 26 27 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 25 def line_items @line_items end |
#locale ⇒ Mindee::V1::Parsing::Standard::LocaleField (readonly)
The locale of the document.
28 29 30 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 28 def locale @locale end |
#receipt_number ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
The receipt number or identifier.
31 32 33 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 31 def receipt_number @receipt_number end |
#subcategory ⇒ Mindee::V1::Parsing::Standard::ClassificationField (readonly)
The purchase subcategory of the receipt for transport and food.
34 35 36 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 34 def subcategory @subcategory end |
#supplier_address ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
The address of the supplier or merchant.
37 38 39 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 37 def supplier_address @supplier_address end |
#supplier_company_registrations ⇒ Array<Mindee::V1::Parsing::Standard::CompanyRegistrationField> (readonly)
List of company registration numbers associated to the supplier.
40 41 42 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 40 def supplier_company_registrations @supplier_company_registrations end |
#supplier_name ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
The name of the supplier or merchant.
43 44 45 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 43 def supplier_name @supplier_name end |
#supplier_phone_number ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
The phone number of the supplier or merchant.
46 47 48 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 46 def supplier_phone_number @supplier_phone_number end |
#taxes ⇒ Mindee::V1::Parsing::Standard::Taxes (readonly)
The list of taxes present on the receipt.
49 50 51 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 49 def taxes @taxes end |
#time ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
The time the purchase was made.
52 53 54 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 52 def time @time end |
#tip ⇒ Mindee::V1::Parsing::Standard::AmountField (readonly)
The total amount of tip and gratuity.
55 56 57 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 55 def tip @tip end |
#total_amount ⇒ Mindee::V1::Parsing::Standard::AmountField (readonly)
The total amount paid: includes taxes, discounts, fees, tips, and gratuity.
58 59 60 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 58 def total_amount @total_amount end |
#total_net ⇒ Mindee::V1::Parsing::Standard::AmountField (readonly)
The net amount paid: does not include taxes, fees, and discounts.
61 62 63 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 61 def total_net @total_net end |
#total_tax ⇒ Mindee::V1::Parsing::Standard::AmountField (readonly)
The sum of all taxes.
64 65 66 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 64 def total_tax @total_tax end |
Instance Method Details
#to_s ⇒ String
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/mindee/v1/product/receipt/receipt_v5_document.rb', line 126 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 |