Skip to content

Instantly share code, notes, and snippets.

@smarenich
Created January 8, 2018 09:50
Show Gist options
  • Save smarenich/0591016daea971929cacce630211d43b to your computer and use it in GitHub Desktop.
Save smarenich/0591016daea971929cacce630211d43b to your computer and use it in GitHub Desktop.
public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
#region Event Handlers
public PXAction<PX.Objects.SO.SOOrder> CreateReceipt;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Create IN Receipt")]
protected void createReceipt()
{
INReceiptEntry graph = PXGraph.CreateInstance<INReceiptEntry>();
//Header
INRegister header = (INRegister)graph.CurrentDocument.Cache.CreateInstance();
header = graph.CurrentDocument.Insert(header);
header.TranDesc = "Test Transaction";
header.TranDate = DateTime.Now;
header = graph.CurrentDocument.Update(header);
//Transactions
for (int i = 0; i < 2; i++)
{
INTran tran = (INTran)graph.transactions.Cache.CreateInstance();
tran = graph.transactions.Insert(tran);
tran.InventoryID = 691;
tran = graph.transactions.Update(tran);
tran.Qty = i+1;
tran = graph.transactions.Update(tran);
tran.AcctID = 1200;
tran.SubID = 467;
tran.InvtAcctID = 1156;
tran.InvtSubID = 467;
}
header.Hold = false;
header = graph.CurrentDocument.Update(header);
graph.Actions.PressSave();
header = graph.CurrentDocument.Current;
graph.release.Press();
throw new PXException(header.DocType + "|" + header.RefNbr + "|" + header.BatchNbr);
}
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment