我希望使用 econnect 在 Dynamics GP 中输入单个 gltransaction。
我下面的代码确实生成了一个 XML 文件。但是,它在 XML 文件中放置了三个相同的 GL 行项目,每个 25 美元,留下一个不平衡的条目。
我希望它按照下面的代码进行 75 美元的借记、50 美元的贷记和 25 美元的贷记。你能帮我解决一下我做错了什么,所以我没有三件 25 美元的物品进入档案吗?
提前致谢。
string DTime = DateTime.Today.ToString();
string CurrentDatabase = "OCITE";
string NextJEno = GetNextJournal.GetNextJournalEntry(CurrentDatabase);
eConnectType eConnect = new eConnectType();
GLTransactionType myGLTrxType = new GLTransactionType();
taGLTransactionHeaderInsert myGLHeader = new taGLTransactionHeaderInsert();
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert [] myGLDetail = new taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert[3];
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert myGLDetailLine = new taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert();
myGLDetailLine.BACHNUMB = CurrentDatabase;
myGLDetailLine.JRNENTRY = Int32.Parse(NextJEno);
myGLDetailLine.CRDTAMNT = (decimal)0;
myGLDetailLine.DEBITAMT = (decimal)75.00;
myGLDetailLine.ACTNUMST = "1000-0000-C";
myGLDetail[0] = myGLDetailLine;
myGLDetailLine.BACHNUMB = CurrentDatabase;
myGLDetailLine.JRNENTRY = Int32.Parse(NextJEno);
myGLDetailLine.CRDTAMNT = (decimal)50;
myGLDetailLine.DEBITAMT = (decimal)0;
myGLDetailLine.ACTNUMST = "6560-0000-C";
myGLDetail[1] = myGLDetailLine;
myGLDetailLine.BACHNUMB = CurrentDatabase;
myGLDetailLine.JRNENTRY = Int32.Parse(NextJEno);
myGLDetailLine.CRDTAMNT = (decimal)25;
myGLDetailLine.DEBITAMT = (decimal)0;
myGLDetailLine.ACTNUMST = "5120-0000-C";
myGLDetail[2] = myGLDetailLine;
myGLHeader.BACHNUMB = CurrentDatabase;
myGLHeader.JRNENTRY = Int32.Parse(NextJEno);
myGLHeader.REFRENCE = "REFRENCE";
myGLHeader.TRXDATE = DTime;
myGLHeader.TRXTYPE = 0;
myGLTrxType.taGLTransactionLineInsert_Items = myGLDetail;
myGLTrxType.taGLTransactionHeaderInsert = myGLHeader;
GLTransactionType[] myGLType = { myGLTrxType };
eConnect.GLTransactionType = myGLType;
FileStream streamFile = new FileStream(filename, FileMode.Create);
XmlTextWriter Xmlwriter = new XmlTextWriter(streamFile, new UTF8Encoding());
XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
serializer.Serialize(Xmlwriter, eConnect);
Xmlwriter.Close();
XML 文件
<eConnect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GLTransactionType>
<eConnectProcessInfo xsi:nil="true" />
<taRequesterTrxDisabler_Items xsi:nil="true" />
<taGLTransactionLineInsert_Items>
<taGLTransactionLineInsert>
<BACHNUMB>OCITE</BACHNUMB>
<JRNENTRY>1750</JRNENTRY>
<CRDTAMNT>25</CRDTAMNT>
<DEBITAMT>0</DEBITAMT>
<ACTNUMST>5120-0000-C</ACTNUMST>
</taGLTransactionLineInsert>
<taGLTransactionLineInsert>
<BACHNUMB>OCITE</BACHNUMB>
<JRNENTRY>1750</JRNENTRY>
<CRDTAMNT>25</CRDTAMNT>
<DEBITAMT>0</DEBITAMT>
<ACTNUMST>5120-0000-C</ACTNUMST>
</taGLTransactionLineInsert>
<taGLTransactionLineInsert>
<BACHNUMB>OCITE</BACHNUMB>
<JRNENTRY>1750</JRNENTRY>
<CRDTAMNT>25</CRDTAMNT>
<DEBITAMT>0</DEBITAMT>
<ACTNUMST>5120-0000-C</ACTNUMST>
</taGLTransactionLineInsert>
</taGLTransactionLineInsert_Items>
<taAnalyticsDistribution_Items xsi:nil="true" />
<taGLTransactionHeaderInsert>
<BACHNUMB>OCITE</BACHNUMB>
<JRNENTRY>1750</JRNENTRY>
<REFRENCE>REFRENCE</REFRENCE>
<TRXDATE>3/21/2013 12:00:00 AM</TRXDATE>
<TRXTYPE>0</TRXTYPE>
</taGLTransactionHeaderInsert>
<taMdaUpdate_Items xsi:nil="true" />
</GLTransactionType>
</eConnect>