Giter Site home page Giter Site logo

Comments (8)

szocsbarni avatar szocsbarni commented on June 21, 2024 1

yes, that commit indeed solves it, my fault, sorry!

from edifact.

sabas avatar sabas commented on June 21, 2024

You are right..
You can mantain the segment disabling the patching $interpreter->togglePatching(false);
The problem lies here
https://github.com/php-edifact/edifact/blob/master/src/EDI/Interpreter.php#L660
The issue is that the code doesn't check currently if the first element of the next group (or a repetition of the same) is the same.

from edifact.

sabas avatar sabas commented on June 21, 2024

@szocsbarni I pushed a commit which should deal with this case, can you test with a larger sample? Thanks :)

from edifact.

szocsbarni avatar szocsbarni commented on June 21, 2024

@sabas the fix is ok, parsing does not stop on the double NAD command and processes larger files. I am still getting a warning though, will it be eliminated?

Array
(
    [0] => Array
        (
            [text] => The message has some additional segments beyond the maximum repetition allowed (skipped)
            [position] => 4
            [segmentId] => NAD
        )

)

from edifact.

sabas avatar sabas commented on June 21, 2024

On the same file? Strange..
Here's my sample (yes I should write tests.... :/)

require('vendor/autoload.php');

$c = new EDI\Parser();
$file = <<<END
UNA:+.?'
UNB+UNOC:3+0000000000000:14+0000000000000:14+231126:1830+502+0000++++PRICAT'
UNH+1+PRICAT:D:01B:UN:EAN009'
BGM+9:::PREISLISTE+11+4'
DTM+137:20231126:102'
NAD+BY+1111111111111::9'
NAD+SU+2222222222222::9'
UNT+0+1'
UNZ+1+502'
END;

$c->loadString($file);
$o = $c->get();
d($o);
d($c->errors());

$mapping = new EDI\Mapping\MappingProvider($c->getMessageDirectory());

$analyser = new EDI\Analyser();
$segs = $analyser->loadSegmentsXml($mapping->getSegments());
$svc = $analyser->loadSegmentsXml($mapping->getServiceSegments(3));

$interpreter = new EDI\Interpreter($mapping->getMessage($c->getMessageFormat()), $segs, $svc);
//$interpreter->togglePatching(false);
$prep = $interpreter->prepare($o);


d($prep);
d($interpreter->getErrors());

from edifact.

szocsbarni avatar szocsbarni commented on June 21, 2024

yes, even running this concrete code segment of yours (replaced function calls of d() to print_r()). Below is my full output:

Array
(
    [0] => Array
        (
            [0] => UNB
            [1] => Array
                (
                    [0] => UNOC
                    [1] => 3
                )

            [2] => Array
                (
                    [0] => 0000000000000
                    [1] => 14
                )

            [3] => Array
                (
                    [0] => 0000000000000
                    [1] => 14
                )

            [4] => Array
                (
                    [0] => 231126
                    [1] => 1830
                )

            [5] => 502
            [6] => 0000
            [7] =>
            [8] =>
            [9] =>
            [10] => PRICAT'
        )

    [1] => Array
        (
            [0] => UNH
            [1] => 1
            [2] => Array
                (
                    [0] => PRICAT
                    [1] => D
                    [2] => 01B
                    [3] => UN
                    [4] => EAN009'
                )

        )

    [2] => Array
        (
            [0] => BGM
            [1] => Array
                (
                    [0] => 9
                    [1] =>
                    [2] =>
                    [3] => PREISLISTE
                )

            [2] => 11
            [3] => 4'
        )

    [3] => Array
        (
            [0] => DTM
            [1] => Array
                (
                    [0] => 137
                    [1] => 20231126
                    [2] => 102'
                )

        )

    [4] => Array
        (
            [0] => NAD
            [1] => BY
            [2] => Array
                (
                    [0] => 1111111111111
                    [1] =>
                    [2] => 9'
                )

        )

    [5] => Array
        (
            [0] => NAD
            [1] => SU
            [2] => Array
                (
                    [0] => 2222222222222
                    [1] =>
                    [2] => 9'
                )

        )

    [6] => Array
        (
            [0] => UNT
            [1] => 0
            [2] => 1'
        )

    [7] => Array
        (
            [0] => UNZ
            [1] => 1
            [2] => 502'
        )

)
Array
(
)
Array
(
    [0] => Array
        (
            [messageHeader] => Array
                (
                    [segmentIdx] => 0
                    [segmentCode] => UNH
                    [segmentGroup] =>
                    [messageReferenceNumber] => 1
                    [messageIdentifier] => Array
                        (
                            [messageType] => PRICAT
                            [messageVersionNumber] => D
                            [messageReleaseNumber] => 01B
                            [controllingAgency] => UN
                            [associationAssignedCode] => EAN009'
                        )

                )

            [beginningOfMessage] => Array
                (
                    [segmentIdx] => 1
                    [segmentCode] => BGM
                    [segmentGroup] =>
                    [document] => Array
                        (
                            [documentNameCode] => 9
                            [codeListIdentificationCode] =>
                            [codeListResponsibleAgencyCode] =>
                            [documentName] => PREISLISTE
                        )

                    [document1] => Array
                        (
                            [documentIdentifier] => 11
                        )

                    [messageFunctionCode] => 4'
                )

            [dateOrtimeOrperiod] => Array
                (
                    [segmentIdx] => 2
                    [segmentCode] => DTM
                    [segmentGroup] =>
                    [date] => Array
                        (
                            [dateOrTimeOrPeriodFunctionCodeQualifier] => 137
                            [dateOrTimeOrPeriodValue] => 20231126
                            [dateOrTimeOrPeriodFormatCode] => 102'
                        )

                )

            [SG2] => Array
                (
                    [0] => Array
                        (
                            [nameAndAddress] => Array
                                (
                                    [segmentIdx] => 3
                                    [segmentCode] => NAD
                                    [segmentGroup] => SG2
                                    [partyFunctionCodeQualifier] => BY
                                    [partyIdentificationDetails] => Array
                                        (
                                            [partyIdentifier] => 1111111111111
                                            [codeListIdentificationCode] =>
                                            [codeListResponsibleAgencyCode] => 9'
                                        )

                                )

                        )

                )

            [messageTrailer] => Array
                (
                    [segmentIdx] => 5
                    [segmentCode] => UNT
                    [segmentGroup] => SG2
                    [numberOfSegmentsInTheMessage] => 0
                    [messageReferenceNumber] => 1'
                )

        )

)
Array
(
    [0] => Array
        (
            [text] => The message has some additional segments beyond the maximum repetition allowed (skipped)
            [position] => 4
            [segmentId] => NAD
        )

)

from edifact.

szocsbarni avatar szocsbarni commented on June 21, 2024

Can I help you anything with this issue? @sabas

from edifact.

sabas avatar sabas commented on June 21, 2024

With the commit dffa093 in the test case you provided it seemed fixed.
Do you replicate it with the same test or with another file? If it's private you can share by email..

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.