sepa_king 0.5.0 → 0.6.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 +4 -4
- data/.travis.yml +1 -0
- data/lib/core_ext/string.rb +27 -0
- data/lib/sepa_king/converter.rb +14 -2
- data/lib/sepa_king/message.rb +7 -0
- data/lib/sepa_king/version.rb +1 -1
- data/lib/sepa_king.rb +2 -0
- data/spec/converter_spec.rb +13 -6
- data/spec/core_ext/string_spec.rb +11 -0
- data/spec/direct_debit_spec.rb +6 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0171ca52d3b9667fa2aab79ce037fc9d82b94f1
|
4
|
+
data.tar.gz: 108d5e3dfab121f5bb8f154ca8a786fdd0fcc02f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d270da4b9707bf2e58daa7d58313f90be7578e3cb7b87e4b4da451479b75710c159513ef86f49aab30e4feff4162290eddf9422ac21690e3bd93905042bb6c2
|
7
|
+
data.tar.gz: ced4136ed50cb16d4256b081d7ef651b6969a7c11593f6490d9fbfe6d492105455d339a63efc8c39965c365bca85b6b4cde99c3f6a70fe48b4b866000c8e12f4
|
data/.travis.yml
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Extend String class to use I18n.transliterate as an instance method
|
4
|
+
#
|
5
|
+
# To have a better ASCII approximation for some languages, it's strongly
|
6
|
+
# recommended to add custom rules in your I18n dictionary like this
|
7
|
+
# example for Germany:
|
8
|
+
#
|
9
|
+
# de:
|
10
|
+
# i18n:
|
11
|
+
# transliterate:
|
12
|
+
# rule:
|
13
|
+
# Ä: 'Ae'
|
14
|
+
# Ö: 'Oe'
|
15
|
+
# Ü: 'Ue'
|
16
|
+
# ä: 'ae'
|
17
|
+
# ö: 'oe'
|
18
|
+
# ü: 'ue'
|
19
|
+
# ß: 'ss'
|
20
|
+
#
|
21
|
+
# Because this stuff is out of scope of this gem, we don't include the rules here
|
22
|
+
|
23
|
+
String.class_eval do
|
24
|
+
def i18n_transliterate(replacement='?')
|
25
|
+
I18n.transliterate(self, replacement)
|
26
|
+
end
|
27
|
+
end
|
data/lib/sepa_king/converter.rb
CHANGED
@@ -18,11 +18,23 @@ module SEPA
|
|
18
18
|
def convert_text(value)
|
19
19
|
return unless value
|
20
20
|
|
21
|
-
|
22
|
-
#
|
21
|
+
value.to_s.
|
22
|
+
# Replace some special characters described as "Best practices" in Chapter 6.2 of this document:
|
23
|
+
# http://www.europeanpaymentscouncil.eu/index.cfm/knowledge-bank/epc-documents/sepa-requirements-for-an-extended-character-set-unicode-subset-best-practices/epc217-08-best-practices-sepa-requirements-for-character-set-ssgpdf/
|
24
|
+
gsub('€','E').
|
25
|
+
gsub('@','(at)').
|
26
|
+
gsub('&', '+').
|
27
|
+
gsub('_','-').
|
28
|
+
|
29
|
+
# Replace non-ASCII characters with an ASCII approximation
|
30
|
+
i18n_transliterate.
|
31
|
+
|
32
|
+
# Replace linebreaks by spaces
|
23
33
|
gsub(/\n+/,' ').
|
34
|
+
|
24
35
|
# Remove all invalid characters
|
25
36
|
gsub(/[^a-zA-Z0-9\ \'\:\?\,\-\(\+\.\)\/]/, '').
|
37
|
+
|
26
38
|
# Remove leading and trailing spaces
|
27
39
|
strip
|
28
40
|
end
|
data/lib/sepa_king/message.rb
CHANGED
@@ -103,6 +103,13 @@ module SEPA
|
|
103
103
|
builder.CtrlSum('%.2f' % amount_total)
|
104
104
|
builder.InitgPty do
|
105
105
|
builder.Nm(account.name)
|
106
|
+
builder.Id do
|
107
|
+
builder.OrgId do
|
108
|
+
builder.Othr do
|
109
|
+
builder.Id(account.creditor_identifier)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end if account.respond_to? :creditor_identifier
|
106
113
|
end
|
107
114
|
end
|
108
115
|
end
|
data/lib/sepa_king/version.rb
CHANGED
data/lib/sepa_king.rb
CHANGED
data/spec/converter_spec.rb
CHANGED
@@ -5,12 +5,11 @@ describe SEPA::Converter do
|
|
5
5
|
include SEPA::Converter::InstanceMethods
|
6
6
|
|
7
7
|
describe :convert_text do
|
8
|
-
it 'should
|
9
|
-
expect(convert_text('
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
expect(convert_text("abc-ABC-0123- ':?,-(+.)/")).to eq("abc-ABC-0123- ':?,-(+.)/")
|
8
|
+
it 'should convert special chars' do
|
9
|
+
expect(convert_text('GmbH & Co. KG')).to eq('GmbH + Co. KG')
|
10
|
+
expect(convert_text('10€')).to eq('10E')
|
11
|
+
expect(convert_text('info@bundesbank.de')).to eq('info(at)bundesbank.de')
|
12
|
+
expect(convert_text('abc_def')).to eq('abc-def')
|
14
13
|
end
|
15
14
|
|
16
15
|
it 'should convert umlaute' do
|
@@ -28,6 +27,14 @@ describe SEPA::Converter do
|
|
28
27
|
expect(convert_text(1234)).to eq('1234')
|
29
28
|
end
|
30
29
|
|
30
|
+
it 'should remove invalid chars' do
|
31
|
+
expect(convert_text('"=<>!')).to eq('')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should not touch valid chars' do
|
35
|
+
expect(convert_text("abc-ABC-0123- ':?,-(+.)/")).to eq("abc-ABC-0123- ':?,-(+.)/")
|
36
|
+
end
|
37
|
+
|
31
38
|
it 'should not touch nil' do
|
32
39
|
expect(convert_text(nil)).to eq(nil)
|
33
40
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe String do
|
5
|
+
describe :i18n_transliterate do
|
6
|
+
it 'should use I18n.transliterate' do
|
7
|
+
expect('Ærøskøbing'.i18n_transliterate).to eq('AEroskobing')
|
8
|
+
expect('Jürgen'.i18n_transliterate).to eq('Jurgen')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/spec/direct_debit_spec.rb
CHANGED
@@ -167,6 +167,10 @@ describe SEPA::DirectDebit do
|
|
167
167
|
expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/GrpHdr/MsgId', /SEPA-KING\/[0-9]+/)
|
168
168
|
end
|
169
169
|
|
170
|
+
it 'should have creditor identifier' do
|
171
|
+
expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/GrpHdr/InitgPty/Id/OrgId/Othr/Id', direct_debit.account.creditor_identifier)
|
172
|
+
end
|
173
|
+
|
170
174
|
it 'should contain <PmtInfId>' do
|
171
175
|
expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/PmtInfId', /SEPA-KING\/[0-9]+\/1/)
|
172
176
|
end
|
@@ -233,8 +237,8 @@ describe SEPA::DirectDebit do
|
|
233
237
|
end
|
234
238
|
|
235
239
|
it 'should contain <Dbtr>' do
|
236
|
-
expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/Dbtr/Nm', 'Zahlemann
|
237
|
-
expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/Dbtr/Nm', 'Meier
|
240
|
+
expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/Dbtr/Nm', 'Zahlemann + Sohne GbR')
|
241
|
+
expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/Dbtr/Nm', 'Meier + Schulze oHG')
|
238
242
|
end
|
239
243
|
|
240
244
|
it 'should contain <DbtrAcct>' do
|
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.
|
4
|
+
version: 0.6.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: 2015-
|
12
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- gemfiles/Gemfile-activemodel-4.0.x
|
174
174
|
- gemfiles/Gemfile-activemodel-4.1.x
|
175
175
|
- gemfiles/Gemfile-activemodel-4.2.x
|
176
|
+
- lib/core_ext/string.rb
|
176
177
|
- lib/schema/pain.001.001.03.xsd
|
177
178
|
- lib/schema/pain.001.002.03.xsd
|
178
179
|
- lib/schema/pain.001.003.03.xsd
|
@@ -195,6 +196,7 @@ files:
|
|
195
196
|
- sepa_king.gemspec
|
196
197
|
- spec/account_spec.rb
|
197
198
|
- spec/converter_spec.rb
|
199
|
+
- spec/core_ext/string_spec.rb
|
198
200
|
- spec/credit_transfer_spec.rb
|
199
201
|
- spec/credit_transfer_transaction_spec.rb
|
200
202
|
- spec/creditor_account_spec.rb
|
@@ -242,6 +244,7 @@ summary: Ruby gem for creating SEPA XML files
|
|
242
244
|
test_files:
|
243
245
|
- spec/account_spec.rb
|
244
246
|
- spec/converter_spec.rb
|
247
|
+
- spec/core_ext/string_spec.rb
|
245
248
|
- spec/credit_transfer_spec.rb
|
246
249
|
- spec/credit_transfer_transaction_spec.rb
|
247
250
|
- spec/creditor_account_spec.rb
|