norma43_parser 2.1.1 → 3.1.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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +22 -0
  3. data/.github/workflows/release.yml +33 -0
  4. data/.rspec +1 -0
  5. data/CHANGELOG.md +26 -10
  6. data/Gemfile +2 -2
  7. data/Gemfile.lock +51 -51
  8. data/README.md +2 -0
  9. data/lib/norma43/models/account/spanish_iban.rb +107 -0
  10. data/lib/norma43/models/account.rb +63 -0
  11. data/lib/norma43/models/additional_currency.rb +22 -0
  12. data/lib/norma43/models/additional_item.rb +20 -0
  13. data/lib/norma43/models/document.rb +42 -0
  14. data/lib/norma43/models/mixins/attributes_assignment.rb +33 -0
  15. data/lib/norma43/models/transaction.rb +51 -0
  16. data/lib/norma43/models.rb +0 -78
  17. data/lib/norma43/version.rb +1 -1
  18. data/norma43_parser.gemspec +3 -6
  19. data/spec/example1_parse_spec.rb +1 -1
  20. data/spec/norma43/line_processors/account_end_spec.rb +1 -4
  21. data/spec/norma43/line_processors/account_start_spec.rb +3 -3
  22. data/spec/norma43/line_processors/additional_currency_spec.rb +3 -3
  23. data/spec/norma43/line_processors/{additional_items_spec.rb → additional_item_spec.rb} +3 -3
  24. data/spec/norma43/line_processors/document_end_spec.rb +3 -6
  25. data/spec/norma43/line_processors/document_start_spec.rb +3 -3
  26. data/spec/norma43/line_processors/transaction_spec.rb +3 -3
  27. data/spec/norma43/models/account/spanish_iban_spec.rb +107 -0
  28. data/spec/norma43/models/account_spec.rb +54 -0
  29. data/spec/norma43/models/document_spec.rb +35 -0
  30. data/spec/norma43/models/transaction_spec.rb +25 -0
  31. data/spec/norma43_spec.rb +1 -1
  32. data/spec/spec_helper.rb +3 -0
  33. data/spec/support/shared_examples_for_models.rb +61 -0
  34. metadata +29 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f57b1728de66fc99d9d73d5d98edb6a5a9524441dedae9bd1a2501d4c9279a1
4
- data.tar.gz: aaf6c47260dd9b1f3adb2e1d557d946e5c9fa6d64f25de616c0346a6c113541d
3
+ metadata.gz: 652bfca27d2c071900dd50639cf8ae2762f9bf558d26c58173c3fb391317ca7c
4
+ data.tar.gz: 74f1b4bf47f3f95470a77a181a48fa642b42287637b9e1ad6dd8d24ee1527aa6
5
5
  SHA512:
