Giter Site home page Giter Site logo

Comments (10)

sabas avatar sabas commented on May 28, 2024

Thanks @cuthbert for the report.
I wonder if, instead of doing that way (in your pull request), it would be better to add a counter to the key like I did with the "extensions"
https://github.com/php-edifact/edifact/blob/master/src/EDI/Interpreter.php#L266

You'd have 5 keys itemNumberIdentification1, itemNumberIdentification2, ... instead of another level in the array.

What do you think?

from edifact.

cuthbert avatar cuthbert commented on May 28, 2024

Yes, what bothers me on my solution is the different type of structure a user might find behind the key.
To keep the output consistent it would make sense to numerate them.
But on the other side it would be better to have it more flexible (so without a number postfix and with an array). And also with your suggestion you (as a user) have to know that the number is not part of the EDIFACT naming definition, which applies for the rest of the fields. I would count the naming strictly by the EDIFACT definition more in for this.

from edifact.

sabas avatar sabas commented on May 28, 2024

Another 'business case' I would like to introduce is how it should be handled when encoding back to Edifact with EDI\Encoder (this is done by some people I talked to).
The criteria IMHO would be that Encoder(Interpreter(x)) == x

Pinging @mtdavidson @Azzurvif if they want to give feedback on this bugfix.

from edifact.

sabas avatar sabas commented on May 28, 2024

I have the same problem today with BGM, apparently they changed the second data element to composite and the name is "document" for the two composites (I checked D16A).
Can we simply do this in case of multiple entries?

$jsonelements[$d_desc_attr['name'].$d_desc_attr['id']] 

Here's my solution (replacing line 303)

                $elementKey = $d_desc_attr['name'];
                if (isset($jsonelements[$elementKey])) {
                    $elementKey = $d_desc_attr['name'].$d_desc_attr['id'];
                }
                $jsonelements[$elementKey] = $jsoncomposite;

from edifact.

cuthbert avatar cuthbert commented on May 28, 2024

So the first one would be the name and the rest numbered?

But generally it's fine for me. Most important thing for me is to get the data.

from edifact.

sabas avatar sabas commented on May 28, 2024

Exactly,
here's the example.
image

If you are ok with this could you update the PR so I'd merge your contribution?

from edifact.

cuthbert avatar cuthbert commented on May 28, 2024

Your example (and the code) leads in the case with the PIA I can have more than 2 (up to 5) of the same elements. So the additional would also be overwritten. My example just has to C212. The specification allows 5.

Then I would follow the way in the Encoder example you stated and just use $n for the enumeration postfix

from edifact.

sabas avatar sabas commented on May 28, 2024

You're right, sorry :-)

from edifact.

cuthbert avatar cuthbert commented on May 28, 2024

Done.

from edifact.

sabas avatar sabas commented on May 28, 2024

Merged, thanks!

from edifact.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.