810 Invoice SAC segment incorrect order?

Apr 5, 2014 at 12:46 AM
I've noticed while generating an 810, that the SAC segment appears above TDS segment. Our vendor has requested the SAC to appear below the TDS, but no matter what I do, the SerializeToX12 places SAC first.

How can I override this?

Here is an example 810:
ST*810*000005167~
  BIG*20140205*01587933*20140131*10989962***DI~
  N1*RE*Remit to**1112223333~
  N3*Company~
  N4*Pasadena*CA*91189-005~
  N1*BT*Bill To~
  N3*AP~
  N4*City*SC*29602~
  N1*ST*Ship To~
  N3*Address~
  N4*Denver*CO*80222~
  ITD*01*03**********Net 30 Days~
  IT1*1*1*EA*100.00**VC*MRB~
  PID*F****Annual Subscription for Monthly Monitoring Ring Med Lt~
  IT1*2*1*EA*100.00**VC*MRB~
  PID*F****Annual Subscription for Monthly Monitoring Ring Sm Lt~
  SAC*C*D240***2000**********Shipping and Handling~
  TDS*22000~
  CTT*2~
SE*20*000005167~
Notice SAC should be below TDS.


The snippet from my Invoice Generator:
        ...
        // TDS
        seg = _810trans.AddSegment("TDS");
        seg.SetElement(1, convertMoney(inv.TotalInvoiceAmount));

        // SAC
        foreach (var sac in inv.InvoiceCharges)
        {
            seg = _810trans.AddLoop("SAC");
            seg.SetElement(1, sac.ChargeIndicator);
            seg.SetElement(2, sac.ChargeCode);
            seg.SetElement(5, convertMoney(sac.ChargeAmount));
            seg.SetElement(15, sac.InvoiceChargeDesc);
        }

        // CCT
        seg = _810trans.AddSegment("CTT");
        seg.SetElement(1, lineCounter);

        return ichg810Msg.SerializeToX12(true);
Coordinator
Apr 19, 2014 at 1:24 PM
This is actually being controlled by the specification. All segments are rendered before their sibling loops unless they are marked with the trailer flag. You can override this by injecting your own copy of the specification and removing the trailer flag from the TDS segment specification. See here https://x12parser.codeplex.com/wikipage?title=Injecting%20your%20own%20X12%20Specification.
The specs are embedded in the project, you can find the 810 here: https://x12parser.codeplex.com/SourceControl/latest#trunk/src/OopFactory.X12/Specifications/Ansi-810-4010Specification.xml