sepa_king 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a55e01a727d2ad4cb40cc2f284f1e77149781359
4
- data.tar.gz: f8a2b539e05d97d6630a260b91362c7ecc7fb2b9
3
+ metadata.gz: dd633edaa40b7ed3cd1dfe6bbcdb5d676053b6a4
4
+ data.tar.gz: 8bdcfc3411785c55878a7a0039815ff046f9f428
5
5
  SHA512:
6
- metadata.gz: 50a4b696964158725ee468d65a00839bb37d0e7d2939bccb17d0ccb25e24ad14b2160ec7acb22c1ba045e0047f6a5866bf96602e3b26406436b2120bb6c11639
7
- data.tar.gz: c78387d1c6fd870f045b1ae37eb8b3d7a1aae21ec68604e00b00c75b0ad8cc584a55872534890e525d2d1e37183fc0d7bf27818def85ea7d8fc6f7fe0688eba4
6
+ metadata.gz: 8e9af124aa9adf73f3b49a4b20880b68ed9f04bbf49fa75bac9bb49140fb1e694efb243595864567bb7544c64a581008b8006afc04e7d404bda9f3d074c104f8
7
+ data.tar.gz: c71cb2fb8a9691c2c9d0e70a9a1d2bc63d96178594ca0f41d913670d0d58d9f188ad3b833e28d63d18a5ff4b4a8b61f05adb039cee23b3f0cbf8065c96fda688
data/.travis.yml CHANGED
@@ -1,9 +1,8 @@
1
1
  rvm:
2
- - 1.9.3
3
2
  - 2.0.0
4
3
  - 2.1.10
5
- - 2.2.5
6
- - 2.3.1
4
+ - 2.2.6
5
+ - 2.3.3
7
6
  gemfile:
8
7
  - gemfiles/Gemfile-activemodel-3.0.x
9
8
  - gemfiles/Gemfile-activemodel-3.1.x
@@ -14,8 +13,6 @@ gemfile:
14
13
  - gemfiles/Gemfile-activemodel-5.0.x
15
14
  matrix:
16
15
  exclude:
17
- - rvm: 1.9.3
18
- gemfile: gemfiles/Gemfile-activemodel-5.0.x
19
16
  - rvm: 2.0.0
20
17
  gemfile: gemfiles/Gemfile-activemodel-5.0.x
21
18
  - rvm: 2.1.10
data/README.md CHANGED
@@ -23,7 +23,7 @@ BTW: **pain** is a shortcut for **Pa**yment **In**itiation.
23
23
 
24
24
  ## Requirements
25
25
 
26
- * Ruby 1.9.3 or newer
26
+ * Ruby 2.0.0 or newer
27
27
  * ActiveModel 3.0 or newer
28
28
 
29
29
 
@@ -170,6 +170,10 @@ sct.add_transaction(
170
170
  # Number with two decimal digit
171
171
  amount: 102.50,
172
172
 
173
+ # OPTIONAL: Instruction Identification, will not be submitted to the creditor
174
+ # String, max. 35 char
175
+ instruction: '12345',
176
+
173
177
  # OPTIONAL: End-To-End-Identification, will be submitted to the creditor
174
178
  # String, max. 35 char
175
179
  reference: 'XYZ-1234/123',
@@ -3,6 +3,6 @@ module SEPA
3
3
  class CreditorAccount < Account
4
4
  attr_accessor :creditor_identifier
5
5
 
6
- validates_with CreditorIdentifierValidator
6
+ validates_with CreditorIdentifierValidator, message: "%{value} is invalid"
7
7
  end
8
8
  end
@@ -8,7 +8,7 @@ module SEPA
8
8
  convert :name, to: :text
9
9
 
10
10
  validates_length_of :name, within: 1..70
11
- validates_with BICValidator, IBANValidator
11
+ validates_with BICValidator, IBANValidator, message: "%{value} is invalid"
12
12
 
13
13
  def initialize(attributes = {})
14
14
  attributes.each do |name, value|
@@ -108,6 +108,9 @@ module SEPA
108
108
  def build_transaction(builder, transaction)
109
109
  builder.DrctDbtTxInf do
110
110
  builder.PmtId do
111
+ if transaction.instruction.present?
112
+ builder.InstrId(transaction.instruction)
113
+ end
111
114
  builder.EndToEndId(transaction.reference)
112
115
  end
113
116
  builder.InstdAmt('%.2f' % transaction.amount, Ccy: 'EUR')
@@ -6,7 +6,7 @@ module SEPA
6
6
 
7
7
  attr_accessor :mandate_id, :mandate_date_of_signature, :local_instrument, :sequence_type, :creditor_account, :original_debtor_account, :same_mandate_new_debtor_agent
8
8
 
9
- validates_with MandateIdentifierValidator, field_name: :mandate_id
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
@@ -17,7 +17,7 @@ module SEPA
17
17
  validates_numericality_of :amount, greater_than: 0
18
18
  validates_presence_of :requested_date
19
19
  validates_inclusion_of :batch_booking, :in => [true, false]
20
- validates_with BICValidator, IBANValidator
20
+ validates_with BICValidator, IBANValidator, message: "%{value} is invalid"
21
21
 
22
22
  def initialize(attributes = {})
23
23
  attributes.each do |name, value|
@@ -9,7 +9,7 @@ module SEPA
9
9
  value = record.send(field_name).to_s
10
10
 
11
11
  unless IBANTools::IBAN.valid?(value) && value.match(REGEX)
12
- record.errors.add(field_name, :invalid)
12
+ record.errors.add(field_name, :invalid, message: options[:message])
13
13
  end
14
14
  end
15
15
  end
@@ -24,7 +24,7 @@ module SEPA
24
24
 
25
25
  if value
26
26
  unless value.to_s.match(REGEX)
27
- record.errors.add(field_name, :invalid)
27
+ record.errors.add(field_name, :invalid, message: options[:message])
28
28
  end
29
29
  end
30
30
  end
@@ -38,7 +38,7 @@ module SEPA
38
38
  value = record.send(field_name)
39
39
 
40
40
  unless valid?(value)
41
- record.errors.add(field_name, :invalid)
41
+ record.errors.add(field_name, :invalid, message: options[:message])
42
42
  end
43
43
  end
44
44
 
@@ -61,7 +61,7 @@ module SEPA
61
61
  value = record.send(field_name)
62
62
 
63
63
  unless value.to_s.match(REGEX)
64
- record.errors.add(field_name, :invalid)
64
+ record.errors.add(field_name, :invalid, message: options[:message])
65
65
  end
66
66
  end
67
67
  end
@@ -1,3 +1,3 @@
1
1
  module SEPA
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
data/sepa_king.gemspec CHANGED
@@ -18,7 +18,7 @@ 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 = '>= 1.9.3'
21
+ s.required_ruby_version = '>= 2.0.0'
22
22
 
23
23
  s.add_runtime_dependency 'activemodel', '>= 3.0.0'
24
24
  s.add_runtime_dependency 'builder'
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency 'bundler'
28
28
  s.add_development_dependency 'rspec'
29
29
  s.add_development_dependency 'coveralls'
30
- s.add_development_dependency 'simplecov', '~> 0.11.2'
30
+ s.add_development_dependency 'simplecov'
31
31
  s.add_development_dependency 'rake'
32
32
  s.add_development_dependency 'nokogiri'
33
33
  end
@@ -267,6 +267,27 @@ describe SEPA::CreditTransfer do
267
267
  expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[4]/CtrlSum', '8.00')
268
268
  end
269
269
  end
270
+
271
+ context 'with instruction given' do
272
+ subject do
273
+ sct = credit_transfer
274
+
275
+ sct.add_transaction name: 'Telekomiker AG',
276
+ iban: 'DE37112589611964645802',
277
+ amount: 102.50,
278
+ instruction: '1234/ABC'
279
+
280
+ sct.to_xml
281
+ end
282
+
283
+ it 'should create valid XML file' do
284
+ expect(subject).to validate_against('pain.001.003.03.xsd')
285
+ end
286
+
287
+ it 'should contain <InstrId>' do
288
+ expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/PmtId/InstrId', '1234/ABC')
289
+ end
290
+ end
270
291
  end
271
292
  end
272
293
  end
@@ -411,6 +411,24 @@ describe SEPA::DirectDebit do
411
411
  expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DrctDbtTx/MndtRltdInf/AmdmntInfDtls/OrgnlDbtrAgt/FinInstnId/Othr/Id', 'SMNDA')
412
412
  end
413
413
  end
414
+
415
+ context 'with instruction given' do
416
+ subject do
417
+ sct = direct_debit
418
+
419
+ sct.add_transaction(direct_debt_transaction.merge(instruction: '1234/ABC'))
420
+
421
+ sct.to_xml
422
+ end
423
+
424
+ it 'should create valid XML file' do
425
+ expect(subject).to validate_against('pain.008.003.02.xsd')
426
+ end
427
+
428
+ it 'should contain <InstrId>' do
429
+ expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/PmtId/InstrId', '1234/ABC')
430
+ end
431
+ end
414
432
  end
415
433
  end
416
434
  end
@@ -5,7 +5,7 @@ describe SEPA::IBANValidator do
5
5
  class Validatable
6
6
  include ActiveModel::Model
7
7
  attr_accessor :iban, :iban_the_terrible
8
- validates_with SEPA::IBANValidator
8
+ validates_with SEPA::IBANValidator, message: "%{value} seems wrong"
9
9
  validates_with SEPA::IBANValidator, field_name: :iban_the_terrible
10
10
  end
11
11
 
@@ -21,13 +21,19 @@ describe SEPA::IBANValidator do
21
21
  'DE87 2005 0000 1234 5678 90', # spaces included
22
22
  for: [:iban, :iban_the_terrible])
