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

TradaComs26v3 file Charge lines contain = sign in TCOD TariffDescription #268

Closed
ianpowell2017 opened this issue Aug 1, 2024 · 5 comments
Assignees

Comments

@ianpowell2017
Copy link

Hi, I am a NOOB when it comes to EDI files and so far I have 1.5 weeks of experience!

In a TradaComs file the vendor seems to think its ok to have = in the Tariff Description below

CCD=13+4+:Additional Cyclic Re (Balance to be charged=20.26)+:::+++++++++++83000+1000:ZZ:+++83000+83:+A+S+20000+'

Please advise how I should parse this and the presence of the = sign in the Tariff Description causing the VATP Vat Rate percentage to be parsed incorrectly.

@ianpowell2017
Copy link
Author

Further research https://www.ibm.com/docs/en/i/7.3?topic=clause-symbols-used-in-picture shows that X(40) should allow 40 characters from the EBCDIC character set.
https://en.wikipedia.org/wiki/EBCDIC shows that ( ) and = are valid characters

@cleftheris
Copy link
Contributor

Hi @ianpowell2017 and thanks for your interest in the library.

Generally in any of the 3 well known EDI formats the grammar is what makes the allowed character set. The only invalid chracters would be those that are part of the grammar delimiters. And in many cases even those can be escaped so that they can take part of a component value. Keep in mind that generally Tradacoms is the UK style of EDIFact. They are in a sense verry similar with slight differences in conventions about the implicit tags/segments they use for groups messages as well as default chracters they use for delimiters/separators.

Are you trying to serialize or deserialize?

@ianpowell2017
Copy link
Author

Hi, thanks for the response.
I am trying to deserialise and I get errors when the sender includes = in the text.

cleftheris added a commit that referenced this issue Sep 13, 2024
@cleftheris
Copy link
Contributor

cleftheris commented Sep 13, 2024

Since you need the equals sign to be transmitted. Then the issuer must make use of an escape character in order for any parser such as EDI.Net to be able to treat it as part of the value and not part of the syntax. The default escape character for TRADACOMS is the questionmark ? but you can change it to whatever you have agreed upon with the issuer. Also just for reference in EDI terms the escape character is also called the "release" character.

This would work if send like this out of the box.

CCD=13+4+:Additional Cyclic Re (Balance to be charged?=20.26)+:::+++++++++++83000+1000:ZZ:+++83000+83:+A+S+20000+'

Look for example this transmissing in the tests tradacoms.utilitybill.escape.edi it makes use for a preceding ? every time a reserved character is used. For instance = becomes ?= and ? becomes ?? (same as \t in a json value becomes \t because the backslash is a reserved character).

You could then try to control the escape character you can do so by setting all special characters (advising the serializer).

The following statement sets the escape/release character to @ or even null.

        var grammar = EdiGrammar.NewTradacoms();
        grammar.SetAdvice(
            segmentNameDelimiter: '=',
            componentDataElementSeparator: ':',
            dataElementSeparator: '+',
            segmentTerminator: '\'',
            releaseCharacter: '@',
            reserved: ' ',
            decimalMark: null);

But still you would not get the whole value if the issuer does not escape the character inside the values.

What I am suspecting but cannot verify in resources is that it is a corner case where the parser could be graceful and implicitly escape the Segment name delimiter if and only if

  1. it is unique (not the same with any other special character that is) and at the same time
  2. the EdiTextReader is inside the a component where the role of the segment name delimiter is neutral.

I have made a change to tackle this and will see to release a version.

@cleftheris cleftheris self-assigned this Sep 13, 2024
@cleftheris
Copy link
Contributor

You can check out the nuget package for the v2.0.0-beta02 that contains this enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants