sepa_king 0.0.6 → 0.0.7
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 +4 -4
- data/README.md +14 -0
- data/lib/sepa_king/message/direct_debit.rb +6 -5
- data/lib/sepa_king/message.rb +4 -1
- data/lib/sepa_king/transaction/direct_debit_transaction.rb +5 -1
- data/lib/sepa_king/version.rb +1 -1
- data/spec/direct_debit_spec.rb +21 -0
- data/spec/message_spec.rb +17 -10
- metadata +28 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecce149363029e74d571ff27d16743316d126460
|
4
|
+
data.tar.gz: ea57de58cac8041d8f618512586b11018ae2abb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee0bdeeade055d746b07247482288163e03762ba6b66bae32be2a06530908e4ab70fb69608a41f040831907862fc984ebe938fc9b68778d66620c63276cf2fbb
|
7
|
+
data.tar.gz: b29f17363268119f3c7f3d324aaace1ffadcc7ba58ae5f7f7940528cf2e808109aa8ffe46c33e2f7be9c6cb9b6541c97a9179b09f17d9bafb752ce0fd036daa5
|
data/README.md
CHANGED
@@ -108,6 +108,15 @@ sdd.add_transaction(
|
|
108
108
|
# OPTIONAL: Enables or disables batch booking, in German "Sammelbuchung / Einzelbuchung"
|
109
109
|
# True or False
|
110
110
|
batch_booking: true
|
111
|
+
|
112
|
+
# Optional: Use a different creditor account
|
113
|
+
# CreditorAccount
|
114
|
+
creditor_account: SEPA::CreditorAccount.new(
|
115
|
+
name: 'Creditor Inc.',
|
116
|
+
bic: 'RABONL2U',
|
117
|
+
iban: 'NL08RABO0135742099',
|
118
|
+
creditor_identifier: 'NL53ZZZ091734220000'
|
119
|
+
)
|
111
120
|
)
|
112
121
|
sdd.add_transaction ...
|
113
122
|
|
@@ -180,6 +189,11 @@ xml_string = sct.to_xml
|
|
180
189
|
https://github.com/salesking/sepa_king/releases
|
181
190
|
|
182
191
|
|
192
|
+
## Contributors
|
193
|
+
|
194
|
+
https://github.com/salesking/sepa_king/graphs/contributors
|
195
|
+
|
196
|
+
|
183
197
|
## Resources
|
184
198
|
|
185
199
|
* http://www.ebics.de/index.php?id=77
|
@@ -26,7 +26,8 @@ module SEPA
|
|
26
26
|
{ requested_date: transaction.requested_date,
|
27
27
|
local_instrument: transaction.local_instrument,
|
28
28
|
sequence_type: transaction.sequence_type,
|
29
|
-
batch_booking: transaction.batch_booking
|
29
|
+
batch_booking: transaction.batch_booking,
|
30
|
+
account: transaction.creditor_account || account
|
30
31
|
}
|
31
32
|
end
|
32
33
|
end
|
@@ -51,16 +52,16 @@ module SEPA
|
|
51
52
|
end
|
52
53
|
builder.ReqdColltnDt(group[:requested_date].iso8601)
|
53
54
|
builder.Cdtr do
|
54
|
-
builder.Nm(account.name)
|
55
|
+
builder.Nm(group[:account].name)
|
55
56
|
end
|
56
57
|
builder.CdtrAcct do
|
57
58
|
builder.Id do
|
58
|
-
builder.IBAN(account.iban)
|
59
|
+
builder.IBAN(group[:account].iban)
|
59
60
|
end
|
60
61
|
end
|
61
62
|
builder.CdtrAgt do
|
62
63
|
builder.FinInstnId do
|
63
|
-
builder.BIC(account.bic)
|
64
|
+
builder.BIC(group[:account].bic)
|
64
65
|
end
|
65
66
|
end
|
66
67
|
builder.ChrgBr('SLEV')
|
@@ -68,7 +69,7 @@ module SEPA
|
|
68
69
|
builder.Id do
|
69
70
|
builder.PrvtId do
|
70
71
|
builder.Othr do
|
71
|
-
builder.Id(account.creditor_identifier)
|
72
|
+
builder.Id(group[:account].creditor_identifier)
|
72
73
|
builder.SchmeNm do
|
73
74
|
builder.Prtry('SEPA')
|
74
75
|
end
|
data/lib/sepa_king/message.rb
CHANGED
@@ -5,7 +5,11 @@ module SEPA
|
|
5
5
|
include ActiveModel::Validations
|
6
6
|
|
7
7
|
attr_reader :account, :transactions
|
8
|
+
|
8
9
|
validates_presence_of :transactions
|
10
|
+
validate do |record|
|
11
|
+
record.errors.add(:account, 'is invalid') unless record.account.valid?
|
12
|
+
end
|
9
13
|
|
10
14
|
class_attribute :account_class, :transaction_class, :xml_main_tag
|
11
15
|
|
@@ -22,7 +26,6 @@ module SEPA
|
|
22
26
|
|
23
27
|
# @return [String] xml
|
24
28
|
def to_xml
|
25
|
-
raise RuntimeError.new(account.errors.full_messages.join("\n")) unless account.valid?
|
26
29
|
raise RuntimeError.new(errors.full_messages.join("\n")) unless valid?
|
27
30
|
|
28
31
|
builder = Builder::XmlMarkup.new indent: 2
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module SEPA
|
3
3
|
class DirectDebitTransaction < Transaction
|
4
|
-
attr_accessor :mandate_id, :mandate_date_of_signature, :local_instrument, :sequence_type
|
4
|
+
attr_accessor :mandate_id, :mandate_date_of_signature, :local_instrument, :sequence_type, :creditor_account
|
5
5
|
|
6
6
|
validates_length_of :mandate_id, within: 1..35
|
7
7
|
validates_presence_of :mandate_date_of_signature
|
@@ -9,6 +9,10 @@ module SEPA
|
|
9
9
|
validates_inclusion_of :sequence_type, :in => %w(FRST OOFF RCUR FNAL)
|
10
10
|
|
11
11
|
validate do |t|
|
12
|
+
if creditor_account
|
13
|
+
errors.add(:creditor_account, 'is not correct') unless creditor_account.valid?
|
14
|
+
end
|
15
|
+
|
12
16
|
if t.mandate_date_of_signature.is_a?(Date)
|
13
17
|
errors.add(:mandate_date_of_signature, 'is in the future') if t.mandate_date_of_signature > Date.today
|
14
18
|
else
|
data/lib/sepa_king/version.rb
CHANGED
data/spec/direct_debit_spec.rb
CHANGED
@@ -273,6 +273,27 @@ describe SEPA::DirectDebit do
|
|
273
273
|
subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/CtrlSum', '8.00')
|
274
274
|
end
|
275
275
|
end
|
276
|
+
|
277
|
+
context 'with transactions containing different creditor_account' do
|
278
|
+
subject do
|
279
|
+
sdd = direct_debit
|
280
|
+
|
281
|
+
sdd.add_transaction(direct_debt_transaction)
|
282
|
+
sdd.add_transaction(direct_debt_transaction.merge(creditor_account: SEPA::CreditorAccount.new(
|
283
|
+
name: 'Creditor Inc.',
|
284
|
+
bic: 'RABONL2U',
|
285
|
+
iban: 'NL08RABO0135742099',
|
286
|
+
creditor_identifier: 'NL53ZZZ091734220000'))
|
287
|
+
)
|
288
|
+
|
289
|
+
sdd.to_xml
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'should contain two payment_informations with <Cdtr>' do
|
293
|
+
subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/Cdtr/Nm', 'Glaeubiger GmbH')
|
294
|
+
subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/Cdtr/Nm', 'Creditor Inc.')
|
295
|
+
end
|
296
|
+
end
|
276
297
|
end
|
277
298
|
end
|
278
299
|
end
|
data/spec/message_spec.rb
CHANGED
@@ -6,32 +6,39 @@ class DummyTransaction < SEPA::Transaction
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class DummyMessage < SEPA::Message
|
9
|
-
self.account_class =
|
9
|
+
self.account_class = SEPA::Account
|
10
10
|
self.transaction_class = DummyTransaction
|
11
11
|
end
|
12
12
|
|
13
13
|
describe SEPA::Message do
|
14
14
|
describe :amount_total do
|
15
|
-
|
15
|
+
subject do
|
16
16
|
message = DummyMessage.new
|
17
17
|
message.add_transaction amount: 1.1
|
18
18
|
message.add_transaction amount: 2.2
|
19
|
-
message
|
19
|
+
message
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should sum up all transactions' do
|
23
|
+
subject.amount_total.should == 3.3
|
20
24
|
end
|
21
25
|
|
22
26
|
it 'should sum up selected transactions' do
|
23
|
-
|
24
|
-
message.add_transaction amount: 1.1
|
25
|
-
message.add_transaction amount: 2.2
|
26
|
-
message.amount_total([message.transactions[0]]).should == 1.1
|
27
|
+
subject.amount_total([subject.transactions[0]]).should == 1.1
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
31
|
describe 'validation' do
|
32
|
+
subject { DummyMessage.new }
|
33
|
+
|
34
|
+
it 'should fail with invalid account' do
|
35
|
+
subject.should_not be_valid
|
36
|
+
subject.should have(1).error_on(:account)
|
37
|
+
end
|
38
|
+
|
31
39
|
it 'should fail without transactions' do
|
32
|
-
|
33
|
-
|
34
|
-
message.should have(1).error_on(:transactions)
|
40
|
+
subject.should_not be_valid
|
41
|
+
subject.should have(1).error_on(:transactions)
|
35
42
|
end
|
36
43
|
end
|
37
44
|
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.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Leciejewski
|
@@ -9,146 +9,146 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
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
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: i18n
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: builder
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: iban-tools
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: bundler
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ~>
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '1.3'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - ~>
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '1.3'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: rspec
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '2.14'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '2.14'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: coveralls
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
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
111
|
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: simplecov
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: rake
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- -
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
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
139
|
version: '0'
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: nokogiri
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- -
|
144
|
+
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
type: :development
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- -
|
151
|
+
- - ">="
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
description: Implemention of pain.001.002.03 and pain.008.002.02 (ISO 20022)
|
@@ -159,9 +159,9 @@ executables: []
|
|
159
159
|
extensions: []
|
160
160
|
extra_rdoc_files: []
|
161
161
|
files:
|
162
|
-
- .gitignore
|
163
|
-
- .rspec
|
164
|
-
- .travis.yml
|
162
|
+
- ".gitignore"
|
163
|
+
- ".rspec"
|
164
|
+
- ".travis.yml"
|
165
165
|
- CONTRIBUTING.md
|
166
166
|
- Gemfile
|
167
167
|
- LICENSE.txt
|
@@ -210,17 +210,17 @@ require_paths:
|
|
210
210
|
- lib
|
211
211
|
required_ruby_version: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
|
-
- -
|
213
|
+
- - ">="
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: 1.9.3
|
216
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
217
|
requirements:
|
218
|
-
- -
|
218
|
+
- - ">="
|
219
219
|
- !ruby/object:Gem::Version
|
220
220
|
version: '0'
|
221
221
|
requirements: []
|
222
222
|
rubyforge_project:
|
223
|
-
rubygems_version: 2.
|
223
|
+
rubygems_version: 2.1.4
|
224
224
|
signing_key:
|
225
225
|
specification_version: 4
|
226
226
|
summary: Ruby gem for creating SEPA XML files
|