Skip to content
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

Statement Field generation_date NoMethodError: undefined method `date' for nil:NilClass #35

Open
TobiTobiM opened this issue Nov 13, 2019 · 3 comments

Comments

@TobiTobiM
Copy link

First of all thanks for sharing the code.

I updated cmxl version in my project from 0.2.0 to 1.4.1. Then one of my tests parsing a mt940 is failing.
Quickly i found why this happens. Generation_date in statement wants to read from field :20 or :13
In my case i get from my bank (Commerzbank) field :20 only with reference no extra values are provided.
Field :13 is not provided at all because it is mt942.

def generation_date field(20).date || field(13).date end

Call of field(13) gives nil and then method date fails with

NoMethodError: undefined method `date' for nil:NilClass

:20 exists in mt940 and mt942 so even if there is no generation_date provided in that field field(20).date will not fail. It only returns nil. But then field(13).date is called and gives error mentioned above.

Method generation_date should check if field :13 is provided before call date on it.

@bumi
Copy link
Contributor

bumi commented Nov 13, 2019

Thanks for reporting this.
and without checking the code and the specs this check sounds like a good addition.
Do you want to make a PR for that? that would be amazing!

@TobiTobiM
Copy link
Author

TobiTobiM commented Nov 13, 2019

Sure i can provide a PR. I checked the rspecs as far i can see generation_date is not called. That seems to be the reason why no rpsec is failing.

Edit: I have to revise my statement above. Generation_date is called but all examples have numbers in :20. In my case :20 has a alphanumeric reference

@bumi
Copy link
Contributor

bumi commented Nov 22, 2019

Thanks a lot for the pull request! PR: #36

bumi added a commit that referenced this issue Jan 7, 2020
Issue #35 Avoid undefined method date for nil class if field 13 is not provided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants