EDI.Net icon indicating copy to clipboard operation
EDI.Net copied to clipboard

Assistance needed with Loop

Open skhan-nacmgit opened this issue 5 years ago • 5 comments

I am trying to parse another 820, but I am unable to get to the IT1 segment. How would you structure the classes according to this screenshot of the loops in the documents? TP_REFERENCE

skhan-nacmgit avatar Dec 16 '19 20:12 skhan-nacmgit

This is what I have:

    [EdiSegment, EdiPath("ADX")]
    public class ADX
    {
        
    }

    [EdiSegment, EdiPath("RMR")]
    public class RMR
    {


    }

    [EdiSegment, EdiPath("REF")]
    public class REF
    {
       
    }

    [EdiSegment, EdiPath("NTE")]
    public class NTE
    {
       
    }

    [EdiSegment, EdiPath("IT1")]
    public class IT1
    {
    [EdiValue("X(15)", Path = "IT1/6")]
        public string PONumber { get; set; }
    }



    [EdiSegmentGroup("ADX", "NTE")]
    public class Adjustment : ADX
    {
        public List<NTE> Notes { get; set; }
    }

    [EdiSegmentGroup("RMR", "REF", "DTM", "IT1")]
    public class RemittanceAdvice : IT1
    {
        
    
        public List<REF> REF { get; set; }
        public DateTimePeriod Date { get; set; }
    }

    [EdiSegment, EdiPath("DTM")]
    public class DateTimePeriod
    {
        

    }

It kinda works, but getting to IT1 segment is not accurate.

skhan-nacmgit avatar Dec 16 '19 20:12 skhan-nacmgit

This is what the details look like. If you notice, one of the IT1 differs.

TP_REFERENCE

skhan-nacmgit avatar Dec 16 '19 21:12 skhan-nacmgit

Hi I am not familiar with this segment. But you could use a condition attribute to bind to a different class when this type of IT1 occures

cleftheris avatar Dec 17 '19 08:12 cleftheris

I considered that option, however, the segment identifier (second element) is not present. My main question though, looking at the loops in the TP docs, how would you have structured your classes?

skhan-nacmgit avatar Dec 17 '19 14:12 skhan-nacmgit

I don't have the time to make an test on this so if you make a pull request with your model and sample transmission along with a test, I may find the time to comment or improve it.

As far as the condition attribute is concerned you can use it to discriminate with any value inside the segment even the absense of a value is enough to work in your case (the empty string ""). Take a look here https://github.com/indice-co/EDI.Net/blob/master/test/indice.Edi.Tests/Models/EdiFact_ORDRSP_Conditions.cs

cleftheris avatar Dec 18 '19 08:12 cleftheris