Hi Everyone,
In the SO Invoice screen, I have overridden the Release action, and when the GL document is created, I would like to delete the GL Tran line created by Acumatica and would like to insert another 3 new lines.
It has the right amounts but still getting error like saying Document out of balance. Can anyone help me with this?
Assume my invoice total is 1000.
public class SOInvoiceEntry_Extension : PXGraphExtension<PX.Objects.SO.SOInvoiceEntry>
{
#region Event Handlers
public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);
[PXOverride]
public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
{
//var res = baseMethod(adapter);
PXGraph.InstanceCreated.AddHandler<JournalEntry>((graph) =>
{
graph.RowInserted.AddHandler<Batch>((cache, e) =>
{
Batch row = e.Row as Batch;
if (row != null)
{
graph.BatchModule.Current = row;
GLTran gl_AAA = new GLTran
{
AccountID = 10025, // New Account
TranDesc = "AAA",
SubID = 467,
ProjectID = Base.Document.Current.ProjectID,
Qty = 1,
RefNbr = Base.Document.Current.RefNbr,
CuryDebitAmt = 500, // 50% of original
DebitAmt = 500,
TranType = ARDocType.Invoice,
Released = true
};
graph.GLTranModuleBatNbr.Cache.Insert(gl_AAA);
GLTran gl_BBB = new GLTran
{
AccountID = 10026,
TranDesc = "BBB",
SubID = 467,
ProjectID = Base.Document.Current.ProjectID,
Qty = 1,
RefNbr = Base.Document.Current.RefNbr,
CuryDebitAmt = 200, // 20% of original
DebitAmt = 200,
TranType = ARDocType.Invoice,
Released = true
};
graph.GLTranModuleBatNbr.Cache.Insert(gl_BBB);
GLTran gl_CCC = new GLTran
{
AccountID = 10027,
TranDesc = "CCC",
SubID = 467,
ProjectID = Base.Document.Current.ProjectID,
RefNbr = Base.Document.Current.RefNbr,
Qty = 1,
CuryDebitAmt = 300,
DebitAmt = 300,
TranType = ARDocType.Invoice,
Released = true
};
graph.GLTranModuleBatNbr.Cache.Insert(gl_CCC);
}
});
graph.RowInserted.AddHandler<GLTran>((cache, e) =>
{
GLTran row = e.Row as GLTran;
if (row != null)
{
if (row.AccountID == 1154)
{
graph.GLTranModuleBatNbr.Cache.Delete(row);
}
}
});
});
return baseMethod(adapter);
}
#endregion
}