salesking / sepa_king

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

External Organization Identifier Code #73

Closed pavlad closed 6 years ago

pavlad commented 6 years ago

Finnish banks (including Nordea bank) require the 001.001.03 XML to contain a Creditor Identifier and an External Organization Identifier Code for their SEPA transfers.

Adding a Creditor Identifier to DebtorAccount and External Organization Identifier Code for Account (as it should be available for both creditor as debtor).

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 81613e3e7baf2e6512a39529f772e934f3e1e652 on playpasshq:external-organization-id-code into 47f3079a95de749416d51e50ecc08284ab33c771 on salesking:master.

carlosiniesta commented 5 years ago

Hey @pavlad,

What happened with this PR? I'm facing this issue too with spanish banks.

@ledermann , I can continue with this if you consider this need some improvements.

pavlad commented 5 years ago

@carlosiniesta Hey, I decided to close the pull request as we realized different banks require the External Organization Identifier Code to be placed in different XML nodes. This means that where I add the code would not make sense for other banks.

That's why I just wrote some code for our exports which depending on the bank searches and injects the External Organization Identifier Code in the correct node using Nokogiri.

carlosiniesta commented 5 years ago

Thanks @pavlad, really appreciate your response.

henrik commented 5 years ago

We ran into the same thing with a Spanish bank (Banco Sabadell). They required the company VAT number (the "CIF") as Document > CstmrCdtTrfInitn > GrpHdr > InitgPty > Id > OrgId > Othr > Id:

screenshot 2019-02-04 15 13 24

Good to know about this decision. Then we'll do the same – generate a file without it, and then add it in later using something like Nokogiri.

henrik commented 5 years ago

@pavlad Co-worker @tskogberg had an interesting idea – would you accept a PR for a general feature to insert a custom node? Then sepa_king wouldn't need to support every single bank variation, but life would be easier for users of the library.

So an API along the lines of this, maybe:

sdd = SEPA::DirectDebit.new(…)

sdd.add_custom_node([ :CstmrCdtTrfInitn, :GrpHdr, :InitgPty, :Id, :OrgId, :Othr, :Id ], "B01234567")

sdd.to_xml

What do you think?

henrik commented 5 years ago

I think we won't contribute that PR after all, but in case it helps others, this is what we (@lavinia) came up with for Banco Sabadell in Spain:

def generate
  xml_document = credit_transfer.to_xml("pain.001.001.03")
  add_organization_number_to_header(xml_document)
end

private

def add_organization_number_to_header(xml_document)
  doc = Nokogiri::XML(xml_document)
  doc.at("CstmrCdtTrfInitn/GrpHdr/InitgPty").add_child("<Id><OrgId><Othr><Id>#{organization_number}</Id></Othr></OrgId></Id>")
  doc.to_xml
end
pavlad commented 5 years ago

Just read this. Glad you have found a workaround!

I still think that that PR is a good idea. I'm considering working on it once I can free up some time for it.

On Wed, Feb 6, 2019 at 5:11 PM Henrik Nyh notifications@github.com wrote:

I think we won't contribute that PR after all, but in case it helps others, this is what we (@Lavinia https://github.com/Lavinia) came up with for Banco Sabadell in Spain:

def generate xml_document = credit_transfer.to_xml("pain.001.001.03") add_organization_number_to_header(xml_document) end

def add_organization_number_to_header(xml_document) doc = Nokogiri::XML(xml_document) doc.at("CstmrCdtTrfInitn/GrpHdr/InitgPty").add_child("#{organization_number}") doc.to_xml end

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/salesking/sepa_king/pull/73#issuecomment-461081876, or mute the thread https://github.com/notifications/unsubscribe-auth/AQ5n219ow8aYeqovYTNtRyR5e2LDupoMks5vKv68gaJpZM4VhW2s .