6
- metadata.gz: a5ddd29c9b554700d7e9060376a8a4cc60ee6c2b75c84ffd55cc46b745f792e064c46daac4a54159a111ae5c809ba3051b185973b502f472b418409f71b02ca5
7
- data.tar.gz: 720c008c9cdc44429cabb0477ba28983852b99d0ef8ebc0274493f782925f697c5bff756cf8dcd6be1207f13a5285cd8c3b2e9213779eede4492518b7f529bd0
6
+ metadata.gz: 7aacbf47d289d4a58e958b8f12d1ec0486897a43ecac0c497f04020f126c7cdb70ea30be7a45e899e7448bbe457d9cfbd73eb85291fb10988cb1853cd06c1dfd
7
+ data.tar.gz: 6f94a39e9179d56efbfd0a72aaebc725cc5d90fac6576ff87ac753f8613448b9eb7e889b8400496991c2133ea629713f00223fa800ee9c5339248c1822af51b5
@@ -0,0 +1,22 @@
1
+ name: Ruby CI
2
+
3
+ on: [ pull_request, push ]
4
+
5
+ jobs:
6
+ test:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ strategy:
11
+ matrix:
12
+ ruby-version: ["3.3", "3.2", "3.1", "3.0", "jruby-head"]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby ${{ matrix.ruby-version }}
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
21
+ - name: Run tests
22
+ run: bundle exec rspec
@@ -0,0 +1,33 @@
1
+ name: Create gem release pull request
2
+ on:
3
+ push:
4
+ branches:
5
+ - 'master'
6
+ jobs:
7
+ release:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: GoogleCloudPlatform/release-please-action@v3
11
+ id: release
12
+ with:
13
+ release-type: ruby
14
+ package-name: norma43_parser
15
+ bump-minor-pre-major: true
16
+ version-file: 'lib/norma43/version.rb'
17
+ - uses: actions/checkout@v2
18
+ if: ${{ steps.release.outputs.release_created }}
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: 3.2
22
+ if: ${{ steps.release.outputs.release_created }}
23
+ - name: Publish gem to Rubygems
24
+ run: |
25
+ mkdir -p $HOME/.gem
26
+ touch $HOME/.gem/credentials
27
+ chmod 0600 $HOME/.gem/credentials
28
+ printf -- "---\n:rubygems: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29
+ gem build *.gemspec
30
+ gem push --KEY rubygems --host https://rubygems.org *.gem
31
+ env:
32
+ GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_PUBLISH_TOKEN }}"
33
+ if: ${{ steps.release.outputs.release_created }}
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/CHANGELOG.md CHANGED
@@ -1,29 +1,45 @@
1
- ## 2.1.1 (2020-03-13)
1
+ ## [4.0.0](https://github.com/sequra/norma43_parser/compare/3.0.0...v4.0.0) (2024-06-18)
2
2
 
3
- ### Breaking Changes
4
3
 
