mindee 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +2 -0
  4. data/.yardopts +1 -0
  5. data/CHANGELOG.md +36 -0
  6. data/README.md +29 -16
  7. data/bin/mindee.rb +23 -26
  8. data/docs/code_samples/bank_account_details_v1.txt +10 -5
  9. data/docs/code_samples/bank_account_details_v2.txt +19 -0
  10. data/docs/code_samples/bank_check_v1.txt +10 -5
  11. data/docs/code_samples/carte_vitale_v1.txt +10 -5
  12. data/docs/code_samples/custom_v1.txt +19 -10
  13. data/docs/code_samples/default.txt +10 -2
  14. data/docs/code_samples/expense_receipts_v4.txt +10 -5
  15. data/docs/code_samples/expense_receipts_v5.txt +11 -6
  16. data/docs/code_samples/financial_document_v1.txt +10 -5
  17. data/docs/code_samples/idcard_fr_v1.txt +10 -5
  18. data/docs/code_samples/invoice_splitter_v1_async.txt +66 -0
  19. data/docs/code_samples/invoices_v4.txt +10 -5
  20. data/docs/code_samples/license_plates_v1.txt +10 -5
  21. data/docs/code_samples/passport_v1.txt +10 -5
  22. data/docs/code_samples/proof_of_address_v1.txt +10 -5
  23. data/docs/ruby-api-builder.md +30 -31
  24. data/docs/ruby-getting-started.md +64 -23
  25. data/docs/ruby-invoice-ocr.md +70 -59
  26. data/docs/ruby-passport-ocr.md +49 -40
  27. data/docs/ruby-receipt-ocr.md +45 -32
  28. data/lib/mindee/client.rb +150 -148
  29. data/lib/mindee/geometry/min_max.rb +23 -0
  30. data/lib/mindee/geometry/point.rb +35 -0
  31. data/lib/mindee/geometry/polygon.rb +23 -0
  32. data/lib/mindee/geometry/quadrilateral.rb +45 -0
  33. data/lib/mindee/geometry/utils.rb +81 -0
  34. data/lib/mindee/geometry.rb +5 -116
  35. data/lib/mindee/http/endpoint.rb +123 -16
  36. data/lib/mindee/http.rb +3 -0
  37. data/lib/mindee/input/sources.rb +87 -73
  38. data/lib/mindee/parsing/common/api_response.rb +109 -0
  39. data/lib/mindee/parsing/common/document.rb +48 -0
  40. data/lib/mindee/parsing/common/error.rb +24 -0
  41. data/lib/mindee/parsing/common/inference.rb +43 -0
  42. data/lib/mindee/parsing/common/ocr/mvision_v1.rb +34 -0
  43. data/lib/mindee/parsing/common/ocr/ocr.rb +169 -0
  44. data/lib/mindee/parsing/common/ocr.rb +3 -0
  45. data/lib/mindee/parsing/common/orientation.rb +26 -0
  46. data/lib/mindee/parsing/common/page.rb +40 -0
  47. data/lib/mindee/parsing/common/prediction.rb +15 -0
  48. data/lib/mindee/parsing/common/product.rb +19 -0
  49. data/lib/mindee/parsing/common.rb +10 -0
  50. data/lib/mindee/parsing/custom/classification_field.rb +28 -0
  51. data/lib/mindee/parsing/custom/list_field.rb +76 -0
  52. data/lib/mindee/parsing/custom.rb +4 -0
  53. data/lib/mindee/parsing/standard/amount_field.rb +26 -0
  54. data/lib/mindee/parsing/standard/base_field.rb +104 -0
  55. data/lib/mindee/parsing/standard/classification_field.rb +16 -0
  56. data/lib/mindee/parsing/standard/company_registration_field.rb +21 -0
  57. data/lib/mindee/parsing/standard/date_field.rb +34 -0
  58. data/lib/mindee/parsing/standard/locale_field.rb +50 -0
  59. data/lib/mindee/parsing/standard/payment_details_field.rb +42 -0
  60. data/lib/mindee/parsing/standard/position_field.rb +44 -0
  61. data/lib/mindee/parsing/standard/tax_field.rb +108 -0
  62. data/lib/mindee/parsing/standard/text_field.rb +16 -0
  63. data/lib/mindee/parsing/standard.rb +12 -0
  64. data/lib/mindee/parsing.rb +3 -2
  65. data/lib/mindee/{input → pdf}/pdf_processing.rb +4 -32
  66. data/lib/mindee/pdf/pdf_tools.rb +34 -0
  67. data/lib/mindee/pdf.rb +3 -0
  68. data/lib/mindee/product/.rubocop.yml +5 -0
  69. data/lib/mindee/product/custom/custom_v1.rb +35 -0
  70. data/lib/mindee/product/custom/custom_v1_document.rb +60 -0
  71. data/lib/mindee/product/custom/custom_v1_page.rb +32 -0
  72. data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +38 -0
  73. data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +37 -0
  74. data/lib/mindee/product/eu/license_plate/license_plate_v1_page.rb +34 -0
  75. data/lib/mindee/product/financial_document/financial_document_v1.rb +36 -0
  76. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +188 -0
  77. data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +90 -0
  78. data/lib/mindee/product/financial_document/financial_document_v1_page.rb +32 -0
  79. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +38 -0
  80. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb +43 -0
  81. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_page.rb +34 -0
  82. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +38 -0
  83. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +71 -0
  84. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +58 -0
  85. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_page.rb +34 -0
  86. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +38 -0
  87. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_document.rb +52 -0
  88. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_page.rb +34 -0
  89. data/lib/mindee/product/fr/id_card/id_card_v1.rb +38 -0
  90. data/lib/mindee/product/fr/id_card/id_card_v1_document.rb +82 -0
  91. data/lib/mindee/product/fr/id_card/id_card_v1_page.rb +48 -0
  92. data/lib/mindee/product/invoice/invoice_v4.rb +37 -0
  93. data/lib/mindee/product/invoice/invoice_v4_document.rb +212 -0
  94. data/lib/mindee/product/invoice/invoice_v4_line_item.rb +66 -0
  95. data/lib/mindee/product/invoice/invoice_v4_page.rb +32 -0
  96. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +36 -0
  97. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +65 -0
  98. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb +32 -0
  99. data/lib/mindee/product/passport/passport_v1.rb +36 -0
  100. data/lib/mindee/{parsing/prediction/fr/id_card/id_card_v1.rb → product/passport/passport_v1_document.rb} +45 -45
  101. data/lib/mindee/product/passport/passport_v1_page.rb +32 -0
  102. data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +36 -0
  103. data/lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb +83 -0
  104. data/lib/mindee/product/proof_of_address/proof_of_address_v1_page.rb +32 -0
  105. data/lib/mindee/product/receipt/receipt_v4.rb +36 -0
  106. data/lib/mindee/product/receipt/receipt_v4_document.rb +86 -0
  107. data/lib/mindee/product/receipt/receipt_v4_page.rb +32 -0
  108. data/lib/mindee/product/receipt/receipt_v5.rb +36 -0
  109. data/lib/mindee/product/receipt/receipt_v5_document.rb +138 -0
  110. data/lib/mindee/product/receipt/receipt_v5_line_item.rb +69 -0
  111. data/lib/mindee/product/receipt/receipt_v5_page.rb +32 -0
  112. data/lib/mindee/product/us/bank_check/bank_check_v1.rb +38 -0
  113. data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +73 -0
  114. data/lib/mindee/product/us/bank_check/bank_check_v1_page.rb +34 -0
  115. data/lib/mindee/product.rb +16 -0
  116. data/lib/mindee/version.rb +2 -1
  117. data/lib/mindee.rb +3 -1
  118. metadata +87 -38
  119. data/docs/code_samples/shipping_containers_v1.txt +0 -14
  120. data/lib/mindee/document_config.rb +0 -60
  121. data/lib/mindee/parsing/document.rb +0 -31
  122. data/lib/mindee/parsing/error.rb +0 -22
  123. data/lib/mindee/parsing/inference.rb +0 -53
  124. data/lib/mindee/parsing/page.rb +0 -46
  125. data/lib/mindee/parsing/prediction/base.rb +0 -30
  126. data/lib/mindee/parsing/prediction/common_fields/amount.rb +0 -21
  127. data/lib/mindee/parsing/prediction/common_fields/base.rb +0 -72
  128. data/lib/mindee/parsing/prediction/common_fields/company_registration.rb +0 -17
  129. data/lib/mindee/parsing/prediction/common_fields/date.rb +0 -30
  130. data/lib/mindee/parsing/prediction/common_fields/locale.rb +0 -45
  131. data/lib/mindee/parsing/prediction/common_fields/payment_details.rb +0 -33
  132. data/lib/mindee/parsing/prediction/common_fields/position.rb +0 -39
  133. data/lib/mindee/parsing/prediction/common_fields/tax.rb +0 -40
  134. data/lib/mindee/parsing/prediction/common_fields/text.rb +0 -12
  135. data/lib/mindee/parsing/prediction/common_fields.rb +0 -11
  136. data/lib/mindee/parsing/prediction/custom/custom_v1.rb +0 -58
  137. data/lib/mindee/parsing/prediction/custom/fields.rb +0 -91
  138. data/lib/mindee/parsing/prediction/eu/license_plate/license_plate_v1.rb +0 -34
  139. data/lib/mindee/parsing/prediction/financial_document/financial_document_v1.rb +0 -237
  140. data/lib/mindee/parsing/prediction/financial_document/financial_document_v1_line_item.rb +0 -58
  141. data/lib/mindee/parsing/prediction/fr/bank_account_details/bank_account_details_v1.rb +0 -40
  142. data/lib/mindee/parsing/prediction/fr/carte_vitale/carte_vitale_v1.rb +0 -49
  143. data/lib/mindee/parsing/prediction/invoice/invoice_v4.rb +0 -212
  144. data/lib/mindee/parsing/prediction/invoice/invoice_v4_line_item.rb +0 -58
  145. data/lib/mindee/parsing/prediction/passport/passport_v1.rb +0 -121
  146. data/lib/mindee/parsing/prediction/proof_of_address/proof_of_address_v1.rb +0 -80
  147. data/lib/mindee/parsing/prediction/receipt/receipt_v4.rb +0 -87
  148. data/lib/mindee/parsing/prediction/receipt/receipt_v5.rb +0 -136
  149. data/lib/mindee/parsing/prediction/receipt/receipt_v5_line_item.rb +0 -37
  150. data/lib/mindee/parsing/prediction/shipping_container/shipping_container_v1.rb +0 -38
  151. data/lib/mindee/parsing/prediction/us/bank_check/bank_check_v1.rb +0 -70
  152. data/lib/mindee/parsing/prediction.rb +0 -15
