Skip to content

Duplicate segments error after updating to v1.0/v1.1 #139

Closed
@olelis

Description

@olelis

Hello,

In our system, we have noticed that after updating to version 1.x of this package, all our purchase order's have empty delivery address.
It was working correctly for version 0.70.

I have found example edifact file that have exact same error:
https://developer.kramp.com/edi-edifact-d96a-purchase-order

As you can see, it has three NAD+ lines:

NAD+SU+8712199999999::9++Supplier Name+Supplier Street+SuppliCity++Postalcode'
NAD+IV+8716106198405::9++Kramp Groep B.V. 07+P.O box 248+Leek++9350 AE+NL'
NAD+DP+8716106053926::9++Kramp Groep B.V.+ZONE REPUBLIQUE III 1 RUE DE GALILE+POITIERS CEDEX++86011+FR'

Each meaning different party.

Here is the example code:

<?php
$data = parseString('editest.txt');
print_r($data);

function parseString(string $filename): array
{
    $parser = new Parser();
    $parser->load($filename);
    $parsed = $parser->get();

    $analyser = new Analyser();
    $mapping = new MappingProvider('D96A');
    $segs = $analyser->loadSegmentsXml($mapping->getSegments());
    $svc = $analyser->loadSegmentsXml($mapping->getServiceSegments());

    $interpreter = new Interpreter($mapping->getMessage('ORDERS'), $segs, $svc);
    $groups = $interpreter->prepare($parsed);


    return [
        'errors' => $interpreter->getErrors(),
        'groups' =>$groups,
    ];
}

If you run same code between different versions
Please compare editest.json files in both folders you will see some differences:

  1. Errors: The message has some additional segments beyond the maximum repetition allowed (skipped)
  2. Missing two NAD segments
  3. segmentGroup is quite often empty for child items

Here is working example that compares between two paths.
https://github.com/olelis/phpedifacttest

I have also compared output of Interpreter and Analyzer and looks like Analyzer reads all addresses correctly.

How can this be fixed in our end, or is there an error in interpreter?

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