You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45-26Lines changed: 45 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,24 +2,24 @@
2
2
3
3
# Cmxl - your friendly ruby MT940 parser
4
4
5
-
At [Railslove](http://railslove.com) we build a lot of financial applications and work on integrating applications with banks and banking functionality.
5
+
At [Railslove](http://railslove.com) we build a lot of financial applications and work on integrating applications with banks and banking functionality.
6
6
Our goal is to make simple solutions for what often looks complicated.
7
7
8
-
Cmxl is a friendly and extendible MT940 bank statement file parser that helps your extracting data from the bank statement files.
8
+
Cmxl is a friendly and extendible MT940 bank statement file parser that helps your extracting data from the bank statement files.
9
9
10
-
## What is MT940?
10
+
## What is MT940 & MT942?
11
11
12
-
MT940 (MT = Message Type) is the SWIFT-Standard for the electronic transfer of bank statement files.
13
-
When integrating with banks you often get MT940 files as interface.
12
+
MT940 (MT = Message Type) is the SWIFT-Standard for the electronic transfer of bank statement files.
13
+
When integrating with banks you often get MT940 or MT942 files as interface.
14
14
For more information have a look at the different [SWIFT message types](http://en.wikipedia.org/wiki/SWIFT_message_types)
15
15
16
16
At some point in the future MT940 file should be exchanged with newer XML documents - but banking institutions are slow so MT940 will stick around for a while.
17
17
18
18
## Reqirements
19
19
20
-
Cmxl is a pure ruby parser and has no dependency on native extensions.
20
+
Cmxl is a pure ruby parser and has no dependency on native extensions.
statements =Cmxl.parse(File.read('mt940.txt'), :encoding => 'ISO-8859-1') # parses the file and returns an array of statement objects. Please note: if no encoding is given Cmxl tries to guess the encoding from the content and converts it to UTF-8.
58
+
statements =Cmxl.parse(File.read('mt940.txt'), :encoding => 'ISO-8859-1') # parses the file and returns an array of statement objects. Please note: if no encoding is given Cmxl tries to guess the encoding from the content and converts it to UTF-8.
59
59
statements.each do |s|
60
60
puts s.reference
61
61
puts s.generation_date
62
62
puts s.opening_balance.amount
63
63
puts s.closing_balance.amount
64
64
puts s.sha # SHA of the statement source - could be used as an unique identifier
65
-
65
+
66
66
s.transactions.each do |t|
67
67
puts t.information
68
68
puts t.description
@@ -87,24 +87,46 @@ Every object responds to `to_h` and let's you easily convert the data to a hash.
87
87
88
88
#### A note about encoding and file wirednesses
89
89
90
-
You probably will encounter encoding issues (hey, you are building banking applications!).
91
-
We try to handle encoding and format wirednesses as much as possible. If no encoding is passed we try to guess the encoding of the data and convert it to UTF8.
92
-
In the likely case that you encouter encoding issues you can pass encoding options to the `Cmxl.parse(<string>, <options hash>)` it accepts the same options as [String#encode](http://ruby-doc.org/core-2.1.3/String.html#method-i-encode)
90
+
You probably will encounter encoding issues (hey, you are building banking applications!).
91
+
We try to handle encoding and format wirednesses as much as possible. If no encoding is passed we try to guess the encoding of the data and convert it to UTF8.
92
+
In the likely case that you encouter encoding issues you can pass encoding options to the `Cmxl.parse(<string>, <options hash>)` it accepts the same options as [String#encode](http://ruby-doc.org/core-2.1.3/String.html#method-i-encode)
93
93
If that fails try to motify the file before you pass it to the parser - and please create an issue.
94
94
95
95
### MT940 SWIFT header data
96
96
97
-
Cmxl currently does not support parsing of the SWIFT headers (like {1:F01AXISINBBA ....)
97
+
Cmxl currently does not support parsing of the SWIFT headers (like {1:F01AXISINBBA ....)
98
98
If your file comes with these headers try the `strip_headers` configuration option to strip data execpt the actual MT940 fields.
99
99
100
100
```ruby
101
101
Cmxl.config[:strip_headers] =true
102
102
Cmxl.parse(...)
103
103
```
104
104
105
+
### MT942 data
106
+
107
+
CMXL is now also capable of parsing MT942 data. Just pass the data and the parser will identify the type automatically.
Because a lot of banks implement the MT940 format slightly different one of the design goals of this library is to be able to customize the individual field parsers.
129
+
Because a lot of banks implement the MT940 format slightly different one of the design goals of this library is to be able to customize the individual field parsers.
108
130
Every line get parsed with a special parser. Here is how to write your own parser:
109
131
110
132
```ruby
@@ -128,23 +150,20 @@ my_field_parser.data #=> {'world' => 'hello from mt940'} - data is the accessor
128
150
129
151
## Parsing issues? - please create an issue with your file
130
152
131
-
The Mt940 format often looks different for the different banks and the different countries. Especially the not strict defined fields are often used for custom bank data.
153
+
The Mt940 format often looks different for the different banks and the different countries. Especially the not strict defined fields are often used for custom bank data.
132
154
If you have a file that can not be parsed please open an issue. We hope to build a parser that handles most of the files.
133
155
134
-
135
156
## ToDo
136
157
137
-
* collect MT940 files from different banks and use them as example for specs
138
-
* support for Mt942
139
-
* better header data handling
140
-
158
+
- collect MT940 files from different banks and use them as example for specs
159
+
- better header data handling
141
160
142
161
## Looking for other Banking and EBICS tools?
143
162
144
163
Maybe these are also interesting for you.
145
164
146
-
*[EPICS: Open Source SEPA EBICS client](https://railslove.github.io/epics/) full implementation to manage all the banking activities like direct debits, credits, etc. (SEPA Lastschrift, Überweisungen, etc.)
147
-
*[EBICS::Box: out of the box solution to automate banking activities](http://www.railslove.com/ebics-box) - The missing API for your bank
165
+
-[EPICS: Open Source SEPA EBICS client](https://railslove.github.io/epics/) full implementation to manage all the banking activities like direct debits, credits, etc. (SEPA Lastschrift, Überweisungen, etc.)
166
+
-[EBICS::Box: out of the box solution to automate banking activities](http://www.railslove.com/ebics-box) - The missing API for your bank
148
167
149
168
## Contributing
150
169
@@ -161,9 +180,9 @@ Automated tests: We use rspec to test Cmxl. Simply run `rake` to execute the who
161
180
Cmxl is inspired and borrows ideas from the `mt940_parser` by the great people at [betterplace](https://www.betterplace.org/).
2014 - built with love by [Railslove](http://railslove.com) and released under the MIT-Licence. We have built quite a number of FinTech products. If you need support we are happy to help. Please contact us at [email protected].
0 commit comments