Skip to content

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

@TobiTobiM

Description

@TobiTobiM

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions