mindee 4.0.0 → 4.1.2
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/CHANGELOG.md +18 -0
- data/bin/cli_products.rb +172 -0
- data/bin/mindee.rb +6 -121
- data/docs/advanced_file_operations.md +7 -9
- data/docs/code_samples/invoice_splitter_v1_async.txt +2 -1
- data/docs/code_samples/{license_plates_v1.txt → us_mail_v2_async.txt} +1 -1
- data/docs/code_samples/workflow_execution.txt +28 -0
- data/docs/getting_started.md +1 -1
- data/docs/global_products/barcode_reader_v1.md +1 -1
- data/docs/global_products/bill_of_lading_v1.md +1 -1
- data/docs/global_products/business_card_v1.md +1 -1
- data/docs/global_products/cropper_v1.md +1 -1
- data/docs/global_products/delivery_notes_v1.md +2 -2
- data/docs/global_products/driver_license_v1.md +1 -1
- data/docs/global_products/expense_receipts_v5.md +26 -25
- data/docs/global_products/financial_document_v1.md +34 -33
- data/docs/global_products/international_id_v2.md +7 -7
- data/docs/global_products/invoice_splitter_v1.md +53 -33
- data/docs/global_products/invoices_v4.md +19 -19
- data/docs/global_products/multi_receipts_detector_v1.md +1 -1
- data/docs/global_products/nutrition_facts_v1.md +1 -1
- data/docs/global_products/passport_v1.md +1 -1
- data/docs/global_products/resume_v1.md +4 -4
- data/docs/global_products/universal.md +1 -1
- data/docs/global_products.md +1 -1
- data/docs/loading_a_document.md +87 -73
- data/docs/localized_products/bank_account_details_v2.md +1 -1
- data/docs/localized_products/bank_check_v1.md +1 -1
- data/docs/localized_products/bank_statement_fr_v2.md +1 -1
- data/docs/localized_products/carte_grise_v1.md +1 -1
- data/docs/localized_products/energy_bill_fra_v1.md +11 -3
- data/docs/localized_products/french_healthcard_v1.md +1 -1
- data/docs/localized_products/idcard_fr_v2.md +6 -6
- data/docs/localized_products/ind_passport_v1.md +5 -5
- data/docs/localized_products/payslip_fra_v3.md +1 -1
- data/docs/localized_products/us_healthcare_cards_v1.md +2 -2
- data/docs/localized_products/us_mail_v3.md +1 -1
- data/docs/localized_products/us_w9_v1.md +1 -1
- data/docs/localized_products.md +1 -1
- data/lib/mindee/client.rb +6 -8
- data/lib/mindee/geometry/polygon.rb +1 -1
- data/lib/mindee/http/workflow_endpoint.rb +23 -23
- data/lib/mindee/pdf/pdf_extractor.rb +3 -3
- data/lib/mindee/product/delivery_note/delivery_note_v1_document.rb +1 -1
- data/lib/mindee/product/delivery_note/delivery_note_v1_page.rb +1 -1
- data/lib/mindee/product/financial_document/financial_document_v1_document.rb +15 -14
- data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +1 -1
- data/lib/mindee/product/financial_document/financial_document_v1_line_items.rb +1 -1
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +5 -1
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +18 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rb +4 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +2 -2
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +1 -1
- data/lib/mindee/product/invoice/invoice_v4_document.rb +14 -14
- data/lib/mindee/product/invoice/invoice_v4_line_item.rb +2 -2
- data/lib/mindee/product/invoice/invoice_v4_line_items.rb +1 -1
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +2 -2
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +38 -42
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_invoice_page_group.rb +55 -0
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_invoice_page_groups.rb +48 -0
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb +9 -5
- data/lib/mindee/product/receipt/receipt_v5_document.rb +8 -8
- data/lib/mindee/product/receipt/receipt_v5_line_item.rb +1 -1
- data/lib/mindee/product/receipt/receipt_v5_line_items.rb +1 -1
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb +1 -1
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb +1 -1
- data/lib/mindee/product/{eu/license_plate/license_plate_v1.rb → us/us_mail/us_mail_v2.rb} +13 -13
- data/lib/mindee/product/us/us_mail/us_mail_v2_document.rb +105 -0
- data/lib/mindee/product/{eu/license_plate/license_plate_v1_page.rb → us/us_mail/us_mail_v2_page.rb} +8 -8
- data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +105 -0
- data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb +63 -0
- data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +66 -0
- data/lib/mindee/product.rb +5 -5
- data/lib/mindee/version.rb +1 -1
- data/mindee.gemspec +11 -11
- data/sig/custom/net_http.rbs +5 -0
- data/sig/mindee/client.rbs +1 -0
- data/sig/mindee/http/workflow_endpoint.rbs +8 -2
- data/sig/mindee/pdf/pdf_extractor.rbs +1 -1
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_items.rbs +1 -1
- data/sig/mindee/product/financial_document/financial_document_v1_line_items.rbs +1 -1
- data/sig/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rbs +1 -1
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rbs +2 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rbs +1 -1
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_subscriptions.rbs +1 -1
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contributions.rbs +1 -1
- data/sig/mindee/product/fr/payslip/payslip_v2_salary_details.rbs +1 -1
- data/sig/mindee/product/fr/payslip/payslip_v3_paid_time_offs.rbs +1 -1
- data/sig/mindee/product/fr/payslip/payslip_v3_salary_details.rbs +1 -1
- data/sig/mindee/product/invoice/invoice_v4_line_items.rbs +1 -1
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1.rbs +1 -4
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_document.rbs +5 -9
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_invoice_page_group.rbs +14 -0
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_invoice_page_groups.rbs +13 -0
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_page.rbs +2 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrients.rbs +1 -1
- data/sig/mindee/product/receipt/receipt_v5_line_items.rbs +1 -1
- data/sig/mindee/product/resume/resume_v1_certificates.rbs +1 -1
- data/sig/mindee/product/resume/resume_v1_educations.rbs +1 -1
- data/sig/mindee/product/resume/resume_v1_languages.rbs +1 -1
- data/sig/mindee/product/resume/resume_v1_professional_experiences.rbs +1 -1
- data/sig/mindee/product/resume/resume_v1_social_networks_urls.rbs +1 -1
- data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rbs +1 -1
- data/sig/mindee/product/us/us_mail/us_mail_v2.rbs +13 -0
- data/sig/mindee/product/us/us_mail/us_mail_v2_document.rbs +20 -0
- data/sig/mindee/product/{eu/license_plate/license_plate_v1_page.rbs → us/us_mail/us_mail_v2_page.rbs} +5 -5
- data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs +22 -0
- data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs +15 -0
- data/sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs +18 -0
- data/sig/mindee/product/us/us_mail/us_mail_v3_recipient_addresses.rbs +1 -1
- metadata +39 -28
- data/docs/localized_products/license_plates_v1.md +0 -112
- data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +0 -37
- data/sig/mindee/product/eu/license_plate/license_plate_v1.rbs +0 -13
- data/sig/mindee/product/eu/license_plate/license_plate_v1_document.rbs +0 -15
@@ -46,7 +46,7 @@ module Mindee
|
|
46
46
|
extension = File.extname(@filename)
|
47
47
|
basename = File.basename(@filename, extension)
|
48
48
|
page_indexes.each do |page_index_list|
|
49
|
-
if page_index_list.
|
49
|
+
if page_index_list.nil? || page_index_list.empty?
|
50
50
|
raise Errors::MindeePDFError, "Empty indexes aren't allowed for extraction #{page_index_list}"
|
51
51
|
end
|
52
52
|
|
@@ -70,12 +70,12 @@ module Mindee
|
|
70
70
|
# rubocop:disable Metrics/PerceivedComplexity
|
71
71
|
|
72
72
|
# Extracts invoices as complete PDFs from the document.
|
73
|
-
# @param page_indexes [Array<Array<Integer>,
|
73
|
+
# @param page_indexes [Array<Array<Integer>, InvoiceSplitterV1InvoicePageGroup>]
|
74
74
|
# @param strict [bool]
|
75
75
|
# @return [Array<Mindee::PDF::PDFExtractor::ExtractedPDF>]
|
76
76
|
def extract_invoices(page_indexes, strict: false)
|
77
77
|
raise Errors::MindeePDFError, 'No indexes provided.' if page_indexes.empty?
|
78
|
-
|
78
|
+
if page_indexes[0].is_a?(Array) && page_indexes[0].all? { |i| i.is_a?(Integer) }
|
79
79
|
return extract_sub_documents(page_indexes)
|
80
80
|
end
|
81
81
|
return extract_sub_documents(page_indexes.map(&:page_indexes)) unless strict
|
@@ -5,7 +5,7 @@ require_relative '../../parsing'
|
|
5
5
|
module Mindee
|
6
6
|
module Product
|
7
7
|
module DeliveryNote
|
8
|
-
# Delivery note API version 1.
|
8
|
+
# Delivery note API version 1.2 document data.
|
9
9
|
class DeliveryNoteV1Document < Mindee::Parsing::Common::Prediction
|
10
10
|
include Mindee::Parsing::Standard
|
11
11
|
# The address of the customer receiving the goods.
|
@@ -6,7 +6,7 @@ require_relative 'delivery_note_v1_document'
|
|
6
6
|
module Mindee
|
7
7
|
module Product
|
8
8
|
module DeliveryNote
|
9
|
-
# Delivery note API version 1.
|
9
|
+
# Delivery note API version 1.2 page data.
|
10
10
|
class DeliveryNoteV1Page < Mindee::Parsing::Common::Page
|
11
11
|
# @param prediction [Hash]
|
12
12
|
def initialize(prediction)
|
@@ -12,13 +12,13 @@ module Mindee
|
|
12
12
|
# The customer's address used for billing.
|
13
13
|
# @return [Mindee::Parsing::Standard::StringField]
|
14
14
|
attr_reader :billing_address
|
15
|
-
# The purchase category
|
15
|
+
# The purchase category, only for receipts.
|
16
16
|
# @return [Mindee::Parsing::Standard::ClassificationField]
|
17
17
|
attr_reader :category
|
18
18
|
# The address of the customer.
|
19
19
|
# @return [Mindee::Parsing::Standard::StringField]
|
20
20
|
attr_reader :customer_address
|
21
|
-
# List of company
|
21
|
+
# List of company registration numbers associated to the customer.
|
22
22
|
# @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
|
23
23
|
attr_reader :customer_company_registrations
|
24
24
|
# The customer account number or identifier from the supplier.
|
@@ -30,10 +30,11 @@ module Mindee
|
|
30
30
|
# The date the purchase was made.
|
31
31
|
# @return [Mindee::Parsing::Standard::DateField]
|
32
32
|
attr_reader :date
|
33
|
-
# The document number or identifier.
|
33
|
+
# The document number or identifier (invoice number or receipt number).
|
34
34
|
# @return [Mindee::Parsing::Standard::StringField]
|
35
35
|
attr_reader :document_number
|
36
|
-
#
|
36
|
+
# The type of the document: INVOICE or CREDIT NOTE if it is an invoice, CREDIT CARD RECEIPT or EXPENSE
|
37
|
+
# RECEIPT if it is a receipt.
|
37
38
|
# @return [Mindee::Parsing::Standard::ClassificationField]
|
38
39
|
attr_reader :document_type
|
39
40
|
# The date on which the payment is due.
|
@@ -42,34 +43,34 @@ module Mindee
|
|
42
43
|
# The invoice number or identifier only if document is an invoice.
|
43
44
|
# @return [Mindee::Parsing::Standard::StringField]
|
44
45
|
attr_reader :invoice_number
|
45
|
-
# List of line item
|
46
|
+
# List of line item present on the document.
|
46
47
|
# @return [Mindee::Product::FinancialDocument::FinancialDocumentV1LineItems]
|
47
48
|
attr_reader :line_items
|
48
|
-
# The locale
|
49
|
+
# The locale of the document.
|
49
50
|
# @return [Mindee::Parsing::Standard::LocaleField]
|
50
51
|
attr_reader :locale
|
51
52
|
# The date on which the payment is due / fullfilled.
|
52
53
|
# @return [Mindee::Parsing::Standard::DateField]
|
53
54
|
attr_reader :payment_date
|
54
|
-
# The purchase order number.
|
55
|
+
# The purchase order number, only if the document is an invoice.
|
55
56
|
# @return [Mindee::Parsing::Standard::StringField]
|
56
57
|
attr_reader :po_number
|
57
58
|
# The receipt number or identifier only if document is a receipt.
|
58
59
|
# @return [Mindee::Parsing::Standard::StringField]
|
59
60
|
attr_reader :receipt_number
|
60
|
-
# List of Reference numbers, including PO number.
|
61
|
+
# List of Reference numbers, including PO number, only if the document is an invoice.
|
61
62
|
# @return [Array<Mindee::Parsing::Standard::StringField>]
|
62
63
|
attr_reader :reference_numbers
|
63
64
|
# The customer's address used for shipping.
|
64
65
|
# @return [Mindee::Parsing::Standard::StringField]
|
65
66
|
attr_reader :shipping_address
|
66
|
-
# The purchase subcategory
|
67
|
+
# The purchase subcategory for transport and food, only for receipts.
|
67
68
|
# @return [Mindee::Parsing::Standard::ClassificationField]
|
68
69
|
attr_reader :subcategory
|
69
70
|
# The address of the supplier or merchant.
|
70
71
|
# @return [Mindee::Parsing::Standard::StringField]
|
71
72
|
attr_reader :supplier_address
|
72
|
-
# List of company
|
73
|
+
# List of company registration numbers associated to the supplier.
|
73
74
|
# @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
|
74
75
|
attr_reader :supplier_company_registrations
|
75
76
|
# The email of the supplier or merchant.
|
@@ -78,7 +79,7 @@ module Mindee
|
|
78
79
|
# The name of the supplier or merchant.
|
79
80
|
# @return [Mindee::Parsing::Standard::StringField]
|
80
81
|
attr_reader :supplier_name
|
81
|
-
# List of payment details associated to the supplier.
|
82
|
+
# List of payment details associated to the supplier (only for invoices).
|
82
83
|
# @return [Array<Mindee::Parsing::Standard::PaymentDetailsField>]
|
83
84
|
attr_reader :supplier_payment_details
|
84
85
|
# The phone number of the supplier or merchant.
|
@@ -87,10 +88,10 @@ module Mindee
|
|
87
88
|
# The website URL of the supplier or merchant.
|
88
89
|
# @return [Mindee::Parsing::Standard::StringField]
|
89
90
|
attr_reader :supplier_website
|
90
|
-
# List of
|
91
|
+
# List of all taxes on the document.
|
91
92
|
# @return [Mindee::Parsing::Standard::Taxes]
|
92
93
|
attr_reader :taxes
|
93
|
-
# The time the purchase was made.
|
94
|
+
# The time the purchase was made (only for receipts).
|
94
95
|
# @return [Mindee::Parsing::Standard::StringField]
|
95
96
|
attr_reader :time
|
96
97
|
# The total amount of tip and gratuity
|
@@ -102,7 +103,7 @@ module Mindee
|
|
102
103
|
# The net amount paid: does not include taxes, fees, and discounts.
|
103
104
|
# @return [Mindee::Parsing::Standard::AmountField]
|
104
105
|
attr_reader :total_net
|
105
|
-
# The
|
106
|
+
# The sum of all taxes present on the document.
|
106
107
|
# @return [Mindee::Parsing::Standard::AmountField]
|
107
108
|
attr_reader :total_tax
|
108
109
|
|
@@ -5,7 +5,7 @@ require_relative '../../parsing'
|
|
5
5
|
module Mindee
|
6
6
|
module Product
|
7
7
|
module FinancialDocument
|
8
|
-
# List of line item
|
8
|
+
# List of line item present on the document.
|
9
9
|
class FinancialDocumentV1LineItem < Mindee::Parsing::Standard::FeatureField
|
10
10
|
include Mindee::Parsing::Standard
|
11
11
|
# The item description.
|
@@ -5,7 +5,7 @@ require_relative 'financial_document_v1_line_item'
|
|
5
5
|
module Mindee
|
6
6
|
module Product
|
7
7
|
module FinancialDocument
|
8
|
-
# List of line item
|
8
|
+
# List of line item present on the document.
|
9
9
|
class FinancialDocumentV1LineItems < Array
|
10
10
|
# Entries.
|
11
11
|
# @return [Array<FinancialDocumentV1LineItem>]
|
@@ -12,7 +12,7 @@ module Mindee
|
|
12
12
|
module Product
|
13
13
|
module FR
|
14
14
|
module EnergyBill
|
15
|
-
# Energy Bill API version 1.
|
15
|
+
# Energy Bill API version 1.2 document data.
|
16
16
|
class EnergyBillV1Document < Mindee::Parsing::Common::Prediction
|
17
17
|
include Mindee::Parsing::Standard
|
18
18
|
# The unique identifier associated with a specific contract.
|
@@ -188,11 +188,13 @@ module Mindee
|
|
188
188
|
def energy_usage_separator(char)
|
189
189
|
out_str = String.new
|
190
190
|
out_str << ' '
|
191
|
+
out_str << "+#{char * 13}"
|
191
192
|
out_str << "+#{char * 38}"
|
192
193
|
out_str << "+#{char * 12}"
|
193
194
|
out_str << "+#{char * 12}"
|
194
195
|
out_str << "+#{char * 10}"
|
195
196
|
out_str << "+#{char * 11}"
|
197
|
+
out_str << "+#{char * 17}"
|
196
198
|
out_str << "+#{char * 12}"
|
197
199
|
out_str << '+'
|
198
200
|
out_str
|
@@ -206,11 +208,13 @@ module Mindee
|
|
206
208
|
out_str = String.new
|
207
209
|
out_str << "\n#{energy_usage_separator('-')}"
|
208
210
|
out_str << "\n |"
|
211
|
+
out_str << ' Consumption |'
|
209
212
|
out_str << ' Description |'
|
210
213
|
out_str << ' End Date |'
|
211
214
|
out_str << ' Start Date |'
|
212
215
|
out_str << ' Tax Rate |'
|
213
216
|
out_str << ' Total |'
|
217
|
+
out_str << ' Unit of Measure |'
|
214
218
|
out_str << ' Unit Price |'
|
215
219
|
out_str << "\n#{energy_usage_separator('=')}"
|
216
220
|
out_str << "\n #{line_items}"
|
@@ -9,6 +9,9 @@ module Mindee
|
|
9
9
|
# Details of energy consumption.
|
10
10
|
class EnergyBillV1EnergyUsage < Mindee::Parsing::Standard::FeatureField
|
11
11
|
include Mindee::Parsing::Standard
|
12
|
+
# The price per unit of energy consumed.
|
13
|
+
# @return [Float]
|
14
|
+
attr_reader :consumption
|
12
15
|
# Description or details of the energy usage.
|
13
16
|
# @return [String]
|
14
17
|
attr_reader :description
|
@@ -24,6 +27,9 @@ module Mindee
|
|
24
27
|
# The total cost of energy consumed.
|
25
28
|
# @return [Float]
|
26
29
|
attr_reader :total
|
30
|
+
# The unit of measurement for energy consumption.
|
31
|
+
# @return [String]
|
32
|
+
attr_reader :unit
|
27
33
|
# The price per unit of energy consumed.
|
28
34
|
# @return [Float]
|
29
35
|
attr_reader :unit_price
|
@@ -32,11 +38,13 @@ module Mindee
|
|
32
38
|
# @param page_id [Integer, nil]
|
33
39
|
def initialize(prediction, page_id)
|
34
40
|
super
|
41
|
+
@consumption = prediction['consumption']
|
35
42
|
@description = prediction['description']
|
36
43
|
@end_date = prediction['end_date']
|
37
44
|
@start_date = prediction['start_date']
|
38
45
|
@tax_rate = prediction['tax_rate']
|
39
46
|
@total = prediction['total']
|
47
|
+
@unit = prediction['unit']
|
40
48
|
@unit_price = prediction['unit_price']
|
41
49
|
@page_id = page_id
|
42
50
|
end
|
@@ -44,6 +52,8 @@ module Mindee
|
|
44
52
|
# @return [Hash]
|
45
53
|
def printable_values
|
46
54
|
printable = {}
|
55
|
+
printable[:consumption] =
|
56
|
+
@consumption.nil? ? '' : Parsing::Standard::BaseField.float_to_string(@consumption)
|
47
57
|
printable[:description] = format_for_display(@description)
|
48
58
|
printable[:end_date] = format_for_display(@end_date)
|
49
59
|
printable[:start_date] = format_for_display(@start_date)
|
@@ -51,6 +61,7 @@ module Mindee
|
|
51
61
|
@tax_rate.nil? ? '' : Parsing::Standard::BaseField.float_to_string(@tax_rate)
|
52
62
|
printable[:total] =
|
53
63
|
@total.nil? ? '' : Parsing::Standard::BaseField.float_to_string(@total)
|
64
|
+
printable[:unit] = format_for_display(@unit)
|
54
65
|
printable[:unit_price] =
|
55
66
|
@unit_price.nil? ? '' : Parsing::Standard::BaseField.float_to_string(@unit_price)
|
56
67
|
printable
|
@@ -59,6 +70,8 @@ module Mindee
|
|
59
70
|
# @return [Hash]
|
60
71
|
def table_printable_values
|
61
72
|
printable = {}
|
73
|
+
printable[:consumption] =
|
74
|
+
@consumption.nil? ? '' : Parsing::Standard::BaseField.float_to_string(@consumption)
|
62
75
|
printable[:description] = format_for_display(@description, 36)
|
63
76
|
printable[:end_date] = format_for_display(@end_date, 10)
|
64
77
|
printable[:start_date] = format_for_display(@start_date, nil)
|
@@ -66,6 +79,7 @@ module Mindee
|
|
66
79
|
@tax_rate.nil? ? '' : Parsing::Standard::BaseField.float_to_string(@tax_rate)
|
67
80
|
printable[:total] =
|
68
81
|
@total.nil? ? '' : Parsing::Standard::BaseField.float_to_string(@total)
|
82
|
+
printable[:unit] = format_for_display(@unit, nil)
|
69
83
|
printable[:unit_price] =
|
70
84
|
@unit_price.nil? ? '' : Parsing::Standard::BaseField.float_to_string(@unit_price)
|
71
85
|
printable
|
@@ -75,11 +89,13 @@ module Mindee
|
|
75
89
|
def to_table_line
|
76
90
|
printable = table_printable_values
|
77
91
|
out_str = String.new
|
92
|
+
out_str << format('| %- 12s', printable[:consumption])
|
78
93
|
out_str << format('| %- 37s', printable[:description])
|
79
94
|
out_str << format('| %- 11s', printable[:end_date])
|
80
95
|
out_str << format('| %- 11s', printable[:start_date])
|
81
96
|
out_str << format('| %- 9s', printable[:tax_rate])
|
82
97
|
out_str << format('| %- 10s', printable[:total])
|
98
|
+
out_str << format('| %- 16s', printable[:unit])
|
83
99
|
out_str << format('| %- 11s', printable[:unit_price])
|
84
100
|
out_str << '|'
|
85
101
|
end
|
@@ -88,11 +104,13 @@ module Mindee
|
|
88
104
|
def to_s
|
89
105
|
printable = printable_values
|
90
106
|
out_str = String.new
|
107
|
+
out_str << "\n :Consumption: #{printable[:consumption]}"
|
91
108
|
out_str << "\n :Description: #{printable[:description]}"
|
92
109
|
out_str << "\n :End Date: #{printable[:end_date]}"
|
93
110
|
out_str << "\n :Start Date: #{printable[:start_date]}"
|
94
111
|
out_str << "\n :Tax Rate: #{printable[:tax_rate]}"
|
95
112
|
out_str << "\n :Total: #{printable[:total]}"
|
113
|
+
out_str << "\n :Unit of Measure: #{printable[:unit]}"
|
96
114
|
out_str << "\n :Unit Price: #{printable[:unit_price]}"
|
97
115
|
out_str
|
98
116
|
end
|
@@ -31,11 +31,13 @@ module Mindee
|
|
31
31
|
# @return [String]
|
32
32
|
def self.line_items_separator(char)
|
33
33
|
out_str = String.new
|
34
|
+
out_str << "+#{char * 13}"
|
34
35
|
out_str << "+#{char * 38}"
|
35
36
|
out_str << "+#{char * 12}"
|
36
37
|
out_str << "+#{char * 12}"
|
37
38
|
out_str << "+#{char * 10}"
|
38
39
|
out_str << "+#{char * 11}"
|
40
|
+
out_str << "+#{char * 17}"
|
39
41
|
out_str << "+#{char * 12}"
|
40
42
|
out_str
|
41
43
|
end
|
@@ -49,11 +51,13 @@ module Mindee
|
|
49
51
|
end.join
|
50
52
|
out_str = String.new
|
51
53
|
out_str << ("\n#{self.class.line_items_separator('-')}\n ")
|
54
|
+
out_str << ' | Consumption'
|
52
55
|
out_str << ' | Description '
|
53
56
|
out_str << ' | End Date '
|
54
57
|
out_str << ' | Start Date'
|
55
58
|
out_str << ' | Tax Rate'
|
56
59
|
out_str << ' | Total '
|
60
|
+
out_str << ' | Unit of Measure'
|
57
61
|
out_str << ' | Unit Price'
|
58
62
|
out_str << (" |\n#{self.class.line_items_separator('=')}")
|
59
63
|
out_str + lines
|
@@ -15,7 +15,7 @@ module Mindee
|
|
15
15
|
# The type of energy meter.
|
16
16
|
# @return [String]
|
17
17
|
attr_reader :meter_type
|
18
|
-
# The unit of
|
18
|
+
# The unit of power for energy consumption.
|
19
19
|
# @return [String]
|
20
20
|
attr_reader :unit
|
21
21
|
|
@@ -44,7 +44,7 @@ module Mindee
|
|
44
44
|
out_str = String.new
|
45
45
|
out_str << "\n :Meter Number: #{printable[:meter_number]}"
|
46
46
|
out_str << "\n :Meter Type: #{printable[:meter_type]}"
|
47
|
-
out_str << "\n :Unit of
|
47
|
+
out_str << "\n :Unit of Power: #{printable[:unit]}"
|
48
48
|
out_str
|
49
49
|
end
|
50
50
|
end
|
@@ -7,7 +7,7 @@ module Mindee
|
|
7
7
|
module Product
|
8
8
|
module FR
|
9
9
|
module EnergyBill
|
10
|
-
# Energy Bill API version 1.
|
10
|
+
# Energy Bill API version 1.2 page data.
|
11
11
|
class EnergyBillV1Page < Mindee::Parsing::Common::Page
|
12
12
|
# @param prediction [Hash]
|
13
13
|
def initialize(prediction)
|
@@ -9,13 +9,13 @@ module Mindee
|
|
9
9
|
# Invoice API version 4.9 document data.
|
10
10
|
class InvoiceV4Document < Mindee::Parsing::Common::Prediction
|
11
11
|
include Mindee::Parsing::Standard
|
12
|
-
# The customer
|
12
|
+
# The customer billing address.
|
13
13
|
# @return [Mindee::Parsing::Standard::StringField]
|
14
14
|
attr_reader :billing_address
|
15
15
|
# The address of the customer.
|
16
16
|
# @return [Mindee::Parsing::Standard::StringField]
|
17
17
|
attr_reader :customer_address
|
18
|
-
# List of company
|
18
|
+
# List of company registration numbers associated to the customer.
|
19
19
|
# @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
|
20
20
|
attr_reader :customer_company_registrations
|
21
21
|
# The customer account number or identifier from the supplier.
|
@@ -27,7 +27,7 @@ module Mindee
|
|
27
27
|
# The date the purchase was made.
|
28
28
|
# @return [Mindee::Parsing::Standard::DateField]
|
29
29
|
attr_reader :date
|
30
|
-
#
|
30
|
+
# Document type: INVOICE or CREDIT NOTE.
|
31
31
|
# @return [Mindee::Parsing::Standard::ClassificationField]
|
32
32
|
attr_reader :document_type
|
33
33
|
# The date on which the payment is due.
|
@@ -36,19 +36,19 @@ module Mindee
|
|
36
36
|
# The invoice number or identifier.
|
37
37
|
# @return [Mindee::Parsing::Standard::StringField]
|
38
38
|
attr_reader :invoice_number
|
39
|
-
# List of line
|
39
|
+
# List of all the line items present on the invoice.
|
40
40
|
# @return [Mindee::Product::Invoice::InvoiceV4LineItems]
|
41
41
|
attr_reader :line_items
|
42
|
-
# The locale
|
42
|
+
# The locale of the document.
|
43
43
|
# @return [Mindee::Parsing::Standard::LocaleField]
|
44
44
|
attr_reader :locale
|
45
|
-
# The date on which the payment is due/ was full-filled.
|
45
|
+
# The date on which the payment is due / was full-filled.
|
46
46
|
# @return [Mindee::Parsing::Standard::DateField]
|
47
47
|
attr_reader :payment_date
|
48
48
|
# The purchase order number.
|
49
49
|
# @return [Mindee::Parsing::Standard::StringField]
|
50
50
|
attr_reader :po_number
|
51
|
-
# List of
|
51
|
+
# List of all reference numbers on the invoice, including the purchase order number.
|
52
52
|
# @return [Array<Mindee::Parsing::Standard::StringField>]
|
53
53
|
attr_reader :reference_numbers
|
54
54
|
# Customer's delivery address.
|
@@ -57,16 +57,16 @@ module Mindee
|
|
57
57
|
# The address of the supplier or merchant.
|
58
58
|
# @return [Mindee::Parsing::Standard::StringField]
|
59
59
|
attr_reader :supplier_address
|
60
|
-
# List of company
|
60
|
+
# List of company registration numbers associated to the supplier.
|
61
61
|
# @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
|
62
62
|
attr_reader :supplier_company_registrations
|
63
|
-
# The email of the supplier or merchant.
|
63
|
+
# The email address of the supplier or merchant.
|
64
64
|
# @return [Mindee::Parsing::Standard::StringField]
|
65
65
|
attr_reader :supplier_email
|
66
66
|
# The name of the supplier or merchant.
|
67
67
|
# @return [Mindee::Parsing::Standard::StringField]
|
68
68
|
attr_reader :supplier_name
|
69
|
-
# List of payment details associated to the supplier.
|
69
|
+
# List of payment details associated to the supplier of the invoice.
|
70
70
|
# @return [Array<Mindee::Parsing::Standard::PaymentDetailsField>]
|
71
71
|
attr_reader :supplier_payment_details
|
72
72
|
# The phone number of the supplier or merchant.
|
@@ -75,16 +75,16 @@ module Mindee
|
|
75
75
|
# The website URL of the supplier or merchant.
|
76
76
|
# @return [Mindee::Parsing::Standard::StringField]
|
77
77
|
attr_reader :supplier_website
|
78
|
-
# List of
|
78
|
+
# List of taxes. Each item contains the detail of the tax.
|
79
79
|
# @return [Mindee::Parsing::Standard::Taxes]
|
80
80
|
attr_reader :taxes
|
81
|
-
# The total amount
|
81
|
+
# The total amount of the invoice: includes taxes, tips, fees, and other charges.
|
82
82
|
# @return [Mindee::Parsing::Standard::AmountField]
|
83
83
|
attr_reader :total_amount
|
84
|
-
# The net amount
|
84
|
+
# The net amount of the invoice: does not include taxes, fees, and discounts.
|
85
85
|
# @return [Mindee::Parsing::Standard::AmountField]
|
86
86
|
attr_reader :total_net
|
87
|
-
# The total tax:
|
87
|
+
# The total tax: the sum of all the taxes for this invoice.
|
88
88
|
# @return [Mindee::Parsing::Standard::AmountField]
|
89
89
|
attr_reader :total_tax
|
90
90
|
|
@@ -5,13 +5,13 @@ require_relative '../../parsing'
|
|
5
5
|
module Mindee
|
6
6
|
module Product
|
7
7
|
module Invoice
|
8
|
-
# List of line
|
8
|
+
# List of all the line items present on the invoice.
|
9
9
|
class InvoiceV4LineItem < Mindee::Parsing::Standard::FeatureField
|
10
10
|
include Mindee::Parsing::Standard
|
11
11
|
# The item description.
|
12
12
|
# @return [String]
|
13
13
|
attr_reader :description
|
14
|
-
# The product code
|
14
|
+
# The product code of the item.
|
15
15
|
# @return [String]
|
16
16
|
attr_reader :product_code
|
17
17
|
# The item quantity
|
@@ -8,12 +8,12 @@ module Mindee
|
|
8
8
|
module Product
|
9
9
|
# Invoice Splitter module.
|
10
10
|
module InvoiceSplitter
|
11
|
-
# Invoice Splitter
|
11
|
+
# Invoice Splitter API version 1 inference prediction.
|
12
12
|
class InvoiceSplitterV1 < Mindee::Parsing::Common::Inference
|
13
13
|
@endpoint_name = 'invoice_splitter'
|
14
14
|
@endpoint_version = '1'
|
15
|
-
@has_sync = false
|
16
15
|
@has_async = true
|
16
|
+
@has_sync = false
|
17
17
|
|
18
18
|
# @param prediction [Hash]
|
19
19
|
def initialize(prediction)
|
@@ -1,65 +1,61 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../../parsing'
|
4
|
+
require_relative 'invoice_splitter_v1_invoice_page_groups'
|
4
5
|
|
5
6
|
module Mindee
|
6
7
|
module Product
|
7
8
|
module InvoiceSplitter
|
8
|
-
#
|
9
|
-
class
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
attr_reader :confidence
|
9
|
+
# Invoice Splitter API version 1.2 document data.
|
10
|
+
class InvoiceSplitterV1Document < Mindee::Parsing::Common::Prediction
|
11
|
+
include Mindee::Parsing::Standard
|
12
|
+
# List of page groups. Each group represents a single invoice within a multi-invoice document.
|
13
|
+
# @return [Mindee::Product::InvoiceSplitter::InvoiceSplitterV1InvoicePageGroups]
|
14
|
+
attr_reader :invoice_page_groups
|
15
15
|
|
16
|
-
# @param prediction[Hash]
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
# @param prediction [Hash]
|
17
|
+
# @param page_id [Integer, nil]
|
18
|
+
def initialize(prediction, page_id)
|
19
|
+
super
|
20
|
+
@invoice_page_groups = Product::InvoiceSplitter::InvoiceSplitterV1InvoicePageGroups.new(
|
21
|
+
prediction['invoice_page_groups'], page_id
|
22
|
+
)
|
20
23
|
end
|
21
24
|
|
22
25
|
# @return [String]
|
23
26
|
def to_s
|
27
|
+
invoice_page_groups = invoice_page_groups_to_s
|
24
28
|
out_str = String.new
|
25
|
-
out_str << ":Page
|
26
|
-
out_str
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
# Invoice Splitter V1 document prediction.
|
31
|
-
class InvoiceSplitterV1Document < Mindee::Parsing::Common::Prediction
|
32
|
-
# @return[Array<Mindee::Product::InvoiceSplitter::InvoiceSplitterV1PageGroup>]
|
33
|
-
attr_reader :invoice_page_groups
|
34
|
-
|
35
|
-
# @param prediction [Hash]
|
36
|
-
# @param _page_id [Integer, nil]
|
37
|
-
def initialize(prediction, _page_id = nil)
|
38
|
-
super(prediction, nil)
|
39
|
-
construct_invoice_page_groups_from_prediction(prediction)
|
29
|
+
out_str << "\n:Invoice Page Groups:"
|
30
|
+
out_str << invoice_page_groups
|
31
|
+
out_str[1..].to_s
|
40
32
|
end
|
41
33
|
|
42
|
-
|
43
|
-
# @param prediction [hash]
|
44
|
-
def construct_invoice_page_groups_from_prediction(prediction)
|
45
|
-
@invoice_page_groups = []
|
46
|
-
return unless prediction.key?('invoice_page_groups') && prediction['invoice_page_groups'].any?
|
34
|
+
private
|
47
35
|
|
48
|
-
|
49
|
-
|
50
|
-
|
36
|
+
# @param char [String]
|
37
|
+
# @return [String]
|
38
|
+
def invoice_page_groups_separator(char)
|
39
|
+
out_str = String.new
|
40
|
+
out_str << ' '
|
41
|
+
out_str << "+#{char * 74}"
|
42
|
+
out_str << '+'
|
43
|
+
out_str
|
51
44
|
end
|
52
45
|
|
53
46
|
# @return [String]
|
54
|
-
def
|
47
|
+
def invoice_page_groups_to_s
|
48
|
+
return '' if @invoice_page_groups.empty?
|
49
|
+
|
50
|
+
line_items = @invoice_page_groups.map(&:to_table_line).join("\n#{invoice_page_groups_separator('-')}\n ")
|
55
51
|
out_str = String.new
|
56
|
-
out_str << "\n
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
out_str
|
52
|
+
out_str << "\n#{invoice_page_groups_separator('-')}"
|
53
|
+
out_str << "\n |"
|
54
|
+
out_str << ' Page Indexes |'
|
55
|
+
out_str << "\n#{invoice_page_groups_separator('=')}"
|
56
|
+
out_str << "\n #{line_items}"
|
57
|
+
out_str << "\n#{invoice_page_groups_separator('-')}"
|
58
|
+
out_str
|
63
59
|
end
|
64
60
|
end
|
65
61
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module InvoiceSplitter
|
8
|
+
# List of page groups. Each group represents a single invoice within a multi-invoice document.
|
9
|
+
class InvoiceSplitterV1InvoicePageGroup < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# List of page indexes that belong to the same invoice (group).
|
12
|
+
# @return [Array<Integer>]
|
13
|
+
attr_reader :page_indexes
|
14
|
+
|
15
|
+
# @param prediction [Hash]
|
16
|
+
# @param page_id [Integer, nil]
|
17
|
+
def initialize(prediction, page_id)
|
18
|
+
super
|
19
|
+
@page_indexes = prediction['page_indexes']
|
20
|
+
@page_id = page_id
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Hash]
|
24
|
+
def printable_values
|
25
|
+
printable = {}
|
26
|
+
printable[:page_indexes] = format_for_display(@page_indexes)
|
27
|
+
printable
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Hash]
|
31
|
+
def table_printable_values
|
32
|
+
printable = {}
|
33
|
+
printable[:page_indexes] = @page_indexes.join(', ')
|
34
|
+
printable
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String]
|
38
|
+
def to_table_line
|
39
|
+
printable = table_printable_values
|
40
|
+
out_str = String.new
|
41
|
+
out_str << format('| %- 73s', printable[:page_indexes])
|
42
|
+
out_str << '|'
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String]
|
46
|
+
def to_s
|
47
|
+
printable = printable_values
|
48
|
+
out_str = String.new
|
49
|
+
out_str << "\n :Page Indexes: #{printable[:page_indexes]}"
|
50
|
+
out_str
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|