indice-co / indice-co/EDI.Net

EdiSegmentGroup doesn't work

Open
#279 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
490
Forks
173
PR merge metrics
No merged PRs in 30d

Description

Here is my edi message:

`
UNB+UNOY:3+DHLPL:ZZZ+3831034599997:14+250522:1242+00000001221034++ADJUSTQUANTITY'
UNH+1+HANMOV:D:98A:UN'
BGM+79+00000000000115263296'
DTM+137:20250611145433:204'
NAD+WH+SMPL+DHL Supply Chain Poland'
LIN+1++110086034:SK'
PIA+1+----:BB'
QTY+156:24:SK'
FTX+ADN+++10'
FTX+WHI+++CN:9404219000'
LOC+5+NB'
LOC+8+NA'
UNT+12+1'
UNZ+1+00000001221034'

`

When I try to serialize it into my class:

`
using indice.Edi.Serialization;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Xml.Serialization;

namespace carrier.dhl.Models
{
[EdiMessage]
[EdiCondition("HANMOV", Path = "UNH/1/0")]
[XmlRoot("InventoryAdjustment")]
public class HanmovInventoryAdjust
{
[EdiValue("X(3)", Path = "BGM/0/0")]
[XmlIgnore]
public string BGMTypeRaw { get; set; }

[EdiValue("X(35)", Path = "BGM/1/0")]
[XmlIgnore]
public string RawDocumentId { get; set; }

[EdiValue("X(14)", Path = "DTM/0/1")]
[XmlIgnore]
public string RawDateTime { get; set; }

[EdiValue("X(20)", Path = "NAD/1/0")]
[XmlElement("WarehouseId")]
public string WarehouseId { get; set; }

[EdiValue("X(35)", Path = "LIN/2/0")]
[XmlIgnore]
public string ItemNumberRaw { get; set; }

[EdiValue("X(15)", Path = "QTY/0/1")]
[XmlIgnore]
public int QuantityRaw { get; set; }

[EdiSegmentGroup("FTX", SequenceEnd = "LOC")]
[XmlIgnore]
public List FTXSegments { get; set; }

[EdiSegmentGroup("LOC", SequenceEnd = "UNT")]
[XmlIgnore]
public List LOCSegments { get; set; }

[XmlElement("DocumentId")]
public string DocumentId { get; set; }

[XmlElement("DocumentDateTime")]
public string DocumentDateTime { get; set; }

[XmlElement("AdjustmentType")]
public int AdjustmentType { get; set; }

[XmlArray("Lines")]
[XmlArrayItem("Line")]
public List Lines { get; set; }

public void LoadDerivedFields()
{
DocumentId = RawDocumentId;

DocumentDateTime = DateTime.TryParseExact(RawDateTime, "yyyyMMddHHmmss", null, DateTimeStyles.None, out var dt)
? dt.ToString("yyyy-MM-ddTHH:mm:ss")
: null;

AdjustmentType = BGMTypeRaw switch
{
"78" => 1,
"79" => 2,
_ => 0
};

var reason = FTXSegments?.FirstOrDefault(x => x.Qualifier == "ADN")?.Value1;
var origin = FTXSegments?.FirstOrDefault(x => x.Qualifier == "WHI")?.Value1;
var revision = FTXSegments?.FirstOrDefault(x => x.Qualifier == "WHI")?.Value2;

var fromStatus = LOCSegments?.FirstOrDefault(x => x.Qualifier == "5")?.LocationCode ?? "NB";
var toStatus = LOCSegments?.FirstOrDefault(x => x.Qualifier == "8")?.LocationCode ?? "NA";

Lines = new List
{
new HanmovLine
{
LineNumber = 1,
ItemNumber = ItemNumberRaw,
AdjustedQuantity = QuantityRaw,
AdjustmentReasonCode = reason,
OriginCode = origin,
RevisionLevel = revision,
FromStatus = fromStatus,
ToStatus = toStatus
}
};
}
}

public class HanmovLine
{
[XmlElement("LineNumber")]
public int LineNumber { get; set; }

[XmlElement("ItemNumber")]
public string ItemNumber { get; set; }

[XmlElement("AdjustedQuantity")]
public int AdjustedQuantity { get; set; }

[XmlElement("AdjustmentReasonCode")]
public string AdjustmentReasonCode { get; set; }

[XmlElement("OriginCode")]
public string OriginCode { get; set; }

[XmlElement("RevisionLevel")]
public string RevisionLevel { get; set; }

[XmlElement("FromStatus")]
public string FromStatus { get; set; }

[XmlElement("ToStatus")]
public string ToStatus { get; set; }
}

[EdiSegment, EdiPath("FTX")]
public class HanmovFtx
{
[EdiValue("X(3)", Path = "FTX/0/0")]
public string Qualifier { get; set; }

[EdiValue("X(35)", Path = "FTX/3/0")]
public string Value1 { get; set; }

[EdiValue("X(35)", Path = "FTX/3/1")]
public string Value2 { get; set; }

[EdiValue("X(35)", Path = "FTX/3/2")]
public string Value3 { get; set; }
}

[EdiSegment, EdiPath("LOC")]
public class HanmovLoc
{
[EdiValue("X(3)", Path = "LOC/0/0")]
public string Qualifier { get; set; }

[EdiValue("X(35)", Path = "LOC/1/0")]
public string LocationCode { get; set; }
}
}`

I have inside FTXSegments only the second row: FTX+WHI+++CN:9404219000
And LOCSegments is NULL.

Why? What is the problem and how to fix it?

Thank you,
Simon

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the EdiSegmentGroup attributes on FTXSegments and LOCSegments and compare their SequenceEnd values with the sample message's segment order. Trace how EdiSegmentGroup processes the FTX and LOC entry points, then reproduce the model serialization and verify that all FTX entries and the LOC group are populated.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.