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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +27 -0
- data/README.md +23 -23
- data/Rakefile +5 -0
- data/bin/mindee.rb +7 -1
- data/docs/bank_account_details_v2.md +5 -1
- data/docs/bank_check_v1.md +6 -2
- data/docs/bank_statement_fr_v1.md +3 -0
- data/docs/barcode_reader_v1.md +5 -1
- data/docs/bill_of_lading_v1.md +202 -0
- data/docs/carte_grise_v1.md +5 -1
- data/docs/carte_vitale_v1.md +5 -1
- data/docs/code_samples/bill_of_lading_v1_async.txt +19 -0
- data/docs/code_samples/energy_bill_fra_v1_async.txt +19 -0
- data/docs/code_samples/financial_document_v1_async.txt +19 -0
- data/docs/code_samples/invoices_v4_async.txt +19 -0
- data/docs/code_samples/nutrition_facts_v1_async.txt +19 -0
- data/docs/code_samples/payslip_fra_v2_async.txt +19 -0
- data/docs/code_samples/us_healthcare_cards_v1_async.txt +19 -0
- data/docs/cropper_v1.md +6 -2
- data/docs/custom_v1.md +5 -3
- data/docs/energy_bill_fra_v1.md +249 -0
- data/docs/eu_driver_license_v1.md +6 -2
- data/docs/expense_receipts_v5.md +38 -11
- data/docs/financial_document_v1.md +80 -23
- data/docs/generated_v1.md +3 -0
- data/docs/getting_started.md +3 -0
- data/docs/idcard_fr_v2.md +15 -2
- data/docs/international_id_v2.md +13 -1
- data/docs/invoice_splitter_v1.md +16 -13
- data/docs/invoices_v4.md +57 -23
- data/docs/license_plates_v1.md +5 -1
- data/docs/multi_receipts_detector_v1.md +5 -1
- data/docs/nutrition_facts_v1.md +295 -0
- data/docs/passport_v1.md +5 -1
- data/docs/payslip_fra_v2.md +218 -0
- data/docs/proof_of_address_v1.md +5 -1
- data/docs/resume_v1.md +24 -1
- data/docs/us_driver_license_v1.md +6 -2
- data/docs/us_healthcare_cards_v1.md +208 -0
- data/docs/us_mail_v2.md +5 -1
- data/docs/us_w9_v1.md +6 -2
- data/examples/auto_invoice_splitter_extraction.rb +43 -0
- data/lib/mindee/client.rb +20 -8
- data/lib/mindee/extraction/common/extracted_image.rb +73 -0
- data/lib/mindee/extraction/common/image_extractor.rb +189 -0
- data/lib/mindee/extraction/common.rb +4 -0
- data/lib/mindee/extraction/multi_receipts_extractor/multi_receipts_extractor.rb +26 -0
- data/lib/mindee/extraction/multi_receipts_extractor.rb +3 -0
- data/lib/mindee/extraction/pdf_extractor/extracted_pdf.rb +55 -0
- data/lib/mindee/extraction/pdf_extractor/pdf_extractor.rb +111 -0
- data/lib/mindee/extraction/pdf_extractor.rb +4 -0
- data/lib/mindee/extraction/tax_extractor/tax_extractor.rb +322 -0
- data/lib/mindee/extraction/tax_extractor.rb +1 -320
- data/lib/mindee/extraction.rb +3 -0
- data/lib/mindee/http/endpoint.rb +18 -6
- data/lib/mindee/input/sources.rb +8 -0
- data/lib/mindee/parsing/common/api_response.rb +1 -1
- data/lib/mindee/parsing/common/document.rb +31 -1
- data/lib/mindee/parsing/common/extras/cropper_extra.rb +29 -0
- data/lib/mindee/parsing/common/extras/extras.rb +50 -0
- data/lib/mindee/parsing/common/extras/full_text_ocr_extra.rb +32 -0
- data/lib/mindee/parsing/common/extras.rb +5 -0
- data/lib/mindee/parsing/common/page.rb +5 -0
- data/lib/mindee/parsing/standard/base_field.rb +1 -0
- data/lib/mindee/parsing/standard/company_registration_field.rb +17 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1.rb +39 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rb +52 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb +95 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rb +58 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_document.rb +136 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rb +58 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_page.rb +32 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rb +58 -0
- data/lib/mindee/product/financial_document/financial_document_v1_document.rb +3 -1
- data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +22 -1
- data/lib/mindee/product/financial_document/financial_document_v1_page.rb +1 -1
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +4 -15
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1.rb +41 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +235 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rb +48 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rb +48 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +97 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +54 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +34 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb +97 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rb +97 -0
- data/lib/mindee/product/fr/payslip/payslip_v2.rb +41 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rb +54 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_document.rb +128 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_employee.rb +78 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_employer.rb +78 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_employment.rb +72 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_page.rb +34 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_pay_detail.rb +100 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_pay_period.rb +66 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_pto.rb +56 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb +81 -0
- data/lib/mindee/product/international_id/international_id_v2_document.rb +1 -1
- data/lib/mindee/product/international_id/international_id_v2_page.rb +1 -1
- data/lib/mindee/product/invoice/invoice_v4_document.rb +3 -1
- data/lib/mindee/product/invoice/invoice_v4_line_item.rb +22 -1
- data/lib/mindee/product/invoice/invoice_v4_page.rb +1 -1
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +1 -1
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +1 -1
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +1 -1
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rb +39 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rb +173 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rb +87 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rb +32 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb +46 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb +58 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rb +52 -0
- data/lib/mindee/product/receipt/receipt_v5_document.rb +1 -1
- data/lib/mindee/product/receipt/receipt_v5_line_item.rb +11 -1
- data/lib/mindee/product/receipt/receipt_v5_page.rb +1 -1
- data/lib/mindee/product/resume/resume_v1_certificate.rb +11 -1
- data/lib/mindee/product/resume/resume_v1_education.rb +14 -1
- data/lib/mindee/product/resume/resume_v1_language.rb +9 -1
- data/lib/mindee/product/resume/resume_v1_professional_experience.rb +15 -1
- data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +9 -1
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1.rb +41 -0
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb +65 -0
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb +127 -0
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb +34 -0
- data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +14 -1
- data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +5 -17
- data/lib/mindee/product.rb +6 -1
- data/lib/mindee/version.rb +1 -1
- data/mindee.gemspec +1 -0
- metadata +91 -3
- /data/lib/mindee/extraction/{ocr_extractor.rb → tax_extractor/ocr_extractor.rb} +0 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
require_relative 'bill_of_lading_v1_shipper'
|
5
|
+
require_relative 'bill_of_lading_v1_consignee'
|
6
|
+
require_relative 'bill_of_lading_v1_notify_party'
|
7
|
+
require_relative 'bill_of_lading_v1_carrier'
|
8
|
+
require_relative 'bill_of_lading_v1_carrier_item'
|
9
|
+
|
10
|
+
module Mindee
|
11
|
+
module Product
|
12
|
+
module BillOfLading
|
13
|
+
# Bill of Lading API version 1.1 document data.
|
14
|
+
class BillOfLadingV1Document < Mindee::Parsing::Common::Prediction
|
15
|
+
include Mindee::Parsing::Standard
|
16
|
+
# A unique identifier assigned to a Bill of Lading document.
|
17
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
18
|
+
attr_reader :bill_of_lading_number
|
19
|
+
# The shipping company responsible for transporting the goods.
|
20
|
+
# @return [Mindee::Product::BillOfLading::BillOfLadingV1Carrier]
|
21
|
+
attr_reader :carrier
|
22
|
+
# The goods being shipped.
|
23
|
+
# @return [Array<Mindee::Product::BillOfLading::BillOfLadingV1CarrierItem>]
|
24
|
+
attr_reader :carrier_items
|
25
|
+
# The party to whom the goods are being shipped.
|
26
|
+
# @return [Mindee::Product::BillOfLading::BillOfLadingV1Consignee]
|
27
|
+
attr_reader :consignee
|
28
|
+
# The date when the bill of lading is issued.
|
29
|
+
# @return [Mindee::Parsing::Standard::DateField]
|
30
|
+
attr_reader :date_of_issue
|
31
|
+
# The date when the vessel departs from the port of loading.
|
32
|
+
# @return [Mindee::Parsing::Standard::DateField]
|
33
|
+
attr_reader :departure_date
|
34
|
+
# The party to be notified of the arrival of the goods.
|
35
|
+
# @return [Mindee::Product::BillOfLading::BillOfLadingV1NotifyParty]
|
36
|
+
attr_reader :notify_party
|
37
|
+
# The place where the goods are to be delivered.
|
38
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
39
|
+
attr_reader :place_of_delivery
|
40
|
+
# The port where the goods are unloaded from the vessel.
|
41
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
42
|
+
attr_reader :port_of_discharge
|
43
|
+
# The port where the goods are loaded onto the vessel.
|
44
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
45
|
+
attr_reader :port_of_loading
|
46
|
+
# The party responsible for shipping the goods.
|
47
|
+
# @return [Mindee::Product::BillOfLading::BillOfLadingV1Shipper]
|
48
|
+
attr_reader :shipper
|
49
|
+
|
50
|
+
# @param prediction [Hash]
|
51
|
+
# @param page_id [Integer, nil]
|
52
|
+
def initialize(prediction, page_id)
|
53
|
+
super()
|
54
|
+
@bill_of_lading_number = StringField.new(prediction['bill_of_lading_number'], page_id)
|
55
|
+
@carrier = BillOfLadingV1Carrier.new(prediction['carrier'], page_id)
|
56
|
+
@carrier_items = []
|
57
|
+
prediction['carrier_items'].each do |item|
|
58
|
+
@carrier_items.push(BillOfLadingV1CarrierItem.new(item, page_id))
|
59
|
+
end
|
60
|
+
@consignee = BillOfLadingV1Consignee.new(prediction['consignee'], page_id)
|
61
|
+
@date_of_issue = DateField.new(prediction['date_of_issue'], page_id)
|
62
|
+
@departure_date = DateField.new(prediction['departure_date'], page_id)
|
63
|
+
@notify_party = BillOfLadingV1NotifyParty.new(prediction['notify_party'], page_id)
|
64
|
+
@place_of_delivery = StringField.new(prediction['place_of_delivery'], page_id)
|
65
|
+
@port_of_discharge = StringField.new(prediction['port_of_discharge'], page_id)
|
66
|
+
@port_of_loading = StringField.new(prediction['port_of_loading'], page_id)
|
67
|
+
@shipper = BillOfLadingV1Shipper.new(prediction['shipper'], page_id)
|
68
|
+
end
|
69
|
+
|
70
|
+
# @return [String]
|
71
|
+
def to_s
|
72
|
+
shipper = @shipper.to_s
|
73
|
+
consignee = @consignee.to_s
|
74
|
+
notify_party = @notify_party.to_s
|
75
|
+
carrier = @carrier.to_s
|
76
|
+
carrier_items = carrier_items_to_s
|
77
|
+
out_str = String.new
|
78
|
+
out_str << "\n:Bill of Lading Number: #{@bill_of_lading_number}".rstrip
|
79
|
+
out_str << "\n:Shipper:"
|
80
|
+
out_str << shipper
|
81
|
+
out_str << "\n:Consignee:"
|
82
|
+
out_str << consignee
|
83
|
+
out_str << "\n:Notify Party:"
|
84
|
+
out_str << notify_party
|
85
|
+
out_str << "\n:Carrier:"
|
86
|
+
out_str << carrier
|
87
|
+
out_str << "\n:Items:"
|
88
|
+
out_str << carrier_items
|
89
|
+
out_str << "\n:Port of Loading: #{@port_of_loading}".rstrip
|
90
|
+
out_str << "\n:Port of Discharge: #{@port_of_discharge}".rstrip
|
91
|
+
out_str << "\n:Place of Delivery: #{@place_of_delivery}".rstrip
|
92
|
+
out_str << "\n:Date of issue: #{@date_of_issue}".rstrip
|
93
|
+
out_str << "\n:Departure Date: #{@departure_date}".rstrip
|
94
|
+
out_str[1..].to_s
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
# @param char [String]
|
100
|
+
# @return [String]
|
101
|
+
def carrier_items_separator(char)
|
102
|
+
out_str = String.new
|
103
|
+
out_str << ' '
|
104
|
+
out_str << "+#{char * 38}"
|
105
|
+
out_str << "+#{char * 14}"
|
106
|
+
out_str << "+#{char * 13}"
|
107
|
+
out_str << "+#{char * 18}"
|
108
|
+
out_str << "+#{char * 10}"
|
109
|
+
out_str << "+#{char * 13}"
|
110
|
+
out_str << '+'
|
111
|
+
out_str
|
112
|
+
end
|
113
|
+
|
114
|
+
# @return [String]
|
115
|
+
def carrier_items_to_s
|
116
|
+
return '' if @carrier_items.empty?
|
117
|
+
|
118
|
+
line_items = @carrier_items.map(&:to_table_line).join("\n#{carrier_items_separator('-')}\n ")
|
119
|
+
out_str = String.new
|
120
|
+
out_str << "\n#{carrier_items_separator('-')}"
|
121
|
+
out_str << "\n |"
|
122
|
+
out_str << ' Description |'
|
123
|
+
out_str << ' Gross Weight |'
|
124
|
+
out_str << ' Measurement |'
|
125
|
+
out_str << ' Measurement Unit |'
|
126
|
+
out_str << ' Quantity |'
|
127
|
+
out_str << ' Weight Unit |'
|
128
|
+
out_str << "\n#{carrier_items_separator('=')}"
|
129
|
+
out_str << "\n #{line_items}"
|
130
|
+
out_str << "\n#{carrier_items_separator('-')}"
|
131
|
+
out_str
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module BillOfLading
|
8
|
+
# The party to be notified of the arrival of the goods.
|
9
|
+
class BillOfLadingV1NotifyParty < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# The address of the notify party.
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :address
|
14
|
+
# The email of the shipper.
|
15
|
+
# @return [String]
|
16
|
+
attr_reader :email
|
17
|
+
# The name of the notify party.
|
18
|
+
# @return [String]
|
19
|
+
attr_reader :name
|
20
|
+
# The phone number of the notify party.
|
21
|
+
# @return [String]
|
22
|
+
attr_reader :phone
|
23
|
+
|
24
|
+
# @param prediction [Hash]
|
25
|
+
# @param page_id [Integer, nil]
|
26
|
+
def initialize(prediction, page_id)
|
27
|
+
super(prediction, page_id)
|
28
|
+
@address = prediction['address']
|
29
|
+
@email = prediction['email']
|
30
|
+
@name = prediction['name']
|
31
|
+
@phone = prediction['phone']
|
32
|
+
@page_id = page_id
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Hash]
|
36
|
+
def printable_values
|
37
|
+
printable = {}
|
38
|
+
printable[:address] = format_for_display(@address)
|
39
|
+
printable[:email] = format_for_display(@email)
|
40
|
+
printable[:name] = format_for_display(@name)
|
41
|
+
printable[:phone] = format_for_display(@phone)
|
42
|
+
printable
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String]
|
46
|
+
def to_s
|
47
|
+
printable = printable_values
|
48
|
+
out_str = String.new
|
49
|
+
out_str << "\n :Address: #{printable[:address]}"
|
50
|
+
out_str << "\n :Email: #{printable[:email]}"
|
51
|
+
out_str << "\n :Name: #{printable[:name]}"
|
52
|
+
out_str << "\n :Phone: #{printable[:phone]}"
|
53
|
+
out_str
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
require_relative 'bill_of_lading_v1_document'
|
5
|
+
|
6
|
+
module Mindee
|
7
|
+
module Product
|
8
|
+
module BillOfLading
|
9
|
+
# Bill of Lading API version 1.1 page data.
|
10
|
+
class BillOfLadingV1Page < Mindee::Parsing::Common::Page
|
11
|
+
# @param prediction [Hash]
|
12
|
+
def initialize(prediction)
|
13
|
+
super(prediction)
|
14
|
+
@prediction = BillOfLadingV1PagePrediction.new(
|
15
|
+
prediction['prediction'],
|
16
|
+
prediction['id']
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Bill of Lading V1 page prediction.
|
22
|
+
class BillOfLadingV1PagePrediction < BillOfLadingV1Document
|
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,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module BillOfLading
|
8
|
+
# The party responsible for shipping the goods.
|
9
|
+
class BillOfLadingV1Shipper < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# The address of the shipper.
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :address
|
14
|
+
# The email of the shipper.
|
15
|
+
# @return [String]
|
16
|
+
attr_reader :email
|
17
|
+
# The name of the shipper.
|
18
|
+
# @return [String]
|
19
|
+
attr_reader :name
|
20
|
+
# The phone number of the shipper.
|
21
|
+
# @return [String]
|
22
|
+
attr_reader :phone
|
23
|
+
|
24
|
+
# @param prediction [Hash]
|
25
|
+
# @param page_id [Integer, nil]
|
26
|
+
def initialize(prediction, page_id)
|
27
|
+
super(prediction, page_id)
|
28
|
+
@address = prediction['address']
|
29
|
+
@email = prediction['email']
|
30
|
+
@name = prediction['name']
|
31
|
+
@phone = prediction['phone']
|
32
|
+
@page_id = page_id
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Hash]
|
36
|
+
def printable_values
|
37
|
+
printable = {}
|
38
|
+
printable[:address] = format_for_display(@address)
|
39
|
+
printable[:email] = format_for_display(@email)
|
40
|
+
printable[:name] = format_for_display(@name)
|
41
|
+
printable[:phone] = format_for_display(@phone)
|
42
|
+
printable
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String]
|
46
|
+
def to_s
|
47
|
+
printable = printable_values
|
48
|
+
out_str = String.new
|
49
|
+
out_str << "\n :Address: #{printable[:address]}"
|
50
|
+
out_str << "\n :Email: #{printable[:email]}"
|
51
|
+
out_str << "\n :Name: #{printable[:name]}"
|
52
|
+
out_str << "\n :Phone: #{printable[:phone]}"
|
53
|
+
out_str
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -6,7 +6,7 @@ require_relative 'financial_document_v1_line_item'
|
|
6
6
|
module Mindee
|
7
7
|
module Product
|
8
8
|
module FinancialDocument
|
9
|
-
# Financial Document API version 1.
|
9
|
+
# Financial Document API version 1.9 document data.
|
10
10
|
class FinancialDocumentV1Document < Mindee::Parsing::Common::Prediction
|
11
11
|
include Mindee::Parsing::Standard
|
12
12
|
# The customer's address used for billing.
|
@@ -206,6 +206,7 @@ module Mindee
|
|
206
206
|
out_str << "+#{char * 12}"
|
207
207
|
out_str << "+#{char * 14}"
|
208
208
|
out_str << "+#{char * 14}"
|
209
|
+
out_str << "+#{char * 17}"
|
209
210
|
out_str << "+#{char * 12}"
|
210
211
|
out_str << '+'
|
211
212
|
out_str
|
@@ -225,6 +226,7 @@ module Mindee
|
|
225
226
|
out_str << ' Tax Amount |'
|
226
227
|
out_str << ' Tax Rate (%) |'
|
227
228
|
out_str << ' Total Amount |'
|
229
|
+
out_str << ' Unit of measure |'
|
228
230
|
out_str << ' Unit Price |'
|
229
231
|
out_str << "\n#{line_items_separator('=')}"
|
230
232
|
out_str << "\n #{line_items}"
|
@@ -26,6 +26,9 @@ module Mindee
|
|
26
26
|
# The item total amount.
|
27
27
|
# @return [Float]
|
28
28
|
attr_reader :total_amount
|
29
|
+
# The item unit of measure.
|
30
|
+
# @return [String]
|
31
|
+
attr_reader :unit_measure
|
29
32
|
# The item unit price.
|
30
33
|
# @return [Float]
|
31
34
|
attr_reader :unit_price
|
@@ -40,12 +43,27 @@ module Mindee
|
|
40
43
|
@tax_amount = prediction['tax_amount']
|
41
44
|
@tax_rate = prediction['tax_rate']
|
42
45
|
@total_amount = prediction['total_amount']
|
46
|
+
@unit_measure = prediction['unit_measure']
|
43
47
|
@unit_price = prediction['unit_price']
|
44
48
|
@page_id = page_id
|
45
49
|
end
|
46
50
|
|
47
51
|
# @return [Hash]
|
48
52
|
def printable_values
|
53
|
+
printable = {}
|
54
|
+
printable[:description] = format_for_display(@description)
|
55
|
+
printable[:product_code] = format_for_display(@product_code)
|
56
|
+
printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
|
57
|
+
printable[:tax_amount] = @tax_amount.nil? ? '' : Field.float_to_string(@tax_amount)
|
58
|
+
printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
|
59
|
+
printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount)
|
60
|
+
printable[:unit_measure] = format_for_display(@unit_measure)
|
61
|
+
printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
|
62
|
+
printable
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [Hash]
|
66
|
+
def table_printable_values
|
49
67
|
printable = {}
|
50
68
|
printable[:description] = format_for_display(@description, 36)
|
51
69
|
printable[:product_code] = format_for_display(@product_code, nil)
|
@@ -53,13 +71,14 @@ module Mindee
|
|
53
71
|
printable[:tax_amount] = @tax_amount.nil? ? '' : Field.float_to_string(@tax_amount)
|
54
72
|
printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
|
55
73
|
printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount)
|
74
|
+
printable[:unit_measure] = format_for_display(@unit_measure, nil)
|
56
75
|
printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
|
57
76
|
printable
|
58
77
|
end
|
59
78
|
|
60
79
|
# @return [String]
|
61
80
|
def to_table_line
|
62
|
-
printable =
|
81
|
+
printable = table_printable_values
|
63
82
|
out_str = String.new
|
64
83
|
out_str << format('| %- 37s', printable[:description])
|
65
84
|
out_str << format('| %- 13s', printable[:product_code])
|
@@ -67,6 +86,7 @@ module Mindee
|
|
67
86
|
out_str << format('| %- 11s', printable[:tax_amount])
|
68
87
|
out_str << format('| %- 13s', printable[:tax_rate])
|
69
88
|
out_str << format('| %- 13s', printable[:total_amount])
|
89
|
+
out_str << format('| %- 16s', printable[:unit_measure])
|
70
90
|
out_str << format('| %- 11s', printable[:unit_price])
|
71
91
|
out_str << '|'
|
72
92
|
end
|
@@ -81,6 +101,7 @@ module Mindee
|
|
81
101
|
out_str << "\n :Tax Amount: #{printable[:tax_amount]}"
|
82
102
|
out_str << "\n :Tax Rate (%): #{printable[:tax_rate]}"
|
83
103
|
out_str << "\n :Total Amount: #{printable[:total_amount]}"
|
104
|
+
out_str << "\n :Unit of measure: #{printable[:unit_measure]}"
|
84
105
|
out_str << "\n :Unit Price: #{printable[:unit_price]}"
|
85
106
|
out_str
|
86
107
|
end
|
@@ -6,7 +6,7 @@ require_relative 'financial_document_v1_document'
|
|
6
6
|
module Mindee
|
7
7
|
module Product
|
8
8
|
module FinancialDocument
|
9
|
-
# Financial Document API version 1.
|
9
|
+
# Financial Document API version 1.9 page data.
|
10
10
|
class FinancialDocumentV1Page < Mindee::Parsing::Common::Page
|
11
11
|
# @param prediction [Hash]
|
12
12
|
def initialize(prediction)
|
@@ -36,24 +36,13 @@ module Mindee
|
|
36
36
|
# @return [Hash]
|
37
37
|
def printable_values
|
38
38
|
printable = {}
|
39
|
-
printable[:bban_bank_code] = format_for_display(@bban_bank_code
|
40
|
-
printable[:bban_branch_code] = format_for_display(@bban_branch_code
|
41
|
-
printable[:bban_key] = format_for_display(@bban_key
|
42
|
-
printable[:bban_number] = format_for_display(@bban_number
|
39
|
+
printable[:bban_bank_code] = format_for_display(@bban_bank_code)
|
40
|
+
printable[:bban_branch_code] = format_for_display(@bban_branch_code)
|
41
|
+
printable[:bban_key] = format_for_display(@bban_key)
|
42
|
+
printable[:bban_number] = format_for_display(@bban_number)
|
43
43
|
printable
|
44
44
|
end
|
45
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
46
|
# @return [String]
|
58
47
|
def to_s
|
59
48
|
printable = printable_values
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../parsing'
|
4
|
+
require_relative 'energy_bill_v1_document'
|
5
|
+
require_relative 'energy_bill_v1_page'
|
6
|
+
|
7
|
+
module Mindee
|
8
|
+
module Product
|
9
|
+
module FR
|
10
|
+
# Energy Bill module.
|
11
|
+
module EnergyBill
|
12
|
+
# Energy Bill API version 1 inference prediction.
|
13
|
+
class EnergyBillV1 < Mindee::Parsing::Common::Inference
|
14
|
+
@endpoint_name = 'energy_bill_fra'
|
15
|
+
@endpoint_version = '1'
|
16
|
+
|
17
|
+
# @param prediction [Hash]
|
18
|
+
def initialize(prediction)
|
19
|
+
super
|
20
|
+
@prediction = EnergyBillV1Document.new(prediction['prediction'], nil)
|
21
|
+
@pages = []
|
22
|
+
prediction['pages'].each do |page|
|
23
|
+
if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
|
24
|
+
@pages.push(EnergyBillV1Page.new(page))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class << self
|
30
|
+
# Name of the endpoint for this product.
|
31
|
+
# @return [String]
|
32
|
+
attr_reader :endpoint_name
|
33
|
+
# Version for this product.
|
34
|
+
# @return [String]
|
35
|
+
attr_reader :endpoint_version
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|