0

我在 ARTran、APTran 和 GLTran DAC中创建了一个自定义的 DB 绑定字段,称为Stock Number :

public class ARTranExt : PXCacheExtension<PX.Objects.AR.ARTran>
{
    public abstract class usrLineStockNbr : IBqlField { }

    [PXDBString(10)]
    [PXUIField(DisplayName = "Stock Number")]
    public virtual string UsrLineStockNbr { get; set; }
}

public class APTranExt : PXCacheExtension<PX.Objects.AP.APTran>
{
    public abstract class usrLineStockNbr : IBqlField { }

    [PXDBString(10)]
    [PXUIField(DisplayName = "Stock Number")]
    public virtual string UsrLineStockNbr { get; set; }
}

public class GLTranExt : PXCacheExtension<PX.Objects.GL.GLTran>
{
    public abstract class usrLineStockNbr : IBqlField { }

    [PXDBString(10)]
    [PXUIField(DisplayName = "Stock Number")]
    public virtual string UsrLineStockNbr { get; set; }
}

我将如何将 AR 发票和 AP 账单详细信息中的自定义字段值直接粘贴到 GL 交易中?

4

1 回答 1

0

要将自定义字段值从 ARTran 粘贴到 GLTran ,您应该为ARReleaseProcess BLC创建一个扩展并覆盖ReleaseInvoice方法,如下面的示例所示:

public class ARReleaseProcess_Extension : PXGraphExtension<PX.Objects.AR.ARReleaseProcess>
{
    public delegate List<ARRegister> ReleaseInvoiceDel(
        JournalEntry je,
        ref ARRegister doc,
        PXResult<ARInvoice, CurrencyInfo, Terms, Customer, Account> res,
        out PMRegister pmDoc);

    [PXOverride]
    public List<ARRegister> ReleaseInvoice(
        JournalEntry je,
        ref ARRegister doc,
        PXResult<ARInvoice, CurrencyInfo, Terms, Customer, Account> res,
        out PMRegister pmDoc,
        ReleaseInvoiceDel del)
    {
        je.RowInserting.AddHandler<GLTran>((s, a) =>
        {
            var tran = (GLTran)a.Row;
            var arTran = (ARTran)PXResult<ARTran>.Current;

            if (tran != null && tran.TranLineNbr != null &&
                arTran != null && arTran.TranType == tran.TranType &&
                arTran.RefNbr == tran.RefNbr && arTran.LineNbr == tran.TranLineNbr)
            {
                var stockNbr = arTran.GetExtension<ARTranExt>().UsrLineStockNbr;
                if (!string.IsNullOrEmpty(stockNbr))
                    tran.GetExtension<GLTranExt>().UsrLineStockNbr = stockNbr;
            }
        });

        return del(je, ref doc, res, out pmDoc);
    }
}

这是新生成的 GL Batch 的样子: 在此处输入图像描述 在下面的 AR 发票发布之后: 在此处输入图像描述

要将自定义字段值从 APTran 粘贴到 GLTran ,您应该为APReleaseProcess BLC创建一个扩展并覆盖ReleaseInvoice方法,如下面的示例所示:

public class APReleaseProcess_Extension : PXGraphExtension<PX.Objects.AP.APReleaseProcess>
{
    public delegate List<APRegister> ReleaseInvoiceDel(
        JournalEntry je,
        ref APRegister doc,
        PXResult<APInvoice, CurrencyInfo, Terms, Vendor> res,
        bool isPrebooking,
        out List<INRegister> inDocs);

    [PXOverride]
    public virtual List<APRegister> ReleaseInvoice(
        JournalEntry je,
        ref APRegister doc,
        PXResult<APInvoice, CurrencyInfo, Terms, Vendor> res,
        bool isPrebooking,
        out List<INRegister> inDocs,
        ReleaseInvoiceDel del)
    {
        je.RowInserting.AddHandler<GLTran>((s, a) =>
        {
            var tran = (GLTran)a.Row;
            var apTran = (APTran)PXResult<APTran>.Current;

            if (tran != null && tran.TranLineNbr != null &&
                apTran != null && apTran.TranType == tran.TranType &&
                apTran.RefNbr == tran.RefNbr && apTran.LineNbr == tran.TranLineNbr)
            {
                var stockNbr = apTran.GetExtension<APTranExt>().UsrLineStockNbr;
                if (!string.IsNullOrEmpty(stockNbr))
                    tran.GetExtension<GLTranExt>().UsrLineStockNbr = stockNbr;
            }
        });

        return del(je, ref doc, res, isPrebooking, out inDocs);
    }
}

下面是一个新 GL 批次的示例: 在此处输入图像描述 在下面的 AP 法案发布期间生成: 在此处输入图像描述

于 2018-02-12T23:49:27.230 回答