Closed pavlad closed 6 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.
@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.
Thanks @pavlad, really appreciate your response.
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
:
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.
@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?
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
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("
") doc.to_xml end #{organization_number} — 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 .
Finnish banks (including Nordea bank) require the 001.001.03 XML to contain a
Creditor Identifier
and anExternal Organization Identifier Code
for their SEPA transfers.Adding a
Creditor Identifier
toDebtorAccount
andExternal Organization Identifier Code
forAccount
(as it should be available for both creditor as debtor).