如何通过代码创建库存收据

时间:2019-02-15 18:03:44

标签: acumatica

我正在尝试从屏幕上创建两步转移的库存收据,当我们选择转移时,将填充屏幕上的所有字段,这与我尝试通过代码传递转移号的方式相同,没有填充任何字段,空白文档正在创造,有人可以帮助我。请看下面的代码

        INReceiptEntry intrgraph = PXGraph.CreateInstance<INReceiptEntry>();
        INRegister objRegister = new INRegister();

        objRegister.DocType = INDocType.Receipt;
        objRegister = intrgraph.receipt.Insert(objRegister);           
        intrgraph.Save.Press();
        INRegister objRegisteru = intrgraph.receipt.Current;
        objRegisteru.TransferNbr = "000578";
        objRegisteru = intrgraph.receipt.Update(objRegisteru);
        intrgraph.Save.Press();

1 个答案:

答案 0 :(得分:0)

此示例创建包含明细行和分配的传输凭证。您可以将Transfer部分替换为Receipt,它使用几乎相同的模式:

INTransferEntry transferEntry = PXGraph.CreateInstance<INTransferEntry>();

// Document Header
INRegister register = transferEntry.CurrentDocument.Insert();
register.DocType = INDocType.Transfer;
register.SiteID = [???];
register.ToSiteID = [???];
register.BranchID = Accessinfo.BranchID;
register.TranDesc = "Description";
register.TotalQty = 1M;

// Transactions Detail line
INTran inTran = new INTran();
inTran.DocType = INDocType.Transfer;
inTran.RefNbr = register.RefNbr;
inTran = transferEntry.transactions.Insert(inTran);

inTran.BranchID = Accessinfo.BranchID;
inTran.LocationID = [???];
inTran.ToLocationID = [???];
inTran.InventoryID = inventoryItem.InventoryID;
inTran.TranDesc = inventoryItem.Descr;
inTran.TranType = INTranType.Transfer;
inTran.UOM = inventoryItem.BaseUnit;
inTran.Qty = 1M;

// Lot/Serial number allocations            
INTranSplit tranSplit = transferEntry.splits.Insert();
tranSplit.Qty = 1M;
tranSplit.LocationID = [???];
tranSplit.LotSerialNbr = [???];
tranSplit.UOM = inventoryItem.BaseUnit;
transferEntry.splits.Update(tranSplit);

transferEntry.Actions.PressSave();

要从Receipt填充Transfer的详细信息行,您需要调用INRegister.TransferNbr字段的事件处理程序。可以使用SetValueExt方法来引发FieldUpdated事件:

graphINReceiptEntry.transactions.Cache.SetValueExt<INRegister.transferNbr>(register, transferNbr)

TransferNbr设置为SetValueExt时,它将调用INRegister_TransferNbr_FieldUpdated图的INReceiptEntry事件处理程序,该事件处理程序将转移中的明细行插入收据中。