mindee 3.11.0 → 3.13.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 (142) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +27 -0
  4. data/README.md +23 -23
  5. data/Rakefile +5 -0
  6. data/bin/mindee.rb +7 -1
  7. data/docs/bank_account_details_v2.md +5 -1
  8. data/docs/bank_check_v1.md +6 -2
  9. data/docs/bank_statement_fr_v1.md +3 -0
  10. data/docs/barcode_reader_v1.md +5 -1
  11. data/docs/bill_of_lading_v1.md +202 -0
  12. data/docs/carte_grise_v1.md +5 -1
  13. data/docs/carte_vitale_v1.md +5 -1
  14. data/docs/code_samples/bill_of_lading_v1_async.txt +19 -0
  15. data/docs/code_samples/energy_bill_fra_v1_async.txt +19 -0
  16. data/docs/code_samples/financial_document_v1_async.txt +19 -0
  17. data/docs/code_samples/invoices_v4_async.txt +19 -0
  18. data/docs/code_samples/nutrition_facts_v1_async.txt +19 -0
  19. data/docs/code_samples/payslip_fra_v2_async.txt +19 -0
  20. data/docs/code_samples/us_healthcare_cards_v1_async.txt +19 -0
  21. data/docs/cropper_v1.md +6 -2
  22. data/docs/custom_v1.md +5 -3
  23. data/docs/energy_bill_fra_v1.md +249 -0
  24. data/docs/eu_driver_license_v1.md +6 -2
  25. data/docs/expense_receipts_v5.md +38 -11
  26. data/docs/financial_document_v1.md +80 -23
  27. data/docs/generated_v1.md +3 -0
  28. data/docs/getting_started.md +3 -0
  29. data/docs/idcard_fr_v2.md +15 -2
  30. data/docs/international_id_v2.md +13 -1
  31. data/docs/invoice_splitter_v1.md +16 -13
  32. data/docs/invoices_v4.md +57 -23
  33. data/docs/license_plates_v1.md +5 -1
  34. data/docs/multi_receipts_detector_v1.md +5 -1
  35. data/docs/nutrition_facts_v1.md +295 -0
  36. data/docs/passport_v1.md +5 -1
  37. data/docs/payslip_fra_v2.md +218 -0
  38. data/docs/proof_of_address_v1.md +5 -1
  39. data/docs/resume_v1.md +24 -1
  40. data/docs/us_driver_license_v1.md +6 -2
  41. data/docs/us_healthcare_cards_v1.md +208 -0
  42. data/docs/us_mail_v2.md +5 -1
  43. data/docs/us_w9_v1.md +6 -2
  44. data/examples/auto_invoice_splitter_extraction.rb +43 -0
  45. data/lib/mindee/client.rb +20 -8
  46. data/lib/mindee/extraction/common/extracted_image.rb +73 -0
  47. data/lib/mindee/extraction/common/image_extractor.rb +189 -0
  48. data/lib/mindee/extraction/common.rb +4 -0
  49. data/lib/mindee/extraction/multi_receipts_extractor/multi_receipts_extractor.rb +26 -0
  50. data/lib/mindee/extraction/multi_receipts_extractor.rb +3 -0
  51. data/lib/mindee/extraction/pdf_extractor/extracted_pdf.rb +55 -0
  52. data/lib/mindee/extraction/pdf_extractor/pdf_extractor.rb +111 -0
  53. data/lib/mindee/extraction/pdf_extractor.rb +4 -0
  54. data/lib/mindee/extraction/tax_extractor/tax_extractor.rb +322 -0
  55. data/lib/mindee/extraction/tax_extractor.rb +1 -320
  56. data/lib/mindee/extraction.rb +3 -0
  57. data/lib/mindee/http/endpoint.rb +18 -6
  58. data/lib/mindee/input/sources.rb +8 -0
  59. data/lib/mindee/parsing/common/api_response.rb +1 -1
  60. data/lib/mindee/parsing/common/document.rb +31 -1
  61. data/lib/mindee/parsing/common/extras/cropper_extra.rb +29 -0
  62. data/lib/mindee/parsing/common/extras/extras.rb +50 -0
  63. data/lib/mindee/parsing/common/extras/full_text_ocr_extra.rb +32 -0
  64. data/lib/mindee/parsing/common/extras.rb +5 -0
  65. data/lib/mindee/parsing/common/page.rb +5 -0
  66. data/lib/mindee/parsing/standard/base_field.rb +1 -0
  67. data/lib/mindee/parsing/standard/company_registration_field.rb +17 -0
  68. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1.rb +39 -0
  69. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rb +52 -0
  70. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb +95 -0
  71. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rb +58 -0
  72. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_document.rb +136 -0
  73. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rb +58 -0
  74. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_page.rb +32 -0
  75. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rb +58 -0
  76. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +3 -1
  77. data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +22 -1
  78. data/lib/mindee/product/financial_document/financial_document_v1_page.rb +1 -1
  79. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +4 -15
  80. data/lib/mindee/product/fr/energy_bill/energy_bill_v1.rb +41 -0
  81. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +235 -0
  82. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rb +48 -0
  83. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rb +48 -0
  84. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +97 -0
  85. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +54 -0
  86. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +34 -0
  87. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb +97 -0
  88. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rb +97 -0
  89. data/lib/mindee/product/fr/payslip/payslip_v2.rb +41 -0
  90. data/lib/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rb +54 -0
  91. data/lib/mindee/product/fr/payslip/payslip_v2_document.rb +128 -0
  92. data/lib/mindee/product/fr/payslip/payslip_v2_employee.rb +78 -0
  93. data/lib/mindee/product/fr/payslip/payslip_v2_employer.rb +78 -0
  94. data/lib/mindee/product/fr/payslip/payslip_v2_employment.rb +72 -0
  95. data/lib/mindee/product/fr/payslip/payslip_v2_page.rb +34 -0
  96. data/lib/mindee/product/fr/payslip/payslip_v2_pay_detail.rb +100 -0
  97. data/lib/mindee/product/fr/payslip/payslip_v2_pay_period.rb +66 -0
  98. data/lib/mindee/product/fr/payslip/payslip_v2_pto.rb +56 -0
  99. data/lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb +81 -0
  100. data/lib/mindee/product/international_id/international_id_v2_document.rb +1 -1
  101. data/lib/mindee/product/international_id/international_id_v2_page.rb +1 -1
  102. data/lib/mindee/product/invoice/invoice_v4_document.rb +3 -1
  103. data/lib/mindee/product/invoice/invoice_v4_line_item.rb +22 -1
  104. data/lib/mindee/product/invoice/invoice_v4_page.rb +1 -1
  105. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +1 -1
  106. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +1 -1
  107. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +1 -1
  108. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rb +39 -0
  109. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rb +52 -0
  110. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rb +52 -0
  111. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb +52 -0
  112. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rb +52 -0
  113. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rb +173 -0
  114. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rb +87 -0
  115. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rb +32 -0
  116. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rb +52 -0
  117. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rb +52 -0
  118. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb +46 -0
  119. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb +58 -0
  120. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rb +52 -0
  121. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb +52 -0
  122. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rb +52 -0
  123. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rb +52 -0
  124. data/lib/mindee/product/receipt/receipt_v5_document.rb +1 -1
  125. data/lib/mindee/product/receipt/receipt_v5_line_item.rb +11 -1
  126. data/lib/mindee/product/receipt/receipt_v5_page.rb +1 -1
  127. data/lib/mindee/product/resume/resume_v1_certificate.rb +11 -1
  128. data/lib/mindee/product/resume/resume_v1_education.rb +14 -1
  129. data/lib/mindee/product/resume/resume_v1_language.rb +9 -1
  130. data/lib/mindee/product/resume/resume_v1_professional_experience.rb +15 -1
  131. data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +9 -1
  132. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1.rb +41 -0
  133. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb +65 -0
  134. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb +127 -0
  135. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb +34 -0
  136. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +14 -1
  137. data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +5 -17
  138. data/lib/mindee/product.rb +6 -1
  139. data/lib/mindee/version.rb +1 -1
  140. data/mindee.gemspec +1 -0
  141. metadata +91 -3
  142. /data/lib/mindee/extraction/{ocr_extractor.rb → tax_extractor/ocr_extractor.rb} +0 -0
@@ -0,0 +1,235 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'energy_bill_v1_energy_supplier'
5
+ require_relative 'energy_bill_v1_energy_consumer'
6
+ require_relative 'energy_bill_v1_subscription'
7
+ require_relative 'energy_bill_v1_energy_usage'
8
+ require_relative 'energy_bill_v1_taxes_and_contribution'
9
+ require_relative 'energy_bill_v1_meter_detail'
10
+
11
+ module Mindee
12
+ module Product
13
+ module FR
14
+ module EnergyBill
15
+ # Energy Bill API version 1.0 document data.
16
+ class EnergyBillV1Document < Mindee::Parsing::Common::Prediction
17
+ include Mindee::Parsing::Standard
18
+ # The unique identifier associated with a specific contract.
19
+ # @return [Mindee::Parsing::Standard::StringField]
20
+ attr_reader :contract_id
21
+ # The unique identifier assigned to each electricity or gas consumption point. It specifies the exact
22
+ # location where the energy is delivered.
23
+ # @return [Mindee::Parsing::Standard::StringField]
24
+ attr_reader :delivery_point
25
+ # The date by which the payment for the energy invoice is due.
26
+ # @return [Mindee::Parsing::Standard::DateField]
27
+ attr_reader :due_date
28
+ # The entity that consumes the energy.
29
+ # @return [Mindee::Product::FR::EnergyBill::EnergyBillV1EnergyConsumer]
30
+ attr_reader :energy_consumer
31
+ # The company that supplies the energy.
32
+ # @return [Mindee::Product::FR::EnergyBill::EnergyBillV1EnergySupplier]
33
+ attr_reader :energy_supplier
34
+ # Details of energy consumption.
35
+ # @return [Array<Mindee::Product::FR::EnergyBill::EnergyBillV1EnergyUsage>]
36
+ attr_reader :energy_usage
37
+ # The date when the energy invoice was issued.
38
+ # @return [Mindee::Parsing::Standard::DateField]
39
+ attr_reader :invoice_date
40
+ # The unique identifier of the energy invoice.
41
+ # @return [Mindee::Parsing::Standard::StringField]
42
+ attr_reader :invoice_number
43
+ # Information about the energy meter.
44
+ # @return [Mindee::Product::FR::EnergyBill::EnergyBillV1MeterDetail]
45
+ attr_reader :meter_details
46
+ # The subscription details fee for the energy service.
47
+ # @return [Array<Mindee::Product::FR::EnergyBill::EnergyBillV1Subscription>]
48
+ attr_reader :subscription
49
+ # Details of Taxes and Contributions.
50
+ # @return [Array<Mindee::Product::FR::EnergyBill::EnergyBillV1TaxesAndContribution>]
51
+ attr_reader :taxes_and_contributions
52
+ # The total amount to be paid for the energy invoice.
53
+ # @return [Mindee::Parsing::Standard::AmountField]
54
+ attr_reader :total_amount
55
+ # The total amount to be paid for the energy invoice before taxes.
56
+ # @return [Mindee::Parsing::Standard::AmountField]
57
+ attr_reader :total_before_taxes
58
+ # Total of taxes applied to the invoice.
59
+ # @return [Mindee::Parsing::Standard::AmountField]
60
+ attr_reader :total_taxes
61
+
62
+ # @param prediction [Hash]
63
+ # @param page_id [Integer, nil]
64
+ def initialize(prediction, page_id)
65
+ super()
66
+ @contract_id = StringField.new(prediction['contract_id'], page_id)
67
+ @delivery_point = StringField.new(prediction['delivery_point'], page_id)
68
+ @due_date = DateField.new(prediction['due_date'], page_id)
69
+ @energy_consumer = EnergyBillV1EnergyConsumer.new(prediction['energy_consumer'], page_id)
70
+ @energy_supplier = EnergyBillV1EnergySupplier.new(prediction['energy_supplier'], page_id)
71
+ @energy_usage = []
72
+ prediction['energy_usage'].each do |item|
73
+ @energy_usage.push(EnergyBillV1EnergyUsage.new(item, page_id))
74
+ end
75
+ @invoice_date = DateField.new(prediction['invoice_date'], page_id)
76
+ @invoice_number = StringField.new(prediction['invoice_number'], page_id)
77
+ @meter_details = EnergyBillV1MeterDetail.new(prediction['meter_details'], page_id)
78
+ @subscription = []
79
+ prediction['subscription'].each do |item|
80
+ @subscription.push(EnergyBillV1Subscription.new(item, page_id))
81
+ end
82
+ @taxes_and_contributions = []
83
+ prediction['taxes_and_contributions'].each do |item|
84
+ @taxes_and_contributions.push(EnergyBillV1TaxesAndContribution.new(item, page_id))
85
+ end
86
+ @total_amount = AmountField.new(prediction['total_amount'], page_id)
87
+ @total_before_taxes = AmountField.new(prediction['total_before_taxes'], page_id)
88
+ @total_taxes = AmountField.new(prediction['total_taxes'], page_id)
89
+ end
90
+
91
+ # @return [String]
92
+ def to_s
93
+ energy_supplier = @energy_supplier.to_s
94
+ energy_consumer = @energy_consumer.to_s
95
+ subscription = subscription_to_s
96
+ energy_usage = energy_usage_to_s
97
+ taxes_and_contributions = taxes_and_contributions_to_s
98
+ meter_details = @meter_details.to_s
99
+ out_str = String.new
100
+ out_str << "\n:Invoice Number: #{@invoice_number}".rstrip
101
+ out_str << "\n:Contract ID: #{@contract_id}".rstrip
102
+ out_str << "\n:Delivery Point: #{@delivery_point}".rstrip
103
+ out_str << "\n:Invoice Date: #{@invoice_date}".rstrip
104
+ out_str << "\n:Due Date: #{@due_date}".rstrip
105
+ out_str << "\n:Total Before Taxes: #{@total_before_taxes}".rstrip
106
+ out_str << "\n:Total Taxes: #{@total_taxes}".rstrip
107
+ out_str << "\n:Total Amount: #{@total_amount}".rstrip
108
+ out_str << "\n:Energy Supplier:"
109
+ out_str << energy_supplier
110
+ out_str << "\n:Energy Consumer:"
111
+ out_str << energy_consumer
112
+ out_str << "\n:Subscription:"
113
+ out_str << subscription
114
+ out_str << "\n:Energy Usage:"
115
+ out_str << energy_usage
116
+ out_str << "\n:Taxes and Contributions:"
117
+ out_str << taxes_and_contributions
118
+ out_str << "\n:Meter Details:"
119
+ out_str << meter_details
120
+ out_str[1..].to_s
121
+ end
122
+
123
+ private
124
+
125
+ # @param char [String]
126
+ # @return [String]
127
+ def subscription_separator(char)
128
+ out_str = String.new
129
+ out_str << ' '
130
+ out_str << "+#{char * 38}"
131
+ out_str << "+#{char * 12}"
132
+ out_str << "+#{char * 12}"
133
+ out_str << "+#{char * 10}"
134
+ out_str << "+#{char * 11}"
135
+ out_str << "+#{char * 12}"
136
+ out_str << '+'
137
+ out_str
138
+ end
139
+
140
+ # @return [String]
141
+ def subscription_to_s
142
+ return '' if @subscription.empty?
143
+
144
+ line_items = @subscription.map(&:to_table_line).join("\n#{subscription_separator('-')}\n ")
145
+ out_str = String.new
146
+ out_str << "\n#{subscription_separator('-')}"
147
+ out_str << "\n |"
148
+ out_str << ' Description |'
149
+ out_str << ' End Date |'
150
+ out_str << ' Start Date |'
151
+ out_str << ' Tax Rate |'
152
+ out_str << ' Total |'
153
+ out_str << ' Unit Price |'
154
+ out_str << "\n#{subscription_separator('=')}"
155
+ out_str << "\n #{line_items}"
156
+ out_str << "\n#{subscription_separator('-')}"
157
+ out_str
158
+ end
159
+
160
+ # @param char [String]
161
+ # @return [String]
162
+ def energy_usage_separator(char)
163
+ out_str = String.new
164
+ out_str << ' '
165
+ out_str << "+#{char * 38}"
166
+ out_str << "+#{char * 12}"
167
+ out_str << "+#{char * 12}"
168
+ out_str << "+#{char * 10}"
169
+ out_str << "+#{char * 11}"
170
+ out_str << "+#{char * 12}"
171
+ out_str << '+'
172
+ out_str
173
+ end
174
+
175
+ # @return [String]
176
+ def energy_usage_to_s
177
+ return '' if @energy_usage.empty?
178
+
179
+ line_items = @energy_usage.map(&:to_table_line).join("\n#{energy_usage_separator('-')}\n ")
180
+ out_str = String.new
181
+ out_str << "\n#{energy_usage_separator('-')}"
182
+ out_str << "\n |"
183
+ out_str << ' Description |'
184
+ out_str << ' End Date |'
185
+ out_str << ' Start Date |'
186
+ out_str << ' Tax Rate |'
187
+ out_str << ' Total |'
188
+ out_str << ' Unit Price |'
189
+ out_str << "\n#{energy_usage_separator('=')}"
190
+ out_str << "\n #{line_items}"
191
+ out_str << "\n#{energy_usage_separator('-')}"
192
+ out_str
193
+ end
194
+
195
+ # @param char [String]
196
+ # @return [String]
197
+ def taxes_and_contributions_separator(char)
198
+ out_str = String.new
199
+ out_str << ' '
200
+ out_str << "+#{char * 38}"
201
+ out_str << "+#{char * 12}"
202
+ out_str << "+#{char * 12}"
203
+ out_str << "+#{char * 10}"
204
+ out_str << "+#{char * 11}"
205
+ out_str << "+#{char * 12}"
206
+ out_str << '+'
207
+ out_str
208
+ end
209
+
210
+ # @return [String]
211
+ def taxes_and_contributions_to_s
212
+ return '' if @taxes_and_contributions.empty?
213
+
214
+ line_items = @taxes_and_contributions.map(&:to_table_line).join(
215
+ "\n#{taxes_and_contributions_separator('-')}\n "
216
+ )
217
+ out_str = String.new
218
+ out_str << "\n#{taxes_and_contributions_separator('-')}"
219
+ out_str << "\n |"
220
+ out_str << ' Description |'
221
+ out_str << ' End Date |'
222
+ out_str << ' Start Date |'
223
+ out_str << ' Tax Rate |'
224
+ out_str << ' Total |'
225
+ out_str << ' Unit Price |'
226
+ out_str << "\n#{taxes_and_contributions_separator('=')}"
227
+ out_str << "\n #{line_items}"
228
+ out_str << "\n#{taxes_and_contributions_separator('-')}"
229
+ out_str
230
+ end
231
+ end
232
+ end
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module EnergyBill
9
+ # The entity that consumes the energy.
10
+ class EnergyBillV1EnergyConsumer < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # The address of the energy consumer.
13
+ # @return [String]
14
+ attr_reader :address
15
+ # The name of the energy consumer.
16
+ # @return [String]
17
+ attr_reader :name
18
+
19
+ # @param prediction [Hash]
20
+ # @param page_id [Integer, nil]
21
+ def initialize(prediction, page_id)
22
+ super(prediction, page_id)
23
+ @address = prediction['address']
24
+ @name = prediction['name']
25
+ @page_id = page_id
26
+ end
27
+
28
+ # @return [Hash]
29
+ def printable_values
30
+ printable = {}
31
+ printable[:address] = format_for_display(@address)
32
+ printable[:name] = format_for_display(@name)
33
+ printable
34
+ end
35
+
36
+ # @return [String]
37
+ def to_s
38
+ printable = printable_values
39
+ out_str = String.new
40
+ out_str << "\n :Address: #{printable[:address]}"
41
+ out_str << "\n :Name: #{printable[:name]}"
42
+ out_str
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module EnergyBill
9
+ # The company that supplies the energy.
10
+ class EnergyBillV1EnergySupplier < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # The address of the energy supplier.
13
+ # @return [String]
14
+ attr_reader :address
15
+ # The name of the energy supplier.
16
+ # @return [String]
17
+ attr_reader :name
18
+
19
+ # @param prediction [Hash]
20
+ # @param page_id [Integer, nil]
21
+ def initialize(prediction, page_id)
22
+ super(prediction, page_id)
23
+ @address = prediction['address']
24
+ @name = prediction['name']
25
+ @page_id = page_id
26
+ end
27
+
28
+ # @return [Hash]
29
+ def printable_values
30
+ printable = {}
31
+ printable[:address] = format_for_display(@address)
32
+ printable[:name] = format_for_display(@name)
33
+ printable
34
+ end
35
+
36
+ # @return [String]
37
+ def to_s
38
+ printable = printable_values
39
+ out_str = String.new
40
+ out_str << "\n :Address: #{printable[:address]}"
41
+ out_str << "\n :Name: #{printable[:name]}"
42
+ out_str
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module EnergyBill
9
+ # Details of energy consumption.
10
+ class EnergyBillV1EnergyUsage < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # Description or details of the energy usage.
13
+ # @return [String]
14
+ attr_reader :description
15
+ # The end date of the energy usage.
16
+ # @return [String]
17
+ attr_reader :end_date
18
+ # The start date of the energy usage.
19
+ # @return [String]
20
+ attr_reader :start_date
21
+ # The rate of tax applied to the total cost.
22
+ # @return [Float]
23
+ attr_reader :tax_rate
24
+ # The total cost of energy consumed.
25
+ # @return [Float]
26
+ attr_reader :total
27
+ # The price per unit of energy consumed.
28
+ # @return [Float]
29
+ attr_reader :unit_price
30
+
31
+ # @param prediction [Hash]
32
+ # @param page_id [Integer, nil]
33
+ def initialize(prediction, page_id)
34
+ super(prediction, page_id)
35
+ @description = prediction['description']
36
+ @end_date = prediction['end_date']
37
+ @start_date = prediction['start_date']
38
+ @tax_rate = prediction['tax_rate']
39
+ @total = prediction['total']
40
+ @unit_price = prediction['unit_price']
41
+ @page_id = page_id
42
+ end
43
+
44
+ # @return [Hash]
45
+ def printable_values
46
+ printable = {}
47
+ printable[:description] = format_for_display(@description)
48
+ printable[:end_date] = format_for_display(@end_date)
49
+ printable[:start_date] = format_for_display(@start_date)
50
+ printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
51
+ printable[:total] = @total.nil? ? '' : Field.float_to_string(@total)
52
+ printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
53
+ printable
54
+ end
55
+
56
+ # @return [Hash]
57
+ def table_printable_values
58
+ printable = {}
59
+ printable[:description] = format_for_display(@description, 36)
60
+ printable[:end_date] = format_for_display(@end_date, 10)
61
+ printable[:start_date] = format_for_display(@start_date, nil)
62
+ printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
63
+ printable[:total] = @total.nil? ? '' : Field.float_to_string(@total)
64
+ printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
65
+ printable
66
+ end
67
+
68
+ # @return [String]
69
+ def to_table_line
70
+ printable = table_printable_values
71
+ out_str = String.new
72
+ out_str << format('| %- 37s', printable[:description])
73
+ out_str << format('| %- 11s', printable[:end_date])
74
+ out_str << format('| %- 11s', printable[:start_date])
75
+ out_str << format('| %- 9s', printable[:tax_rate])
76
+ out_str << format('| %- 10s', printable[:total])
77
+ out_str << format('| %- 11s', printable[:unit_price])
78
+ out_str << '|'
79
+ end
80
+
81
+ # @return [String]
82
+ def to_s
83
+ printable = printable_values
84
+ out_str = String.new
85
+ out_str << "\n :Description: #{printable[:description]}"
86
+ out_str << "\n :End Date: #{printable[:end_date]}"
87
+ out_str << "\n :Start Date: #{printable[:start_date]}"
88
+ out_str << "\n :Tax Rate: #{printable[:tax_rate]}"
89
+ out_str << "\n :Total: #{printable[:total]}"
90
+ out_str << "\n :Unit Price: #{printable[:unit_price]}"
91
+ out_str
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module EnergyBill
9
+ # Information about the energy meter.
10
+ class EnergyBillV1MeterDetail < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # The unique identifier of the energy meter.
13
+ # @return [String]
14
+ attr_reader :meter_number
15
+ # The type of energy meter.
16
+ # @return [String]
17
+ attr_reader :meter_type
18
+ # The unit of measurement for energy consumption, which can be kW, m³, or L.
19
+ # @return [String]
20
+ attr_reader :unit
21
+
22
+ # @param prediction [Hash]
23
+ # @param page_id [Integer, nil]
24
+ def initialize(prediction, page_id)
25
+ super(prediction, page_id)
26
+ @meter_number = prediction['meter_number']
27
+ @meter_type = prediction['meter_type']
28
+ @unit = prediction['unit']
29
+ @page_id = page_id
30
+ end
31
+
32
+ # @return [Hash]
33
+ def printable_values
34
+ printable = {}
35
+ printable[:meter_number] = format_for_display(@meter_number)
36
+ printable[:meter_type] = format_for_display(@meter_type)
37
+ printable[:unit] = format_for_display(@unit)
38
+ printable
39
+ end
40
+
41
+ # @return [String]
42
+ def to_s
43
+ printable = printable_values
44
+ out_str = String.new
45
+ out_str << "\n :Meter Number: #{printable[:meter_number]}"
46
+ out_str << "\n :Meter Type: #{printable[:meter_type]}"
47
+ out_str << "\n :Unit of Measure: #{printable[:unit]}"
48
+ out_str
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'energy_bill_v1_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module FR
9
+ module EnergyBill
10
+ # Energy Bill API version 1.0 page data.
11
+ class EnergyBillV1Page < Mindee::Parsing::Common::Page
12
+ # @param prediction [Hash]
13
+ def initialize(prediction)
14
+ super(prediction)
15
+ @prediction = EnergyBillV1PagePrediction.new(
16
+ prediction['prediction'],
17
+ prediction['id']
18
+ )
19
+ end
20
+ end
21
+
22
+ # Energy Bill V1 page prediction.
23
+ class EnergyBillV1PagePrediction < EnergyBillV1Document
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,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module EnergyBill
9
+ # The subscription details fee for the energy service.
10
+ class EnergyBillV1Subscription < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # Description or details of the subscription.
13
+ # @return [String]
14
+ attr_reader :description
15
+ # The end date of the subscription.
16
+ # @return [String]
17
+ attr_reader :end_date
18
+ # The start date of the subscription.
19
+ # @return [String]
20
+ attr_reader :start_date
21
+ # The rate of tax applied to the total cost.
22
+ # @return [Float]
23
+ attr_reader :tax_rate
24
+ # The total cost of subscription.
25
+ # @return [Float]
26
+ attr_reader :total
27
+ # The price per unit of subscription.
28
+ # @return [Float]
29
+ attr_reader :unit_price
30
+
31
+ # @param prediction [Hash]
32
+ # @param page_id [Integer, nil]
33
+ def initialize(prediction, page_id)
34
+ super(prediction, page_id)
35
+ @description = prediction['description']
36
+ @end_date = prediction['end_date']
37
+ @start_date = prediction['start_date']
38
+ @tax_rate = prediction['tax_rate']
39
+ @total = prediction['total']
40
+ @unit_price = prediction['unit_price']
41
+ @page_id = page_id
42
+ end
43
+
44
+ # @return [Hash]
45
+ def printable_values
46
+ printable = {}
47
+ printable[:description] = format_for_display(@description)
48
+ printable[:end_date] = format_for_display(@end_date)
49
+ printable[:start_date] = format_for_display(@start_date)
50
+ printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
51
+ printable[:total] = @total.nil? ? '' : Field.float_to_string(@total)
52
+ printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
53
+ printable
54
+ end
55
+
56
+ # @return [Hash]
57
+ def table_printable_values
58
+ printable = {}
59
+ printable[:description] = format_for_display(@description, 36)
60
+ printable[:end_date] = format_for_display(@end_date, 10)
61
+ printable[:start_date] = format_for_display(@start_date, nil)
62
+ printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
63
+ printable[:total] = @total.nil? ? '' : Field.float_to_string(@total)
64
+ printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
65
+ printable
66
+ end
67
+
68
+ # @return [String]
69
+ def to_table_line
70
+ printable = table_printable_values
71
+ out_str = String.new
72
+ out_str << format('| %- 37s', printable[:description])
73
+ out_str << format('| %- 11s', printable[:end_date])
74
+ out_str << format('| %- 11s', printable[:start_date])
75
+ out_str << format('| %- 9s', printable[:tax_rate])
76
+ out_str << format('| %- 10s', printable[:total])
77
+ out_str << format('| %- 11s', printable[:unit_price])
78
+ out_str << '|'
79
+ end
80
+
81
+ # @return [String]
82
+ def to_s
83
+ printable = printable_values
84
+ out_str = String.new
85
+ out_str << "\n :Description: #{printable[:description]}"
86
+ out_str << "\n :End Date: #{printable[:end_date]}"
87
+ out_str << "\n :Start Date: #{printable[:start_date]}"
88
+ out_str << "\n :Tax Rate: #{printable[:tax_rate]}"
89
+ out_str << "\n :Total: #{printable[:total]}"
90
+ out_str << "\n :Unit Price: #{printable[:unit_price]}"
91
+ out_str
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end