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

时间:2015-09-29 15:13:04

标签: axapta dynamics-ax-2012 x++

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

下面的代码会运行,但会显示"库存调整中的交易"日志。我想在库存运动中找到它。

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 个答案:

答案 0 :(得分:1)

当您使用基本上正在创建的ProfitLossJournalService时,库存调整。

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