salesking / sepa_king

Ruby gem for creating SEPA XML files
MIT License
149 stars 118 forks source link

Incompatibility to Swiss Banks #42

Closed dodgeram closed 8 years ago

dodgeram commented 9 years ago

Hi,

I'm not quite familiar with github and don't want be part of this project, but I've made some improvements you might want to include to this.

Swiss Banks are obviously using a special form of the ISO 20022 standard. They partially use limitations to fields and declare some fields as mandatory that are usually optionally and therefore not implemented here in this package.

See here for the implementation recommendations of SIX, that explain the Swiss modifications: http://www.six-interbank-clearing.com/de/home/standardization/iso-payments/customer-bank/swiss-recommendations.html

I patched the following files to adapt this package, maybe you'd like to take over these changes to this project.

diff -rupN sepa_king-master/lib/sepa_king/message/direct_debit.rb sepa_king-patched/lib/sepa_king/message/direct_debit.rb
--- sepa_king-master/lib/sepa_king/message/direct_debit.rb  2015-03-31 07:44:59.000000000 +0200
+++ sepa_king-patched/lib/sepa_king/message/direct_debit.rb 2015-04-20 18:03:50.313914000 +0200
@@ -86,6 +86,9 @@ module SEPA
     def build_transaction(builder, transaction)
       builder.DrctDbtTxInf do
         builder.PmtId do
+          if transaction.instruction.present?
+            builder.InstrId(transaction.instruction)
+          end
           builder.EndToEndId(transaction.reference)
         end
         builder.InstdAmt('%.2f' % transaction.amount, Ccy: 'EUR')
diff -rupN sepa_king-master/lib/sepa_king/message.rb sepa_king-patched/lib/sepa_king/message.rb
--- sepa_king-master/lib/sepa_king/message.rb   2015-03-31 07:44:59.000000000 +0200
+++ sepa_king-patched/lib/sepa_king/message.rb  2015-04-20 18:17:54.105928000 +0200
@@ -103,6 +103,15 @@ module SEPA
         builder.CtrlSum('%.2f' % amount_total)
         builder.InitgPty do
           builder.Nm(account.name)
+          if account.class == CreditorAccount and account.creditor_identifier.present?
+            builder.Id do
+              builder.OrgId do
+                builder.Othr do
+                  builder.Id(account.creditor_identifier)
+                end
+              end
+            end
+          end
         end
       end
     end

Furthermore I got the following recommendations from our Swiss Bank:

(0001) Der Namespace 'urn:iso:std:iso:20022:tech:xsd:pain.008.003.02' wurde ersetzt durch 'http://www.six-interbank-clearing.com/de/pain.008.001.02.ch.01.xsd', um gegen das XML-Schema testen zu können.

(0001) Hinweis: Statt dem Schweizer XML-Schema wurde das ISO XML-Schema verwendet. Das zu verwendende XML-Schema ist mit den jeweiligen Finanzinstituten abzustimmen.

(0024) Hinweis: <NbOfTxs> wird in der Regel von den Schweizer Instituten nicht geprüft

(0025) Hinweis: <CtrlSum> wird in der Regel von den Schweizer Instituten nicht geprüft.

(0065) Hinweis: <EndToEndId> - In der Schweiz wird die Verwendung von maximal 16 Stellen empfohlen

Only important thing seems to be the change of the namespace, which is currently not possible to set with sepa_king. Maybe you can find a solution to pass it through or set it automatically for Swiss Bank connections.

Cheers, Markus

bhh commented 9 years ago

hehe same problem for austria with the schema except its not a warning and a suggestion they refuse it with the non austrian schema. why is there an international standard if every country adapts it anyway? ;)

sloanecourt commented 9 years ago

Even worse when you get to the Italian CBI* implementation.

ledermann commented 8 years ago

Seems to me that this issue was fixed by #44, so I'm closing it. Please tell if there are still any problems.