Skip to content

Commit 695bf42

Browse files
✨ add support for fr_bank_statement_v2 (#163)
1 parent 70f4372 commit 695bf42

File tree

12 files changed

+621
-12
lines changed

12 files changed

+621
-12
lines changed

docs/bank_statement_fr_v2.md

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
![Bank Statement sample](https://github.com/mindee/client-lib-test-data/blob/main/products/bank_statement_fr/default_sample.jpg?raw=true)
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)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

docs/driver_license_v1.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ parentDoc: 6294d97ee723f1008d2ab28e
66
---
77
The Ruby OCR SDK supports the [Driver License API](https://platform.mindee.com/mindee/driver_license).
88

9-
The [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/driver_license/default_sample.jpg) can be used for testing purposes.
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.
1010
![Driver License sample](https://github.com/mindee/client-lib-test-data/blob/main/products/driver_license/default_sample.jpg?raw=true)
1111

1212
# Quick-Start
@@ -32,6 +32,37 @@ puts result.document
3232
# puts result.document.inference.prediction
3333

3434
```
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+
3566
# Field Types
3667
## Standard Fields
3768
These fields are generic and used in several products.

docs/financial_document_v1.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ puts result.document
6363
########
6464
Document
6565
########
66-
:Mindee ID: b26161ce-35d0-4984-b1ff-886645e160e6
66+
:Mindee ID: f469a24d-3875-4a83-ad43-e0d5aa9da604
6767
:Filename: default_sample.jpg
6868
6969
Inference
@@ -80,8 +80,8 @@ Prediction
8080
:Document Number: INT-001
8181
:Reference Numbers: 2412/2019
8282
:Purchase Date: 2019-11-02
83-
:Due Date: 2019-02-26
84-
:Payment Date: 2019-02-26
83+
:Due Date: 2019-11-17
84+
:Payment Date: 2019-11-17
8585
:Total Net: 195.00
8686
:Total Amount: 204.75
8787
:Taxes:
@@ -132,8 +132,8 @@ Page 0
132132
:Document Number: INT-001
133133
:Reference Numbers: 2412/2019
134134
:Purchase Date: 2019-11-02
135-
:Due Date: 2019-02-26
136-
:Payment Date: 2019-02-26
135+
:Due Date: 2019-11-17
136+
:Payment Date: 2019-11-17
137137
:Total Net: 195.00
138138
:Total Amount: 204.75
139139
:Taxes:

docs/invoices_v4.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ puts result.document
6363
########
6464
Document
6565
########
66-
:Mindee ID: a67b70ea-4b1e-4eac-ae75-dda47a7064ae
66+
:Mindee ID: 86b1833f-138b-4a01-8387-860204b0e631
6767
:Filename: default_sample.jpg
6868
6969
Inference
@@ -78,8 +78,8 @@ Prediction
7878
:Purchase Order Number: AD29094
7979
:Reference Numbers: AD29094
8080
:Purchase Date: 2018-09-25
81-
:Due Date: 2011-12-01
82-
:Payment Date: 2011-12-01
81+
:Due Date:
82+
:Payment Date:
8383
:Total Net: 2145.00
8484
:Total Amount: 2608.20
8585
:Total Tax: 193.20
@@ -124,8 +124,8 @@ Page 0
124124
:Purchase Order Number: AD29094
125125
:Reference Numbers: AD29094
126126
:Purchase Date: 2018-09-25
127-
:Due Date: 2011-12-01
128-
:Payment Date: 2011-12-01
127+
:Due Date:
128+
:Payment Date:
129129
:Total Net: 2145.00
130130
:Total Amount: 2608.20
131131
:Total Tax: 193.20

lib/mindee/product.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
require_relative 'product/fr/bank_account_details/bank_account_details_v1'
1313
require_relative 'product/fr/bank_account_details/bank_account_details_v2'
1414
require_relative 'product/fr/bank_statement/bank_statement_v1'
15+
require_relative 'product/fr/bank_statement/bank_statement_v2'
1516
require_relative 'product/fr/carte_grise/carte_grise_v1'
1617
require_relative 'product/fr/id_card/id_card_v1'
1718
require_relative 'product/fr/id_card/id_card_v2'

0 commit comments

Comments
 (0)