EDI edifabric x12 813 format sequence/arrangement issue

190 views Asked by At

Unable to switch "Tax Information and Amount" and "Form Group". "Form Group" should come first:

Following below are my functions for Form Group and TIA, on the EDI Guide Form Group first before TIA but upon generation TIA always comes first.

     public void FGS_FormGroupSummary(G_TFS g_tfs, string assignedId)
     {
         if (g_tfs.G_FGS == null)
         {
             g_tfs.G_FGS = new List<G_FGS>();
         }
         G_FGS formGroup = new G_FGS();
         formGroup.S_FGS = new S_FGS();
         formGroup.S_FGS.D_350_1 = assignedId;
         g_tfs.G_FGS.Add(formGroup);
     }
     public void TIA_TaxInformationAndAmount2(G_TFS g_tfs, string taxInfoCode, string monetaryAmount, string quantity)
     {
         //Tax Information and Amount Segment
         G_TIA tia = new G_TIA();
         g_tfs.G_TIA = new List<G_TIA>();
         tia.S_TIA_2 = new S_TIA_2();

         tia.S_TIA_2.C_C037_2 = new C_C037_2();
         tia.S_TIA_2.C_C001_2 = new C_C001_2();

         tia.S_TIA_2.C_C037_2.D_817_1 = taxInfoCode;                //"5003" = Total Due In Dollars
         tia.S_TIA_2.D_782_2 = monetaryAmount;
         tia.S_TIA_2.D_380_4 = quantity;                            //Quantity
         tia.S_TIA_2.C_C001_2.D_355_1 = X12_ID_355.GA;              //"GA" = Gallons
         g_tfs.G_TIA.Add(tia);
     }

Image attached below is the code that calls the functions above, you can see there that I call first the Form Group before TIA

Code posted as image. Sorry screen-reader users, the person who posted this question doesn't care about you.

2

There are 2 answers

1
Don Zoeggerle On

Generation follows the sequence of the class definition. What transaction set and version is this ? If you need these two swapped then you need to swap them in the class definition.

0
Don Zoeggerle On

In the class definition for 813 change this:

    [Serializable]
    [XmlType(AnonymousType=true, Namespace="www.edifabric.com/x12")]
    [XmlRoot(Namespace="www.edifabric.com/x12", IsNullable=false)]
    public class G_TFS {
    [XmlElement(Order=0)]
    public S_TFS S_TFS {get; set;}
    [XmlElement("S_REF_2",Order=1)]
    public List<S_REF_2> S_REF_2 {get; set;}
    [XmlElement("S_DTM_2",Order=2)]
    public List<S_DTM_2> S_DTM_2 {get; set;}
    [XmlElement("S_MSG",Order=3)]
    public List<S_MSG> S_MSG {get; set;}
    [XmlElement("G_N1_2",Order=4)]
    public List<G_N1_2> G_N1_2 {get; set;}
    [XmlElement("G_TIA",Order=5)]
    public List<G_TIA> G_TIA {get; set;}
    [XmlElement("G_FGS",Order=6)]
    public List<G_FGS> G_FGS {get; set;}
    }

to this:

    [Serializable]
    [XmlType(AnonymousType=true, Namespace="www.edifabric.com/x12")]
    [XmlRoot(Namespace="www.edifabric.com/x12", IsNullable=false)]
    public class G_TFS {
    [XmlElement(Order=0)]
    public S_TFS S_TFS {get; set;}
    [XmlElement("S_REF_2",Order=1)]
    public List<S_REF_2> S_REF_2 {get; set;}
    [XmlElement("S_DTM_2",Order=2)]
    public List<S_DTM_2> S_DTM_2 {get; set;}
    [XmlElement("S_MSG",Order=3)]
    public List<S_MSG> S_MSG {get; set;}
    [XmlElement("G_N1_2",Order=4)]
    public List<G_N1_2> G_N1_2 {get; set;}        
    [XmlElement("G_FGS",Order=5)]
    public List<G_FGS> G_FGS {get; set;}
    [XmlElement("G_TIA",Order=6)]
    public List<G_TIA> G_TIA {get; set;}
    }