Class: Mindee::Product::FinancialDocument::FinancialDocumentV1LineItem
- Inherits:
-
Mindee::Parsing::Standard::FeatureField
- Object
- Mindee::Parsing::Standard::AbstractField
- Mindee::Parsing::Standard::FeatureField
- Mindee::Product::FinancialDocument::FinancialDocumentV1LineItem
- Includes:
- Mindee::Parsing::Standard
- Defined in:
- lib/mindee/product/financial_document/financial_document_v1_line_item.rb
Overview
List of line item details.
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
The item description.
-
#product_code ⇒ String
readonly
The product code referring to the item.
-
#quantity ⇒ Float
readonly
The item quantity.
-
#tax_amount ⇒ Float
readonly
The item tax amount.
-
#tax_rate ⇒ Float
readonly
The item tax rate in percentage.
-
#total_amount ⇒ Float
readonly
The item total amount.
-
#unit_measure ⇒ String
readonly
The item unit of measure.
-
#unit_price ⇒ Float
readonly
The item unit price.
Attributes inherited from Mindee::Parsing::Standard::AbstractField
#bounding_box, #confidence, #page_id, #polygon
Instance Method Summary collapse
-
#initialize(prediction, page_id) ⇒ FinancialDocumentV1LineItem
constructor
A new instance of FinancialDocumentV1LineItem.
- #printable_values ⇒ Hash
- #table_printable_values ⇒ Hash
- #to_s ⇒ String
- #to_table_line ⇒ String
Methods inherited from Mindee::Parsing::Standard::FeatureField
Methods inherited from Mindee::Parsing::Standard::AbstractField
array_confidence, array_sum, float_to_string
Constructor Details
#initialize(prediction, page_id) ⇒ FinancialDocumentV1LineItem
Returns a new instance of FinancialDocumentV1LineItem.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 38 def initialize(prediction, page_id) super(prediction, page_id) @description = prediction['description'] @product_code = prediction['product_code'] @quantity = prediction['quantity'] @tax_amount = prediction['tax_amount'] @tax_rate = prediction['tax_rate'] @total_amount = prediction['total_amount'] @unit_measure = prediction['unit_measure'] @unit_price = prediction['unit_price'] @page_id = page_id end |
Instance Attribute Details
#description ⇒ String (readonly)
The item description.
13 14 15 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 13 def description @description end |
#product_code ⇒ String (readonly)
The product code referring to the item.
16 17 18 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 16 def product_code @product_code end |
#quantity ⇒ Float (readonly)
The item quantity
19 20 21 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 19 def quantity @quantity end |
#tax_amount ⇒ Float (readonly)
The item tax amount.
22 23 24 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 22 def tax_amount @tax_amount end |
#tax_rate ⇒ Float (readonly)
The item tax rate in percentage.
25 26 27 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 25 def tax_rate @tax_rate end |
#total_amount ⇒ Float (readonly)
The item total amount.
28 29 30 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 28 def total_amount @total_amount end |
#unit_measure ⇒ String (readonly)
The item unit of measure.
31 32 33 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 31 def unit_measure @unit_measure end |
#unit_price ⇒ Float (readonly)
The item unit price.
34 35 36 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 34 def unit_price @unit_price end |
Instance Method Details
#printable_values ⇒ Hash
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 52 def printable_values printable = {} printable[:description] = format_for_display(@description) printable[:product_code] = format_for_display(@product_code) printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity) printable[:tax_amount] = @tax_amount.nil? ? '' : Field.float_to_string(@tax_amount) printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate) printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount) printable[:unit_measure] = format_for_display(@unit_measure) printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price) printable end |
#table_printable_values ⇒ Hash
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 66 def table_printable_values printable = {} printable[:description] = format_for_display(@description, 36) printable[:product_code] = format_for_display(@product_code, nil) printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity) printable[:tax_amount] = @tax_amount.nil? ? '' : Field.float_to_string(@tax_amount) printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate) printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount) printable[:unit_measure] = format_for_display(@unit_measure, nil) printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price) printable end |
#to_s ⇒ String
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 95 def to_s printable = printable_values out_str = String.new out_str << "\n :Description: #{printable[:description]}" out_str << "\n :Product code: #{printable[:product_code]}" out_str << "\n :Quantity: #{printable[:quantity]}" out_str << "\n :Tax Amount: #{printable[:tax_amount]}" out_str << "\n :Tax Rate (%): #{printable[:tax_rate]}" out_str << "\n :Total Amount: #{printable[:total_amount]}" out_str << "\n :Unit of measure: #{printable[:unit_measure]}" out_str << "\n :Unit Price: #{printable[:unit_price]}" out_str end |
#to_table_line ⇒ String
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/mindee/product/financial_document/financial_document_v1_line_item.rb', line 80 def to_table_line printable = table_printable_values out_str = String.new out_str << format('| %- 37s', printable[:description]) out_str << format('| %- 13s', printable[:product_code]) out_str << format('| %- 9s', printable[:quantity]) out_str << format('| %- 11s', printable[:tax_amount]) out_str << format('| %- 13s', printable[:tax_rate]) out_str << format('| %- 13s', printable[:total_amount]) out_str << format('| %- 16s', printable[:unit_measure]) out_str << format('| %- 11s', printable[:unit_price]) out_str << '|' end |