mindee 3.19.0 → 3.20.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/CHANGELOG.md +10 -0
- data/README.md +59 -2
- data/docs/bank_statement_fr_v2.md +244 -0
- data/docs/code_samples/bank_statement_fr_v2_async.txt +19 -0
- data/docs/driver_license_v1.md +32 -1
- data/docs/financial_document_v1.md +5 -5
- data/docs/invoices_v4.md +5 -5
- data/lib/mindee/parsing/common/document.rb +1 -2
- data/lib/mindee/product/fr/bank_statement/bank_statement_v2.rb +41 -0
- data/lib/mindee/product/fr/bank_statement/bank_statement_v2_document.rb +134 -0
- data/lib/mindee/product/fr/bank_statement/bank_statement_v2_page.rb +34 -0
- data/lib/mindee/product/fr/bank_statement/bank_statement_v2_transaction.rb +73 -0
- data/lib/mindee/product.rb +1 -0
- data/lib/mindee/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59ac099d28439b6b41128226d0ef764b98fb5dfd290f36b9e7406b94f5bace85
|
4
|
+
data.tar.gz: 5ce4b7983bc953a9e26976eedf28674e5854a5e1280261c711d213ee6912a6a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fc033f2699ab4eafd13cbe7dc54c93c162bca731f39fd0efb7a79ff0110cd4184d60343121eb6ef517dd85b281af92ce4ef55232ddb4a05dcf4cd4b5522ec49
|
7
|
+
data.tar.gz: 5de541e8d42968c167731d555b51502b6a01a55daeb8e6b1c2c408892d1d511f9c2b553abfd2cd3f79ba1ccc16ffb2af7d7c50f1fae630336a4d7f511a022587
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Mindee Ruby API Library Changelog
|
2
2
|
|
3
|
+
## v3.20.0 - 2025-02-26
|
4
|
+
### Changes
|
5
|
+
* :sparkles: add support for FR Banks Statement V2
|
6
|
+
|
7
|
+
|
8
|
+
## v3.19.1 - 2025-01-21
|
9
|
+
### Changes
|
10
|
+
* :bug: fix extras failing at document level if missing from prediction
|
11
|
+
|
12
|
+
|
3
13
|
## v3.19.0 - 2025-01-14
|
4
14
|
### Changes
|
5
15
|
* :sparkles: add support for US Mail V3
|
data/README.md
CHANGED
@@ -147,21 +147,78 @@ result.document.inference.prediction.fields.each do |field_name, field_data|
|
|
147
147
|
puts field_data.to_s
|
148
148
|
end
|
149
149
|
```
|
150
|
+
## Asynchronously Parsing a File
|
151
|
+
|
152
|
+
This allows for easier handling of bursts of documents sent.
|
153
|
+
|
154
|
+
Some products are only available asynchronously, check the example code
|
155
|
+
directly on the Mindee platform.
|
156
|
+
|
157
|
+
|
158
|
+
### Enqueue and Parse a Webhook Response
|
159
|
+
This is an optional way of handling asynchronous APIs.
|
160
|
+
|
161
|
+
```rb
|
162
|
+
require 'mindee'
|
163
|
+
|
164
|
+
# Init a new client
|
165
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
166
|
+
|
167
|
+
# Load a file from disk
|
168
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
169
|
+
|
170
|
+
|
171
|
+
# Parse the file
|
172
|
+
enqueue_response = mindee_client.enqueue(
|
173
|
+
input_source,
|
174
|
+
Mindee::Product::InternationalId::InternationalIdV2
|
175
|
+
)
|
176
|
+
|
177
|
+
job_id = enqueue_response.job.id
|
178
|
+
|
179
|
+
# Load the JSON string sent by the Mindee webhook POST callback.
|
180
|
+
# Reading the callback data will vary greatly depending on your HTTP server.
|
181
|
+
# This is therefore beyond the scope of this example.
|
182
|
+
|
183
|
+
local_response = Mindee::Input::LocalResponse.new(request.body.string)
|
184
|
+
|
185
|
+
# You can also use a File object as the input.
|
186
|
+
# FILE_PATH = File.join('path', 'to', 'file.json').freeze
|
187
|
+
# local_response = Mindee::Input::LocalResponse.new(FILE_PATH);
|
188
|
+
|
189
|
+
# Optional: verify the HMAC signature.
|
190
|
+
unless local_response.valid_hmac_signature?(my_secret_key, 'invalid signature')
|
191
|
+
raise "Invalid HMAC signature!"
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
# Deserialize the response:
|
196
|
+
result = mindee_client.load_prediction(
|
197
|
+
Mindee::Product::InternationalId::InternationalIdV2,
|
198
|
+
local_response
|
199
|
+
)
|
200
|
+
|
201
|
+
# Print a full summary of the parsed data in RST format
|
202
|
+
puts result.document
|
203
|
+
```
|
204
|
+
|
150
205
|
|
151
206
|
## CLI Tool
|
152
207
|
|
153
208
|
A command-line interface tool is available to quickly test documents:
|
154
209
|
|
155
210
|
```sh
|
156
|
-
ruby ./bin/mindee.rb
|
211
|
+
ruby ./bin/mindee.rb <product_name> path/to/your/file.ext
|
157
212
|
```
|
158
213
|
|
159
214
|
Using the ruby bundler:
|
160
215
|
|
161
216
|
```sh
|
162
|
-
bundle exec ruby ./bin/mindee.rb
|
217
|
+
bundle exec ruby ./bin/mindee.rb <product_name> path/to/your/file.ext
|
163
218
|
```
|
164
219
|
|
220
|
+
Where possible values for `<product_name>` can be displayed by running the command with no arguments.
|
221
|
+
|
165
222
|
## Further Reading
|
166
223
|
|
167
224
|
There's more to it than that for those that need more features, or want to
|
@@ -0,0 +1,244 @@
|
|
1
|
+
---
|
2
|
+
title: FR Bank Statement OCR Ruby
|
3
|
+
category: 622b805aaec68102ea7fcbc2
|
4
|
+
slug: ruby-fr-bank-statement-ocr
|
5
|
+
parentDoc: 6294d97ee723f1008d2ab28e
|
6
|
+
---
|
7
|
+
The Ruby OCR SDK supports the [Bank Statement API](https://platform.mindee.com/mindee/bank_statement_fr).
|
8
|
+
|
9
|
+
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/bank_statement_fr/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
|
10
|
+

|
11
|
+
|
12
|
+
# Quick-Start
|
13
|
+
```rb
|
14
|
+
require 'mindee'
|
15
|
+
|
16
|
+
# Init a new client
|
17
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
18
|
+
|
19
|
+
# Load a file from disk
|
20
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
21
|
+
|
22
|
+
# Parse the file
|
23
|
+
result = mindee_client.enqueue_and_parse(
|
24
|
+
input_source,
|
25
|
+
Mindee::Product::FR::BankStatement::BankStatementV2
|
26
|
+
)
|
27
|
+
|
28
|
+
# Print a full summary of the parsed data in RST format
|
29
|
+
puts result.document
|
30
|
+
|
31
|
+
# Print the document-level parsed data
|
32
|
+
# puts result.document.inference.prediction
|
33
|
+
|
34
|
+
```
|
35
|
+
|
36
|
+
**Output (RST):**
|
37
|
+
```rst
|
38
|
+
########
|
39
|
+
Document
|
40
|
+
########
|
41
|
+
:Mindee ID: 3c1811c0-9876-45ae-91ad-c2e9cd75dd83
|
42
|
+
:Filename: default_sample.jpg
|
43
|
+
|
44
|
+
Inference
|
45
|
+
#########
|
46
|
+
:Product: mindee/bank_statement_fr v2.0
|
47
|
+
:Rotation applied: Yes
|
48
|
+
|
49
|
+
Prediction
|
50
|
+
==========
|
51
|
+
:Account Number: XXXXXXXXXXXXXX
|
52
|
+
:Bank Name: Banque lafinancepourtous
|
53
|
+
:Bank Address: 1 rue de la Banque, 100210 Cassette
|
54
|
+
:Client Names: Karine Plume
|
55
|
+
:Client Address: 1 rue des Cigales, 100210 Cassette
|
56
|
+
:Statement Date: 2002-02-28
|
57
|
+
:Statement Start Date: 2002-02-01
|
58
|
+
:Statement End Date: 2002-02-28
|
59
|
+
:Opening Balance: 22.15
|
60
|
+
:Closing Balance: -278.96
|
61
|
+
:Transactions:
|
62
|
+
+------------+------------+--------------------------------------+
|
63
|
+
| Amount | Date | Description |
|
64
|
+
+============+============+======================================+
|
65
|
+
| 1240.00 | 2002-02-01 | Virement salaire |
|
66
|
+
+------------+------------+--------------------------------------+
|
67
|
+
| -520.00 | 2002-02-02 | Virement loyer |
|
68
|
+
+------------+------------+--------------------------------------+
|
69
|
+
| -312.00 | 2002-02-03 | Débit Carte nºxxxx |
|
70
|
+
+------------+------------+--------------------------------------+
|
71
|
+
| 12.47 | 2002-02-04 | Virement CPAM |
|
72
|
+
+------------+------------+--------------------------------------+
|
73
|
+
| 65.00 | 2002-02-05 | Virement APL |
|
74
|
+
+------------+------------+--------------------------------------+
|
75
|
+
| -110.00 | 2002-02-07 | Débit Carte nxxxxxxxxxxxxxxxx |
|
76
|
+
+------------+------------+--------------------------------------+
|
77
|
+
| -3.30 | 2002-02-08 | Cotisation mensuelle carte bancaire |
|
78
|
+
+------------+------------+--------------------------------------+
|
79
|
+
| -120.00 | 2002-02-09 | Chèque n° xxxxxx98 |
|
80
|
+
+------------+------------+--------------------------------------+
|
81
|
+
| -60.00 | 2002-02-09 | Retrait espèces DAB |
|
82
|
+
+------------+------------+--------------------------------------+
|
83
|
+
| -55.00 | 2002-02-15 | Chèque n° xxxxxx99 |
|
84
|
+
+------------+------------+--------------------------------------+
|
85
|
+
| -80.00 | 2002-02-16 | Prélèvement supercrédit |
|
86
|
+
+------------+------------+--------------------------------------+
|
87
|
+
| -120.00 | 2002-02-17 | Chèque n° xxxxx 100 |
|
88
|
+
+------------+------------+--------------------------------------+
|
89
|
+
| -163.25 | 2002-02-20 | Débit Carte nºxxxxxxxxxxxxx |
|
90
|
+
+------------+------------+--------------------------------------+
|
91
|
+
| -25.50 | 2002-02-21 | Débit Carte n°xxxxxxxxxxxxxxxxxx |
|
92
|
+
+------------+------------+--------------------------------------+
|
93
|
+
| -30.00 | 2002-02-24 | Prélèvement Opérateur téléphonique |
|
94
|
+
+------------+------------+--------------------------------------+
|
95
|
+
| -6.53 | 2002-02-25 | Agios |
|
96
|
+
+------------+------------+--------------------------------------+
|
97
|
+
| -13.00 | 2002-02-28 | Frais irrégularités et incidents ... |
|
98
|
+
+------------+------------+--------------------------------------+
|
99
|
+
:Total Debits: 1618.58
|
100
|
+
:Total Credits: 1339.62
|
101
|
+
```
|
102
|
+
|
103
|
+
# Field Types
|
104
|
+
## Standard Fields
|
105
|
+
These fields are generic and used in several products.
|
106
|
+
|
107
|
+
### Basic Field
|
108
|
+
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
109
|
+
A typical `Field` object will have the following attributes:
|
110
|
+
|
111
|
+
* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
|
112
|
+
* **confidence** (Float, nil): the confidence score of the field prediction.
|
113
|
+
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
114
|
+
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
115
|
+
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
|
116
|
+
* **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
|
117
|
+
|
118
|
+
|
119
|
+
Aside from the previous attributes, all basic fields have access to a `to_s` method that can be used to print their value as a string.
|
120
|
+
|
121
|
+
|
122
|
+
### Amount Field
|
123
|
+
The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
|
124
|
+
|
125
|
+
### Date Field
|
126
|
+
Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
|
127
|
+
|
128
|
+
* **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
|
129
|
+
|
130
|
+
### String Field
|
131
|
+
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
132
|
+
|
133
|
+
## Specific Fields
|
134
|
+
Fields which are specific to this product; they are not used in any other product.
|
135
|
+
|
136
|
+
### Transactions Field
|
137
|
+
The list of values that represent the financial transactions recorded in a bank statement.
|
138
|
+
|
139
|
+
A `BankStatementV2Transaction` implements the following attributes:
|
140
|
+
|
141
|
+
* `amount` (Float): The monetary amount of the transaction.
|
142
|
+
* `date` (String): The date on which the transaction occurred.
|
143
|
+
* `description` (String): The additional information about the transaction.
|
144
|
+
|
145
|
+
# Attributes
|
146
|
+
The following fields are extracted for Bank Statement V2:
|
147
|
+
|
148
|
+
## Account Number
|
149
|
+
**account_number** ([StringField](#string-field)): The unique identifier for a customer's account in the bank's system.
|
150
|
+
|
151
|
+
```rb
|
152
|
+
puts result.document.inference.prediction.account_number.value
|
153
|
+
```
|
154
|
+
|
155
|
+
## Bank Address
|
156
|
+
**bank_address** ([StringField](#string-field)): The physical location of the bank where the statement was issued.
|
157
|
+
|
158
|
+
```rb
|
159
|
+
puts result.document.inference.prediction.bank_address.value
|
160
|
+
```
|
161
|
+
|
162
|
+
## Bank Name
|
163
|
+
**bank_name** ([StringField](#string-field)): The name of the bank that issued the statement.
|
164
|
+
|
165
|
+
```rb
|
166
|
+
puts result.document.inference.prediction.bank_name.value
|
167
|
+
```
|
168
|
+
|
169
|
+
## Client Address
|
170
|
+
**client_address** ([StringField](#string-field)): The address of the client associated with the bank statement.
|
171
|
+
|
172
|
+
```rb
|
173
|
+
puts result.document.inference.prediction.client_address.value
|
174
|
+
```
|
175
|
+
|
176
|
+
## Client Names
|
177
|
+
**client_names** (Array<[StringField](#string-field)>): The name of the clients who own the bank statement.
|
178
|
+
|
179
|
+
```rb
|
180
|
+
for client_names_elem in result.document.inference.prediction.client_names do
|
181
|
+
puts client_names_elem.value
|
182
|
+
end
|
183
|
+
```
|
184
|
+
|
185
|
+
## Closing Balance
|
186
|
+
**closing_balance** ([AmountField](#amount-field)): The final amount of money in the account at the end of the statement period.
|
187
|
+
|
188
|
+
```rb
|
189
|
+
puts result.document.inference.prediction.closing_balance.value
|
190
|
+
```
|
191
|
+
|
192
|
+
## Opening Balance
|
193
|
+
**opening_balance** ([AmountField](#amount-field)): The initial amount of money in an account at the start of the period.
|
194
|
+
|
195
|
+
```rb
|
196
|
+
puts result.document.inference.prediction.opening_balance.value
|
197
|
+
```
|
198
|
+
|
199
|
+
## Statement Date
|
200
|
+
**statement_date** ([DateField](#date-field)): The date on which the bank statement was generated.
|
201
|
+
|
202
|
+
```rb
|
203
|
+
puts result.document.inference.prediction.statement_date.value
|
204
|
+
```
|
205
|
+
|
206
|
+
## Statement End Date
|
207
|
+
**statement_end_date** ([DateField](#date-field)): The date when the statement period ends.
|
208
|
+
|
209
|
+
```rb
|
210
|
+
puts result.document.inference.prediction.statement_end_date.value
|
211
|
+
```
|
212
|
+
|
213
|
+
## Statement Start Date
|
214
|
+
**statement_start_date** ([DateField](#date-field)): The date when the bank statement period begins.
|
215
|
+
|
216
|
+
```rb
|
217
|
+
puts result.document.inference.prediction.statement_start_date.value
|
218
|
+
```
|
219
|
+
|
220
|
+
## Total Credits
|
221
|
+
**total_credits** ([AmountField](#amount-field)): The total amount of money deposited into the account.
|
222
|
+
|
223
|
+
```rb
|
224
|
+
puts result.document.inference.prediction.total_credits.value
|
225
|
+
```
|
226
|
+
|
227
|
+
## Total Debits
|
228
|
+
**total_debits** ([AmountField](#amount-field)): The total amount of money debited from the account.
|
229
|
+
|
230
|
+
```rb
|
231
|
+
puts result.document.inference.prediction.total_debits.value
|
232
|
+
```
|
233
|
+
|
234
|
+
## Transactions
|
235
|
+
**transactions** (Array<[BankStatementV2Transaction](#transactions-field)>): The list of values that represent the financial transactions recorded in a bank statement.
|
236
|
+
|
237
|
+
```rb
|
238
|
+
for transactions_elem in result.document.inference.prediction.transactions do
|
239
|
+
puts transactions_elem.value
|
240
|
+
end
|
241
|
+
```
|
242
|
+
|
243
|
+
# Questions?
|
244
|
+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.enqueue_and_parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::FR::BankStatement::BankStatementV2
|
13
|
+
)
|
14
|
+
|
15
|
+
# Print a full summary of the parsed data in RST format
|
16
|
+
puts result.document
|
17
|
+
|
18
|
+
# Print the document-level parsed data
|
19
|
+
# puts result.document.inference.prediction
|
data/docs/driver_license_v1.md
CHANGED
@@ -6,7 +6,7 @@ parentDoc: 6294d97ee723f1008d2ab28e
|
|
6
6
|
---
|
7
7
|
The Ruby OCR SDK supports the [Driver License API](https://platform.mindee.com/mindee/driver_license).
|
8
8
|
|
9
|
-
|
9
|
+
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/driver_license/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
|
10
10
|

|
11
11
|
|
12
12
|
# Quick-Start
|
@@ -32,6 +32,37 @@ puts result.document
|
|
32
32
|
# puts result.document.inference.prediction
|
33
33
|
|
34
34
|
```
|
35
|
+
|
36
|
+
**Output (RST):**
|
37
|
+
```rst
|
38
|
+
########
|
39
|
+
Document
|
40
|
+
########
|
41
|
+
:Mindee ID: fbdeae38-ada3-43ac-aa58-e01a3d47e474
|
42
|
+
:Filename: default_sample.jpg
|
43
|
+
|
44
|
+
Inference
|
45
|
+
#########
|
46
|
+
:Product: mindee/driver_license v1.0
|
47
|
+
:Rotation applied: Yes
|
48
|
+
|
49
|
+
Prediction
|
50
|
+
==========
|
51
|
+
:Country Code: USA
|
52
|
+
:State: AZ
|
53
|
+
:ID: D12345678
|
54
|
+
:Category: D
|
55
|
+
:Last Name: Sample
|
56
|
+
:First Name: Jelani
|
57
|
+
:Date of Birth: 1957-02-01
|
58
|
+
:Place of Birth:
|
59
|
+
:Expiry Date: 2018-02-01
|
60
|
+
:Issued Date: 2013-01-10
|
61
|
+
:Issuing Authority:
|
62
|
+
:MRZ:
|
63
|
+
:DD Number: DD1234567890123456
|
64
|
+
```
|
65
|
+
|
35
66
|
# Field Types
|
36
67
|
## Standard Fields
|
37
68
|
These fields are generic and used in several products.
|
@@ -63,7 +63,7 @@ puts result.document
|
|
63
63
|
########
|
64
64
|
Document
|
65
65
|
########
|
66
|
-
:Mindee ID:
|
66
|
+
:Mindee ID: f469a24d-3875-4a83-ad43-e0d5aa9da604
|
67
67
|
:Filename: default_sample.jpg
|
68
68
|
|
69
69
|
Inference
|
@@ -80,8 +80,8 @@ Prediction
|
|
80
80
|
:Document Number: INT-001
|
81
81
|
:Reference Numbers: 2412/2019
|
82
82
|
:Purchase Date: 2019-11-02
|
83
|
-
:Due Date: 2019-
|
84
|
-
:Payment Date: 2019-
|
83
|
+
:Due Date: 2019-11-17
|
84
|
+
:Payment Date: 2019-11-17
|
85
85
|
:Total Net: 195.00
|
86
86
|
:Total Amount: 204.75
|
87
87
|
:Taxes:
|
@@ -132,8 +132,8 @@ Page 0
|
|
132
132
|
:Document Number: INT-001
|
133
133
|
:Reference Numbers: 2412/2019
|
134
134
|
:Purchase Date: 2019-11-02
|
135
|
-
:Due Date: 2019-
|
136
|
-
:Payment Date: 2019-
|
135
|
+
:Due Date: 2019-11-17
|
136
|
+
:Payment Date: 2019-11-17
|
137
137
|
:Total Net: 195.00
|
138
138
|
:Total Amount: 204.75
|
139
139
|
:Taxes:
|
data/docs/invoices_v4.md
CHANGED
@@ -63,7 +63,7 @@ puts result.document
|
|
63
63
|
########
|
64
64
|
Document
|
65
65
|
########
|
66
|
-
:Mindee ID:
|
66
|
+
:Mindee ID: 86b1833f-138b-4a01-8387-860204b0e631
|
67
67
|
:Filename: default_sample.jpg
|
68
68
|
|
69
69
|
Inference
|
@@ -78,8 +78,8 @@ Prediction
|
|
78
78
|
:Purchase Order Number: AD29094
|
79
79
|
:Reference Numbers: AD29094
|
80
80
|
:Purchase Date: 2018-09-25
|
81
|
-
:Due Date:
|
82
|
-
:Payment Date:
|
81
|
+
:Due Date:
|
82
|
+
:Payment Date:
|
83
83
|
:Total Net: 2145.00
|
84
84
|
:Total Amount: 2608.20
|
85
85
|
:Total Tax: 193.20
|
@@ -124,8 +124,8 @@ Page 0
|
|
124
124
|
:Purchase Order Number: AD29094
|
125
125
|
:Reference Numbers: AD29094
|
126
126
|
:Purchase Date: 2018-09-25
|
127
|
-
:Due Date:
|
128
|
-
:Payment Date:
|
127
|
+
:Due Date:
|
128
|
+
:Payment Date:
|
129
129
|
:Total Net: 2145.00
|
130
130
|
:Total Amount: 2608.20
|
131
131
|
:Total Tax: 193.20
|
@@ -61,8 +61,7 @@ module Mindee
|
|
61
61
|
private
|
62
62
|
|
63
63
|
def inject_full_text_ocr(raw_prediction)
|
64
|
-
return unless raw_prediction.dig('inference', 'pages')
|
65
|
-
raw_prediction['inference']['pages'][0]['extras']['full_text_ocr']
|
64
|
+
return unless raw_prediction.dig('inference', 'pages', 0, 'extras', 'full_text_ocr')
|
66
65
|
|
67
66
|
full_text_ocr = String.new
|
68
67
|
raw_prediction.dig('inference', 'pages').each do |page|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../parsing'
|
4
|
+
require_relative 'bank_statement_v2_document'
|
5
|
+
require_relative 'bank_statement_v2_page'
|
6
|
+
|
7
|
+
module Mindee
|
8
|
+
module Product
|
9
|
+
module FR
|
10
|
+
# Bank Statement module.
|
11
|
+
module BankStatement
|
12
|
+
# Bank Statement API version 2 inference prediction.
|
13
|
+
class BankStatementV2 < Mindee::Parsing::Common::Inference
|
14
|
+
@endpoint_name = 'bank_statement_fr'
|
15
|
+
@endpoint_version = '2'
|
16
|
+
|
17
|
+
# @param prediction [Hash]
|
18
|
+
def initialize(prediction)
|
19
|
+
super
|
20
|
+
@prediction = BankStatementV2Document.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(BankStatementV2Page.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
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../parsing'
|
4
|
+
require_relative 'bank_statement_v2_transaction'
|
5
|
+
|
6
|
+
module Mindee
|
7
|
+
module Product
|
8
|
+
module FR
|
9
|
+
module BankStatement
|
10
|
+
# Bank Statement API version 2.0 document data.
|
11
|
+
class BankStatementV2Document < Mindee::Parsing::Common::Prediction
|
12
|
+
include Mindee::Parsing::Standard
|
13
|
+
# The unique identifier for a customer's account in the bank's system.
|
14
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
15
|
+
attr_reader :account_number
|
16
|
+
# The physical location of the bank where the statement was issued.
|
17
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
18
|
+
attr_reader :bank_address
|
19
|
+
# The name of the bank that issued the statement.
|
20
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
21
|
+
attr_reader :bank_name
|
22
|
+
# The address of the client associated with the bank statement.
|
23
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
24
|
+
attr_reader :client_address
|
25
|
+
# The name of the clients who own the bank statement.
|
26
|
+
# @return [Array<Mindee::Parsing::Standard::StringField>]
|
27
|
+
attr_reader :client_names
|
28
|
+
# The final amount of money in the account at the end of the statement period.
|
29
|
+
# @return [Mindee::Parsing::Standard::AmountField]
|
30
|
+
attr_reader :closing_balance
|
31
|
+
# The initial amount of money in an account at the start of the period.
|
32
|
+
# @return [Mindee::Parsing::Standard::AmountField]
|
33
|
+
attr_reader :opening_balance
|
34
|
+
# The date on which the bank statement was generated.
|
35
|
+
# @return [Mindee::Parsing::Standard::DateField]
|
36
|
+
attr_reader :statement_date
|
37
|
+
# The date when the statement period ends.
|
38
|
+
# @return [Mindee::Parsing::Standard::DateField]
|
39
|
+
attr_reader :statement_end_date
|
40
|
+
# The date when the bank statement period begins.
|
41
|
+
# @return [Mindee::Parsing::Standard::DateField]
|
42
|
+
attr_reader :statement_start_date
|
43
|
+
# The total amount of money deposited into the account.
|
44
|
+
# @return [Mindee::Parsing::Standard::AmountField]
|
45
|
+
attr_reader :total_credits
|
46
|
+
# The total amount of money debited from the account.
|
47
|
+
# @return [Mindee::Parsing::Standard::AmountField]
|
48
|
+
attr_reader :total_debits
|
49
|
+
# The list of values that represent the financial transactions recorded in a bank statement.
|
50
|
+
# @return [Array<Mindee::Product::FR::BankStatement::BankStatementV2Transaction>]
|
51
|
+
attr_reader :transactions
|
52
|
+
|
53
|
+
# @param prediction [Hash]
|
54
|
+
# @param page_id [Integer, nil]
|
55
|
+
def initialize(prediction, page_id)
|
56
|
+
super()
|
57
|
+
@account_number = StringField.new(prediction['account_number'], page_id)
|
58
|
+
@bank_address = StringField.new(prediction['bank_address'], page_id)
|
59
|
+
@bank_name = StringField.new(prediction['bank_name'], page_id)
|
60
|
+
@client_address = StringField.new(prediction['client_address'], page_id)
|
61
|
+
@client_names = []
|
62
|
+
prediction['client_names'].each do |item|
|
63
|
+
@client_names.push(StringField.new(item, page_id))
|
64
|
+
end
|
65
|
+
@closing_balance = AmountField.new(prediction['closing_balance'], page_id)
|
66
|
+
@opening_balance = AmountField.new(prediction['opening_balance'], page_id)
|
67
|
+
@statement_date = DateField.new(prediction['statement_date'], page_id)
|
68
|
+
@statement_end_date = DateField.new(prediction['statement_end_date'], page_id)
|
69
|
+
@statement_start_date = DateField.new(prediction['statement_start_date'], page_id)
|
70
|
+
@total_credits = AmountField.new(prediction['total_credits'], page_id)
|
71
|
+
@total_debits = AmountField.new(prediction['total_debits'], page_id)
|
72
|
+
@transactions = []
|
73
|
+
prediction['transactions'].each do |item|
|
74
|
+
@transactions.push(BankStatementV2Transaction.new(item, page_id))
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [String]
|
79
|
+
def to_s
|
80
|
+
client_names = @client_names.join("\n #{' ' * 14}")
|
81
|
+
transactions = transactions_to_s
|
82
|
+
out_str = String.new
|
83
|
+
out_str << "\n:Account Number: #{@account_number}".rstrip
|
84
|
+
out_str << "\n:Bank Name: #{@bank_name}".rstrip
|
85
|
+
out_str << "\n:Bank Address: #{@bank_address}".rstrip
|
86
|
+
out_str << "\n:Client Names: #{client_names}".rstrip
|
87
|
+
out_str << "\n:Client Address: #{@client_address}".rstrip
|
88
|
+
out_str << "\n:Statement Date: #{@statement_date}".rstrip
|
89
|
+
out_str << "\n:Statement Start Date: #{@statement_start_date}".rstrip
|
90
|
+
out_str << "\n:Statement End Date: #{@statement_end_date}".rstrip
|
91
|
+
out_str << "\n:Opening Balance: #{@opening_balance}".rstrip
|
92
|
+
out_str << "\n:Closing Balance: #{@closing_balance}".rstrip
|
93
|
+
out_str << "\n:Transactions:"
|
94
|
+
out_str << transactions
|
95
|
+
out_str << "\n:Total Debits: #{@total_debits}".rstrip
|
96
|
+
out_str << "\n:Total Credits: #{@total_credits}".rstrip
|
97
|
+
out_str[1..].to_s
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
# @param char [String]
|
103
|
+
# @return [String]
|
104
|
+
def transactions_separator(char)
|
105
|
+
out_str = String.new
|
106
|
+
out_str << ' '
|
107
|
+
out_str << "+#{char * 12}"
|
108
|
+
out_str << "+#{char * 12}"
|
109
|
+
out_str << "+#{char * 38}"
|
110
|
+
out_str << '+'
|
111
|
+
out_str
|
112
|
+
end
|
113
|
+
|
114
|
+
# @return [String]
|
115
|
+
def transactions_to_s
|
116
|
+
return '' if @transactions.empty?
|
117
|
+
|
118
|
+
line_items = @transactions.map(&:to_table_line).join("\n#{transactions_separator('-')}\n ")
|
119
|
+
out_str = String.new
|
120
|
+
out_str << "\n#{transactions_separator('-')}"
|
121
|
+
out_str << "\n |"
|
122
|
+
out_str << ' Amount |'
|
123
|
+
out_str << ' Date |'
|
124
|
+
out_str << ' Description |'
|
125
|
+
out_str << "\n#{transactions_separator('=')}"
|
126
|
+
out_str << "\n #{line_items}"
|
127
|
+
out_str << "\n#{transactions_separator('-')}"
|
128
|
+
out_str
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../parsing'
|
4
|
+
require_relative 'bank_statement_v2_document'
|
5
|
+
|
6
|
+
module Mindee
|
7
|
+
module Product
|
8
|
+
module FR
|
9
|
+
module BankStatement
|
10
|
+
# Bank Statement API version 2.0 page data.
|
11
|
+
class BankStatementV2Page < Mindee::Parsing::Common::Page
|
12
|
+
# @param prediction [Hash]
|
13
|
+
def initialize(prediction)
|
14
|
+
super(prediction)
|
15
|
+
@prediction = BankStatementV2PagePrediction.new(
|
16
|
+
prediction['prediction'],
|
17
|
+
prediction['id']
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Bank Statement V2 page prediction.
|
23
|
+
class BankStatementV2PagePrediction < BankStatementV2Document
|
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,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module FR
|
8
|
+
module BankStatement
|
9
|
+
# The list of values that represent the financial transactions recorded in a bank statement.
|
10
|
+
class BankStatementV2Transaction < Mindee::Parsing::Standard::FeatureField
|
11
|
+
include Mindee::Parsing::Standard
|
12
|
+
# The monetary amount of the transaction.
|
13
|
+
# @return [Float]
|
14
|
+
attr_reader :amount
|
15
|
+
# The date on which the transaction occurred.
|
16
|
+
# @return [String]
|
17
|
+
attr_reader :date
|
18
|
+
# The additional information about the transaction.
|
19
|
+
# @return [String]
|
20
|
+
attr_reader :description
|
21
|
+
|
22
|
+
# @param prediction [Hash]
|
23
|
+
# @param page_id [Integer, nil]
|
24
|
+
def initialize(prediction, page_id)
|
25
|
+
super(prediction, page_id)
|
26
|
+
@amount = prediction['amount']
|
27
|
+
@date = prediction['date']
|
28
|
+
@description = prediction['description']
|
29
|
+
@page_id = page_id
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Hash]
|
33
|
+
def printable_values
|
34
|
+
printable = {}
|
35
|
+
printable[:amount] = @amount.nil? ? '' : Field.float_to_string(@amount)
|
36
|
+
printable[:date] = format_for_display(@date)
|
37
|
+
printable[:description] = format_for_display(@description)
|
38
|
+
printable
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [Hash]
|
42
|
+
def table_printable_values
|
43
|
+
printable = {}
|
44
|
+
printable[:amount] = @amount.nil? ? '' : Field.float_to_string(@amount)
|
45
|
+
printable[:date] = format_for_display(@date, 10)
|
46
|
+
printable[:description] = format_for_display(@description, 36)
|
47
|
+
printable
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [String]
|
51
|
+
def to_table_line
|
52
|
+
printable = table_printable_values
|
53
|
+
out_str = String.new
|
54
|
+
out_str << format('| %- 11s', printable[:amount])
|
55
|
+
out_str << format('| %- 11s', printable[:date])
|
56
|
+
out_str << format('| %- 37s', printable[:description])
|
57
|
+
out_str << '|'
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [String]
|
61
|
+
def to_s
|
62
|
+
printable = printable_values
|
63
|
+
out_str = String.new
|
64
|
+
out_str << "\n :Amount: #{printable[:amount]}"
|
65
|
+
out_str << "\n :Date: #{printable[:date]}"
|
66
|
+
out_str << "\n :Description: #{printable[:description]}"
|
67
|
+
out_str
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/mindee/product.rb
CHANGED
@@ -12,6 +12,7 @@ require_relative 'product/eu/driver_license/driver_license_v1'
|
|
12
12
|
require_relative 'product/fr/bank_account_details/bank_account_details_v1'
|
13
13
|
require_relative 'product/fr/bank_account_details/bank_account_details_v2'
|
14
14
|
require_relative 'product/fr/bank_statement/bank_statement_v1'
|
15
|
+
require_relative 'product/fr/bank_statement/bank_statement_v2'
|
15
16
|
require_relative 'product/fr/carte_grise/carte_grise_v1'
|
16
17
|
require_relative 'product/fr/id_card/id_card_v1'
|
17
18
|
require_relative 'product/fr/id_card/id_card_v2'
|
data/lib/mindee/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mindee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mindee, SA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: marcel
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- docs/bank_account_details_v2.md
|
155
155
|
- docs/bank_check_v1.md
|
156
156
|
- docs/bank_statement_fr_v1.md
|
157
|
+
- docs/bank_statement_fr_v2.md
|
157
158
|
- docs/barcode_reader_v1.md
|
158
159
|
- docs/bill_of_lading_v1.md
|
159
160
|
- docs/business_card_v1.md
|
@@ -162,6 +163,7 @@ files:
|
|
162
163
|
- docs/code_samples/bank_account_details_v2.txt
|
163
164
|
- docs/code_samples/bank_check_v1.txt
|
164
165
|
- docs/code_samples/bank_statement_fr_v1_async.txt
|
166
|
+
- docs/code_samples/bank_statement_fr_v2_async.txt
|
165
167
|
- docs/code_samples/barcode_reader_v1.txt
|
166
168
|
- docs/code_samples/bill_of_lading_v1_async.txt
|
167
169
|
- docs/code_samples/business_card_v1_async.txt
|
@@ -356,6 +358,10 @@ files:
|
|
356
358
|
- lib/mindee/product/fr/bank_statement/bank_statement_v1_document.rb
|
357
359
|
- lib/mindee/product/fr/bank_statement/bank_statement_v1_page.rb
|
358
360
|
- lib/mindee/product/fr/bank_statement/bank_statement_v1_transaction.rb
|
361
|
+
- lib/mindee/product/fr/bank_statement/bank_statement_v2.rb
|
362
|
+
- lib/mindee/product/fr/bank_statement/bank_statement_v2_document.rb
|
363
|
+
- lib/mindee/product/fr/bank_statement/bank_statement_v2_page.rb
|
364
|
+
- lib/mindee/product/fr/bank_statement/bank_statement_v2_transaction.rb
|
359
365
|
- lib/mindee/product/fr/carte_grise/carte_grise_v1.rb
|
360
366
|
- lib/mindee/product/fr/carte_grise/carte_grise_v1_document.rb
|
361
367
|
- lib/mindee/product/fr/carte_grise/carte_grise_v1_page.rb
|