5
- -
4
+ ### ⚠ BREAKING CHANGES
5
+
6
+ * Drop Ruby support below 3
7
+
8
+ ### Features
9
+
10
+ * Get IBANs from account instances ([#15](https://github.com/sequra/norma43_parser/issues/15)) ([c69d162](https://github.com/sequra/norma43_parser/commit/c69d162361b188f2b2d904b1958e3108be9a3939))
11
+
12
+
13
+ ## [3.1.0](https://github.com/sequra/norma43_parser/compare/3.0.0...v3.1.0) (2024-06-19)
14
+
6
15
 
7
- ### Bug fixes
16
+ ### Features
8
17
 
9
- -
18
+ * get IBANs from account instances ([#15](https://github.com/sequra/norma43_parser/issues/15)) ([3a5dd36](https://github.com/sequra/norma43_parser/commit/3a5dd366a934525e421d3cbcaceabb88a285fb6d))
19
+
20
+ ## v3.0.0 (2021-12-15)
21
+
22
+ ### Breaking Changes
23
+
24
+ - Drop Ruby support below 2.6.
25
+
26
+ ## v2.1.1 (2020-03-13)
10
27
 
11
28
  ### Enhancements
12
29
 
13
30
  - Update rake requirement from ~> 10.0 to ~> 13.0 (#6)
14
31
 
15
- ## 2.0.0 (2019-10-17)
32
+ ## v2.0.0 (2019-10-17)
16
33
 
17
34
  ### Breaking Changes
18
35
 
19
36
  - Drop Ruby support below 2.4.
20
37
 
21
- ### Bug fixes
22
-
23
- -
24
38
 
25
39
  ### Enhancements
26
40
 
27
41
  - Clean up dependencies
28
42
 
29
- ## 1.0.1 (2016-02-16)
43
+ ## v1.0.1 (2016-02-16)
44
+
45
+ - Initial release
data/Gemfile CHANGED
@@ -3,8 +3,8 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  group :development, :test do
6
- gem "rubocop", ">= 0.75", require: false
7
- gem "rubocop-performance", require: false
6
+ gem "rubocop", "~> 1", require: false
7
+ gem "rubocop-performance", "~> 1", require: false
8
8
  end
9
9
 
10
10
  gemspec
data/Gemfile.lock CHANGED
@@ -1,73 +1,73 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- norma43_parser (2.1.1)
5
- virtus (~> 1.0)
4
+ norma43_parser (3.1.0)
6
5
  zeitwerk (~> 2.0)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- ast (2.4.0)
12
- axiom-types (0.1.1)
13
- descendants_tracker (~> 0.0.4)
14
- ice_nine (~> 0.11.0)
15
- thread_safe (~> 0.3, >= 0.3.1)
16
- coercible (1.0.0)
17
- descendants_tracker (~> 0.0.1)
18
- descendants_tracker (0.0.4)
19
- thread_safe (~> 0.3, >= 0.3.1)
20
- diff-lcs (1.3)
21
- equalizer (0.0.11)
22
- ice_nine (0.11.2)
23
- jaro_winkler (1.5.3)
24
- parallel (1.18.0)
25
- parser (2.6.5.0)
26
- ast (~> 2.4.0)
27
- rainbow (3.0.0)
28
- rake (13.0.1)
29
- rspec (3.9.0)
30
- rspec-core (~> 3.9.0)
31
- rspec-expectations (~> 3.9.0)
32
- rspec-mocks (~> 3.9.0)
33
- rspec-core (3.9.0)
34
- rspec-support (~> 3.9.0)
35
- rspec-expectations (3.9.0)
10
+ ast (2.4.2)
11
+ diff-lcs (1.5.1)
12
+ json (2.7.2)
13
+ json (2.7.2-java)
14
+ language_server-protocol (3.17.0.3)
15
+ parallel (1.25.1)
16
+ parser (3.3.3.0)
17
+ ast (~> 2.4.1)
18
+ racc
19
+ racc (1.8.0)
20
+ racc (1.8.0-java)
21
+ rainbow (3.1.1)
22
+ rake (13.2.1)
23
+ regexp_parser (2.9.2)
24
+ rexml (3.3.0)
25
+ strscan
26
+ rspec (3.13.0)
27
+ rspec-core (~> 3.13.0)
28
+ rspec-expectations (~> 3.13.0)
29
+ rspec-mocks (~> 3.13.0)
30
+ rspec-core (3.13.0)
31
+ rspec-support (~> 3.13.0)
32
+ rspec-expectations (3.13.0)
36
33
  diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.9.0)
38
- rspec-mocks (3.9.0)
34
+ rspec-support (~> 3.13.0)
35
+ rspec-mocks (3.13.1)
39
36
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.9.0)
41
- rspec-support (3.9.0)
42
- rubocop (0.75.0)
43
- jaro_winkler (~> 1.5.1)
37
+ rspec-support (~> 3.13.0)
38
+ rspec-support (3.13.1)
39
+ rubocop (1.64.1)
40
+ json (~> 2.3)
41
+ language_server-protocol (>= 3.17.0)
44
42
  parallel (~> 1.10)
45
- parser (>= 2.6)
43
+ parser (>= 3.3.0.2)
46
44
  rainbow (>= 2.2.2, < 4.0)
45
+ regexp_parser (>= 1.8, < 3.0)
46
+ rexml (>= 3.2.5, < 4.0)
47
+ rubocop-ast (>= 1.31.1, < 2.0)
47
48
  ruby-progressbar (~> 1.7)
48
- unicode-display_width (>= 1.4.0, < 1.7)
49
- rubocop-performance (1.5.0)
50
- rubocop (>= 0.71.0)
51
- ruby-progressbar (1.10.1)
52
- thread_safe (0.3.6)
53
- unicode-display_width (1.6.0)
54
- virtus (1.0.5)
55
- axiom-types (~> 0.1)
56
- coercible (~> 1.0)
57
- descendants_tracker (~> 0.0, >= 0.0.3)
58
- equalizer (~> 0.0, >= 0.0.9)
59
- zeitwerk (2.3.0)
49
+ unicode-display_width (>= 2.4.0, < 3.0)
50
+ rubocop-ast (1.31.3)
51
+ parser (>= 3.3.1.0)
52
+ rubocop-performance (1.21.0)
53
+ rubocop (>= 1.48.1, < 2.0)
54
+ rubocop-ast (>= 1.31.1, < 2.0)
55
+ ruby-progressbar (1.13.0)
56
+ strscan (3.1.0)
57
+ strscan (3.1.0-java)
58
+ unicode-display_width (2.5.0)
59
+ zeitwerk (2.6.15)
60
60
 
61
61
  PLATFORMS
62
+ java
62
63
  ruby
63
64
 
64
65
  DEPENDENCIES
65
- bundler (~> 1.0)
66
66
  norma43_parser!
67
67
  rake (~> 13.0)
68
- rspec (~> 3.0)
69
- rubocop (>= 0.75)
70
- rubocop-performance
68
+ rspec (~> 3.9)
69
+ rubocop (~> 1)
70
+ rubocop-performance (~> 1)
71
71
 
72
72
  BUNDLED WITH
73
- 1.17.3
73
+ 2.4.22
data/README.md CHANGED
@@ -49,6 +49,8 @@ information_mode_code=3,
49
49
  transactions=[transaction1..transactionN]
50
50
  ```
51
51
 
52
+ Also, accounts know their full IBAN. For the example above, `#iban` returns `"ES5400810054180001234567"`.
53
+
52
54
  ### Transaction
53
55
 
54
56
  The transaction object has all the information described in the standard format and may include a maximum of five additional items.
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Norma43
4
+ module Models
5
+ class Account
6
+ class SpanishIban
7
+ COUNTRY_CODE = "ES"
8
+ BANK_CODE_RANGE = BRANCH_CODE_RANGE = 0..9999
9
+ MAX_BANK_CODE_SIZE = MAX_BRANCH_CODE_SIZE = 4
10
+ ACCOUNT_NUMBER_RANGE = 0..9_999_999_999
11
+ IBAN_MODULUS = 97
12
+ IBAN_FORMAT_STRING = "%{country_code}%<checksum_number>02d%{ccc}"
13
+ CCC_MODULUS = 11
14
+ CCC_FORMAT_STRING = "%<bank_code>04d%<branch_code>04d%<checksum_number>02d%<account_number>010d"
15
+ CCC_WEIGHTS = [6, 3, 7, 9, 10, 5, 8, 4, 2, 1].freeze # Sorted by order of magnitude: units, tens, hundreds, etc.
16
+
17
+ def self.from_account(account)
18
+ return nil unless valid_numbers?(account.bank_code, account.branch_code, account.account_number)
19
+
20
+ new(
21
+ bank_code: account.bank_code,
22
+ branch_code: account.branch_code,
23
+ account_number: account.account_number
24
+ ).to_s
25
+ end
26
+
27
+ def initialize(bank_code:, branch_code:, account_number:)
28
+ @bank_code, @branch_code, @account_number =
29
+ if self.class.valid_numbers?(bank_code, branch_code, account_number)
30
+ [bank_code, branch_code, account_number]
31
+ else
32
+ [nil, nil, nil]
33
+ end
34
+ end
35
+
36
+ def to_s
37
+ return "" if [bank_code, branch_code, account_number].any?(nil)
38
+
39
+ iban
40
+ end
41
+
42
+ private
43
+ attr_reader :bank_code, :branch_code, :account_number
44
+
45
+ def self.valid_numbers?(bank_code, branch_code, account_number)
46
+ return false unless BANK_CODE_RANGE.include?(bank_code)
47
+ return false unless BRANCH_CODE_RANGE.include?(branch_code)
48
+ return false unless ACCOUNT_NUMBER_RANGE.include?(account_number)
49
+ true
50
+ end
51
+
52
+ def iban
53
+ format_string = IBAN_FORMAT_STRING
54
+ country_code = COUNTRY_CODE
55
+ country_number = calculate_country_number
56
+ ccc = calculate_ccc
57
+ number = "#{ccc}#{country_number}00".to_i
58
+ checksum_number = calculate_iban_checksum_number(number)
59
+
60
+ sprintf(format_string,
61
+ country_code: country_code,
62
+ checksum_number: checksum_number,
63
+ ccc: ccc)
64
+ end
65
+
66
+ def calculate_country_number
67
+ COUNTRY_CODE.chars.map { |char| char.to_i(36) }.join
68
+ end
69
+
70
+ def calculate_ccc
71
+ format_string = CCC_FORMAT_STRING
72
+ bank_with_branch_number = (bank_code * 10**MAX_BRANCH_CODE_SIZE) + branch_code
73
+
74
+ bank_with_branch_check_digit, account_number_check_digit = [
75
+ bank_with_branch_number, account_number
76
+ ].map { |number| calculate_spanish_checksum_digit(number) }
77
+
78
+ checksum_number = bank_with_branch_check_digit * 10 + account_number_check_digit
79
+
80
+ sprintf(format_string,
81
+ bank_code: bank_code,
82
+ branch_code: branch_code,
83
+ checksum_number: checksum_number,
84
+ account_number: account_number)
85
+ end
86
+
87
+ def calculate_spanish_checksum_digit(number)
88
+ modulus = CCC_MODULUS
89
+
90
+ reminder = CCC_WEIGHTS.map.with_index { |weight, order_of_magnitude|
91
+ digit_at_position = (number / 10**order_of_magnitude) % 10
92
+
93
+ digit_at_position * weight
94
+ }.sum % modulus
95
+
96
+ return reminder if reminder.zero? || reminder == 1
97
+ modulus - reminder
98
+ end
99
+
100
+ def calculate_iban_checksum_number(number)
101
+ modulus = IBAN_MODULUS
102
+ (modulus + 1) - (number % modulus)
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Norma43
4
+ module Models
5
+ class Account
6
+ include Mixins::AttributesAssignment
7
+
8
+ attr_accessor :bank_code,
9
+ :branch_code,
10
+ :account_number,
11
+ :start_date,
12
+ :end_date,
13
+ :balance_code,
14
+ :balance_amount,
15
+ :currency_code,
16
+ :information_mode_code,
17
+ :abbreviated_name,
18
+ :debit_entries,
19
+ :debit_amount,
20
+ :credit_entries,
21
+ :credit_amount,
22
+ :transactions
23
+
24
+ def initialize(attributes = EMPTY_ATTRIBUTES)
25
+ @bank_code,
26
+ @branch_code,
27
+ @account_number,
28
+ @start_date,
29
+ @end_date,
30
+ @balance_code,
31
+ @balance_amount,
32
+ @currency_code,
33
+ @information_mode_code,
34
+ @abbreviated_name,
35
+ @debit_entries,
36
+ @debit_amount,
37
+ @credit_entries,
38
+ @credit_amount,
39
+ transactions = Hash(attributes).values_at(
40
+ :bank_code,
41
+ :branch_code,
42
+ :account_number,
43
+ :start_date,
44
+ :end_date,
45
+ :balance_code,
46
+ :balance_amount,
47
+ :currency_code,
48
+ :information_mode_code,
49
+ :abbreviated_name,
50
+ :debit_entries,
51
+ :debit_amount,
52
+ :credit_entries,
53
+ :credit_amount,
54
+ :transactions)
55
+ @transactions = Array(transactions).map { |attrs| Transaction.new(attrs) }
56
+ end
57
+
58
+ def iban
59
+ SpanishIban.from_account(self)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Norma43
4
+ module Models
5
+ class AdditionalCurrency
6
+ include Mixins::AttributesAssignment
7
+
8
+ attr_accessor :data_code, :currency_code, :amount, :free
9
+
10
+ def initialize(attributes = EMPTY_ATTRIBUTES)
11
+ @data_code,
12
+ @currency_code,
13
+ @amount,
14
+ @free = Hash(attributes).values_at(
15
+ :data_code,
16
+ :currency_code,
17
+ :amount,
18
+ :free)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Norma43
4
+ module Models
5
+ class AdditionalItem
6
+ include Mixins::AttributesAssignment
7
+
8
+ attr_accessor :data_code, :item_1, :item_2
9
+
10
+ def initialize(attributes = EMPTY_ATTRIBUTES)
11
+ @data_code,
12
+ @item_1,
13
+ @item_2 = Hash(attributes).values_at(
14
+ :data_code,
15
+ :item_1,
16
+ :item_2)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Norma43
4
+ module Models
5
+ class Document
6
+ include Mixins::AttributesAssignment
7
+
8
+ attr_accessor :id, :created_at, :delivery_number, :file_type, :name, :number_of_lines, :accounts
9
+
10
+ def initialize(attributes = EMPTY_ATTRIBUTES)
11
+ @id,
12
+ @created_at,
13
+ @delivery_number,
14
+ @file_type,
15
+ @name,
16
+ @number_of_lines,
17
+ accounts = Hash(attributes).values_at(
18
+ :id,
19
+ :created_at,
20
+ :delivery_number,
21
+ :file_type,
22
+ :name,
23
+ :number_of_lines,
24
+ :accounts)
25
+ @accounts = Array(accounts).map { |account| Account.new(account) }
26
+ end
27
+
28
+ # @deprecated Please ask each transaction inside accounts for their transaction_date instead
29
+ def transaction_date
30
+ warn "[DEPRECATION] `transaction_date` is deprecated, use `#transaction_date` from transactions in `#accounts` instead"
31
+ date = nil
32
+
33
+ accounts.flat_map(&:transactions).each { |transaction|
34
+ date = transaction&.transaction_date
35
+ break unless date.nil?
36
+ }
37
+
38
+ date
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Norma43
4
+ module Models
5
+ module Mixins
6
+ module AttributesAssignment
7
+ EMPTY_ATTRIBUTES = {}.freeze
8
+
9
+ def attributes=(new_attributes)
10
+ Hash(new_attributes).each do |attr_name, attr_value|
11
+ attr_writer_method_name = "#{attr_name}=".to_sym
12
+ next unless public_methods(false).include?(attr_writer_method_name)
13
+
14
+ public_send(attr_writer_method_name, attr_value)
15
+ end
16
+ end
17
+
18
+ def attributes
19
+ instance_variables.map { |ivar_name|
20
+ attr_reader_method_name = ivar_name.to_s.delete_prefix("@").to_sym
21
+ next unless public_methods(false).include?(attr_reader_method_name)
22
+
23
+ attr_value = public_send(attr_reader_method_name)
24
+
25
+ [attr_reader_method_name, attr_value]
26
+ }.compact.to_h
27
+ end
28
+ alias_method :to_hash, :attributes # Implicit coercion for `Hash(model)`
29
+ alias_method :to_h, :attributes # Explicit coercion
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Norma43
4
+ module Models
5
+ class Transaction
6
+ include Mixins::AttributesAssignment
7
+
8
+ attr_accessor :origin_branch_code,
9
+ :transaction_date,
10
+ :value_date,
11
+ :shared_item,
12
+ :own_item,
13
+ :amount_code,
14
+ :amount,
15
+ :document_number,
16
+ :reference_1,
17
+ :reference_2,
18
+ :additional_items,
19
+ :additional_currency
20
+
21
+ def initialize(attributes = EMPTY_ATTRIBUTES)
22
+ @origin_branch_code,
23
+ @transaction_date,
24
+ @value_date,
25
+ @shared_item,
26
+ @own_item,
27
+ @amount_code,
28
+ @amount,
29
+ @document_number,
30
+ @reference_1,
31
+ @reference_2,
32
+ additional_items,
33
+ additional_currency = Hash(attributes).values_at(
34
+ :origin_branch_code,
35
+ :transaction_date,
36
+ :value_date,
37
+ :shared_item,
38
+ :own_item,
39
+ :amount_code,
40
+ :amount,
41
+ :document_number,
42
+ :reference_1,
43
+ :reference_2)
44
+ @additional_items = Array(additional_items).map { |attrs| AdditionalItem.new(attrs) }
45
+ @additional_currency = AdditionalCurrency.new(additional_currency) if additional_currency
46
+ end
47
+
48
+ def debit?; self.amount_code == DEBIT_CODE end
49
+ end
50
+ end
51
+ end