将ParentAccountId和Name添加到AR Print Statements屏幕

时间:2017-06-20 23:23:29

标签: acumatica

我正在努力解决这个问题,看起来很简单,我可能会错过一些愚蠢的东西,但我需要一些帮助。

我正在尝试将另一个字段添加到AR503500中“打印语句”屏幕下的“详细信息”网格中。该字段只是客户的parentAccountId。 DetailsResult已包含CustomerID。

我已经扩展了AR.ARStatementPrint.DetailsResult DAC并添加了以下内容

        public abstract class parentAccountTest2 : IBqlField
    {
    }

    #region Parent Account test 2
    [PXString]
    [PXUIField(DisplayName = "Parent Account test 2")]
    [PXDBScalar(typeof(Search<Customer.parentBAccountID,
                                 Where<Customer.bAccountID, Equal<DetailsResult.customerID>>>))]
    public string ParentAccountTest2 { get; set; }
    #endregion

但是我无法在网格上显示任何值。

我在图上注意到有一个方法details()调用了DetailsResult上的copy方法 - 我是否需要以某种方式覆盖它并以这种方式设置parentAccountId?

以下是图表中的详细信息方法

protected virtual IEnumerable details()
{
    ARSetup setup = ARSetup.Current;

    PrintParameters header = Filter.Current;
    List<DetailsResult> result = new List<DetailsResult>();
    if (header == null)
        yield break;

    GL.Company company = PXSelect<GL.Company>.Select(this);
    foreach (PXResult<ARStatement, Customer> it in PXSelectJoin<ARStatement,
            InnerJoin<Customer, On<Customer.bAccountID, Equal<ARStatement.statementCustomerID>>>,
            Where<ARStatement.statementDate, Equal<Required<ARStatement.statementDate>>,
                And<ARStatement.statementCycleId, Equal<Required<ARStatement.statementCycleId>>>>,
            OrderBy<Asc<ARStatement.statementCustomerID, Asc<ARStatement.curyID>>>>
            .Select(this, header.StatementDate, header.StatementCycleId))
    {
        DetailsResult res = new DetailsResult();
        ARStatement st = it;
        Customer cust = it;
        res.Copy(st, cust);

        if (setup.ConsolidatedStatement != true && st.BranchID != header.BranchID)
                continue;

        if (Filter.Current.Action == 0 &&
            header.ShowAll != true &&
            (st.DontPrint == true || st.Printed == true))
                continue;

        if ((Filter.Current.Action == 1 || Filter.Current.Action == 2) &&
            header.ShowAll != true &&
            (st.DontEmail == true || st.Emailed == true))
                continue;

        if (cust.PrintCuryStatements == true)
        {
            if (Filter.Current.CuryStatements != true)
                continue;

            DetailsResult last = result.Count > 0 ? result[result.Count - 1] : null;
            if (last?.CustomerID == res.CustomerID && last?.CuryID == res.CuryID)
            {
                last.Append(res);
            }
            else
            {
                result.Add(res);
            }
        }
        else
        {
            if (Filter.Current.CuryStatements == true)
                continue;

            res.ResetToBaseCury(company.BaseCuryID);

            DetailsResult last = result.Count > 0 ? result[result.Count - 1] : null;
            if (last?.CustomerID == res.CustomerID)
            {
                last.Append(res);
            }
            else
            {
                result.Add(res);
            }
        }
    }

    foreach (var item in result)
    {
        var located = Details.Cache.Locate(item);
        if (located != null)
        {
            yield return located;
        }
        else
        {
            Details.Cache.SetStatus(item, PXEntryStatus.Held);
            yield return item;
        }
    }

    Details.Cache.IsDirty = false;
}

是PX.Objects.AR.ARStatementPrint.DetailsResult类上的复制方法

    public virtual void Copy(ARStatement aSrc, Customer cust)
{
    this.CustomerID = cust.BAccountID;
    this.UseCurrency = cust.PrintCuryStatements;
    this.StatementBalance = aSrc.EndBalance ?? decimal.Zero;
    this.AgeBalance00 = aSrc.AgeBalance00 ?? decimal.Zero;
    this.CuryID = aSrc.CuryID;
    this.CuryStatementBalance = aSrc.CuryEndBalance ?? decimal.Zero;
    this.CuryAgeBalance00 = aSrc.CuryAgeBalance00 ?? decimal.Zero;
    this.DontEmail = aSrc.DontEmail;
    this.DontPrint = aSrc.DontPrint;
    this.Emailed = aSrc.Emailed;
    this.Printed = aSrc.Printed;
            this.BranchID = aSrc.BranchID;
}

1 个答案:

答案 0 :(得分:1)

'details'方法称为DataView Delegate。在它的定义中,您将返回DataView的记录列表。它通常用于未绑定的DAC和自定义逻辑,不适合单个BQL查询。在“详细信息”DataView委托中,新记录创建为空白,然后将值复制到其中。

我怀疑在执行PXDBScalar时CustomerID为空,因为DAC记录是空白的。

对于在DataView委托而不是DAC中计算值的情况,可以使用FieldSelecting事件处理程序在委托执行后计算自定义字段的值。

注意DAC扩展不包含BQL查询:

public class DetailsResultExt: PXCacheExtension<ARStatementPrint.DetailsResult>
{
    #region Parent Account  
    public abstract class parentAccount : IBqlField { }

    [PXString(60, IsUnicode = true)]
    [PXUIField(DisplayName = "Parent Account")]
    public virtual string ParentAccount { get; set; }
    #endregion
}

在DataID委托中复制CustomerID之后,在Print Statement图形扩展的FieldSelecting事件处理程序中执行查询:

public class ARStatementPrint_Extension : PXGraphExtension<ARStatementPrint>
{
    #region Event Handlers
    protected virtual void DetailsResult_ParentAccount_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
    {
        ARStatementPrint.DetailsResult detailsResult = e.Row as ARStatementPrint.DetailsResult;

        if (detailsResult != null)
        {
            BAccount2 bAccount = PXSelectJoin<BAccount2,
                                 InnerJoin<Customer, On<Customer.bAccountID, Equal<Required<ARStatementPrint.DetailsResult.customerID>>>>,
                                 Where<BAccount2.bAccountID, Equal<Customer.parentBAccountID>>>.Select(Base, detailsResult.CustomerID);

            if (bAccount != null)
            {
                e.ReturnValue = bAccount.AcctName;
            }
        }
    }
    #endregion
}

在项目编辑器中将未绑定的自定义字段添加到屏幕: enter image description here

自定义字段将显示父业务帐户名称: enter image description here