Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Segments does not map properly #262

Open
kgbuddhima opened this issue Jun 12, 2024 · 0 comments
Open

Some Segments does not map properly #262

kgbuddhima opened this issue Jun 12, 2024 · 0 comments

Comments

@kgbuddhima
Copy link

I was trying to map the properties of the following EDI model

UNA:+.? '
UNB+UNOC:3+4099200007441:14+4099200999999:14+200121:0630+ORD001++ORDERS+++EANCOM+1'
UNH+ORD001+ORDERS:D:01B:UN:EAN010+2.0'
BGM+220::9+8500099999:1+9'
DTM+137:20200121:102'
DTM+2:20200127:102'
DTM+64:20200124:102'
DTM+200:20200123:102'
RFF+CU:54321'
NAD+BY+4099200999999::9++ALDI+ALDI STREET 1+ALDI City++6020+AU'
NAD+SU+4012345500004::9++Supplier+Supplier Street 1+Supplier City++8010+AU'
NAD+DP+1234567890128::9++ALDI WH+ALDI Street 1+ALDI City++6020+AU'
CTA+CN'
COM+004920899270:TE'
[email protected]:EM'
NAD+PW+4089876511113::9++Pickup Warehouse+Abholstrasse 1+Muelheim++45481+AU'
LIN+00010++40700719670720:SRV'
QTY+21:42.000'
RFF+AJL:EXW'
LIN+00020++40700719680729:SRV'
QTY+21:42.000'
RFF+AJL:EXW'
LIN+00030++40700719690728:SRV'
QTY+21:42.000'
RFF+AJL:EXW'
LIN+00010++40700719660721:SRV'
QTY+21:42.000
RFF+AJL:DDP'
UNS+S'
CNT+38E:10'
UNT+28+ORD001'
UNZ+1+ORD001'

Then I was testing it using a unit test and I'm having an issue where the RFF property does not map when following property is enabled.

[EdiCondition("200", Path = "DTM")]
public DTM PickupDate { get; set; }

But when I comment it and try the unit test, the RFF object will have the values as expected.

Here are the steps for the success scenario

image

image

And here is the failed scenario

image

image

Below I have added my code and I want to understand why it happens and how to fix the issue?
I was using the Nuget package before and later I have download the source code and not using the NuGet package anymore.

using indice.Edi.Serialization;

namespace Models.AldiModels.IndiceModels
{
    public class ORDRSP
    {
        /// <summary>
        /// 0000 Interchange Header
        /// </summary>
        public UNB UNB { get; set; }

        /// <summary>
        /// 0010 Message Header
        /// </summary>
        public UNH UNH { get; set; }

        /// <summary>
        /// 0020 Beginning of message
        /// </summary>
        public BGM BGM { get; set; }

        [EdiCondition("137", Path = "DTM")]
        public DTM DateTimePeriod { get; set; }

        [EdiCondition("2", Path = "DTM")]
        public DTM DeliveryDateRequested { get; set; }

        [EdiCondition("64", Path = "DTM")]
        public DTM DeliveryDateEearliest { get; set; }

        [EdiCondition("200", Path = "DTM")]
        public DTM PickupDate { get; set; }

        [EdiCondition("CU", Path = "RFF")]
        public RFF RFF { get; set; }

    }

    /// <summary>
    /// 0000 Interchange Header
    /// MaxOcc: 1
    /// Level: 0
    /// </summary>
    [EdiSegment, EdiPath("UNB")]
    public class UNB
    {
        #region S001 Syntax Identifier

        [EdiValue("X(4)", Path = "UNB/0/0")]
        public string SyntaxIdentifier_0001 { get; set; }

        [EdiValue("9(1)", Path = "UNB/0/1")]
        public string SyntaxVersionNumber_0002 { get; set; }

        #endregion

        #region S002 Interchange sender

