-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map text according to EPC SEPA conversion table #105
base: master
Are you sure you want to change the base?
Conversation
I think this is stunning in its clarity, following the Best Practices outlined by the EPC. |
Hey guys, thanks for your great work! diff --git a/lib/sepa_king/converter.rb b/lib/sepa_king/converter.rb
index ead034f..9dbea7e 100644
--- a/lib/sepa_king/converter.rb
+++ b/lib/sepa_king/converter.rb
@@ -23,7 +23,7 @@ module InstanceMethods
private_constant :EPC_MAPPING
def convert_text(value)
- return unless value
+ return value unless value.present?
# Map chars according to:
# http://www.europeanpaymentscouncil.eu/index.cfm/knowledge-bank/epc-documents/sepa-requirements-for-an-extended-character-set-unicode-subset-best-practices/
diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb
index 6f0521a..0219fa3 100644
--- a/spec/converter_spec.rb
+++ b/spec/converter_spec.rb
@@ -26,6 +26,10 @@ it 'should convert number' do
expect(convert_text(1234)).to eq('1234')
end
+ it 'should not touch valid chars' do
+ expect(convert_text("abc-ABC-0123- :?,-(+.)/")).to eq("abc-ABC-0123- :?,-(+.)/")
+ end
+
it 'should not touch nil' do
expect(convert_text(nil)).to eq(nil)
end
diff --git a/spec/transaction_spec.rb b/spec/transaction_spec.rb
index d7f8d01..30f5730 100644
--- a/spec/transaction_spec.rb
+++ b/spec/transaction_spec.rb
@@ -68,7 +68,7 @@ it 'should accept valid value' do
end
it 'should not accept invalid value' do
- expect(SEPA::Transaction).not_to accept('', for: :name)
+ expect(SEPA::Transaction).not_to accept('', {}, for: :name)
end
end What do you think? |
This is about the desired behaviour. Do we want to convert an empty hash to Also, something else; am I correct to assume that this block belongs to the |
59d1150
to
6082f4b
Compare
I was wondering: in the official conversion table they suggest both a "basic" and a "long term" replacement. Won't there be any issue introducing html entities (containing & character) if, maybe, the bank isn't ready to process this character at all? It may be a non issue as I haven't tested it myself, but I thought it would we worth talking about. |
We tested with |
Would it be interesting to be able to supply one's own set of replacements? |
@olleolleolle I'm divided about this, as I would rather not handle SEPA conversion in my own project 🤔. FYI I was referring at the conversion table in which I think we can understand that basic character set often means removing them (which seems to be my case): |
Hello, for special characters I followed chapter 6.2 here. For the
Two possible solutions that come to mind are:
What do you think? |
@kiriakosv what we're doing in the meantime is removing those chars. |
I too prefer removing these chars. If everyone is OK we can proceed like this. |
Instead of whitelisting certain characters, we map according to EPC SEPA conversion guidelines.
Resolves #92