Adding Invoices via EFx Not Storing

I am implementing a 3rd party software that submits invoices to Epicor as our AP team wants it all automated but I’m having trouble with the APInvDtl.

I’m using Swagger UI and Postman to help build and troubleshoot the function. I built alternate functions that also create a Group for the Heads to be assigned to and then it also creates the heads as well. When creating details, I get returned an APInvoiceTableset and comparing it to the returned data in the trace, appears identical but there isn’t anything saved to the invoice head. Am I missing a step? this.Db.SaveChanges is only used when you make a change to the field without BOs, right?

As a whole, the library takes a string from an outside program that contains all the data needed for the transactions. I have a ‘Main’ function that is the primary caller. There is also ‘CreateAPInvGrp’ and ‘CreateNewHed’ that is called from ‘Main’.

CreateNewDtl

var fields = Line.Split('|');

try
{

  //
  // 'out' variables used within Epicor space
  //
  string errMess;
  string opLocMsg;
  decimal grpTotalAmt;
  bool requireUserInput;
  string opMess;
  string opMsgChk;
  string opChkRev;
  bool GenLedgNum;
  bool UpdateRan;
  string opDUAMsg;
  
  string comp = fields[0].Trim();
  string ID = fields[1];

  //
  // Required Variables
  //
  var RcptBill = new Erp.Tablesets.APInvReceiptBillingTableset();
  var APInvTS = new Erp.Tablesets.APInvoiceTableset();
  var Vend_Row = this.Db.Vendor.Where(vend => vend.Company == comp && vend.VendorID == ID).FirstOrDefault();
  
  if (Vend_Row != null)
  {
  
    //
    // Verify that the Vendor Row does have data prior to performing actions
    //
    
    using (var trx = IceContext.CreateDefaultTransactionScope())
    {
    
    
      int VendNum = Vend_Row.VendorNum;
      int PONum = fields[24] == "" ? 0 : Convert.ToInt32(fields[24].Trim());
      
      
      //
      // Build context and get services from Epicor to perform 
      //  database operations
      //
      var context = Ice.Services.ContextFactory.CreateContext<ErpContext>();
      var APInv = ServiceRenderer.GetService<Erp.Contracts.APInvoiceSvcContract>(context);
      
      
      //
      // Get all received receipts to the PONum
      //
      if (PONum != 0)
      {
      
        //APInv.GetAPUninvoicedReceipts(ref RcptBill, VendNum, fields[3].Trim(), PONum);
        
        //APInv.SelectUninvoicedRcptLines(ref RcptBill, VendNum, "", PONum, (fields[28] == "" ? "" : fields[28].Trim()), false, fields[3].Trim(), false);
      
        //APInv.InvokeInvoiceSelectedLines(ref RcptBill, out opLocMsg);
        
        //APInv.GetByID(VendNum, fields[3].Trim());
        
      } else
      {
        
        APInv.GetNewAPInvDtlMiscellaneous(ref APInvTS, VendNum, fields[3].Trim());
        APInv.ChangePartNum("Vision NON-PO Part", ref APInvTS);
        APInv.ChangeVendorQty(Convert.ToDecimal(fields[30].Trim()), ref APInvTS);
        APInv.ChangeUnitCost((fields[31].Trim() == "" ? 0.0m : Convert.ToDecimal(fields[31])), ref APInvTS);
        
      }
      
      APInv.CheckVendorTaxID(fields[1].Trim(), out errMess);
      
      APInvTS.APInvDtl[0].Description = fields[33].Trim() == "" ? "Vision Part" : fields[33].Trim();
      
      APInv.UpdateMaster(ref APInvTS, GroupID, "APInvDtl", true, false, true, true, out grpTotalAmt, out requireUserInput, out opMess, out opMsgChk, out opChkRev, out GenLedgNum, out UpdateRan, out opDUAMsg);
      TS = APInvTS;
      
    } // End of using statement
    
    
  } // end of Vend_Row If-statement
  
  
} catch (Exception ex)
{

  Err = $"{ex.Message} -- {ex.InnerException}";
  //Err = $"{Line}";

}

I did a diff between the JSON returned from the manually inputted detail and the programmactically generate detail and I didn’t find any difference aside from costing. It gets to the very end of the program and throws away the data. What would cause that?