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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31135b499c4feea2fb23f4b0378637220e2e36ef
4
- data.tar.gz: 5e073a7c3dd05cfba2ebb4dc88aa6bcdf803faab
3
+ metadata.gz: f0171ca52d3b9667fa2aab79ce037fc9d82b94f1
4
+ data.tar.gz: 108d5e3dfab121f5bb8f154ca8a786fdd0fcc02f
5
5
  SHA512:
6
- metadata.gz: 9b7ee7b9cf4962fa4caa9d807e09bbb5b111cf307aa5dcd58d366110132e15eab841364dc30cb2e6aab3ebd1eb3373bc04eae8a8595d9c76548c0512ec3f1b86
7
- data.tar.gz: f656ff1bba65a9e711fa1f58c169ce637c24ad2af6069c099bb16b7a61a2a10e1bd2822af841b06c1b2138e58a52cb01080c33acdda67d07721a9560e7187a6b
6
+ metadata.gz: 8d270da4b9707bf2e58daa7d58313f90be7578e3cb7b87e4b4da451479b75710c159513ef86f49aab30e4feff4162290eddf9422ac21690e3bd93905042bb6c2
7
+ data.tar.gz: ced4136ed50cb16d4256b081d7ef651b6969a7c11593f6490d9fbfe6d492105455d339a63efc8c39965c365bca85b6b4cde99c3f6a70fe48b4b866000c8e12f4
data/.travis.yml CHANGED
@@ -10,3 +10,4 @@ gemfile:
10
10
  - gemfiles/Gemfile-activemodel-4.0.x
11
11
  - gemfiles/Gemfile-activemodel-4.1.x
12
12
  - gemfiles/Gemfile-activemodel-4.2.x
13
+ sudo: false
@@ -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
@@ -18,11 +18,23 @@ module SEPA
18
18
  def convert_text(value)
19
19
  return unless value
20
20
 
21
- I18n.transliterate(value.to_s).
22
- # Change linebreaks to whitespaces
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SEPA
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
data/lib/sepa_king.rb CHANGED
@@ -4,6 +4,8 @@ require 'bigdecimal'
4
4
  require 'builder'
5
5
  require 'iban-tools'
6
6
 
7
+ require 'core_ext/string'
8
+
7
9
  require 'sepa_king/converter'
8
10
  require 'sepa_king/validator'
9
11
  require 'sepa_king/account'
@@ -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 remove invalid chars' do
9
- expect(convert_text('&@"=<>!')).to eq('')
10
- end
11
-
12
- it 'should not touch valid chars' do
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
@@ -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 Sohne GbR')
237
- expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/Dbtr/Nm', 'Meier Schulze oHG')
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.5.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-06-18 00:00:00.000000000 Z
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