sepa_king 0.10.1 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 06ba65debe0037b33312ef3e37e26ee1961f455e
4
- data.tar.gz: 2a18cefa0543ff2e0f4d3ca80fe85188e97615a2
2
+ SHA256:
3
+ metadata.gz: 770829019aef0e261d784bff74bba479c2bc629d5b5cd29fd8ed5987dd3f2a36
4
+ data.tar.gz: 2929b12cc5c35646e0991f1747e8d329b1d88293bad2ed0d1ddc0f4c0c90522c
5
5
  SHA512:
6
- metadata.gz: dad5f9e7304d1cba1cc7e241cfd3a5a394d7ca5214a0e64194dd774fb72b10d749d44bba655152e7e92339a3496bd6b51da26da529b6012e5517165d2800cae0
7
- data.tar.gz: aea41790a245876bf8659a85118034c80f5ed09f7e9d9d7080af65a0de96679f58648e2945ed309abc0d0437aa5e4545ba711e061b697f3b5c3ab4420664ea75
6
+ metadata.gz: f78107df5faad7d6cd0f71ceeefcc8ed385aba409aab707c6d7552530d425cdad7d33fd5f4e9087236ea68d57c1b35888a29f9ffc176802c36e7c459afa2a6b0
7
+ data.tar.gz: 2d42905a7c00c9d5daa8fd64a4eaa6018c3210b542d935a962beab83e035b6ec227501c5bfa847645382381dbca5c953eea68c7df547dab53454af92083cb4f6
@@ -1,11 +1,9 @@
1
1
  rvm:
2
- - 2.0.0
3
- - 2.1.10
4
- - 2.2.8
5
- - 2.3.5
6
- - 2.4.2
2
+ - 2.2.10
3
+ - 2.3.7
4
+ - 2.4.4
5
+ - 2.5.1
7
6
  gemfile:
8
- - gemfiles/Gemfile-activemodel-3.0.x
9
7
  - gemfiles/Gemfile-activemodel-3.1.x
10
8
  - gemfiles/Gemfile-activemodel-3.2.x
11
9
  - gemfiles/Gemfile-activemodel-4.0.x
@@ -13,18 +11,15 @@ gemfile:
13
11
  - gemfiles/Gemfile-activemodel-4.2.x
14
12
  - gemfiles/Gemfile-activemodel-5.0.x
15
13
  - gemfiles/Gemfile-activemodel-5.1.x
14
+ - gemfiles/Gemfile-activemodel-5.2.x
16
15
  matrix:
17
16
  exclude:
18
- - rvm: 2.0.0
19
- gemfile: gemfiles/Gemfile-activemodel-5.1.x
20
- - rvm: 2.1.10
21
- gemfile: gemfiles/Gemfile-activemodel-5.1.x
22
- - rvm: 2.0.0
23
- gemfile: gemfiles/Gemfile-activemodel-5.0.x
24
- - rvm: 2.1.10
25
- gemfile: gemfiles/Gemfile-activemodel-5.0.x
26
- - rvm: 2.4.2
17
+ - rvm: 2.4.4
27
18
  gemfile: gemfiles/Gemfile-activemodel-4.1.x
28
- - rvm: 2.4.2
19
+ - rvm: 2.4.4
20
+ gemfile: gemfiles/Gemfile-activemodel-4.2.x
21
+ - rvm: 2.5.1
22
+ gemfile: gemfiles/Gemfile-activemodel-4.1.x
23
+ - rvm: 2.5.1
29
24
  gemfile: gemfiles/Gemfile-activemodel-4.2.x
30
25
  sudo: false
data/README.md CHANGED
@@ -23,8 +23,8 @@ BTW: **pain** is a shortcut for **Pa**yment **In**itiation.
23
23
 
24
24
  ## Requirements
25
25
 
26
- * Ruby 2.0.0 or newer
27
- * ActiveModel 3.0 or newer
26
+ * Ruby 2.2 or newer
27
+ * ActiveModel 3.1 or newer
28
28
 
29
29
 
30
30
  ## Installation
@@ -101,7 +101,7 @@ sdd.add_transaction(
101
101
  # Local instrument, in German "Lastschriftart"
102
102
  # One of these strings:
103
103
  # 'CORE' ("Basis-Lastschrift")
104
- # 'COR1' ("Basis-Lastschrift mit verkürzter Vorlagefrist")
104
+ # 'COR1' ("Basis-Lastschrift mit verkürzter Vorlagefrist")
105
105
  # 'B2B' ("Firmen-Lastschrift")
106
106
  local_instrument: 'CORE',
107
107
 
@@ -129,6 +129,13 @@ sdd.add_transaction(
129
129
  iban: 'NL08RABO0135742099',
130
130
  creditor_identifier: 'NL53ZZZ091734220000'
131
131
  )
132
+
133
+ # OPTIONAL: Specify the country & address of the debtor (REQUIRED for SEPA debits outside of EU)
134
+ debtor_address: SEPA::DebtorAddress.new(
135
+ country_code: 'CH',
136
+ address_line1: 'Mustergasse 123a',
137
+ address_line2: '1234 Musterstadt'
138
+ )
132
139
  )
133
140
  sdd.add_transaction ...
134
141
 
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec path: '..'
4
4
 
5
- gem 'activemodel', '~>3.0.20'
5
+ gem 'activemodel', '~> 5.2.0'
@@ -7,6 +7,7 @@ require 'sepa_king/converter'
7
7
  require 'sepa_king/validator'
8
8
  require 'sepa_king/account'
9
9
  require 'sepa_king/account/debtor_account'
10
+ require 'sepa_king/account/debtor_address'
10
11
  require 'sepa_king/account/creditor_account'
11
12
  require 'sepa_king/transaction'
12
13
  require 'sepa_king/transaction/direct_debit_transaction'
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ module SEPA
3
+ class DebtorAddress
4
+ include ActiveModel::Validations
5
+ extend Converter
6
+
7
+ attr_accessor :country_code, :address_line1, :address_line2
8
+
9
+ convert :country_code, to: :text
10
+ convert :address_line1, to: :text
11
+ convert :address_line2, to: :text
12
+
13
+ validates_length_of :country_code, is: 2
14
+ validates_length_of :address_line1, maximum: 70
15
+ validates_length_of :address_line2, maximum: 70
16
+
17
+ def initialize(attributes = {})
18
+ attributes.each do |name, value|
19
+ public_send("#{name}=", value)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -84,7 +84,6 @@ module SEPA
84
84
  end
85
85
 
86
86
  def build_amendment_informations(builder, transaction)
87
- return unless transaction.original_debtor_account || transaction.same_mandate_new_debtor_agent
88
87
  builder.AmdmntInd(true)
89
88
  builder.AmdmntInfDtls do
90
89
  if transaction.original_debtor_account
@@ -93,7 +92,7 @@ module SEPA
93
92
  builder.IBAN(transaction.original_debtor_account)
94
93
  end
95
94
  end
96
- else
95
+ elsif transaction.same_mandate_new_debtor_agent
97
96
  builder.OrgnlDbtrAgt do
98
97
  builder.FinInstnId do
99
98
  builder.Othr do
@@ -102,6 +101,22 @@ module SEPA
102
101
  end
103
102
  end
104
103
  end
104
+ if transaction.original_creditor_account
105
+ builder.OrgnlCdtrSchmeId do
106
+ if transaction.original_creditor_account.name
107
+ builder.Nm(transaction.original_creditor_account.name)
108
+ end
109
+ if transaction.original_creditor_account.creditor_identifier
110
+ builder.Id do
111
+ builder.PrvtId do
112
+ builder.Othr do
113
+ builder.Id(transaction.original_creditor_account.creditor_identifier)
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
105
120
  end
106
121
  end
107
122
 
@@ -118,7 +133,7 @@ module SEPA
118
133
  builder.MndtRltdInf do
119
134
  builder.MndtId(transaction.mandate_id)
120
135
  builder.DtOfSgntr(transaction.mandate_date_of_signature.iso8601)
121
- build_amendment_informations(builder, transaction)
136
+ build_amendment_informations(builder, transaction) if transaction.amendment_informations?
122
137
  end
123
138
  end
124
139
  builder.DbtrAgt do
@@ -134,6 +149,13 @@ module SEPA
134
149
  end
135
150
  builder.Dbtr do
136
151
  builder.Nm(transaction.name)
152
+ if transaction.debtor_address
153
+ builder.PstlAdr do
154
+ builder.Ctry transaction.debtor_address.country_code
155
+ builder.AdrLine transaction.debtor_address.address_line1
156
+ builder.AdrLine transaction.debtor_address.address_line2
157
+ end
158
+ end
137
159
  end
138
160
  builder.DbtrAcct do
139
161
  builder.Id do
@@ -6,7 +6,8 @@ module SEPA
6
6
 
7
7
  DEFAULT_REQUESTED_DATE = Date.new(1999, 1, 1).freeze
8
8
 
9
- attr_accessor :name, :iban, :bic, :amount, :instruction, :reference, :remittance_information, :requested_date, :batch_booking, :currency
9
+ attr_accessor :name, :iban, :bic, :amount, :instruction, :reference, :remittance_information, :requested_date, :batch_booking, :currency, :debtor_address
10
+
10
11
  convert :name, :instruction, :reference, :remittance_information, to: :text
11
12
  convert :amount, to: :decimal
12
13
 
@@ -4,13 +4,12 @@ module SEPA
4
4
  SEQUENCE_TYPES = %w(FRST OOFF RCUR FNAL)
5
5
  LOCAL_INSTRUMENTS = %w(CORE COR1 B2B)
6
6
 
7
- attr_accessor :mandate_id, :mandate_date_of_signature, :local_instrument, :sequence_type, :creditor_account, :original_debtor_account, :same_mandate_new_debtor_agent
7
+ attr_accessor :mandate_id, :mandate_date_of_signature, :local_instrument, :sequence_type, :creditor_account, :original_debtor_account, :same_mandate_new_debtor_agent, :original_creditor_account, :debtor_address
8
8
 
9
9
  validates_with MandateIdentifierValidator, field_name: :mandate_id, message: "%{value} is invalid"
10
10
  validates_presence_of :mandate_date_of_signature
11
11
  validates_inclusion_of :local_instrument, in: LOCAL_INSTRUMENTS
12
12
  validates_inclusion_of :sequence_type, in: SEQUENCE_TYPES
13
-
14
13
  validate { |t| t.validate_requested_date_after(Date.today.next) }
15
14
 
16
15
  validate do |t|
@@ -31,6 +30,10 @@ module SEPA
31
30
  self.sequence_type ||= 'OOFF'
32
31
  end
33
32
 
33
+ def amendment_informations?
34
+ original_debtor_account || same_mandate_new_debtor_agent || original_creditor_account
35
+ end
36
+
34
37
  def schema_compatible?(schema_name)
35
38
  case schema_name
36
39
  when PAIN_008_002_02
@@ -1,3 +1,3 @@
1
1
  module SEPA
2
- VERSION = '0.10.1'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -18,9 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
19
  s.require_paths = ['lib']
20
20
 
21
- s.required_ruby_version = '>= 2.0.0'
21
+ s.required_ruby_version = '>= 2.2'
22
22
 
23
- s.add_runtime_dependency 'activemodel', '>= 3.0.0'
23
+ s.add_runtime_dependency 'activemodel', '>= 3.1'
24
24
  s.add_runtime_dependency 'builder'
25
25
  s.add_runtime_dependency 'iban-tools'
26
26
 
@@ -29,5 +29,5 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency 'coveralls'
30
30
  s.add_development_dependency 'simplecov'
31
31
  s.add_development_dependency 'rake'
32
- s.add_development_dependency 'nokogiri', RUBY_VERSION < '2.1.0' ? '~> 1.6.0' : '~> 1'
32
+ s.add_development_dependency 'nokogiri'
33
33
  end
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe SEPA::DebtorAddress do
5
+ it 'should initialize a new address' do
6
+ expect(
7
+ SEPA::DebtorAddress.new country_code: 'CH',
8
+ address_line1: 'Mustergasse 123',
9
+ address_line2: '12345 Musterstadt'
10
+ ).to be_valid
11
+ end
12
+ end
@@ -74,6 +74,34 @@ describe SEPA::DirectDebit do
74
74
  end
75
75
  end
76
76
 
77
+ context 'setting debtor address' do
78
+ subject do
79
+ sdd = SEPA::DirectDebit.new name: 'Gläubiger GmbH',
80
+ iban: 'DE87200500001234567890',
81
+ creditor_identifier: 'DE98ZZZ09999999999'
82
+
83
+ sda = SEPA::DebtorAddress.new country_code: 'CH',
84
+ address_line1: 'Mustergasse 123',
85
+ address_line2: '1234 Musterstadt'
86
+
87
+ sdd.add_transaction name: 'Zahlemann & Söhne GbR',
88
+ bic: 'SPUEDE2UXXX',
89
+ iban: 'DE21500500009876543210',
90
+ amount: 39.99,
91
+ reference: 'XYZ/2013-08-ABO/12345',
92
+ remittance_information: 'Unsere Rechnung vom 10.08.2013',
93
+ mandate_id: 'K-02-2011-12345',
94
+ debtor_address: sda,
95
+ mandate_date_of_signature: Date.new(2011,1,25)
96
+
97
+ sdd
98
+ end
99
+
100
+ it 'should validate against pain.008.003.02' do
101
+ expect(subject.to_xml(SEPA::PAIN_008_003_02)).to validate_against('pain.008.003.02.xsd')
102
+ end
103
+ end
104
+
77
105
  context 'for valid creditor' do
78
106
  context 'without BIC (IBAN-only)' do
79
107
  subject do
@@ -137,6 +165,42 @@ describe SEPA::DirectDebit do
137
165
  end
138
166
  end
139
167
 
168
+ context 'with BIC and debtor address ' do
169
+ subject do
170
+ sdd = direct_debit
171
+
172
+ sda = SEPA::DebtorAddress.new(
173
+ country_code: 'CH',
174
+ address_line1: 'Mustergasse 123',
175
+ address_line2: '1234 Musterstadt'
176
+ )
177
+
178
+ sdd.add_transaction name: 'Zahlemann & Söhne GbR',
179
+ bic: 'SPUEDE2UXXX',
180
+ iban: 'DE21500500009876543210',
181
+ amount: 39.99,
182
+ reference: 'XYZ/2013-08-ABO/12345',
183
+ remittance_information: 'Unsere Rechnung vom 10.08.2013',
184
+ mandate_id: 'K-02-2011-12345',
185
+ debtor_address: sda,
186
+ mandate_date_of_signature: Date.new(2011,1,25)
187
+
188
+ sdd
189
+ end
190
+
191
+ it 'should validate against pain.008.001.02' do
192
+ expect(subject.to_xml(SEPA::PAIN_008_001_02)).to validate_against('pain.008.001.02.xsd')
193
+ end
194
+
195
+ it 'should validate against pain.008.002.02' do
196
+ expect(subject.to_xml(SEPA::PAIN_008_002_02)).to validate_against('pain.008.002.02.xsd')
197
+ end
198
+
199
+ it 'should validate against pain.008.003.02' do
200
+ expect(subject.to_xml(SEPA::PAIN_008_003_02)).to validate_against('pain.008.003.02.xsd')
201
+ end
202
+ end
203
+
140
204
  context 'without requested_date given' do
141
205
  subject do
142
206
  sdd = direct_debit
@@ -398,17 +462,21 @@ describe SEPA::DirectDebit do
398
462
 
399
463
  sdd.add_transaction(direct_debt_transaction.merge(original_debtor_account: 'NL08RABO0135742099'))
400
464
  sdd.add_transaction(direct_debt_transaction.merge(same_mandate_new_debtor_agent: true))
465
+ sdd.add_transaction(direct_debt_transaction.merge(original_creditor_account: SEPA::CreditorAccount.new(creditor_identifier: 'NL53ZZZ091734220000', name: 'Creditor Inc.')))
401
466
  sdd.to_xml
402
467
  end
403
468
 
404
469
  it 'should include amendment indicator' do
405
470
  expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DrctDbtTx/MndtRltdInf/AmdmntInd', 'true')
406
471
  expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DrctDbtTx/MndtRltdInf/AmdmntInd', 'true')
472
+ expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[3]/DrctDbtTx/MndtRltdInf/AmdmntInd', 'true')
407
473
  end
408
474
 
409
475
  it 'should include amendment information details' do
410
476
  expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DrctDbtTx/MndtRltdInf/AmdmntInfDtls/OrgnlDbtrAcct/Id/IBAN', 'NL08RABO0135742099')
411
477
  expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DrctDbtTx/MndtRltdInf/AmdmntInfDtls/OrgnlDbtrAgt/FinInstnId/Othr/Id', 'SMNDA')
478
+ expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[3]/DrctDbtTx/MndtRltdInf/AmdmntInfDtls/OrgnlCdtrSchmeId/Nm', 'Creditor Inc.')
479
+ expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[3]/DrctDbtTx/MndtRltdInf/AmdmntInfDtls/OrgnlCdtrSchmeId/Id/PrvtId/Othr/Id', 'NL53ZZZ091734220000')
412
480
  end
413
481
  end
414
482
 
