-
Notifications
You must be signed in to change notification settings - Fork 24
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
Possibility of extracting address fields ? #64
Comments
Good morning Christian, thank you for your very kind and polite request. 😃 Yes, it is definitely possible to extend camt_parser accordingly. Based on the code you linked to, you are currently using name and iban from the transactions object. It provides the convenience of automatically selecting the respective creditor or debitor that would probably be of interest. The creditor or debitor allow access through statement.entries.each do |entry|
related_party = entry.transactions[0].credit? ? entry.transactions[0].debitor : entry.transactions[0].creditor
street_name = related_party.xml_data.xpath('PstlAdr/StrtNm/text()').text
# ...
end So it would be possible for you to use that approach to get to the data. Right now I would imagine a convenient access like: address = entry.transactions[0].postal_address
# for unstructured address data
address.lines
# => ["Chemin du Closel 2", "1020 Renens VD"]
# for structured address data
address.street_name
# => "Avenue de Milan"
address.building_number
# => "26"
address.postal_code
# => "1007"
address.town_name
# => "Lausanne"
address.country
# => "CH" With that all the data would then be conveniently accessible, and also distinctly per related party by going through creditor and debitor if needed. Would you have anything else in mind here or is this already sufficient for your use case? Best, |
Hi Christian, please have a look at #65 This adds what I had in mind based on your request. Your feedback would be appreciated. Best, |
Good evening, Sorry for the late reply but I was out walking all day with my family! And thank you for responding so quickly, BRAVO for the support and responsiveness! I studied the code: It seems correct to me and meets my expectations. I'll try modifying my Gemfile to work with the branch: https://github.com/viafintech/camt_parser/tree/feature/64-add-postal-address-support But since the Ruby language is very new to me, it will take me a little time. THANKS |
Good evening as well, no explanation necessary. Fortunately text patiently waits for people to read it. 😄 Considering that you will need to probably deal with cases where address lines as well as the individual fields are present, I would assume that you might want to get the address into a single column in your CSV file? If so, I might have a suggestion on how to do this in Ruby and could provide you with a pull request or a code snippet based on your code. Best, |
Good evening, So, as expected, I spent a lot of time to successfully create my Docker container (Gemfile) with your test repository (modification of my Gemfile): https://github.com/viafintech/camt_parser/tree/feature/64-add-postal-address-support But finally I got there \o/ Except that I have problems using the 'postal_address' fields! Nothing to do, I tried everything in every direction, I must not have understood how to use them. My test code, lines 32 and 33, can be found here: https://github.com/zuzu59/zcamt2csv/blob/master/app/app.rb Could you please point out my mistake? And yes, I would like to be able to retrieve the 'postal_address' fields in detail in order to be able to create a db with the addresses of the principals thanks again |
Good morning Christian, line 32 is how it would have to be used. The way it is currently implemented is that
<Cdtr>
<Nm>Association MakeRevolution</Nm>
<PstlAdr>
<AdrLine>Chemin du Closel 2</AdrLine>
<AdrLine>1020 Renens VD</AdrLine>
</PstlAdr>
</Cdtr> Here is an example that should work to just get it into the file somehow independent of whether the address data would be provided structured or unstructured. statement.entries.each do |entry|
address = nil
postal_address = entry.transactions[0].postal_address
if postal_address != nil
address = [
postal_address.lines,
street_name,
building_number,
postal_code,
town_name,
country
].flatten.join(' ')
end
csv << [
entry.value_date,
entry.amount,
entry.sign,
entry.additional_information,
entry.transactions[0].remittance_information,
address,
entry.transactions[0].transaction_id,
entry.transactions[0].name,
entry.transactions[0].iban,
]
end If this does not work for you, I would ask you to provide an anonymized example of an XML file, so that I may take a look at whether I got something wrong about where the address is found in your XML file(s). Best, |
Hello, So, I used your sample code to retrieve the address fields and it works fine. I had to make some small corrections because the 'postal_address' table was missing in the concatenation of the 'address' variable. I abandoned the idea of being able to retrieve the details of the address fields because the bank does a bit of nonsense with these addresses at the CAMT level and it was not usable. So that's going well, I have everything I need to be able to work well and I can therefore validate the pull request :-) I am quite surprised, not knowing the Ruby language, to have managed relatively easily to use your dev branch (feature/64-add-postal-address-support) to validate the tests on my code. A former developer who recently retired, I know quite a few computer languages, but unfortunately not Ruby. So I thank you very much for very quickly adding this new possibility of retrieving the address field in camt_parser! thanks again |
Good evening, happy to hear that! Best, |
Good morning, I released it in v2.16.0. Best, |
Good morning,
First of all, a BIG thank you for writing this superb lib (camt_parser) to process these CAMT XML files which are really painful.
Among all the libs I tested, only yours, written in Ruby, worked well but above all can be modified very easily to have the columns you want for extracting the CAMT file !
In order to simplify the life of our financial secretary, who is not a computer scientist, I created a very small WEB service that is very simple to use:
https://github.com/zuzu59/zcamt2csv
This works great, except we need to be able to extract the transaction proxy address columns:
and
And this is where my limits in Ruby are exceeded !
Would it be possible, please, to add in your camt_parser lib the possibility of extracting address fields ?
THANKS
Sincerely
Ch. Zufferey
The text was updated successfully, but these errors were encountered: