2015-09-29 86 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。