2015-09-29 106 views
1

这个问题让我发疯......我不知道如何解决它。我正在尝试使用ProfitLossJournalService创建库存移动日记帐分录。在Dynamics AX 2012中创建库存移动日记

下面的代码会运行,但它显示“库存调整”日记帐中的交易。我想在库存运动jounal。

public void UpdateInventoryForConsumableItem(InventoryUpdate update) 
{ 
var svc = new ProfitLossJournalServiceClient(); 
var cc = new CallContext {Company = "SS"}; 
var journal = new AxdProfitLossJournal(); 


var table = new AxdEntity_InventJournalTable 
{ 
InventDimFixedSpecified = false, 
InventSiteId = "MC", 
InventLocationId = "MAIN WH", 
JournalType = AxdEnum_InventJournalType.Movement, 
JournalNameId = "InvMovJour", 
Description = Constants.InventoryMovementJournalDescription, 

NumOfLines = 1, 
NumOfLinesSpecified = true, 
JournalTypeSpecified = true, 
JournalId = "InvMovJour", 
JournalIdOrignal = "InvMovJour", 
action = AxdEnum_AxdEntityAction.update 
}; 


var inventoryDims = new AxdEntity_InventDim 
{ 
InventLocationId = "MAIN WH", 
InventDimId = update.InventoryDimId, 
InventColorId = update.Color, 
InventSiteId = "MC", 
InventSizeId = update.Size, 
InventStyleId = update.Style, 
action = AxdEnum_AxdEntityAction.create 
}; 


var entry = new AxdEntity_InventJournalTrans 
{ 
InventDimId = update.InventoryDimId, 
TransDate = DateTime.Now, 
ItemId = update.ItemId, 
CostMarkupSpecified = false, 
InventRefTypeSpecified = false, 
LineNumSpecified = false, 
JournalType = AxdEnum_InventJournalType.Movement, 
JournalTypeSpecified = true, 
Qty = update.Quantity, 
QtySpecified = true, 
InventDim = new AxdEntity_InventDim[1] {inventoryDims} 
}; 



table.InventJournalTrans = new[] {entry}; 

journal.InventJournalTable = new[] {table}; 


try 
{ 
var result = svc.create(cc, journal); 

Logger.LogTrace(string.Format("sending InventoryTransferJournal {0}", result.GetValue(0))); 
Logger.LogEvent(Logger.SentConsumableInventoryUpdateToDynamics); 
} 
catch (Exception e) 
{ 
Logger.LogException(e); 

throw; 
} 
} 

回答

1

当您使用ProfitLossJournalService这基本上是您创建的内容,一个库存调整。

如果您想创建库存移动日志,遗憾的是没有标准的AIF服务可以实现这一点。您需要自行实施并将其公开给AIF。