@@ -26,6 +26,19 @@ describe SEPA::Transaction do
26
26
  end
27
27
  end
28
28
 
29
+ context 'Adress' do
30
+ it 'should accept valid value' do
31
+ expect(SEPA::Transaction).to accept(SEPA::DebtorAddress.new(
32
+ country_code: "CH",
33
+ address_line1: "Musterstrasse 123",
34
+ address_line2: "1234 Musterstadt"
35
+ ), for: :debtor_address)
36
+ end
37
+
38
+ it 'should not accept invalid value' do
39
+ expect(SEPA::Transaction).not_to accept('', {} , for: :name)
40
+ end
41
+ end
29
42
  context 'IBAN' do
30
43
  it 'should accept valid value' do
31
44
  expect(SEPA::Transaction).to accept('DE21500500009876543210', 'PL61109010140000071219812874', for: :iban)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sepa_king
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Leciejewski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-09-18 00:00:00.000000000 Z
12
+ date: 2018-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 3.0.0
20
+ version: '3.1'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 3.0.0
27
+ version: '3.1'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: builder
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -127,16 +127,16 @@ dependencies:
127
127
  name: nokogiri
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - "~>"
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
- version: '1'
132
+ version: '0'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - "~>"
137
+ - - ">="
138
138
  - !ruby/object:Gem::Version
139
- version: '1'
139
+ version: '0'
140
140
  description: Implemention of pain.001.002.03 and pain.008.002.02 (ISO 20022)
141
141
  email:
142
142
  - gl@salesking.eu
@@ -153,7 +153,6 @@ files:
153
153
  - LICENSE.txt
154
154
  - README.md
155
155
  - Rakefile
156
- - gemfiles/Gemfile-activemodel-3.0.x
157
156
  - gemfiles/Gemfile-activemodel-3.1.x
158
157
  - gemfiles/Gemfile-activemodel-3.2.x
159
158
  - gemfiles/Gemfile-activemodel-4.0.x
@@ -161,6 +160,7 @@ files:
161
160
  - gemfiles/Gemfile-activemodel-4.2.x
162
161
  - gemfiles/Gemfile-activemodel-5.0.x
163
162
  - gemfiles/Gemfile-activemodel-5.1.x
163
+ - gemfiles/Gemfile-activemodel-5.2.x
164
164
  - lib/schema/pain.001.001.03.xsd
165
165
  - lib/schema/pain.001.002.03.xsd
166
166
  - lib/schema/pain.001.003.03.xsd
@@ -171,6 +171,7 @@ files:
171
171
  - lib/sepa_king/account.rb
172
172
  - lib/sepa_king/account/creditor_account.rb
173
173
  - lib/sepa_king/account/debtor_account.rb
174
+ - lib/sepa_king/account/debtor_address.rb
174
175
  - lib/sepa_king/converter.rb
175
176
  - lib/sepa_king/message.rb
176
177
  - lib/sepa_king/message/credit_transfer.rb
@@ -187,6 +188,7 @@ files:
187
188
  - spec/credit_transfer_transaction_spec.rb
188
189
  - spec/creditor_account_spec.rb
189
190
  - spec/debtor_account_spec.rb
191
+ - spec/debtor_address_spec.rb
190
192
  - spec/direct_debit_spec.rb
191
193
  - spec/direct_debit_transaction_spec.rb
192
194
  - spec/examples/pain.001.001.03.xml
@@ -215,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
217
  requirements:
216
218
  - - ">="
217
219
  - !ruby/object:Gem::Version
218
- version: 2.0.0
220
+ version: '2.2'
219
221
  required_rubygems_version: !ruby/object:Gem::Requirement
220
222
  requirements:
221
223
  - - ">="
@@ -223,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
225
  version: '0'
224
226
  requirements: []
225
227
  rubyforge_project:
226
- rubygems_version: 2.6.13
228
+ rubygems_version: 2.7.6
227
229
  signing_key:
228
230
  specification_version: 4
229
231
  summary: Ruby gem for creating SEPA XML files
@@ -234,6 +236,7 @@ test_files:
234
236
  - spec/credit_transfer_transaction_spec.rb
235
237
  - spec/creditor_account_spec.rb
236
238
  - spec/debtor_account_spec.rb
239
+ - spec/debtor_address_spec.rb
237
240
  - spec/direct_debit_spec.rb
238
241
  - spec/direct_debit_transaction_spec.rb
239
242
  - spec/examples/pain.001.001.03.xml