在 Dynamics AX 2012 中创建库存移动日记帐

Create a inventory movement journal in Dynamics AX 2012

这个问题快把我逼疯了...我不知道如何解决。我正在尝试使用 ProfitLossJournalService 创建库存移动日记帐分录。

下面的代码运行,但它在 "inventory adjustment" 日志中显示交易。我想要它在库存移动日志中。

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;
}
}

当您使用 ProfitLossJournalService 时,本质上就是您正在创建的内容,库存调整。

如果您想创建库存移动日记帐,不幸的是没有标准的 AIF 服务可以做到这一点。您需要自己实施并将其公开给 AIF。