@@ -0,0 +1,188 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'financial_document_v1_line_item'
5
+
6
+ module Mindee
7
+ module Product
8
+ module FinancialDocument
9
+ # Financial Document V1 document prediction.
10
+ class FinancialDocumentV1Document < Mindee::Parsing::Common::Prediction
11
+ include Mindee::Parsing::Standard
12
+ # The purchase category among predefined classes.
13
+ # @return [Mindee::Parsing::Standard::ClassificationField]
14
+ attr_reader :category
15
+ # The address of the customer.
16
+ # @return [Mindee::Parsing::Standard::TextField]
17
+ attr_reader :customer_address
18
+ # List of company registrations associated to the customer.
19
+ # @return [Array<Mindee::Parsing::Standard::CompanyRegistration>]
20
+ attr_reader :customer_company_registrations
21
+ # The name of the customer.
22
+ # @return [Mindee::Parsing::Standard::TextField]
23
+ attr_reader :customer_name
24
+ # The date the purchase was made.
25
+ # @return [Mindee::Parsing::Standard::DateField]
26
+ attr_reader :date
27
+ # One of: 'INVOICE', 'CREDIT NOTE', 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'.
28
+ # @return [Mindee::Parsing::Standard::ClassificationField]
29
+ attr_reader :document_type
30
+ # The date on which the payment is due.
31
+ # @return [Mindee::Parsing::Standard::DateField]
32
+ attr_reader :due_date
33
+ # The invoice number or identifier.
34
+ # @return [Mindee::Parsing::Standard::TextField]
35
+ attr_reader :invoice_number
36
+ # List of line item details.
37
+ # @return [Array<Mindee::Product::FinancialDocument::FinancialDocumentV1LineItem>]
38
+ attr_reader :line_items
39
+ # The locale detected on the document.
40
+ # @return [Mindee::Parsing::Standard::Locale]
41
+ attr_reader :locale
42
+ # List of Reference numbers, including PO number.
43
+ # @return [Array<Mindee::Parsing::Standard::TextField>]
44
+ attr_reader :reference_numbers
45
+ # The purchase subcategory among predefined classes for transport and food.
46
+ # @return [Mindee::Parsing::Standard::ClassificationField]
47
+ attr_reader :subcategory
48
+ # The address of the supplier or merchant.
49
+ # @return [Mindee::Parsing::Standard::TextField]
50
+ attr_reader :supplier_address
51
+ # List of company registrations associated to the supplier.
52
+ # @return [Array<Mindee::Parsing::Standard::CompanyRegistration>]
53
+ attr_reader :supplier_company_registrations
54
+ # The name of the supplier or merchant.
55
+ # @return [Mindee::Parsing::Standard::TextField]
56
+ attr_reader :supplier_name
57
+ # List of payment details associated to the supplier.
58
+ # @return [Array<Mindee::Parsing::Standard::PaymentDetails>]
59
+ attr_reader :supplier_payment_details
60
+ # The phone number of the supplier or merchant.
61
+ # @return [Mindee::Parsing::Standard::TextField]
62
+ attr_reader :supplier_phone_number
63
+ # List of tax lines information.
64
+ # @return [Mindee::Parsing::Standard::Taxes]
65
+ attr_reader :taxes
66
+ # The time the purchase was made.
67
+ # @return [Mindee::Parsing::Standard::TextField]
68
+ attr_reader :time
69
+ # The total amount of tip and gratuity
70
+ # @return [Mindee::Parsing::Standard::AmountField]
71
+ attr_reader :tip
72
+ # The total amount paid: includes taxes, tips, fees, and other charges.
73
+ # @return [Mindee::Parsing::Standard::AmountField]
74
+ attr_reader :total_amount
75
+ # The net amount paid: does not include taxes, fees, and discounts.
76
+ # @return [Mindee::Parsing::Standard::AmountField]
77
+ attr_reader :total_net
78
+ # The total amount of taxes.
79
+ # @return [Mindee::Parsing::Standard::AmountField]
80
+ attr_reader :total_tax
81
+
82
+ # @param prediction [Hash]
83
+ # @param page_id [Integer, nil]
84
+ def initialize(prediction, page_id)
85
+ super()
86
+ @category = ClassificationField.new(prediction['category'], page_id)
87
+ @customer_address = TextField.new(prediction['customer_address'], page_id)
88
+ @customer_company_registrations = []
89
+ prediction['customer_company_registrations'].each do |item|
90
+ @customer_company_registrations.push(CompanyRegistration.new(item, page_id))
91
+ end
92
+ @customer_name = TextField.new(prediction['customer_name'], page_id)
93
+ @date = DateField.new(prediction['date'], page_id)
94
+ @document_type = ClassificationField.new(prediction['document_type'], page_id)
95
+ @due_date = DateField.new(prediction['due_date'], page_id)
96
+ @invoice_number = TextField.new(prediction['invoice_number'], page_id)
97
+ @line_items = []
98
+ prediction['line_items'].each do |item|
99
+ @line_items.push(FinancialDocumentV1LineItem.new(item, page_id))
100
+ end
101
+ @locale = Locale.new(prediction['locale'], page_id)
102
+ @reference_numbers = []
103
+ prediction['reference_numbers'].each do |item|
104
+ @reference_numbers.push(TextField.new(item, page_id))
105
+ end
106
+ @subcategory = ClassificationField.new(prediction['subcategory'], page_id)
107
+ @supplier_address = TextField.new(prediction['supplier_address'], page_id)
108
+ @supplier_company_registrations = []
109
+ prediction['supplier_company_registrations'].each do |item|
110
+ @supplier_company_registrations.push(CompanyRegistration.new(item, page_id))
111
+ end
112
+ @supplier_name = TextField.new(prediction['supplier_name'], page_id)
113
+ @supplier_payment_details = []
114
+ prediction['supplier_payment_details'].each do |item|
115
+ @supplier_payment_details.push(PaymentDetails.new(item, page_id))
116
+ end
117
+ @supplier_phone_number = TextField.new(prediction['supplier_phone_number'], page_id)
118
+ @taxes = Taxes.new(prediction['taxes'], page_id)
119
+ @time = TextField.new(prediction['time'], page_id)
120
+ @tip = AmountField.new(prediction['tip'], page_id)
121
+ @total_amount = AmountField.new(prediction['total_amount'], page_id)
122
+ @total_net = AmountField.new(prediction['total_net'], page_id)
123
+ @total_tax = AmountField.new(prediction['total_tax'], page_id)
124
+ end
125
+
126
+ # @return [String]
127
+ def to_s
128
+ reference_numbers = @reference_numbers.join("\n #{' ' * 19}")
129
+ supplier_payment_details = @supplier_payment_details.join("\n #{' ' * 26}")
130
+ supplier_company_registrations = @supplier_company_registrations.join("\n #{' ' * 32}")
131
+ customer_company_registrations = @customer_company_registrations.join("\n #{' ' * 32}")
132
+ line_items = line_items_to_s
133
+ out_str = String.new
134
+ out_str << "\n:Locale: #{@locale}".rstrip
135
+ out_str << "\n:Invoice Number: #{@invoice_number}".rstrip
136
+ out_str << "\n:Reference Numbers: #{reference_numbers}".rstrip
137
+ out_str << "\n:Purchase Date: #{@date}".rstrip
138
+ out_str << "\n:Due Date: #{@due_date}".rstrip
139
+ out_str << "\n:Total Net: #{@total_net}".rstrip
140
+ out_str << "\n:Total Amount: #{@total_amount}".rstrip
141
+ out_str << "\n:Taxes:#{@taxes}".rstrip
142
+ out_str << "\n:Supplier Payment Details: #{supplier_payment_details}".rstrip
143
+ out_str << "\n:Supplier name: #{@supplier_name}".rstrip
144
+ out_str << "\n:Supplier Company Registrations: #{supplier_company_registrations}".rstrip
145
+ out_str << "\n:Supplier Address: #{@supplier_address}".rstrip
146
+ out_str << "\n:Supplier Phone Number: #{@supplier_phone_number}".rstrip
147
+ out_str << "\n:Customer name: #{@customer_name}".rstrip
148
+ out_str << "\n:Customer Company Registrations: #{customer_company_registrations}".rstrip
149
+ out_str << "\n:Customer Address: #{@customer_address}".rstrip
150
+ out_str << "\n:Document Type: #{@document_type}".rstrip
151
+ out_str << "\n:Purchase Subcategory: #{@subcategory}".rstrip
152
+ out_str << "\n:Purchase Category: #{@category}".rstrip
153
+ out_str << "\n:Total Tax: #{@total_tax}".rstrip
154
+ out_str << "\n:Tip and Gratuity: #{@tip}".rstrip
155
+ out_str << "\n:Purchase Time: #{@time}".rstrip
156
+ out_str << "\n:Line Items:"
157
+ out_str << line_items
158
+ out_str[1..].to_s
159
+ end
160
+
161
+ private
162
+
163
+ def line_items_separator(char)
164
+ " +#{char * 38}+#{char * 14}+#{char * 10}+#{char * 12}+#{char * 14}+#{char * 14}+#{char * 12}+"
165
+ end
166
+
167
+ def line_items_to_s
168
+ return '' if @line_items.empty?
169
+
170
+ line_items = @line_items.map(&:to_table_line).join("\n#{line_items_separator('-')}\n ")
171
+ out_str = String.new
172
+ out_str << "\n#{line_items_separator('-')}"
173
+ out_str << "\n |"
174
+ out_str << ' Description |'
175
+ out_str << ' Product code |'
176
+ out_str << ' Quantity |'
177
+ out_str << ' Tax Amount |'
178
+ out_str << ' Tax Rate (%) |'
179
+ out_str << ' Total Amount |'
180
+ out_str << ' Unit Price |'
181
+ out_str << "\n#{line_items_separator('=')}"
182
+ out_str << "\n #{line_items}"
183
+ out_str << "\n#{line_items_separator('-')}"
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FinancialDocument
8
+ # List of line item details.
9
+ class FinancialDocumentV1LineItem < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # The item description.
12
+ # @return [String]
13
+ attr_reader :description
14
+ # The product code referring to the item.
15
+ # @return [String]
16
+ attr_reader :product_code
17
+ # The item quantity
18
+ # @return [Float]
19
+ attr_reader :quantity
20
+ # The item tax amount.
21
+ # @return [Float]
22
+ attr_reader :tax_amount
23
+ # The item tax rate in percentage.
24
+ # @return [Float]
25
+ attr_reader :tax_rate
26
+ # The item total amount.
27
+ # @return [Float]
28
+ attr_reader :total_amount
29
+ # The item unit price.
30
+ # @return [Float]
31
+ attr_reader :unit_price
32
+
33
+ # @param prediction [Hash]
34
+ # @param page_id [Integer, nil]
35
+ def initialize(prediction, page_id)
36
+ super(prediction, page_id)
37
+ @description = prediction['description']
38
+ @product_code = prediction['product_code']
39
+ @quantity = prediction['quantity']
40
+ @tax_amount = prediction['tax_amount']
41
+ @tax_rate = prediction['tax_rate']
42
+ @total_amount = prediction['total_amount']
43
+ @unit_price = prediction['unit_price']
44
+ @page_id = page_id
45
+ end
46
+
47
+ # @return [Hash]
48
+ def printable_values
49
+ printable = {}
50
+ printable[:description] = format_for_display(@description, 36)
51
+ printable[:product_code] = format_for_display(@product_code, nil)
52
+ printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
53
+ printable[:tax_amount] = @tax_amount.nil? ? '' : Field.float_to_string(@tax_amount)
54
+ printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
55
+ printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount)
56
+ printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
57
+ printable
58
+ end
59
+
60
+ # @return [String]
61
+ def to_table_line
62
+ printable = printable_values
63
+ out_str = String.new
64
+ out_str << format('| %- 37s', printable[:description])
65
+ out_str << format('| %- 13s', printable[:product_code])
66
+ out_str << format('| %- 9s', printable[:quantity])
67
+ out_str << format('| %- 11s', printable[:tax_amount])
68
+ out_str << format('| %- 13s', printable[:tax_rate])
69
+ out_str << format('| %- 13s', printable[:total_amount])
70
+ out_str << format('| %- 11s', printable[:unit_price])
71
+ out_str << '|'
72
+ end
73
+
74
+ # @return [String]
75
+ def to_s
76
+ printable = printable_values
77
+ out_str = String.new
78
+ out_str << printable[:description]
79
+ out_str << printable[:product_code]
80
+ out_str << printable[:quantity]
81
+ out_str << printable[:tax_amount]
82
+ out_str << printable[:tax_rate]
83
+ out_str << printable[:total_amount]
84
+ out_str << printable[:unit_price]
85
+ out_str.strip
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'financial_document_v1_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module FinancialDocument
9
+ # Financial Document V1 page.
10
+ class FinancialDocumentV1Page < Mindee::Parsing::Common::Page
11
+ # @param prediction [Hash]
12
+ def initialize(prediction)
13
+ super(prediction)
14
+ @prediction = FinancialDocumentV1PagePrediction.new(
15
+ prediction['prediction'],
16
+ prediction['id']
17
+ )
18
+ end
19
+ end
20
+
21
+ # Financial Document V1 page prediction.
22
+ class FinancialDocumentV1PagePrediction < FinancialDocumentV1Document
23
+ # @return [String]
24
+ def to_s
25
+ out_str = String.new
26
+ out_str << "\n#{super}"
27
+ out_str
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'bank_account_details_v1_document'
5
+ require_relative 'bank_account_details_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ module FR
10
+ module BankAccountDetails
11
+ # Bank Account Details V1 prediction inference.
12
+ class BankAccountDetailsV1 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'bank_account_details'
14
+ @endpoint_version = '1'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = BankAccountDetailsV1Document.new(prediction['prediction'], nil)
20
+ @pages = []
21
+ prediction['pages'].each do |page|
22
+ @pages.push(BankAccountDetailsV1Page.new(page))
23
+ end
24
+ end
25
+
26
+ class << self
27
+ # Name of the endpoint for this product.
28
+ # @return [String]
29
+ attr_reader :endpoint_name
30
+ # Version for this product.
31
+ # @return [String]
32
+ attr_reader :endpoint_version
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module BankAccountDetails
9
+ # Bank Account Details V1 document prediction.
10
+ class BankAccountDetailsV1Document < Mindee::Parsing::Common::Prediction
11
+ include Mindee::Parsing::Standard
12
+ # The name of the account holder as seen on the document.
13
+ # @return [Mindee::Parsing::Standard::TextField]
14
+ attr_reader :account_holder_name
15
+ # The International Bank Account Number (IBAN).
16
+ # @return [Mindee::Parsing::Standard::TextField]
17
+ attr_reader :iban
18
+ # The bank's SWIFT Business Identifier Code (BIC).
19
+ # @return [Mindee::Parsing::Standard::TextField]
20
+ attr_reader :swift
21
+
22
+ # @param prediction [Hash]
23
+ # @param page_id [Integer, nil]
24
+ def initialize(prediction, page_id)
25
+ super()
26
+ @account_holder_name = TextField.new(prediction['account_holder_name'], page_id)
27
+ @iban = TextField.new(prediction['iban'], page_id)
28
+ @swift = TextField.new(prediction['swift'], page_id)
29
+ end
30
+
31
+ # @return [String]
32
+ def to_s
33
+ out_str = String.new
34
+ out_str << "\n:IBAN: #{@iban}".rstrip
35
+ out_str << "\n:Account Holder's Name: #{@account_holder_name}".rstrip
36
+ out_str << "\n:SWIFT Code: #{@swift}".rstrip
37
+ out_str[1..].to_s
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'bank_account_details_v1_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module FR
9
+ module BankAccountDetails
10
+ # Bank Account Details V1 page.
11
+ class BankAccountDetailsV1Page < Mindee::Parsing::Common::Page
12
+ # @param prediction [Hash]
13
+ def initialize(prediction)
14
+ super(prediction)
15
+ @prediction = BankAccountDetailsV1PagePrediction.new(
16
+ prediction['prediction'],
17
+ prediction['id']
18
+ )
19
+ end
20
+ end
21
+
22
+ # Bank Account Details V1 page prediction.
23
+ class BankAccountDetailsV1PagePrediction < BankAccountDetailsV1Document
24
+ # @return [String]
25
+ def to_s
26
+ out_str = String.new
27
+ out_str << "\n#{super}"
28
+ out_str
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'bank_account_details_v2_document'
5
+ require_relative 'bank_account_details_v2_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ module FR
10
+ module BankAccountDetails
11
+ # Bank Account Details V2 prediction inference.
12
+ class BankAccountDetailsV2 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'bank_account_details'
14
+ @endpoint_version = '2'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = BankAccountDetailsV2Document.new(prediction['prediction'], nil)
20
+ @pages = []
21
+ prediction['pages'].each do |page|
22
+ @pages.push(BankAccountDetailsV2Page.new(page))
23
+ end
24
+ end
25
+
26
+ class << self
27
+ # Name of the endpoint for this product.
28
+ # @return [String]
29
+ attr_reader :endpoint_name
30
+ # Version for this product.
31
+ # @return [String]
32
+ attr_reader :endpoint_version
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module BankAccountDetails
9
+ # Full extraction of BBAN, including: branch code, bank code, account and key.
10
+ class BankAccountDetailsV2Bban < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # The BBAN bank code outputted as a string.
13
+ # @return [String]
14
+ attr_reader :bban_bank_code
15
+ # The BBAN branch code outputted as a string.
16
+ # @return [String]
17
+ attr_reader :bban_branch_code
18
+ # The BBAN key outputted as a string.
19
+ # @return [String]
20
+ attr_reader :bban_key
21
+ # The BBAN Account number outputted as a string.
22
+ # @return [String]
23
+ attr_reader :bban_number
24
+
25
+ # @param prediction [Hash]
26
+ # @param page_id [Integer, nil]
27
+ def initialize(prediction, page_id)
28
+ super(prediction, page_id)
29
+ @bban_bank_code = prediction['bban_bank_code']
30
+ @bban_branch_code = prediction['bban_branch_code']
31
+ @bban_key = prediction['bban_key']
32
+ @bban_number = prediction['bban_number']
33
+ @page_id = page_id
34
+ end
35
+
36
+ # @return [Hash]
37
+ def printable_values
38
+ printable = {}
39
+ printable[:bban_bank_code] = format_for_display(@bban_bank_code, nil)
40
+ printable[:bban_branch_code] = format_for_display(@bban_branch_code, nil)
41
+ printable[:bban_key] = format_for_display(@bban_key, nil)
42
+ printable[:bban_number] = format_for_display(@bban_number, nil)
43
+ printable
44
+ end
45
+
46
+ # @return [String]
47
+ def to_table_line
48
+ printable = printable_values
49
+ out_str = String.new
50
+ out_str << format('| %- 10s', printable[:bban_bank_code])
51
+ out_str << format('| %- 12s', printable[:bban_branch_code])
52
+ out_str << format('| %- 4s', printable[:bban_key])
53
+ out_str << format('| %- 15s', printable[:bban_number])
54
+ out_str << '|'
55
+ end
56
+
57
+ # @return [String]
58
+ def to_s
59
+ printable = printable_values
60
+ out_str = String.new
61
+ out_str << "\n :Bank Code: #{printable[:bban_bank_code]}"
62
+ out_str << "\n :Branch Code: #{printable[:bban_branch_code]}"
63
+ out_str << "\n :Key: #{printable[:bban_key]}"
64
+ out_str << "\n :Account Number: #{printable[:bban_number]}"
65
+ out_str
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'bank_account_details_v2_bban'
5
+
6
+ module Mindee
7
+ module Product
8
+ module FR
9
+ module BankAccountDetails
10
+ # Bank Account Details V2 document prediction.
11
+ class BankAccountDetailsV2Document < Mindee::Parsing::Common::Prediction
12
+ include Mindee::Parsing::Standard
13
+ # Full extraction of the account holders names.
14
+ # @return [Mindee::Parsing::Standard::TextField]
15
+ attr_reader :account_holders_names
16
+ # Full extraction of BBAN, including: branch code, bank code, account and key.
17
+ # @return [Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV2Bban]
18
+ attr_reader :bban
19
+ # Full extraction of the IBAN number.
20
+ # @return [Mindee::Parsing::Standard::TextField]
21
+ attr_reader :iban
22
+ # Full extraction of the SWIFT code.
23
+ # @return [Mindee::Parsing::Standard::TextField]
24
+ attr_reader :swift_code
25
+
26
+ # @param prediction [Hash]
27
+ # @param page_id [Integer, nil]
28
+ def initialize(prediction, page_id)
29
+ super()
30
+ @account_holders_names = TextField.new(prediction['account_holders_names'], page_id)
31
+ @bban = BankAccountDetailsV2Bban.new(prediction['bban'], page_id)
32
+ @iban = TextField.new(prediction['iban'], page_id)
33
+ @swift_code = TextField.new(prediction['swift_code'], page_id)
34
+ end
35
+
36
+ # @return [String]
37
+ def to_s
38
+ bban = bban_to_s
39
+ out_str = String.new
40
+ out_str << "\n:Account Holder's Names: #{@account_holders_names}".rstrip
41
+ out_str << "\n:Basic Bank Account Number:"
42
+ out_str << bban
43
+ out_str << "\n:IBAN: #{@iban}".rstrip
44
+ out_str << "\n:SWIFT Code: #{@swift_code}".rstrip
45
+ out_str[1..].to_s
46
+ end
47
+
48
+ private
49
+
50
+ # @return [String]
51
+ def bban_to_s
52
+ @bban.to_s
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'bank_account_details_v2_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module FR
9
+ module BankAccountDetails
10
+ # Bank Account Details V2 page.
11
+ class BankAccountDetailsV2Page < Mindee::Parsing::Common::Page
12
+ # @param prediction [Hash]
13
+ def initialize(prediction)
14
+ super(prediction)
15
+ @prediction = BankAccountDetailsV2PagePrediction.new(
16
+ prediction['prediction'],
17
+ prediction['id']
18
+ )
19
+ end
20
+ end
21
+
22
+ # Bank Account Details V2 page prediction.
23
+ class BankAccountDetailsV2PagePrediction < BankAccountDetailsV2Document
24
+ # @return [String]
25
+ def to_s
26
+ out_str = String.new
27
+ out_str << "\n#{super}"
28
+ out_str
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'carte_vitale_v1_document'
5
+ require_relative 'carte_vitale_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ module FR
10
+ module CarteVitale
11
+ # Carte Vitale V1 prediction inference.
12
+ class CarteVitaleV1 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'carte_vitale'
14
+ @endpoint_version = '1'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = CarteVitaleV1Document.new(prediction['prediction'], nil)
20
+ @pages = []
21
+ prediction['pages'].each do |page|
22
+ @pages.push(CarteVitaleV1Page.new(page))
23
+ end
24
+ end
25
+
26
+ class << self
27
+ # Name of the endpoint for this product.
28
+ # @return [String]
29
+ attr_reader :endpoint_name
30
+ # Version for this product.
31
+ # @return [String]
32
+ attr_reader :endpoint_version
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end