【发布时间】:2018-03-13 05:13:32
【问题描述】:
目标是获取从 AP 账单页面生成的日记帐交易,并在 GLTran 中添加 2 行。
第一次尝试
首先,我从日记帐交易图表中扩展了发布操作,以包括两个新行:
public class JournalEntryExt : PXGraphExtension<JournalEntry>
{
public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);
[PXOverride]
public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
{
baseMethod(adapter);
//new code
GLTran tranRow = new GLTran();
tranRow = this.Base.GLTranModuleBatNbr.Insert(tranRow);
tranRow.AccountID = 2713;
tranRow.SubID = 467;
tranRow.CuryDebitAmt = 100;
this.Base.GLTranModuleBatNbr.Update(tranRow);
tranRow = new GLTran();
tranRow = this.Base.GLTranModuleBatNbr.Insert(tranRow);
tranRow.AccountID = 1514;
tranRow.SubID = 467;
tranRow.CuryCreditAmt = 100;
this.Base.GLTranModuleBatNbr.Update(tranRow);
this.Base.Actions.PressSave();
return adapter.Get();
}
结果:创建和发布批次,正确输入了 2 个新行。
在此之后,我认为发布 AP Bill 也会从 GL Page 触发这个扩展逻辑。然而,这并没有发生 - 法案的发布似乎没有重用 GL 页面中定义的 Release 逻辑。
第二次尝试
然后,我回到 GL 页面并将逻辑包含在 RowPersisted 事件中,以便在保存文档后立即创建 2 个新行:
public class JournalEntryExt : PXGraphExtension<JournalEntry>
{
protected virtual void Batch_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
{
if (e.Row == null)
{
return;
}
Batch batchRow = (Batch)e.Row;
if (batchRow != null
&& e.Operation == PXDBOperation.Insert
&& e.TranStatus == PXTranStatus.Completed)
{
////new code
GLTran tranRow = new GLTran();
tranRow = this.Base.GLTranModuleBatNbr.Insert(tranRow);
tranRow.AccountID = 2713;
tranRow.SubID = 467;
tranRow.CuryDebitAmt = 102;
this.Base.GLTranModuleBatNbr.Update(tranRow);
tranRow = new GLTran();
tranRow = this.Base.GLTranModuleBatNbr.Insert(tranRow);
tranRow.AccountID = 1514;
tranRow.SubID = 467;
tranRow.CuryCreditAmt = 102;
this.Base.GLTranModuleBatNbr.Update(tranRow);
}
}
结果:创建和保存批次正确输入了 2 个新行。
在此之后,我认为发布 AP 账单会触发此扩展事件,因为应该从账单页面创建和使用日记帐分录图,但在这种情况下,同时发布 AP 账单,并没有添加生成的 Batch 中有 2 个新行。
第三次尝试
然后我想我可以扩展 Bill 的 Release 操作并使用 Search 方法控制生成的 Journal Entry。但是,在这种情况下,扩展逻辑似乎在事务中执行,因为 Document.Current.BatchNbr 仍然为 NULL:
第四次尝试
最后,我尝试扩展 APReleaseProcess 的 Persist() 方法,类似于指南 T300 中的方法,但是没有列出任何方法(版本 17.207.0029):
关于如何输入这些 GL 行还有其他想法吗?
谢谢!
【问题讨论】: