我在自定义屏幕AR Relase All(AR501000)中遇到问题。问题是当我尝试使用复选框使用屏幕AR Release All Process(AR501000)在屏幕发票和备忘录(AR301000)中传递发票号码(客户订单的字段)的值时。
首先,我创建如下所示的GLTranExtension:
using System;
using PX.Data;
using PX.Objects.CM;
using PX.Objects.CS;
using PX.Objects.PM;
using PX.Objects.CR;
using PX.Objects.TX;
using System.Collections.Generic;
using PX.Objects;
using PX.Objects.GL;
namespace SGLCustomizeProject
{
[Serializable]
public class GLTranExtension: PXCacheExtension<PX.Objects.GL.GLTran>
{
#region UsrInvoiceNbr
public abstract class usrInvoiceNbr : IBqlTable { }
[PXDBString(60, IsFixed = true)]
[PXUIField(DisplayName = "Vendor Ref. / Customer Order")]
public string UsrInvoiceNbr { get; set; }
#endregion
}
}
然后我尝试创建自定义ARReleaseProcessExtension。 这是我的自定义代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PX.Data;
using PX.Objects.AR;
using PX.Objects.GL;
using PX.Objects.CM;
using PX.Objects.CA;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.CT;
using PX.Objects.PM;
namespace SGLCustomizeProject
{
public class ARRelaseProcessExtension: PXGraphExtension<ARReleaseProcess>
{
public delegate List<ARRegister> ReleaseDocProcDel(JournalEntry je, ref ARRegister doc, PXResult<ARInvoice, CurrencyInfo, Terms, Customer, Account> res, out PMRegister pmDoc);
[PXOverride]
public List<ARRegister>ReleaseDocProc(JournalEntry je, ref ARRegister doc, PXResult<ARInvoice, CurrencyInfo, Terms, Customer, Account> res, out PMRegister pmDoc, ReleaseDocProcDel del)
{
je.RowInserting.AddHandler<GLTran>((sender, e) =>
{
GLTran glTran = e.Row as GLTran;
ARInvoice ari = PXResult<ARInvoice>.Current;
if (ari != null && ari.InvoiceNbr != null)
{
GLTranExtension glTex = PXCache<GLTran>.GetExtension<GLTranExtension>(glTran);
glTex.UsrInvoiceNbr = ari.InvoiceNbr;
}
});
return del(je, ref doc, res, out pmDoc);
}
}
}
如果转到屏幕发布AR文档(AR501000),我只需要使用复选框按钮释放一个事务。有用.. 但是当我尝试使用复选框按钮释放多个交易时,我的第二笔交易在期刊交易屏幕中填写相同的发票编号,我将描述使用这个条件:
如果我发布两笔交易
然后我发布这两笔交易,并在期刊交易中显示如下结果:
我不知道为什么第二次交易在期刊交易屏幕中显示相同的发票编号值。
答案 0 :(得分:3)
在你的情况下,由于
,它正在发生ARInvoice ari = PXResult<ARInvoice>.Current;
PXResult.Current可能与您正在处理的实际发票不同。
在这种情况下,最好明确选择所需的发票:
ARInvoice ari = PXSelect<ARInvoice, Where<ARInvoice.refNbr, Equal<Required<GLTran.refNbr>>, And<ARInvoice.docType, Equal<Required<GLTran.tranType>>>>>.Select(sender.Graph, glTran.RefNbr, glTran.TranType);