        [EdiValue("X(35)", Path = "UNB/1/0")]
        public string SenderIdentification_0004 { get; set; }
        [EdiValue("X(4)", Path = "UNB/1/1")]
        public string Sender_PartnerIdentificationQualifier_0007 { get; set; }

        #endregion

        #region S003 Interchange Receipient

        [EdiValue("X(35)", Path = "UNB/2/0")]
        public string ReceipientIdentification_0010 { get; set; }
        [EdiValue("X(4)", Path = "UNB/2/1")]
        public string Receipient_PartnerIdentificationQualifier_0007 { get; set; }

        #endregion

        #region S004 Datetime Preparation

        [EdiValue("9(6)", Path = "UNB/3/0")]
        public string DatePreparation_0017 { get; set; }

        [EdiValue("9(4)", Path = "UNB/3/1")]
        public string TimePreparation_0019 { get; set; }

        #endregion

        [EdiValue("X(14)", Path = "UNB/4/0")]
        public string InterchangeControlReference_0020 { get; set; }

        // [EdiValue("X(1)", Path = "UNB/5/0")] Receipient's referance - not in use

        [EdiValue("X(1)", Path = "UNB/6/0")]
        public string ApplicationReferance_0026 { get; set; }

        //[EdiValue("X(1)", Path = "UNB/7/0")] Processing priority code - not in use
        //[EdiValue("X(1)", Path = "UNB/8/0")] Acknowledgement request - not in use

        [EdiValue("X(35)", Path = "UNB/9/0")]
        public string CommunicationAgreementID_0032 { get; set; }

        [EdiValue("9(1)", Path = "UNB/10/0")]
        public string TestIndicator_0035 { get; set; }
    }

    /// <summary>
    /// 0010 Message Header
    /// MaxOcc: 1
    /// Level : 0
    /// </summary>
    [EdiSegment, EdiPath("UNH")]
    public class UNH
    {
        [EdiValue("X(14)", Path = "UNH/0/0")]
        public string MessageReferenceNumber_0062 { get; set; }

        #region S009  Message Identifier

        [EdiValue("X(6)", Path = "UNH/1/0")]
        public string MessageType_0065 { get; set; }
        [EdiValue("X(3)", Path = "UNH/1/1")]
        public string MessageTypeVersionNumber_0052 { get; set; }
        [EdiValue("X(3)", Path = "UNH/1/2")]
        public string MessageTypeReleaseNumber_0054 { get; set; }
        [EdiValue("X(2)", Path = "UNH/1/3")]
        public string ControllingAgencyCoded_0051 { get; set; }
        [EdiValue("X(6)", Path = "UNH/1/4")]
        public string AssociationAssignedCode_0057 { get; set; }

        #endregion

        [EdiValue("X(3)", Path = "UNH/2/0")]
        public string CommonAccessReference_0068 { get; set; }

        // S010 Status of the transfer - not in use

    }

    /// <summary>
    /// 00020 Beginning of message
    /// MaxOcc: 1
    /// Level : 0
    /// </summary>
    [EdiSegment, EdiPath("BGM")]
    public class BGM
    {
        #region C002 Document/Message name

        [EdiValue("X(3)", Path = "BGM/0/0")]
        public string DocumentNameCode_1001 { get; set; }
        //[EdiValue("X(17)", Path = "BGM/0/1")] - Not used
        //public string CodeListIdentificationCode_1131 { get; set; }
        [EdiValue("X(3)", Path = "BGM/0/2")]
        public string CodeListResponsibleAgencyCode_3055 { get; set; }
        [EdiValue("X(35)", Path = "BGM/0/3")]
        public string DocumentName_1000 { get; set; }

        #endregion

        #region C106 Document/message identification

        [EdiValue("X(35)", Path = "BGM/1/0")]
        public string DocumentIdentifier_1004 { get; set; }
        [EdiValue("X(9)", Path = "BGM/1/1")]
        public string VersionIdentifier_1056 { get; set; }
        //[EdiValue("X(6)", Path = "BGM/1/2")] - Not used
        //public string RevisionIdentifier_1060 { get; set; }

