I m writing a program to modify some invoices in GP10 using eConnect. Some of the invoices require the distributions to be reset because the totals do not add up correctly due to various other (not important for this question) processes; this is accomplished through this program. Additionally, most of the invoices will be moved to a different batch (think buckets if you re not familiar with GP), also using this program.
Both of these tasks are accomplished by processing the same type of file through eConnect. This is the method that processes that file:
public bool PersistAllChangesInDynamics()
{
//instantiate the proper eConnect object for updating the invoice.
eConnectType eConnect = new eConnectType();
SOPTransactionType transType = new SOPTransactionType();
transType.taSopHdrIvcInsert = this.ConvertToSopHdrIvcInsertXml();
//Adjust fields to reset distributions.
transType.taSopHdrIvcInsert.UpdateExisting = 1;
transType.taSopHdrIvcInsert.CREATEDIST = 1;
SOPTransactionType[] updateInvTypeArray = { transType };
eConnect.SOPTransactionType = updateInvTypeArray;
//serialize and process the document.
XmlDocument eConnectDoc = eConnectHelper.SerializeEConnectDoc(eConnect);
return eConnectHelper.ProcessEConnectDoc(eConnectDoc);
}
My question revolves around this bit of code:
transType.taSopHdrIvcInsert.UpdateExisting = 1; //updates the batch changes
transType.taSopHdrIvcInsert.CREATEDIST = 1; //re-creates the distributions
The taSopHdrIvcInsert is the object provided by eConnect to persist any changes to invoices. As far as I m aware, there isn t an object that ONLY re-creates distributions. Whenever I process the document, eConnect calls a similarly named stored procedure on the Dynamics db to save those changes correctly. UpdateExisting and CREATEDIST are optional parameters for that SP.
Sometimes, I will only need to update the batch (or other parts of the invoice), or only re-create distributions, but other times, I ll need to do both. Re-creating the distributions doesn t cause any undesirable changes, you always want to distributions to be correct for every invoice. I haven t tested for any time savings between doing just one thing at a time; since the object is calling a SP on the server side, I don t see where it would take significantly different amounts of time.
Do any of you see any reason to re-factor this into 2-3 different methods to keep each desired function separate?