sepa_king 0.0.2 → 0.0.3
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.markdown +50 -19
- data/lib/sepa_king/credit_transaction.rb +1 -44
- data/lib/sepa_king/{credit_transfer_initiation.rb → credit_transfer.rb} +5 -3
- data/lib/sepa_king/debt_transaction.rb +5 -40
- data/lib/sepa_king/{direct_debit_initiation.rb → direct_debit.rb} +6 -1
- data/lib/sepa_king/transaction.rb +54 -0
- data/lib/sepa_king/version.rb +1 -1
- data/lib/sepa_king.rb +4 -2
- data/sepa_king.gemspec +18 -18
- data/spec/sepa_king/credit_transfer_spec.rb +26 -0
- data/spec/sepa_king/debt_transaction_spec.rb +39 -2
- data/spec/sepa_king/direct_debit_spec.rb +31 -0
- data/spec/sepa_king/transaction_spec.rb +112 -0
- data/spec/spec_helper.rb +2 -0
- metadata +63 -16
- data/spec/sepa_king/credit_transfer_initiation_spec.rb +0 -27
- data/spec/sepa_king/direct_debit_inititation_spec.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 975c5018834a59ef2185c0b36f0f9ae64a49f600
|
4
|
+
data.tar.gz: 0af3c482071e0b707162776b948d4cc55fa2bacf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b1b3c8cd76dfe4142b549c5b7c3512a9e3077ff278f9d7c0a879ecf278824b0da5d629043b72dce7762ba5bb61c5005bfd0a307b1c84899446bf9177345720
|
7
|
+
data.tar.gz: 7c6b844e79e783258601b637596c30c7bc07a3f557e475a9ea667ffd67cacafe3780bf4992ba2448965547575d5ca4261b5e4a9dbda89af56a01b91cc5c5b2b7
|
data/README.markdown
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# Handle SEPA like a king
|
2
2
|
|
3
3
|
[](http://travis-ci.org/salesking/sepa_king)
|
4
|
+
[](https://codeclimate.com/github/salesking/sepa_king)
|
5
|
+
[](https://coveralls.io/r/salesking/sepa_king)
|
4
6
|
|
5
|
-
We love building payment applications! So after developing the
|
7
|
+
We love building payment applications! So after developing the [DTAUS library for Ruby](https://github.com/salesking/king_dtaus) we move on with SEPA!
|
6
8
|
|
7
9
|
This is just the beginning. There is still a lot to do. Please stay tuned...
|
8
10
|
|
@@ -22,31 +24,60 @@ This is just the beginning. There is still a lot to do. Please stay tuned...
|
|
22
24
|
|
23
25
|
## Examples
|
24
26
|
|
25
|
-
How to create a SEPA
|
27
|
+
How to create a SEPA file for direct debit ("Lastschrift")
|
26
28
|
|
27
29
|
```ruby
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
# Add transactions
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
30
|
+
# First: Create the main object
|
31
|
+
dd = SEPA::DirectDebit.new :name => 'Gläubiger GmbH',
|
32
|
+
:bic => 'BANKDEFFXXX',
|
33
|
+
:iban => 'DE87200500001234567890',
|
34
|
+
:identifier => 'DE98ZZZ09999999999'
|
35
|
+
|
36
|
+
# Second: Add transactions
|
37
|
+
dd.add_transaction :name => 'Zahlemann & Söhne GbR',
|
38
|
+
:bic => 'SPUEDE2UXXX',
|
39
|
+
:iban => 'DE21500500009876543210',
|
40
|
+
:amount => 39.99,
|
41
|
+
:reference => 'XYZ/2013-08-ABO/6789',
|
42
|
+
:remittance_information => 'Vielen Dank für Ihren Einkauf!',
|
43
|
+
:mandate_id => 'K-02-2011-12345',
|
44
|
+
:mandate_date_of_signature => Date.new(2011,1,25)
|
45
|
+
dd.add_transaction ...
|
46
|
+
|
47
|
+
# Last: create XML string
|
48
|
+
xml_string = dd.to_xml
|
49
|
+
```
|
50
|
+
|
51
|
+
|
52
|
+
How to create a SEPA file for credit transfer ("Überweisung")
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
# First: Create the main object
|
56
|
+
ct = SEPA::CreditTransfer.new :name => 'Schuldner GmbH',
|
57
|
+
:bic => 'BANKDEFFXXX',
|
58
|
+
:iban => 'DE87200500001234567890'
|
59
|
+
|
60
|
+
# Second: Add transactions
|
61
|
+
ct.add_transaction :name => 'Telekomiker AG',
|
62
|
+
:bic => 'PBNKDEFF370',
|
63
|
+
:iban => 'DE37112589611964645802',
|
64
|
+
:amount => 102.50,
|
65
|
+
:reference => 'XYZ-1234/123',
|
66
|
+
:remittance_information => 'Rechnung vom 22.08.2013'
|
67
|
+
ct.add_transaction ...
|
68
|
+
|
69
|
+
# Last: create XML string
|
70
|
+
xml_string = ct.to_xml
|
45
71
|
```
|
46
72
|
|
47
73
|
Make sure to read the code and the specs!
|
48
74
|
|
49
75
|
|
76
|
+
## Changelog
|
77
|
+
|
78
|
+
https://github.com/salesking/sepa_king/releases
|
79
|
+
|
80
|
+
|
50
81
|
## Resources
|
51
82
|
|
52
83
|
* http://www.ebics.de/index.php?id=77
|
@@ -1,48 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module SEPA
|
3
|
-
class CreditTransaction
|
4
|
-
include TextConverter
|
5
|
-
attr_reader :name, :iban, :bic, :amount, :reference, :remittance_information
|
6
|
-
|
7
|
-
def initialize(options)
|
8
|
-
options.each_pair do |k,v|
|
9
|
-
send("#{k}=", v)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def name=(value)
|
14
|
-
raise ArgumentError.new('Name is missing') unless value
|
15
|
-
@name = convert_text(value)
|
16
|
-
end
|
17
|
-
|
18
|
-
def iban=(value)
|
19
|
-
raise ArgumentError.new('IBAN is missing') unless value
|
20
|
-
raise ArgumentError.new("IBAN has wrong length: #{value.length}, must be between 15-34") unless value.length.between?(15,34)
|
21
|
-
@iban = value
|
22
|
-
end
|
23
|
-
|
24
|
-
def bic=(value)
|
25
|
-
raise ArgumentError.new('BIC is missing') unless value
|
26
|
-
raise ArgumentError.new("BIC has wrong length: #{value.length} must be between 8-11") unless value.length.between?(8,11)
|
27
|
-
@bic = value
|
28
|
-
end
|
29
|
-
|
30
|
-
def amount=(value)
|
31
|
-
raise ArgumentError.new('Amount is not a number') unless value.is_a?(Numeric)
|
32
|
-
raise ArgumentError.new('Amount cannot be zero') if value.zero?
|
33
|
-
raise ArgumentError.new('Amount cannot be negative') if value < 0
|
34
|
-
@amount = value
|
35
|
-
end
|
36
|
-
|
37
|
-
def reference=(value)
|
38
|
-
raise ArgumentError.new('Reference is missing') unless value
|
39
|
-
raise ArgumentError.new("Reference has wrong length: #{value.length}, must be 35 maximum") if value.length > 35
|
40
|
-
@reference = convert_text(value)
|
41
|
-
end
|
42
|
-
|
43
|
-
def remittance_information=(value)
|
44
|
-
raise ArgumentError.new('Remittance information is missing') unless value
|
45
|
-
@remittance_information = convert_text(value)
|
46
|
-
end
|
3
|
+
class CreditTransaction < Transaction
|
47
4
|
end
|
48
5
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module SEPA
|
4
|
-
class
|
4
|
+
class CreditTransfer
|
5
5
|
attr_reader :debitor, :transactions
|
6
6
|
|
7
7
|
def initialize(debitor_options)
|
@@ -76,8 +76,10 @@ module SEPA
|
|
76
76
|
builder.IBAN(transaction.iban)
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
80
|
-
builder.
|
79
|
+
if transaction.remittance_information
|
80
|
+
builder.RmtInf do
|
81
|
+
builder.Ustrd(transaction.remittance_information)
|
82
|
+
end
|
81
83
|
end
|
82
84
|
end
|
83
85
|
end
|
@@ -1,52 +1,17 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module SEPA
|
3
|
-
class DebtTransaction
|
4
|
-
|
5
|
-
attr_reader :name, :iban, :bic, :amount, :reference, :mandate_id, :mandate_date_of_signature
|
6
|
-
|
7
|
-
def initialize(options)
|
8
|
-
options.each_pair do |k,v|
|
9
|
-
send("#{k}=", v)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def name=(value)
|
14
|
-
raise ArgumentError.new('Name is missing') unless value
|
15
|
-
@name = convert_text(value)
|
16
|
-
end
|
17
|
-
|
18
|
-
def iban=(value)
|
19
|
-
raise ArgumentError.new('IBAN is missing') unless value
|
20
|
-
raise ArgumentError.new("IBAN has wrong length: #{value.length}, must be between 15-34") unless value.length.between?(15,34)
|
21
|
-
@iban = value
|
22
|
-
end
|
23
|
-
|
24
|
-
def bic=(value)
|
25
|
-
raise ArgumentError.new('BIC is missing') unless value
|
26
|
-
raise ArgumentError.new("BIC has wrong length: #{value.length} must be between 8-11") unless value.length.between?(8,11)
|
27
|
-
@bic = value
|
28
|
-
end
|
29
|
-
|
30
|
-
def amount=(value)
|
31
|
-
raise ArgumentError.new('Amount is not a Number') unless value.is_a?(Numeric)
|
32
|
-
raise ArgumentError.new('Amount cannot be zero') if value.zero?
|
33
|
-
raise ArgumentError.new('Amount cannot be negative') if value < 0
|
34
|
-
@amount = value
|
35
|
-
end
|
36
|
-
|
37
|
-
def reference=(value)
|
38
|
-
raise ArgumentError.new('Reference is missing') unless value
|
39
|
-
raise ArgumentError.new("Reference has wrong length: #{value.length}, must be 35 maximum") if value.length > 35
|
40
|
-
@reference = convert_text(value)
|
41
|
-
end
|
3
|
+
class DebtTransaction < Transaction
|
4
|
+
attr_reader :mandate_id, :mandate_date_of_signature
|
42
5
|
|
43
6
|
def mandate_id=(value)
|
44
|
-
raise ArgumentError.new('Mandate ID is missing')
|
7
|
+
raise ArgumentError.new('Mandate ID is missing') if value.nil? || value.empty?
|
8
|
+
raise ArgumentError.new("Mandate ID is too long: #{value.length}, must be 35 maximum") if value.length > 35
|
45
9
|
@mandate_id = convert_text(value)
|
46
10
|
end
|
47
11
|
|
48
12
|
def mandate_date_of_signature=(value)
|
49
13
|
raise ArgumentError.new('Mandate Date of Signature is missing') unless value.is_a?(Date)
|
14
|
+
raise ArgumentError.new('Mandate Date of Signature is in the future') if value > Date.today
|
50
15
|
@mandate_date_of_signature = value
|
51
16
|
end
|
52
17
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module SEPA
|
4
|
-
class
|
4
|
+
class DirectDebit
|
5
5
|
attr_reader :creditor, :transactions
|
6
6
|
|
7
7
|
def initialize(creditor_options)
|
@@ -94,6 +94,11 @@ module SEPA
|
|
94
94
|
builder.IBAN(transaction.iban)
|
95
95
|
end
|
96
96
|
end
|
97
|
+
if transaction.remittance_information
|
98
|
+
builder.RmtInf do
|
99
|
+
builder.Ustrd(transaction.remittance_information)
|
100
|
+
end
|
101
|
+
end
|
97
102
|
end
|
98
103
|
end
|
99
104
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module SEPA
|
3
|
+
class Transaction
|
4
|
+
include TextConverter
|
5
|
+
attr_reader :name, :iban, :bic, :amount, :reference, :remittance_information
|
6
|
+
|
7
|
+
def initialize(options)
|
8
|
+
options.each_pair do |k,v|
|
9
|
+
send("#{k}=", v)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def name=(value)
|
14
|
+
raise ArgumentError.new('Name is missing') if value.nil? || value.empty?
|
15
|
+
raise ArgumentError.new("Name is too long: #{value.length}, must be 70 maximum") if value.length > 70
|
16
|
+
@name = convert_text(value)
|
17
|
+
end
|
18
|
+
|
19
|
+
def iban=(value)
|
20
|
+
raise ArgumentError.new('IBAN is missing') if value.nil? || value.empty?
|
21
|
+
raise ArgumentError.new('IBAN is invalid') unless IBANTools::IBAN.valid?(value)
|
22
|
+
@iban = value
|
23
|
+
end
|
24
|
+
|
25
|
+
def bic=(value)
|
26
|
+
raise ArgumentError.new('BIC is missing') if value.nil? || value.empty?
|
27
|
+
raise ArgumentError.new("BIC has wrong length: #{value.length} must be between 8-11") unless value.length.between?(8,11)
|
28
|
+
@bic = value
|
29
|
+
end
|
30
|
+
|
31
|
+
def amount=(value)
|
32
|
+
raise ArgumentError.new('Amount is not a number') unless value.is_a?(Numeric)
|
33
|
+
raise ArgumentError.new('Amount cannot be zero') if value.zero?
|
34
|
+
raise ArgumentError.new('Amount cannot be negative') if value < 0
|
35
|
+
raise ArgumentError.new('Amount has more than 2 digits') if value.round(2) != value
|
36
|
+
@amount = value
|
37
|
+
end
|
38
|
+
|
39
|
+
def reference=(value)
|
40
|
+
raise ArgumentError.new('Reference is missing') if value.nil? || value.empty?
|
41
|
+
raise ArgumentError.new("Reference is too long: #{value.length}, must be 35 maximum") if value.length > 35
|
42
|
+
@reference = convert_text(value)
|
43
|
+
end
|
44
|
+
|
45
|
+
def remittance_information=(value)
|
46
|
+
if value
|
47
|
+
raise ArgumentError.new('Remittance information has to be a string') unless value.is_a?(String)
|
48
|
+
raise ArgumentError.new('Remittance information cannot be blank') if value.empty?
|
49
|
+
raise ArgumentError.new("Remittance information is too long: #{value.length}, must be 140 maximum") if value.length > 140
|
50
|
+
end
|
51
|
+
@remittance_information = convert_text(value)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/sepa_king/version.rb
CHANGED
data/lib/sepa_king.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'i18n'
|
2
2
|
require 'bigdecimal'
|
3
3
|
require 'builder'
|
4
|
+
require 'iban-tools'
|
4
5
|
|
5
6
|
require 'sepa_king/text_converter'
|
6
7
|
require 'sepa_king/account'
|
8
|
+
require 'sepa_king/transaction'
|
7
9
|
require 'sepa_king/debt_transaction'
|
8
10
|
require 'sepa_king/credit_transaction'
|
9
11
|
require 'sepa_king/exception'
|
10
|
-
require 'sepa_king/
|
11
|
-
require 'sepa_king/
|
12
|
+
require 'sepa_king/direct_debit'
|
13
|
+
require 'sepa_king/credit_transfer'
|
data/sepa_king.gemspec
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
4
|
require 'sepa_king/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
|
-
s.name
|
7
|
-
s.version
|
7
|
+
s.name = 'sepa_king'
|
8
|
+
s.version = SEPA::VERSION
|
9
|
+
s.authors = ['Georg Leciejewski', 'Georg Ledermann']
|
10
|
+
s.email = ['gl@salesking.eu', 'mail@georg-ledermann.de']
|
11
|
+
s.description = 'Implemention of pain.001.002.03 and pain.008.002.02 (ISO 20022)'
|
12
|
+
s.summary = 'Generate SEPA XML files with Ruby ... the easy way'
|
13
|
+
s.homepage = 'http://github.com/salesking/sepa_king'
|
14
|
+
s.license = 'MIT'
|
8
15
|
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.summary = %q{Generate SEPA XML files with Ruby .. the easy way}
|
13
|
-
s.description = %q{}
|
14
|
-
s.email = %q{gl@salesking.eu}
|
15
|
-
s.extra_rdoc_files = ['README.markdown']
|
16
|
-
s.executables = nil
|
17
|
-
s.files = `git ls-files`.split("\n").reject{|i| i[/^docs\//] }
|
18
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
-
|
20
|
-
s.homepage = %q{http://github.com/salesking/sepa_king}
|
16
|
+
s.files = `git ls-files`.split($/)
|
17
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
21
19
|
s.require_paths = ['lib']
|
22
|
-
s.rubygems_version = %q{1.6.2}
|
23
20
|
|
24
21
|
s.add_runtime_dependency 'i18n'
|
25
22
|
s.add_runtime_dependency 'builder'
|
23
|
+
s.add_runtime_dependency 'iban-tools'
|
26
24
|
|
25
|
+
s.add_development_dependency 'bundler', '~> 1.3'
|
27
26
|
s.add_development_dependency 'rspec'
|
28
27
|
s.add_development_dependency 'simplecov'
|
29
|
-
s.add_development_dependency '
|
28
|
+
s.add_development_dependency 'coveralls'
|
29
|
+
s.add_development_dependency 'rake'
|
30
30
|
s.add_development_dependency 'libxml-ruby'
|
31
31
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe SEPA::CreditTransfer do
|
5
|
+
it 'should create valid XML file' do
|
6
|
+
ct = SEPA::CreditTransfer.new :name => 'Schuldner GmbH',
|
7
|
+
:bic => 'BANKDEFFXXX',
|
8
|
+
:iban => 'DE87200500001234567890'
|
9
|
+
|
10
|
+
ct.add_transaction :name => 'Telekomiker AG',
|
11
|
+
:bic => 'PBNKDEFF370',
|
12
|
+
:iban => 'DE37112589611964645802',
|
13
|
+
:amount => 102.50,
|
14
|
+
:reference => 'XYZ-1234/123',
|
15
|
+
:remittance_information => 'Rechnung vom 22.08.2013'
|
16
|
+
|
17
|
+
ct.add_transaction :name => 'Amazonas GmbH',
|
18
|
+
:bic => 'TUBDDEDDXXX',
|
19
|
+
:iban => 'DE27793589132923472195',
|
20
|
+
:amount => 59.00,
|
21
|
+
:reference => 'XYZ-5678/456',
|
22
|
+
:remittance_information => 'Rechnung vom 21.08.2013'
|
23
|
+
|
24
|
+
XML::Document.string(ct.to_xml).should validate_against('pain.001.002.03.xsd')
|
25
|
+
end
|
26
|
+
end
|
@@ -5,12 +5,49 @@ describe SEPA::DebtTransaction do
|
|
5
5
|
it 'should initialize a new transaction' do
|
6
6
|
lambda{
|
7
7
|
SEPA::DebtTransaction.new :name => 'Zahlemann & Söhne Gbr',
|
8
|
-
:iban => 'DE21500500009876543210',
|
9
8
|
:bic => 'SPUEDE2UXXX',
|
9
|
+
:iban => 'DE21500500009876543210',
|
10
10
|
:amount => 39.99,
|
11
11
|
:reference => 'XYZ-1234/123',
|
12
|
+
:remittance_information => 'Vielen Dank für Ihren Einkauf!',
|
12
13
|
:mandate_id => 'K-02-2011-12345',
|
13
|
-
:mandate_date_of_signature => Date.new(2011,
|
14
|
+
:mandate_date_of_signature => Date.new(2011,1,25)
|
14
15
|
}.should_not raise_error
|
15
16
|
end
|
17
|
+
|
18
|
+
context 'Mandate Date of Signature' do
|
19
|
+
it 'should allow valid value' do
|
20
|
+
[ Date.today, Date.today - 1 ].each do |valid_value|
|
21
|
+
lambda {
|
22
|
+
SEPA::DebtTransaction.new :mandate_date_of_signature => valid_value
|
23
|
+
}.should_not raise_error
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should not allow invalid value' do
|
28
|
+
[ nil, '2010-12-01', Date.today + 1 ].each do |invalid_value|
|
29
|
+
lambda {
|
30
|
+
SEPA::DebtTransaction.new :mandate_date_of_signature => invalid_value
|
31
|
+
}.should raise_error(ArgumentError, /Signature/)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'Mandate ID' do
|
37
|
+
it 'should allow valid value' do
|
38
|
+
[ 'XYZ-123', 'X' * 35 ].each do |valid_value|
|
39
|
+
lambda {
|
40
|
+
SEPA::DebtTransaction.new :mandate_id => valid_value
|
41
|
+
}.should_not raise_error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should not allow invalid value' do
|
46
|
+
[ nil, '', 'X' * 36 ].each do |invalid_value|
|
47
|
+
lambda {
|
48
|
+
SEPA::DebtTransaction.new :mandate_id => invalid_value
|
49
|
+
}.should raise_error(ArgumentError, /Mandate ID/)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
16
53
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe SEPA::DirectDebit do
|
5
|
+
it 'should create valid XML file' do
|
6
|
+
dd = SEPA::DirectDebit.new :name => 'Gläubiger GmbH',
|
7
|
+
:bic => 'BANKDEFFXXX',
|
8
|
+
:iban => 'DE87200500001234567890',
|
9
|
+
:identifier => 'DE98ZZZ09999999999'
|
10
|
+
|
11
|
+
dd.add_transaction :name => 'Zahlemann & Söhne GbR',
|
12
|
+
:bic => 'SPUEDE2UXXX',
|
13
|
+
:iban => 'DE21500500009876543210',
|
14
|
+
:amount => 39.99,
|
15
|
+
:reference => 'XYZ/2013-08-ABO/12345',
|
16
|
+
:remittance_information => 'Unsere Rechnung vom 10.08.2013',
|
17
|
+
:mandate_id => 'K-02-2011-12345',
|
18
|
+
:mandate_date_of_signature => Date.new(2011,1,25)
|
19
|
+
|
20
|
+
dd.add_transaction :name => 'Meier & Schulze oHG',
|
21
|
+
:bic => 'GENODEF1JEV',
|
22
|
+
:iban => 'DE68210501700012345678',
|
23
|
+
:amount => 750.00,
|
24
|
+
:reference => 'XYZ/2013-08-ABO/6789',
|
25
|
+
:remittance_information => 'Vielen Dank für Ihren Einkauf!',
|
26
|
+
:mandate_id => 'K-08-2010-42123',
|
27
|
+
:mandate_date_of_signature => Date.new(2010,7,25)
|
28
|
+
|
29
|
+
XML::Document.string(dd.to_xml).should validate_against('pain.008.002.02.xsd')
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe SEPA::Transaction do
|
5
|
+
context 'Name' do
|
6
|
+
it 'should accept valid value' do
|
7
|
+
[ 'Manfred Mustermann III.', 'Zahlemann & Söhne GbR', 'X' * 70 ].each do |value_value|
|
8
|
+
lambda {
|
9
|
+
SEPA::CreditTransaction.new :name => value_value
|
10
|
+
}.should_not raise_error
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should not accept invalid value' do
|
15
|
+
[ nil, '', 'X' * 71 ].each do |invalue_value|
|
16
|
+
lambda {
|
17
|
+
SEPA::CreditTransaction.new :name => invalue_value
|
18
|
+
}.should raise_error(ArgumentError, /Name/)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'IBAN' do
|
24
|
+
it 'should accept valid value' do
|
25
|
+
[ 'DE21500500009876543210', 'PL61109010140000071219812874' ].each do |value_value|
|
26
|
+
lambda {
|
27
|
+
SEPA::CreditTransaction.new :iban => value_value
|
28
|
+
}.should_not raise_error
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should not accept invalid value' do
|
33
|
+
[ nil, '', 'invalid' ].each do |invalue_value|
|
34
|
+
lambda {
|
35
|
+
SEPA::CreditTransaction.new :iban => invalue_value
|
36
|
+
}.should raise_error(ArgumentError, /IBAN/)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'BIC' do
|
42
|
+
it 'should accept valid value' do
|
43
|
+
[ 'DEUTDEFF', 'DEUTDEFF500', 'SPUEDE2UXXX' ].each do |value_value|
|
44
|
+
lambda {
|
45
|
+
SEPA::CreditTransaction.new :bic => value_value
|
46
|
+
}.should_not raise_error
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should not accept invalid value' do
|
51
|
+
[ nil, '', 'invalid' ].each do |invalue_value|
|
52
|
+
lambda {
|
53
|
+
SEPA::CreditTransaction.new :bic => invalue_value
|
54
|
+
}.should raise_error(ArgumentError, /BIC/)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'Amount' do
|
60
|
+
it 'should accept valid value' do
|
61
|
+
[ 0.01, 1, 100, 100.00, 99.99, 1234567890.12, BigDecimal("10") ].each do |value_value|
|
62
|
+
lambda {
|
63
|
+
SEPA::CreditTransaction.new :amount => value_value
|
64
|
+
}.should_not raise_error
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should not accept invalid value' do
|
69
|
+
[ nil, 0, -3, 1.23456 ].each do |invalue_value|
|
70
|
+
lambda {
|
71
|
+
SEPA::CreditTransaction.new :amount => invalue_value
|
72
|
+
}.should raise_error(ArgumentError, /Amount/)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'Reference' do
|
78
|
+
it 'should accept valid value' do
|
79
|
+
[ 'ABC-1234/78.0', 'X' * 35 ].each do |value_value|
|
80
|
+
lambda {
|
81
|
+
SEPA::CreditTransaction.new :reference => value_value
|
82
|
+
}.should_not raise_error
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should not accept invalid value' do
|
87
|
+
[ nil, '', 'X' * 36 ].each do |invalue_value|
|
88
|
+
lambda {
|
89
|
+
SEPA::CreditTransaction.new :reference => invalue_value
|
90
|
+
}.should raise_error(ArgumentError, /Reference/)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'Remittance information' do
|
96
|
+
it 'should allow valid value' do
|
97
|
+
[ nil, 'Bonus', 'X' * 140 ].each do |valid_value|
|
98
|
+
lambda {
|
99
|
+
SEPA::CreditTransaction.new :remittance_information => valid_value
|
100
|
+
}.should_not raise_error
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should not allow invalid value' do
|
105
|
+
[ '', 'X' * 141, 42 ].each do |invalid_value|
|
106
|
+
lambda {
|
107
|
+
SEPA::CreditTransaction.new :remittance_information => invalid_value
|
108
|
+
}.should raise_error(ArgumentError, /Remittance/)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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.3
|
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: 2013-08-
|
12
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
@@ -39,6 +39,34 @@ dependencies:
|
|
39
39
|
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: iban-tools
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: bundler
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.3'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.3'
|
42
70
|
- !ruby/object:Gem::Dependency
|
43
71
|
name: rspec
|
44
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,20 +95,34 @@ dependencies:
|
|
67
95
|
- - '>='
|
68
96
|
- !ruby/object:Gem::Version
|
69
97
|
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: coveralls
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
70
112
|
- !ruby/object:Gem::Dependency
|
71
113
|
name: rake
|
72
114
|
requirement: !ruby/object:Gem::Requirement
|
73
115
|
requirements:
|
74
116
|
- - '>='
|
75
117
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0
|
118
|
+
version: '0'
|
77
119
|
type: :development
|
78
120
|
prerelease: false
|
79
121
|
version_requirements: !ruby/object:Gem::Requirement
|
80
122
|
requirements:
|
81
123
|
- - '>='
|
82
124
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0
|
125
|
+
version: '0'
|
84
126
|
- !ruby/object:Gem::Dependency
|
85
127
|
name: libxml-ruby
|
86
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,12 +137,13 @@ dependencies:
|
|
95
137
|
- - '>='
|
96
138
|
- !ruby/object:Gem::Version
|
97
139
|
version: '0'
|
98
|
-
description:
|
99
|
-
email:
|
140
|
+
description: Implemention of pain.001.002.03 and pain.008.002.02 (ISO 20022)
|
141
|
+
email:
|
142
|
+
- gl@salesking.eu
|
143
|
+
- mail@georg-ledermann.de
|
100
144
|
executables: []
|
101
145
|
extensions: []
|
102
|
-
extra_rdoc_files:
|
103
|
-
- README.markdown
|
146
|
+
extra_rdoc_files: []
|
104
147
|
files:
|
105
148
|
- .gitignore
|
106
149
|
- .rspec
|
@@ -114,26 +157,29 @@ files:
|
|
114
157
|
- lib/sepa_king.rb
|
115
158
|
- lib/sepa_king/account.rb
|
116
159
|
- lib/sepa_king/credit_transaction.rb
|
117
|
-
- lib/sepa_king/
|
160
|
+
- lib/sepa_king/credit_transfer.rb
|
118
161
|
- lib/sepa_king/debt_transaction.rb
|
119
|
-
- lib/sepa_king/
|
162
|
+
- lib/sepa_king/direct_debit.rb
|
120
163
|
- lib/sepa_king/exception.rb
|
121
164
|
- lib/sepa_king/text_converter.rb
|
165
|
+
- lib/sepa_king/transaction.rb
|
122
166
|
- lib/sepa_king/version.rb
|
123
167
|
- sepa_king.gemspec
|
124
168
|
- spec/fixtures/pain.001.002.03.xml
|
125
169
|
- spec/fixtures/pain.008.002.02.xml
|
126
170
|
- spec/sepa_king/account_spec.rb
|
127
171
|
- spec/sepa_king/credit_transaction_spec.rb
|
128
|
-
- spec/sepa_king/
|
172
|
+
- spec/sepa_king/credit_transfer_spec.rb
|
129
173
|
- spec/sepa_king/debt_transaction_spec.rb
|
130
|
-
- spec/sepa_king/
|
174
|
+
- spec/sepa_king/direct_debit_spec.rb
|
131
175
|
- spec/sepa_king/text_converter_spec.rb
|
176
|
+
- spec/sepa_king/transaction_spec.rb
|
132
177
|
- spec/sepa_king/validation_spec.rb
|
133
178
|
- spec/spec_helper.rb
|
134
179
|
- spec/support/custom_matcher.rb
|
135
180
|
homepage: http://github.com/salesking/sepa_king
|
136
|
-
licenses:
|
181
|
+
licenses:
|
182
|
+
- MIT
|
137
183
|
metadata: {}
|
138
184
|
post_install_message:
|
139
185
|
rdoc_options: []
|
@@ -154,16 +200,17 @@ rubyforge_project:
|
|
154
200
|
rubygems_version: 2.0.7
|
155
201
|
signing_key:
|
156
202
|
specification_version: 4
|
157
|
-
summary: Generate SEPA XML files with Ruby
|
203
|
+
summary: Generate SEPA XML files with Ruby ... the easy way
|
158
204
|
test_files:
|
159
205
|
- spec/fixtures/pain.001.002.03.xml
|
160
206
|
- spec/fixtures/pain.008.002.02.xml
|
161
207
|
- spec/sepa_king/account_spec.rb
|
162
208
|
- spec/sepa_king/credit_transaction_spec.rb
|
163
|
-
- spec/sepa_king/
|
209
|
+
- spec/sepa_king/credit_transfer_spec.rb
|
164
210
|
- spec/sepa_king/debt_transaction_spec.rb
|
165
|
-
- spec/sepa_king/
|
211
|
+
- spec/sepa_king/direct_debit_spec.rb
|
166
212
|
- spec/sepa_king/text_converter_spec.rb
|
213
|
+
- spec/sepa_king/transaction_spec.rb
|
167
214
|
- spec/sepa_king/validation_spec.rb
|
168
215
|
- spec/spec_helper.rb
|
169
216
|
- spec/support/custom_matcher.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe SEPA::CreditTransferInitiation do
|
5
|
-
it 'should create valid XML file' do
|
6
|
-
cti = SEPA::CreditTransferInitiation.new :name => 'Schuldner GmbH',
|
7
|
-
:bic => 'BANKDEFFXXX',
|
8
|
-
:iban => 'DE87200500001234567890',
|
9
|
-
:identifier => 'DE98ZZZ09999999999'
|
10
|
-
|
11
|
-
cti.add_transaction :name => 'Telekomiker AG',
|
12
|
-
:iban => 'DE37112589611964645802',
|
13
|
-
:bic => 'PBNKDEFF370',
|
14
|
-
:amount => 102.50,
|
15
|
-
:reference => 'XYZ-1234/123',
|
16
|
-
:remittance_information => 'Rechnung vom 22.08.2013'
|
17
|
-
|
18
|
-
cti.add_transaction :name => 'Amazonas GmbH',
|
19
|
-
:iban => 'DE27793589132923472195',
|
20
|
-
:bic => 'TUBDDEDDXXX',
|
21
|
-
:amount => 59.00,
|
22
|
-
:reference => 'XYZ-5678/456',
|
23
|
-
:remittance_information => 'Rechnung om 21.08.2013'
|
24
|
-
|
25
|
-
XML::Document.string(cti.to_xml).should validate_against('pain.001.002.03.xsd')
|
26
|
-
end
|
27
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe SEPA::DirectDebitInitiation do
|
5
|
-
it 'should create valid XML file' do
|
6
|
-
ddi = SEPA::DirectDebitInitiation.new :name => 'Gläubiger GmbH',
|
7
|
-
:bic => 'BANKDEFFXXX',
|
8
|
-
:iban => 'DE87200500001234567890',
|
9
|
-
:identifier => 'DE98ZZZ09999999999'
|
10
|
-
|
11
|
-
ddi.add_transaction :name => 'Zahlemann & Söhne GbR',
|
12
|
-
:iban => 'DE21500500009876543210',
|
13
|
-
:bic => 'SPUEDE2UXXX',
|
14
|
-
:amount => 39.99,
|
15
|
-
:reference => 'XYZ/2013-08-ABO/12345',
|
16
|
-
:mandate_id => 'K-02-2011-12345',
|
17
|
-
:mandate_date_of_signature => Date.new(2011,01,25)
|
18
|
-
|
19
|
-
ddi.add_transaction :name => 'Meier & Schulze oHG',
|
20
|
-
:iban => 'DE68210501700012345678',
|
21
|
-
:bic => 'GENODEF1JEV',
|
22
|
-
:amount => 750.00,
|
23
|
-
:reference => 'XYZ/2013-08-ABO/6789',
|
24
|
-
:mandate_id => 'K-08-2010-42123',
|
25
|
-
:mandate_date_of_signature => Date.new(2010,07,25)
|
26
|
-
|
27
|
-
XML::Document.string(ddi.to_xml).should validate_against('pain.008.002.02.xsd')
|
28
|
-
end
|
29
|
-
end
|