norma43_parser 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +85 -0
  5. data/Rakefile +1 -0
  6. data/doc/classes.jpg +0 -0
  7. data/doc/cuaderno_43_-_junio_2012.pdf +800 -1
  8. data/lib/norma43/line_handlers.rb +54 -0
  9. data/lib/norma43/line_parsers/file_format_validator.rb +19 -0
  10. data/lib/norma43/line_parsers/line_parser.rb +42 -0
  11. data/lib/norma43/line_parsers/line_parsers.rb +69 -0
  12. data/lib/norma43/line_processors.rb +60 -0
  13. data/lib/norma43/models.rb +85 -0
  14. data/lib/norma43/parser.rb +79 -0
  15. data/lib/norma43/utils/contexts.rb +54 -0
  16. data/lib/norma43/utils/string_helpers.rb +10 -0
  17. data/lib/norma43/utils/typecaster.rb +19 -0
  18. data/lib/norma43/version.rb +3 -0
  19. data/lib/norma43.rb +8 -0
  20. data/norma43_parser.gemspec +27 -0
  21. data/spec/example1_parse_spec.rb +91 -0
  22. data/spec/fixtures/example1.n43 +10 -0
  23. data/spec/norma43/line_parsers/account_end_spec.rb +51 -0
  24. data/spec/norma43/line_parsers/account_start_spec.rb +55 -0
  25. data/spec/norma43/line_parsers/additional_currency_spec.rb +27 -0
  26. data/spec/norma43/line_parsers/additional_items_spec.rb +23 -0
  27. data/spec/norma43/line_parsers/document_end_spec.rb +16 -0
  28. data/spec/norma43/line_parsers/document_start_spec.rb +32 -0
  29. data/spec/norma43/line_parsers/transaction_spec.rb +55 -0
  30. data/spec/norma43/line_processors/account_end_spec.rb +34 -0
  31. data/spec/norma43/line_processors/account_start_spec.rb +40 -0
  32. data/spec/norma43/line_processors/additional_currency_spec.rb +42 -0
  33. data/spec/norma43/line_processors/additional_items_spec.rb +42 -0
  34. data/spec/norma43/line_processors/document_end_spec.rb +30 -0
  35. data/spec/norma43/line_processors/document_start_spec.rb +27 -0
  36. data/spec/norma43/line_processors/transaction_spec.rb +42 -0
  37. data/spec/norma43/parser_spec.rb +23 -0
  38. data/spec/norma43_spec.rb +13 -0
  39. data/spec/spec_helper.rb +20 -0
  40. data/spec/support/shared_examples_for_values_line_parsers.rb +15 -0
  41. metadata +173 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4efe95db38bc547fc36d8f649c83f65a90a078b2
4
+ data.tar.gz: 04d5b299d47f187c907aa2b15725a9adf96fe20b
5
+ SHA512:
6
+ metadata.gz: 972ca63a8512c51a2dd6100cf5570d942bf39ed5bb4d97856231ece753a8dcf1de916505ac3019aa163c1fe581ea59a69256d9a3f9ea927354c13dc4338f0147
7
+ data.tar.gz: 4893dd41e41ccd78f47f63fa10007b989576be1826fad09f9eb017a3604667ebb3dc33ea5a7a2f0b047638eab360e7c42535029bfaa3c0e085bf110f93f20a31
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "codeclimate-test-reporter", group: :test, require: nil
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Joel Junström
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # Norma43 file parser
2
+
3
+ Norma43 is the standard format file to extract bank transactions from the SEPA (Single euro payments area), format details and content is described in the [Norma43 format](https://github.com/sequra/norma43_parser/blob/master/doc/cuaderno_43_-_junio_2012.pdf).
4
+
5
+ ## Usage
6
+
7
+ Include it in your Gemfile
8
+ ```
9
+ gem 'norma43_parser', git: "git@github.com:sequra/norma43_parser.git"
10
+ ```
11
+
12
+
13
+ ```ruby
14
+ require "norma43"
15
+
16
+ norma43_file_contents = File.open("path_to_file.n43", encoding: "iso-8859-1")
17
+ document = norma43.parse norma43_file_contents
18
+ ```
19
+
20
+ ### Document
21
+
22
+ The parser returns a Norma43 Document that may include multiple accounts.
23
+
24
+ ```
25
+ accounts=[account1..accountN]
26
+ ```
27
+
28
+ ### Account
29
+
30
+ The account object has all the information described in the standard format and the transactions between **start_date** and **end_date**.
31
+
32
+ ```
33
+ abbreviated_name="ACCOUNT NAME",
34
+ account_number=1234567,
35
+ balance_amount=504585,
36
+ balance_code=2,
37
+ bank_code=81,
38
+ branch_code=54,
39
+ credit_amount=254785,
40
+ credit_entries=45,
41
+ currency_code=978,
42
+ debit_amount=0,
43
+ debit_entries=0,
44
+ start_date=Tue, 04 Feb 2016,
45
+ end_date=Tue, 04 Feb 2016,
46
+ information_mode_code=3,
47
+ transactions=[transaction1..transactionN]
48
+ ```
49
+
50
+ ### Transaction
51
+
52
+ The transaction object has all the information described in the standard format and may include a maximum of five additional items.
53
+
54
+ ```
55
+ additional_currency=nil,
56
+ amount=3206,
57
+ amount_code=2,
58
+ document_number=0,
59
+ origin_branch_code=123,
60
+ own_item=16,
61
+ reference_1=0,
62
+ reference_2=nil,
63
+ shared_item=4,
64
+ transaction_date=Tue, 04 Feb 2016,
65
+ value_date=Tue, 04 Feb 2016,
66
+ additional_items=[additional_item1..aditional_item5]
67
+ ```
68
+
69
+ ### Additional items
70
+
71
+ The additional item object has an identifier and two free text fields that may include or not relevant information
72
+
73
+ ```
74
+ data_code=1,
75
+ item_1="TRANSFERENC. ANTONIO JOSE GARCIA MARTI",
76
+ item_2="NEZ"
77
+ ```
78
+
79
+ ## Contributing
80
+
81
+ 1. Fork it ( https://github.com/sequra/norma43_parser.git )
82
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
83
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
84
+ 4. Push to the branch (`git push origin my-new-feature`)
85
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/doc/classes.jpg ADDED
Binary file