Hello,
I am trying to set blank GL account codes on line items when creating a purchase order in Dynamics GP, however it keeps defaulting to our default "Stock" GL code.
If I create the purchase order using the same information through the Dynamics GP GUI, the GL account code is left blank, which is what I'm desiring from eConnect.
I have tried setting the `InventoryAccount` property of `taPoLine` to a blank string and tried setting the `IVIVINDX` property of `taPoLine` to 0 (zero), but in both of these instances the GL account code is still set to our "Stock" GL code.
A bit of background -- I only want this to be blank for non-inventory purchase orders so that the finance team are forced to enter the correct GL code before processing the purchase order. This is because there are numerous different non-inventory categories and we want to allocate the non-inventory PO line to the appropriate one. Inventory purchase orders can (and do) just take the "Stock" GL code.
Here is my code so far. The `PO` object is deserialized from an XML file.
static string eCon_PurchaseOrder (PO po)
{
// PO header generate
taPoHdr poHead = new taPoHdr();
poHead.PONUMBER = po.Header.DynamicsPONumber;
poHead.POSTATUS = 2;
poHead.POSTATUSSpecified = true;
poHead.VENDORID = po.Header.CreditorID;
poHead.DOCDATE = po.Header.PODate;
poHead.CURNCYID = po.Header.CurrencyID;
poHead.UpdateIfExists = 1;
poHead.BUYERID = "INTERFACEPO";
poHead.PRMDATE = po.Header.DeliveryDate;
poHead.REQDATE = po.Header.DeliveryDate;
// PO lines generate
IEnumerable<taPoLine_ItemsTaPoLine> poLines = eCon_POLines(po);
POPTransactionType eConPo = new POPTransactionType();
eConPo.taPoHdr = poHead;
eConPo.taPoLine_Items = poLines.ToArray();
// Create eConnect transaction and serialize it to string
eConnectType eConType = new eConnectType()
{
POPTransactionType = new POPTransactionType[] {eConPo}
};
return SerializeToXmlString(eConType);
}
static IEnumerable<taPoLine_ItemsTaPoLine> eCon_POLines(PO po)
{
foreach (PO_Line line in po.LineItems)
{
taPoLine_ItemsTaPoLine eConPoLine = new taPoLine_ItemsTaPoLine();
eConPoLine.PONUMBER = po.Header.DynamicsPONumber;
eConPoLine.UNITCOST = decimal.Parse(line.UnitCost);
eConPoLine.UNITCOSTSpecified = true;
eConPoLine.QUANTITY = line.QtyOrdered_Int;
eConPoLine.QUANTITYSpecified = true;
eConPoLine.QTYCANCE = line.QtyCancelled_Int;
eConPoLine.QTYCANCESpecified = true;
eConPoLine.ITEMNMBR = line.ItemCode;
eConPoLine.UOFM = "EACH";
eConPoLine.UpdateIfExists = 1;
eConPoLine.LineNumber = int.Parse(line.ORD);
eConPoLine.LineNumberSpecified = true;
eConPoLine.REQDATE = line.DeliveryDate_Sql;
eConPoLine.VENDORID = po.Header.CreditorID;
eConPoLine.CURNCYID = po.Header.CurrencyID;
eConPoLine.LOCNCODE = line.SiteID;
eConPoLine.ORD = int.Parse(line.ORD);
if (!line.IsInventoryItem)
{
// Non-inventory item
eConPoLine.IVIVINDXSpecified = true;
eConPoLine.IVIVINDX = 0; // Set a blank distribution account
eConPoLine.NONINVEN = 1; // Set noninven
eConPoLine.ITEMDESC = line.ItemDescription; // Set item description as it won't pull from IV00101
}
else
{
// Inventory item
eConPoLine.IVIVINDXSpecified = true;
eConPoLine.IVIVINDX = 5; // Assign "Stock" account 8130-00-0000
eConPoLine.VNDITNUM = line.ItemCode; // Assign vendor item code previously created
}
yield return eConPoLine;
}
}
So my question is, what am I missing to ensure that the GL account code is left blank for the non-inventory line items?