23
23
  end
24
+
25
+ it "should customize error message" do
26
+ v = Validatable.new(:iban => 'xxx')
27
+ v.valid?
28
+ expect(v.errors[:iban]).to eq(['xxx seems wrong'])
29
+ end
24
30
  end
25
31
 
26
32
  describe SEPA::BICValidator do
27
33
  class Validatable
28
34
  include ActiveModel::Model
29
35
  attr_accessor :bic, :custom_bic
30
- validates_with SEPA::BICValidator
36
+ validates_with SEPA::BICValidator, message: "%{value} seems wrong"
31
37
  validates_with SEPA::BICValidator, field_name: :custom_bic
32
38
  end
33
39
 
@@ -38,13 +44,19 @@ describe SEPA::BICValidator do
38
44
  it 'should not accept an invalid BIC' do
39
45
  expect(Validatable).not_to accept('', 'GENODE61HR', 'DEUTDEDBDUEDEUTDEDBDUE', for: [:bic, :custom_bic])
40
46
  end
47
+
48
+ it "should customize error message" do
49
+ v = Validatable.new(:bic => 'xxx')
50
+ v.valid?
51
+ expect(v.errors[:bic]).to eq(['xxx seems wrong'])
52
+ end
41
53
  end
42
54
 
43
55
  describe SEPA::CreditorIdentifierValidator do
44
56
  class Validatable
45
57
  include ActiveModel::Model
46
58
  attr_accessor :creditor_identifier, :crid
47
- validates_with SEPA::CreditorIdentifierValidator
59
+ validates_with SEPA::CreditorIdentifierValidator, message: "%{value} seems wrong"
48
60
  validates_with SEPA::CreditorIdentifierValidator, field_name: :crid
49
61
  end
50
62
 
@@ -55,13 +67,19 @@ describe SEPA::CreditorIdentifierValidator do
55
67
  it 'should not accept an invalid creditor_identifier' do
56
68
  expect(Validatable).not_to accept('', 'xxx', 'DE98ZZZ099999999990', for: [:creditor_identifier, :crid])
57
69
  end
70
+
71
+ it "should customize error message" do
72
+ v = Validatable.new(:creditor_identifier => 'xxx')
73
+ v.valid?
74
+ expect(v.errors[:creditor_identifier]).to eq(['xxx seems wrong'])
75
+ end
58
76
  end
59
77
 
60
78
  describe SEPA::MandateIdentifierValidator do
61
79
  class Validatable
62
80
  include ActiveModel::Model
63
81
  attr_accessor :mandate_id, :mid
64
- validates_with SEPA::MandateIdentifierValidator
82
+ validates_with SEPA::MandateIdentifierValidator, message: "%{value} seems wrong"
65
83
  validates_with SEPA::MandateIdentifierValidator, field_name: :mid
66
84
  end
67
85
 
@@ -72,4 +90,10 @@ describe SEPA::MandateIdentifierValidator do
72
90
  it 'should not accept an invalid mandate_identifier' do
73
91
  expect(Validatable).not_to accept(nil, '', 'X' * 36, 'ABC 123', '#/*', 'Ümläüt', for: [:mandate_id, :mid])
74
92
  end
93
+
94
+ it "should customize error message" do
95
+ v = Validatable.new(:mandate_id => 'ABC 123')
96
+ v.valid?
97
+ expect(v.errors[:mandate_id]).to eq(['ABC 123 seems wrong'])
98
+ end
75
99
  end
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.8.0
4
+ version: 0.9.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: 2016-07-12 00:00:00.000000000 Z
12
+ date: 2016-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -99,16 +99,16 @@ dependencies:
99
99
  name: simplecov
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - "~>"
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
- version: 0.11.2
104
+ version: '0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - "~>"
109
+ - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: 0.11.2
111
+ version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: rake
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -214,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
214
214
  requirements:
215
215
  - - ">="
216
216
  - !ruby/object:Gem::Version
217
- version: 1.9.3
217
+ version: 2.0.0
218
218
  required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - ">="
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  version: '0'
223
223
  requirements: []
224
224
  rubyforge_project:
225
- rubygems_version: 2.6.6
225
+ rubygems_version: 2.6.8
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: Ruby gem for creating SEPA XML files