        #endregion

        [EdiValue("9(1)", Path = "BGM/2/0")]
        public string MessageFunctionCode_1225 { get; set; }

        //[EdiValue("X(3)", Path = "BGM/3/0")] - Not used
        //public string ResponseTypeCode_4343 { get; set; }
    }

    /// <summary>
    /// 0030 Date/time/period
    /// MaxOcc: 1
    /// Level: 0
    /// </summary>
    [EdiSegmentGroup("DTM/0/0")]
    public class DTM
    {
        #region C507

        [EdiValue("9(3)", Path = "DTM/0/0")]
        public string Qualifier_2005 { get; set; }
        [EdiValue("X(35)", Path = "DTM/0/1")]
        public string Value_2380 { get; set; }
        [EdiValue("9(3)", Path = "DTM/0/2")]
        public string FormatCode_2379 { get; set; }

        #endregion
    }

    //[EdiSegment, EdiPath("RFF")]
    [EdiSegmentGroup("RFF/0/0")]
    public class RFF
    {
        #region C506 Reference

        [EdiValue("X(3)", Path = "RFF/0/0")]
        public string ReferanceCodeQualifier_1153 { get; set; }
        [EdiValue("X(35)", Path = "RFF/0/1")]
        public string ReferenceIdentifier_1154 { get; set; }

        #endregion
    }

}

And here is my unit test

    [TestFixture]
    public class RFF_SalesOrderNumber_Tests
    {
        [Test]
        public void Read_RFF_SalesOrderNumber_DropShip()
        {
            var grammar = new EdiGrammar();
            var order = default(ORDRSP);
            string edi = @"UNA:+.? '
UNB+UNOC:3+4099200007441:14+4099200999999:14+200121:0630+ORD001++ORDERS+++EANCOM+1'
UNH+ORD001+ORDERS:D:01B:UN:EAN010+2.0'
BGM+220::9+8500099999:1+9'
DTM+137:20200121:102'
DTM+2:20200127:102'
DTM+64:20200124:102'
DTM+200:20200123:102'
RFF+CU:54321'
NAD+BY+4099200999999::9++ALDI+ALDI STREET 1+ALDI City++6020+AU'
NAD+SU+4012345500004::9++Supplier+Supplier Street 1+Supplier City++8010+AU'
NAD+DP+1234567890128::9++ALDI WH+ALDI Street 1+ALDI City++6020+AU'
CTA+CN'
COM+004920899270:TE'
[email protected]:EM'
NAD+PW+4089876511113::9++Pickup Warehouse+Abholstrasse 1+Muelheim++45481+AU'
LIN+00010++40700719670720:SRV'
QTY+21:42.000'
RFF+AJL:EXW'
LIN+00020++40700719680729:SRV'
QTY+21:42.000'
RFF+AJL:EXW'
LIN+00030++40700719690728:SRV'
QTY+21:42.000'
RFF+AJL:EXW'
LIN+00010++40700719660721:SRV'
QTY+21:42.000
RFF+AJL:DDP'
UNS+S'
CNT+38E:10'
UNT+28+ORD001'
UNZ+1+ORD001'";
            using (var stream = EdiHelpers.StreamFromString(edi))
            {
                order = new EdiSerializer().Deserialize<ORDRSP>(new StreamReader(stream), grammar);
            }

            Assert.That(order.RFF, Is.Not.Null);
            Assert.That(order.RFF.ReferanceCodeQualifier_1153, Is.EqualTo("CU"));
            Assert.That(order.RFF.ReferenceIdentifier_1154, Is.EqualTo("54321"));

        }
@kgbuddhima kgbuddhima changed the title Some Segments does not map proeprly Some Segments does not map properly Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant